feat: Add workflow sharing telemetry (#4906)

* feat: Add workflow sharing telemetry

* chore: fix linting issue

* fix: fix telemetry typo
This commit is contained in:
Alex Grozav
2022-12-15 10:05:54 +02:00
committed by GitHub
parent 9956547504
commit ac066fc9f3
7 changed files with 84 additions and 6 deletions

View File

@@ -132,7 +132,8 @@ import { useSettingsStore } from '@/stores/settings';
import { useUIStore } from '@/stores/ui';
import { useUsersStore } from '@/stores/users';
import { useWorkflowsStore } from '@/stores/workflows';
import useWorkflowsEEStore from '@/stores/workflows.ee';
import { useWorkflowsEEStore } from '@/stores/workflows.ee';
import { ITelemetryTrackProperties } from 'n8n-workflow';
export default mixins(showMessage).extend({
name: 'workflow-share-modal',
@@ -248,12 +249,26 @@ export default mixins(showMessage).extend({
};
try {
const shareesAdded = this.sharedWith.filter(
(sharee) =>
!this.workflow.sharedWith?.find((previousSharee) => sharee.id === previousSharee.id),
);
const shareesRemoved =
this.workflow.sharedWith?.filter(
(previousSharee) => !this.sharedWith.find((sharee) => sharee.id === previousSharee.id),
) || [];
const workflowId = await saveWorkflowPromise();
await this.workflowsEEStore.saveWorkflowSharedWith({
workflowId,
sharedWith: this.sharedWith,
});
this.trackTelemetry({
user_ids_sharees_added: shareesAdded.map((sharee) => sharee.id),
sharees_removed: shareesRemoved.length,
});
this.$showMessage({
title: this.$locale.baseText('workflows.shareModal.onSave.success.title'),
type: 'success',
@@ -270,6 +285,10 @@ export default mixins(showMessage).extend({
const sharee = { id, firstName, lastName, email };
this.sharedWith = this.sharedWith.concat(sharee);
this.trackTelemetry({
user_id_sharee: userId,
});
},
async onRemoveSharee(userId: string) {
const user = this.usersStore.getUserById(userId)!;
@@ -348,6 +367,11 @@ export default mixins(showMessage).extend({
this.sharedWith = this.sharedWith.filter((sharee: Partial<IUser>) => {
return sharee.id !== user.id;
});
this.trackTelemetry({
user_id_sharee: userId,
warning_orphan_credentials: isLastUserWithAccessToCredentials,
});
}
},
onRoleAction(user: IUser, action: string) {
@@ -379,6 +403,14 @@ export default mixins(showMessage).extend({
this.$router.push({ name: VIEWS.USERS_SETTINGS });
this.modalBus.$emit('close');
},
trackTelemetry(data: ITelemetryTrackProperties) {
this.$telemetry.track('User selected sharee to remove', {
workflow_id: this.workflow.id,
user_id_sharer: this.currentUser?.id,
sub_view: this.$route.name === VIEWS.WORKFLOWS ? 'Workflows listing' : 'Workflow editor',
...data,
});
},
},
mounted() {
if (this.isSharingAvailable) {