Skip to content

Commit

Permalink
Merge pull request #3285 from n8n-io/N8N-3624-welcome-experience-tele…
Browse files Browse the repository at this point in the history
…metry

📈 Added telemetry events to quickstart sticky note.
  • Loading branch information
MiloradFilipovic authored May 13, 2022
2 parents 1e35d45 + c7a2bcf commit 85039f4
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
17 changes: 17 additions & 0 deletions packages/design-system/src/components/N8nMarkdown/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-if="!loading"
ref="editor"
:class="$style[theme]" v-html="htmlContent"
@click="onClick"
/>
<div v-else :class="$style.markdown">
<div v-for="(block, index) in loadingBlocks"
Expand Down Expand Up @@ -158,6 +159,22 @@ export default {
.use(markdownTasklists, this.options.tasklists),
};
},
methods: {
onClick(event) {
let clickedLink = null;
if(event.target instanceof HTMLAnchorElement) {
clickedLink = event.target;
}
if(event.target.matches('a *')) {
const parentLink = event.target.closest('a');
if(parentLink) {
clickedLink = parentLink;
}
}
this.$emit('markdown-click', clickedLink, event);
}
}
};
</script>

Expand Down
4 changes: 4 additions & 0 deletions packages/design-system/src/components/N8nSticky/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
theme="sticky"
:content="content"
:withMultiBreaks="true"
@markdown-click="onMarkdownClick"
/>
</div>
<div
Expand Down Expand Up @@ -164,6 +165,9 @@ export default mixins(Locale).extend({
onInput(value: string) {
this.$emit('input', value);
},
onMarkdownClick(link, event) {
this.$emit('markdown-click', link, event);
},
onResize(values) {
this.$emit('resize', values);
},
Expand Down
13 changes: 12 additions & 1 deletion packages/editor-ui/src/components/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@resizestart="onResizeStart"
@resize="onResize"
@resizeend="onResizeEnd"
@markdown-click="onMarkdownClick"
/>
</div>

Expand All @@ -54,6 +55,7 @@ import { INodeUi, XYPosition } from '@/Interface';
import {
INodeTypeDescription,
} from 'n8n-workflow';
import { QUICKSTART_NOTE_NAME } from '@/constants';
export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).extend({
name: 'Sticky',
Expand Down Expand Up @@ -124,7 +126,7 @@ export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).ext
workflowRunning (): boolean {
return this.$store.getters.isActionActive('workflowRunning');
},
},
},
data () {
return {
isResizing: false,
Expand All @@ -146,6 +148,15 @@ export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).ext
this.$store.commit('setActiveNode', null);
}
},
onMarkdownClick ( link:HTMLAnchorElement, event: Event ) {
if (link) {
const isOnboardingNote = this.name === QUICKSTART_NOTE_NAME;
const isWelcomeVideo = link.querySelector('img[alt="n8n quickstart video"');
const type = isOnboardingNote && isWelcomeVideo ? 'welcome_video' : isOnboardingNote && link.getAttribute('href') === '/templates' ? 'templates' : 'other';
this.$telemetry.track('User clicked note link', { type } );
}
},
onInputChange(content: string) {
this.setParameters({content});
},
Expand Down
11 changes: 9 additions & 2 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ import {
} from 'jsplumb';
import { MessageBoxInputData } from 'element-ui/types/message-box';
import { jsPlumb, OnConnectionBindInfo } from 'jsplumb';
import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, NODE_NAME_PREFIX, NODE_OUTPUT_DEFAULT_KEY, PLACEHOLDER_EMPTY_WORKFLOW_ID, START_NODE_TYPE, STICKY_NODE_TYPE, VIEWS, WEBHOOK_NODE_TYPE, WORKFLOW_OPEN_MODAL_KEY } from '@/constants';
import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, NODE_NAME_PREFIX, NODE_OUTPUT_DEFAULT_KEY, PLACEHOLDER_EMPTY_WORKFLOW_ID, QUICKSTART_NOTE_NAME, START_NODE_TYPE, STICKY_NODE_TYPE, VIEWS, WEBHOOK_NODE_TYPE, WORKFLOW_OPEN_MODAL_KEY } from '@/constants';
import { copyPaste } from '@/components/mixins/copyPaste';
import { externalHooks } from '@/components/mixins/externalHooks';
import { genericHelpers } from '@/components/mixins/genericHelpers';
Expand Down Expand Up @@ -1864,6 +1864,7 @@ export default mixins(
},
]);
this.zoomToFit();
this.$telemetry.track('welcome node inserted');
});
}
}, 0);
Expand Down Expand Up @@ -2231,7 +2232,13 @@ export default mixins(
}
if(node.type === STICKY_NODE_TYPE) {
this.$telemetry.track('User deleted workflow note', { workflow_id: this.$store.getters.workflowId });
this.$telemetry.track(
'User deleted workflow note',
{
workflow_id: this.$store.getters.workflowId,
is_welcome_note: node.name === QUICKSTART_NOTE_NAME,
},
);
} else {
this.$externalHooks().run('node.deleteNode', { node });
this.$telemetry.track('User deleted node', { node_type: node.type, workflow_id: this.$store.getters.workflowId });
Expand Down

0 comments on commit 85039f4

Please sign in to comment.