Fire matomoTrackEvents not in then but before

This commit is contained in:
Daniel Egger 2023-04-05 12:18:44 +02:00
parent 0c5f2dc522
commit b27e13fa12
5 changed files with 91 additions and 92 deletions

View File

@ -214,9 +214,8 @@ export default {
},
},
},
}).then(() => {
matomoTrackEvent('Auftrag', 'Ergebnis mit Lehrperson geteilt', this.assignment.id);
});
matomoTrackEvent('Auftrag', 'Ergebnis mit Lehrperson geteilt', this.assignment.id);
},
reopen() {
this.$apollo.mutate({
@ -265,8 +264,8 @@ export default {
})
.then(() => {
this.spellcheckLoading = false;
matomoTrackEvent('Auftrag', 'Rechtschreibung geprüft', this.assignment.id);
});
matomoTrackEvent('Auftrag', 'Rechtschreibung geprüft', this.assignment.id);
},
},

View File

@ -135,51 +135,53 @@ export default {
title: 'Snapshot löschen',
})
.then(() => {
this.$apollo.mutate({
mutation: DELETE_SNAPSHOT_MUTATION,
variables: {
input: {
id: this.snapshot.id,
},
},
update: (
store,
{
data: {
deleteSnapshot: { result },
this.$apollo
.mutate({
mutation: DELETE_SNAPSHOT_MUTATION,
variables: {
input: {
id: this.snapshot.id,
},
}
) => {
if (result.__typename === 'Success') {
const slug = this.$route.params.slug;
const query = SNAPSHOTS_QUERY;
const variables = {
slug,
};
const { module } = store.readQuery({
query,
variables,
});
const index = module.snapshots.findIndex((snapshot) => snapshot.id === this.snapshot.id);
const snapshots = removeAtIndex(module.snapshots, index);
const data = {
module: {
...module,
snapshots,
},
update: (
store,
{
data: {
deleteSnapshot: { result },
},
};
}
) => {
if (result.__typename === 'Success') {
const slug = this.$route.params.slug;
const query = SNAPSHOTS_QUERY;
const variables = {
slug,
};
const { module } = store.readQuery({
query,
variables,
});
const index = module.snapshots.findIndex((snapshot) => snapshot.id === this.snapshot.id);
const snapshots = removeAtIndex(module.snapshots, index);
store.writeQuery({
query,
variables,
data,
});
}
},
}).then(() => {
matomoTrackEvent('Modul Snapshot', 'Snapshot gelöscht', this.$route.params.slug);
});
const data = {
module: {
...module,
snapshots,
},
};
store.writeQuery({
query,
variables,
data,
});
}
},
})
.then(() => {
matomoTrackEvent('Modul Snapshot', 'Snapshot gelöscht', this.$route.params.slug);
});
})
.catch(() => {});
},
@ -215,13 +217,14 @@ export default {
},
});
},
}).then(() => {
if (this.snapshot.shared) {
matomoTrackEvent('Modul Snapshot', 'Snapshot mit Team geteilt', this.$route.params.slug);
} else {
matomoTrackEvent('Modul Snapshot', 'Snapshot nicht mehr geteilt', this.$route.params.slug);
}
});
const slug = this.$route.params.slug;
if (this.snapshot.shared) {
matomoTrackEvent('Modul Snapshot', 'Snapshot mit Team geteilt', slug);
} else {
matomoTrackEvent('Modul Snapshot', 'Snapshot nicht mehr geteilt', slug);
}
},
},
};

View File

@ -111,8 +111,7 @@ export default {
createSnapshot: { snapshot },
},
}) => {
log.debug('snapshot created', snapshot)
matomoTrackEvent('Modul Snapshot', 'Snapshot erstellt', this.$route.params.slug);
log.debug('snapshot created', snapshot);
this.showPopover = false;
this.$modal.open('snapshot-created', {
@ -120,6 +119,7 @@ export default {
});
}
);
matomoTrackEvent('Modul Snapshot', 'Snapshot erstellt', this.$route.params.slug);
},
},
};

View File

@ -77,9 +77,9 @@ export default {
this.$apollo.mutate({
mutation,
variables,
}).then(() => {
matomoTrackModuleVisibilityEvent(this.type, this.block, hidden);
});
matomoTrackModuleVisibilityEvent(this.type, this.block, hidden);
},
},
};

View File

@ -174,45 +174,42 @@ export default {
data: JSON.stringify(data),
};
this.$apollo
.mutate({
mutation: UPDATE_ANSWER,
variables: {
input: {
answer,
this.$apollo.mutate({
mutation: UPDATE_ANSWER,
variables: {
input: {
answer,
},
},
update: (
store,
{
data: {
updateAnswer: { answer },
},
},
update: (
store,
{
data: {
updateAnswer: { answer },
},
}
) => {
const query = SURVEY_QUERY;
const variables = { id: this.id };
const { survey } = store.readQuery({ query, variables });
if (survey) {
const newData = {
// data is already in use in parent scope
survey: {
...survey,
answer,
},
};
store.writeQuery({ query, variables, data: newData });
}
},
})
.then(() => {
if (exit) {
matomoTrackEvent('Übung', 'Übung erfolgreich abgeschlossen', this.id)
this.$router.go(-1);
} else {
matomoTrackEvent('Übung', 'Übungsschritt abgeschlossen', this.id)
}
});
) => {
const query = SURVEY_QUERY;
const variables = { id: this.id };
const { survey } = store.readQuery({ query, variables });
if (survey) {
const newData = {
// data is already in use in parent scope
survey: {
...survey,
answer,
},
};
store.writeQuery({ query, variables, data: newData });
}
},
});
if (exit) {
matomoTrackEvent('Übung', 'Übung erfolgreich abgeschlossen', this.id);
this.$router.go(-1);
} else {
matomoTrackEvent('Übung', 'Übungsschritt abgeschlossen', this.id);
}
};
survey.onComplete.add((sender, options) => {