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() { reopen() {
this.$apollo.mutate({ this.$apollo.mutate({
@ -265,8 +264,8 @@ export default {
}) })
.then(() => { .then(() => {
this.spellcheckLoading = false; 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', title: 'Snapshot löschen',
}) })
.then(() => { .then(() => {
this.$apollo.mutate({ this.$apollo
mutation: DELETE_SNAPSHOT_MUTATION, .mutate({
variables: { mutation: DELETE_SNAPSHOT_MUTATION,
input: { variables: {
id: this.snapshot.id, input: {
}, id: this.snapshot.id,
},
update: (
store,
{
data: {
deleteSnapshot: { result },
}, },
} },
) => { update: (
if (result.__typename === 'Success') { store,
const slug = this.$route.params.slug; {
const query = SNAPSHOTS_QUERY; data: {
const variables = { deleteSnapshot: { result },
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,
}, },
}; }
) => {
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({ const data = {
query, module: {
variables, ...module,
data, snapshots,
}); },
} };
},
}).then(() => { store.writeQuery({
matomoTrackEvent('Modul Snapshot', 'Snapshot gelöscht', this.$route.params.slug); query,
}); variables,
data,
});
}
},
})
.then(() => {
matomoTrackEvent('Modul Snapshot', 'Snapshot gelöscht', this.$route.params.slug);
});
}) })
.catch(() => {}); .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 }, createSnapshot: { snapshot },
}, },
}) => { }) => {
log.debug('snapshot created', snapshot) log.debug('snapshot created', snapshot);
matomoTrackEvent('Modul Snapshot', 'Snapshot erstellt', this.$route.params.slug);
this.showPopover = false; this.showPopover = false;
this.$modal.open('snapshot-created', { 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({ this.$apollo.mutate({
mutation, mutation,
variables, 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), data: JSON.stringify(data),
}; };
this.$apollo this.$apollo.mutate({
.mutate({ mutation: UPDATE_ANSWER,
mutation: UPDATE_ANSWER, variables: {
variables: { input: {
input: { answer,
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) => { survey.onComplete.add((sender, options) => {