Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(editor-ui): Update telemetry #4040

Merged
merged 17 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cli/src/InternalHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class InternalHooksClass implements IInternalHooksClass {
}

const manualExecEventProperties: ITelemetryTrackProperties = {
user_id: userId,
workflow_id: workflow.id.toString(),
status: properties.success ? 'success' : 'failed',
error_message: properties.error_message as string,
Expand Down
26 changes: 11 additions & 15 deletions packages/cli/src/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ export class Telemetry {
[key: string]: string | number | boolean | object | undefined | null;
}): Promise<void> {
return new Promise<void>((resolve) => {
if (this.postHog) {
this.postHog.identify({
distinctId: this.instanceId,
properties: {
...traits,
instanceId: this.instanceId,
},
});
}

if (this.rudderStack) {
this.rudderStack.identify(
{
Expand Down Expand Up @@ -192,13 +182,19 @@ export class Telemetry {
};

if (withPostHog && this.postHog) {
this.postHog.capture({ ...payload, distinctId: payload.userId });
return Promise.all([
this.postHog.capture({
distinctId: payload.userId,
...payload,
}),
this.rudderStack.track(payload),
]).then(() => resolve());
}

this.rudderStack.track(payload, resolve);
} else {
resolve();
return this.rudderStack.track(payload, resolve);
}

return resolve();
});
}

Expand All @@ -208,7 +204,7 @@ export class Telemetry {
): Promise<boolean> {
if (!this.postHog) return Promise.resolve(false);

const fullId = [this.instanceId, userId].join('_'); // PostHog disallows # in ID
const fullId = [this.instanceId, userId].join('#');

return this.postHog.isFeatureEnabled(featureFlagName, fullId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div
v-if="!loading"
ref="editor"
class="ph-no-capture"
:class="$style[theme]" v-html="htmlContent"
@click="onClick"
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/design-system/src/components/N8nSticky/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<template>
<div
v-show="!editMode"
class="ph-no-capture"
:class="$style.wrapper"
@dblclick.stop="onDoubleClick"
>
Expand All @@ -37,7 +38,7 @@
@keydown.esc="onInputBlur"
@keydown.stop
@wheel.stop
class="sticky-textarea"
class="sticky-textarea ph-no-capture"
:class="{'full-height': !shouldShowFooter}"
>
<n8n-input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="classes">
<div class="ph-no-capture" :class="classes">
<div :class="$style.avatarContainer">
<n8n-avatar :firstName="firstName" :lastName="lastName" />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div
v-for="(user, i) in sortedUsers"
:key="user.id"
class='ph-no-capture'
:class="i === sortedUsers.length - 1 ? $style.itemContainer : $style.itemWithBorder"
>
<n8n-user-info v-bind="user" :isCurrentUser="currentUserId === user.id" />
Expand Down
3 changes: 0 additions & 3 deletions packages/editor-ui/src/components/CopyInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ export default mixins(copyPaste, showMessage).extend({
});
},
},
mounted() {
this.$externalHooks().run('copyInput.mounted', { copyInputValueRef: this.$refs.copyInputValue });
},
});
</script>

Expand Down
5 changes: 1 addition & 4 deletions packages/editor-ui/src/components/CredentialsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/>
</div>

