From 6063483047fdf863aca2206c11f585f91ac329b6 Mon Sep 17 00:00:00 2001 From: Elinor Date: Thu, 22 Jun 2023 18:43:46 +0300 Subject: [PATCH] add assignment context to telemetry data --- src/app/middleware/telemetryMiddleware.ts | 3 +-- src/telemetry/telemetry.ts | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/middleware/telemetryMiddleware.ts b/src/app/middleware/telemetryMiddleware.ts index 5cfb8670f..acbdd9595 100644 --- a/src/app/middleware/telemetryMiddleware.ts +++ b/src/app/middleware/telemetryMiddleware.ts @@ -64,8 +64,7 @@ const telemetryMiddleware = case RESOURCEPATHS_ADD_SUCCESS: { telemetry.trackEvent(eventTypes.LISTITEM_CLICK_EVENT, { ComponentName: componentNames.ADD_RESOURCE_TO_COLLECTION_LIST_ITEM, - ResourcePath: action.response[0].url, - AssignmentContext: variantService.getAssignmentContext() + ResourcePath: action.response[0].url }); break; } diff --git a/src/telemetry/telemetry.ts b/src/telemetry/telemetry.ts index 8eebb3e34..454bb615f 100644 --- a/src/telemetry/telemetry.ts +++ b/src/telemetry/telemetry.ts @@ -32,6 +32,7 @@ import { getBrowserScreenSize, getDeviceScreenScale } from '../app/utils/device-characteristics-telemetry'; +import variantService from '../app/services/variant-service'; class Telemetry implements ITelemetry { private appInsights: ApplicationInsights; @@ -66,8 +67,10 @@ class Telemetry implements ITelemetry { this.appInsights.context.application.ver = getVersion().toString(); } - public trackEvent(name: string, properties: {}) { - this.appInsights.trackEvent({ name, properties }); + public trackEvent(name: string, properties:{ AssignmentContext?: string, [key: string]: any } = {}) { + const defaultProperties = { AssignmentContext: variantService.getAssignmentContext() }; + const mergedProperties = { ...defaultProperties, ...properties }; + this.appInsights.trackEvent({ name, properties: mergedProperties }); } public trackException(