feat(editor): Send template id as string in all telemetry events (#8498)

This commit is contained in:
Milorad FIlipović
2024-01-31 13:34:11 +01:00
committed by GitHub
parent 839dd96c7d
commit 2aed788dc3
6 changed files with 25 additions and 7 deletions

View File

@@ -21,6 +21,7 @@ import type { Telemetry } from '@/plugins/telemetry';
import type { useExternalHooks } from '@/composables/useExternalHooks';
import { assert } from '@/utils/assert';
import { doesNodeHaveCredentialsToFill } from '@/utils/nodes/nodeTransforms';
import { tryToParseNumber } from '@/utils/typesUtils';
type ExternalHooks = ReturnType<typeof useExternalHooks>;
@@ -106,7 +107,7 @@ async function openTemplateWorkflowOnNodeView(opts: {
};
const telemetryPayload = {
source: 'workflow',
template_id: templateId,
template_id: tryToParseNumber(templateId),
wf_template_repo_session_id: templatesStore.currentSessionId,
};

View File

@@ -156,3 +156,12 @@ export const isValidDate = (input: string | number | Date): boolean => {
export const getObjectKeys = <T extends object, K extends keyof T>(o: T): K[] =>
Object.keys(o) as K[];
/**
* Converts a string to a number if possible. If not it returns the original string.
* For a string to be converted to a number it has to contain only digits.
* @param value The value to convert to a number
*/
export const tryToParseNumber = (value: string): number | string => {
return isNaN(+value) ? value : +value;
};