<el-table :data="credentialsToDisplay" v-loading="loading" :default-sort = "{prop: 'name', order: 'ascending'}" stripe max-height="450" @row-click="editCredential" ref="table">
<el-table class="ph-no-capture" :data="credentialsToDisplay" v-loading="loading" :default-sort = "{prop: 'name', order: 'ascending'}" stripe max-height="450" @row-click="editCredential">
<el-table-column property="name" :label="$locale.baseText('credentialsList.name')" class-name="clickable" sortable></el-table-column>
<el-table-column property="type" :label="$locale.baseText('credentialsList.type')" class-name="clickable" sortable></el-table-column>
<el-table-column property="createdAt" :label="$locale.baseText('credentialsList.created')" class-name="clickable" sortable></el-table-column>
Expand Down Expand Up @@ -96,9 +96,6 @@ export default mixins(
this.$showError(e, this.$locale.baseText('credentialsList.errorLoadingCredentials'));
}
this.loading = false;
this.$externalHooks().run('credentialsList.mounted', {
tableRef: this.$refs['table'],
});
this.$telemetry.track('User opened Credentials panel', { workflow_id: this.$store.getters.workflowId });
},
destroyed() {
Expand Down
31 changes: 15 additions & 16 deletions packages/editor-ui/src/components/ExecutionsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@
>
<template v-slot:content>

<div class="filters" ref="filters">
<div class="filters">
<el-row>
<el-col :span="2" class="filter-headline">
{{ $locale.baseText('executionsList.filters') }}:
</el-col>
<el-col :span="7">
<n8n-select v-model="filter.workflowId" :placeholder="$locale.baseText('executionsList.selectWorkflow')" size="medium" filterable @change="handleFilterChanged">
<n8n-option
v-for="item in workflows"
:key="item.id"
:label="item.name"
:value="item.id">
</n8n-option>
<div class="ph-no-capture">
<n8n-option
v-for="item in workflows"
:key="item.id"
:label="item.name"
:value="item.id">
</n8n-option>
</div>
</n8n-select>
</el-col>
<el-col :span="5" :offset="1">
Expand All @@ -45,7 +47,7 @@
</span>
</div>

<el-table :data="combinedExecutions" stripe v-loading="isDataLoading" :row-class-name="getRowClass" ref="table">
<el-table :data="combinedExecutions" stripe v-loading="isDataLoading" :row-class-name="getRowClass">
<el-table-column label="" width="30">
<!-- eslint-disable-next-line vue/no-unused-vars -->
<template slot="header" slot-scope="scope">
Expand All @@ -63,9 +65,11 @@
</el-table-column>
<el-table-column property="workflowName" :label="$locale.baseText('executionsList.name')">
<template slot-scope="scope">
<span class="workflow-name">
{{ scope.row.workflowName || $locale.baseText('executionsList.unsavedWorkflow') }}
</span>
<div class="ph-no-capture">
<span class="workflow-name">
{{ scope.row.workflowName || $locale.baseText('executionsList.unsavedWorkflow') }}
</span>
</div>

<span v-if="scope.row.stoppedAt === undefined">
({{ $locale.baseText('executionsList.running') }})
Expand Down Expand Up @@ -245,11 +249,6 @@ export default mixins(

this.$externalHooks().run('executionsList.openDialog');
this.$telemetry.track('User opened Executions log', { workflow_id: this.$store.getters.workflowId });

this.$externalHooks().run('executionsList.created', {
tableRef: this.$refs['table'],
filtersRef: this.$refs['filters'],
});
},
beforeDestroy() {
if (this.autoRefreshInterval) {
Expand Down
15 changes: 2 additions & 13 deletions packages/editor-ui/src/components/ExpressionEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="editor-description">
{{ $locale.baseText('expressionEdit.expression') }}
</div>
<div class="expression-editor" ref="expressionInput">
<div class="expression-editor ph-no-capture">
<expression-input :parameter="parameter" ref="inputFieldExpression" rows="8" :value="value" :path="path" @change="valueChanged" @keydown.stop="noOp"></expression-input>
</div>
</div>
Expand All @@ -30,7 +30,7 @@
<div class="editor-description">
{{ $locale.baseText('expressionEdit.result') }}
</div>
<div ref="expressionOutput">
<div class="ph-no-capture">
<expression-input :parameter="parameter" resolvedValue="true" ref="expressionResult" rows="8" :value="displayValue" :path="path"></expression-input>
</div>
</div>
Expand Down Expand Up @@ -76,17 +76,6 @@ export default mixins(
latestValue: '',
};
},
updated() {
if (this.$refs.expressionInput && this.$refs.expressionOutput) {
this.$externalHooks().run(
'expressionEdit.mounted',
{
expressionInputRef: this.$refs.expressionInput,
expressionOutputRef: this.$refs.expressionOutput,
},
);
}
},
methods: {
valueChanged (value: string, forceUpdate = false) {
this.latestValue = value;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/InlineNameEdit.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="$style.container">
<div class='ph-no-capture' :class="$style.container">
<span
v-if="readonly"
:class="$style.headline"
Expand Down
7 changes: 1 addition & 6 deletions packages/editor-ui/src/components/MainSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<span slot="title" class="item-title-root">{{nextVersions.length > 99 ? '99+' : nextVersions.length}} update{{nextVersions.length > 1 ? 's' : ''}} available</span>
</n8n-menu-item>
<el-dropdown placement="right-end" trigger="click" @command="onUserActionToggle" v-if="canUserAccessSidebarUserInfo && currentUser">
<div ref="user">
<div class="ph-no-capture">
<n8n-menu-item class="user">
<div class="avatar">
<n8n-avatar :firstName="currentUser.firstName" :lastName="currentUser.lastName" size="small" />
Expand Down Expand Up @@ -346,11 +346,6 @@ export default mixins(
return this.$route.meta && this.$route.meta.nodeView;
},
},
mounted() {
if (this.$refs.user) {
this.$externalHooks().run('mainSidebar.mounted', { userRef: this.$refs.user });
}
},
methods: {
trackHelpItemClick (itemType: string) {
this.$telemetry.track('User clicked help resource', { type: itemType, workflow_id: this.$store.getters.workflowId });
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/Node.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
({{ $locale.baseText('node.disabled') }})
</p>
</div>
<div v-if="nodeSubtitle !== undefined" class="node-subtitle" :title="nodeSubtitle">
<div v-if="nodeSubtitle !== undefined" class="node-subtitle ph-no-capture" :title="nodeSubtitle">
{{ nodeSubtitle }}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ParameterInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
>
<div class="list-option">
<div
class="option-headline"
class="option-headline ph-no-capture"
:class="{ 'remote-parameter-option': isRemoteParameterOption(option) }"
>
{{ getOptionsOptionDisplayName(option) }}
Expand Down
16 changes: 2 additions & 14 deletions packages/editor-ui/src/components/RunData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@
</n8n-text>
</div>

<div v-else-if="hasNodeRun && displayMode === 'table'" :class="$style.dataDisplay">
<div v-else-if="hasNodeRun && displayMode === 'table'" class="ph-no-capture" :class="$style.dataDisplay">
<RunDataTable :node="node" :inputData="inputData" :mappingEnabled="mappingEnabled" :distanceFromActive="distanceFromActive" :showMappingHint="showMappingHint" :runIndex="runIndex" :totalRuns="maxRunIndex" @mounted="$emit('tableMounted', $event)" />
</div>

<div v-else-if="hasNodeRun && displayMode === 'json'" :class="$style.jsonDisplay">
<div v-else-if="hasNodeRun && displayMode === 'json'" class="ph-no-capture" :class="$style.jsonDisplay">
<vue-json-pretty
:data="jsonData"
:deep="10"
Expand Down Expand Up @@ -489,18 +489,6 @@ export default mixins(
}
}
},
updated() {
this.$nextTick(() => {
const jsonValues = this.$el.querySelectorAll('.vjs-value');
const tableRows = this.$el.querySelectorAll('tbody tr');

const elements = [...jsonValues, ...tableRows].reduce<Element[]>((acc, cur) => [...acc, cur], []);

if (elements.length > 0) {
this.$externalHooks().run('runData.updated', { elements });
}
});
},
destroyed() {
this.hidePinDataDiscoveryTooltip();
this.eventBus.$off('data-pinning-error', this.onDataPinningError);
Expand Down
3 changes: 0 additions & 3 deletions packages/editor-ui/src/components/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).ext
type: Number,
},
},
mounted() {
this.$externalHooks().run('sticky.mounted', { stickyRef: this.$refs['sticky'] });
},
computed: {
defaultText (): string {
if (!this.nodeType) {
Expand Down
6 changes: 6 additions & 0 deletions packages/editor-ui/src/components/Telemetry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ export default mixins(externalHooks).extend({
instanceId: this.instanceId,
userId: this.currentUserId,
store: this.$store,
versionCli: this.$store.getters['settings/versionCli'],
},
);

this.$externalHooks().run('telemetry.currentUserIdChanged', {
instanceId: this.instanceId,
userId: this.currentUserId,
});

this.isTelemetryInitialized = true;
},
},
Expand Down
10 changes: 1 addition & 9 deletions packages/editor-ui/src/components/VariableSelectorItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
</div>
<div v-else class="value clickable" @click="selectItem(item)">
<div class="item-title" :title="item.key" ref="variableSelectorItem">
<div class="item-title ph-no-capture" :title="item.key">
{{item.name}}:
<font-awesome-icon icon="dot-circle" title="Select Item" />
</div>
Expand Down Expand Up @@ -87,14 +87,6 @@ export default mixins(externalHooks).extend({
extended: false,
};
},
mounted() {
if (this.$refs.variableSelectorItem) {
this.$externalHooks().run(
'variableSelectorItem.mounted',
{ variableSelectorItemRef: this.$refs.variableSelectorItem },
);
}
},
methods: {
optionSelected (command: string, item: IVariableSelectorOption) {
// By default it is raw
Expand Down
8 changes: 2 additions & 6 deletions packages/editor-ui/src/components/WorkflowOpen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
</template>

<template v-slot:content>
<el-table class="search-table" :data="filteredWorkflows" stripe @cell-click="openWorkflow" :default-sort = "{prop: 'updatedAt', order: 'descending'}" v-loading="isDataLoading" ref="table">
<el-table class="search-table" :data="filteredWorkflows" stripe @cell-click="openWorkflow" :default-sort = "{prop: 'updatedAt', order: 'descending'}" v-loading="isDataLoading">
<el-table-column property="name" :label="$locale.baseText('workflowOpen.name')" class-name="clickable" sortable>
<template slot-scope="scope">
<div :key="scope.row.id">
<div class="ph-no-capture" :key="scope.row.id">
<span class="name">{{scope.row.name}}</span>
<TagsContainer v-if="areTagsEnabled" class="hidden-sm-and-down" :tagIds="getIds(scope.row.tags)" :limit="3" @click="onTagClick" :clickable="true" :hoverable="true" />
</div>
Expand Down Expand Up @@ -127,10 +127,6 @@ export default mixins(
// Make sure that users can directly type in the filter
(this.$refs.inputFieldFilter as HTMLInputElement).focus();
});

this.$externalHooks().run('workflowOpen.mounted', {
tableRef: this.$refs['table'],
});
},
methods: {
getIds(tags: ITag[] | undefined) {
Expand Down
Loading