Skip to content

Commit

Permalink
add assignment context to telemetry data
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW committed Jun 22, 2023
1 parent e78ded7 commit 6063483
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/app/middleware/telemetryMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6063483

Please sign in to comment.