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

fix(editor): Send template id as a number in telemetry events #8484

Merged
merged 1 commit into from
Jan 30, 2024
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
2 changes: 1 addition & 1 deletion packages/editor-ui/src/mixins/workflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ export const workflowHelpers = defineComponent({
const templateId = this.$route.query.templateId;
if (templateId) {
this.$telemetry.track('User saved new workflow from template', {
template_id: templateId,
template_id: isNaN(+templateId) ? templateId : +templateId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is personal opinion, but I feel the + operator for converting something to a number is such an obscure pattern, as it's not very obvious that there's a conversion happening here. Could we perhaps use parseInt or Number instead? They do behave a bit differently, but it shouldn't matter in this case.

Suggested change
template_id: isNaN(+templateId) ? templateId : +templateId,
const templateIdNum = parseInt(templateId, 10)
template_id: isNaN(templateIdNum) ? templateId : templateIdNum,

Copy link
Contributor Author

@MiloradFilipovic MiloradFilipovic Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tomi! This makes sense but decided to go with the unary operator here since, when going over this with @nik8n, we decided that we don't want to ignore non-numeric characters in invalid ids such as 123abc and cast them to 123.
Using + these will also be flagged as NaN.
Also, there is a transformation on the rudderstack side that does this check and converts ids to numbers

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, makes sense 👍

workflow_id: workflowData.id,
wf_template_repo_session_id: this.templatesStore.previousSessionId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const useSetupTemplateStore = defineStore('setupTemplate', () => {
);

telemetry.track('User saved new workflow from template', {
template_id: templateId.value,
template_id: isNaN(+templateId.value) ? templateId : +templateId.value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

workflow_id: createdWorkflow.id,
wf_template_repo_session_id: templatesStore.currentSessionId,
});
Expand Down
Loading