diff --git a/src/api/client-event-manager-api.ts b/src/api/client-event-manager-api.ts index 8a2557ca4e..af22fb371d 100644 --- a/src/api/client-event-manager-api.ts +++ b/src/api/client-event-manager-api.ts @@ -40,6 +40,8 @@ export interface ClientEvent { timestamp?: number; /** Optional. ID of the associated action configuration. */ configurationId?: string | null; + /** Optional. context label of the event. */ + label?: string[] | null; } export interface ClientEventManagerApi { diff --git a/src/components/activities.ts b/src/components/activities.ts index 54a2faa5f8..2903f555a6 100644 --- a/src/components/activities.ts +++ b/src/components/activities.ts @@ -148,6 +148,7 @@ export class ActivityIframePort implements ActivityPortDef { isFromUserAction: request.getMeta()?.getIsFromUserAction(), additionalParameters: request.getParams(), configurationId: request.getMeta()?.getConfigurationId(), + label: request.getContext()?.getLabelList(), }); }); } diff --git a/src/proto/api_messages-test.js b/src/proto/api_messages-test.js index 5e5eb4a777..2bbb2577c7 100644 --- a/src/proto/api_messages-test.js +++ b/src/proto/api_messages-test.js @@ -19,7 +19,7 @@ * Auto generated, do not edit */ - import {AccountCreationRequest, ActionRequest, ActionType, AlreadySubscribedResponse, AnalyticsContext, AnalyticsEvent, AnalyticsEventMeta, AnalyticsRequest, AudienceActivityClientLogsRequest, CloseWindowRequest, CompleteAudienceActionResponse, Duration, EntitlementJwt, EntitlementResult, EntitlementSource, EntitlementsRequest, EntitlementsResponse, EventOriginator, EventParams, FinishedLoggingResponse, LinkSaveTokenRequest, LinkingInfoResponse, OpenDialogRequest, ReaderSurfaceType, RewardedAdAlternateActionRequest, RewardedAdLoadAdRequest, RewardedAdLoadAdResponse, RewardedAdViewAdRequest, SkuSelectedResponse, SmartBoxMessage, SubscribeResponse, SubscriptionLinkingCompleteResponse, SubscriptionLinkingLinkResult, SubscriptionLinkingResponse, SurveyAnswer, SurveyDataTransferRequest, SurveyDataTransferResponse, SurveyQuestion, Timestamp, ToastCloseRequest, ViewSubscriptionsResponse, deserialize, getLabel} from './api_messages'; + import {AccountCreationRequest, ActionRequest, ActionType, AlreadySubscribedResponse, AnalyticsContext, AnalyticsEvent, AnalyticsEventMeta, AnalyticsRequest, AudienceActivityClientLogsRequest, CloseWindowRequest, CompleteAudienceActionResponse, CtaMode, Duration, EntitlementJwt, EntitlementResult, EntitlementSource, EntitlementsRequest, EntitlementsResponse, EventOriginator, EventParams, FinishedLoggingResponse, LinkSaveTokenRequest, LinkingInfoResponse, OpenDialogRequest, ReaderSurfaceType, RewardedAdAlternateActionRequest, RewardedAdLoadAdRequest, RewardedAdLoadAdResponse, RewardedAdViewAdRequest, SkuSelectedResponse, SmartBoxMessage, SubscribeResponse, SubscriptionLinkingCompleteResponse, SubscriptionLinkingLinkResult, SubscriptionLinkingResponse, SurveyAnswer, SurveyDataTransferRequest, SurveyDataTransferResponse, SurveyQuestion, Timestamp, ToastCloseRequest, ViewSubscriptionsResponse, deserialize, getLabel} from './api_messages'; describe('deserialize', () => { it('throws if deserialization fails', () => { @@ -456,6 +456,7 @@ eventparams1.setSubscriptionTimestamp(timestamp4); eventparams1.setCampaignId(''); eventparams1.setLinkedPublicationsCount(0); + eventparams1.setCtaMode(CtaMode.CTA_MODE_POPUP); analyticsrequest1.setParams(eventparams1); let analyticsrequestDeserialized; @@ -936,6 +937,7 @@ eventparams1.setSubscriptionTimestamp(timestamp1); eventparams1.setCampaignId(''); eventparams1.setLinkedPublicationsCount(0); + eventparams1.setCtaMode(CtaMode.CTA_MODE_INLINE); let eventparamsDeserialized; @@ -967,6 +969,8 @@ eventparams1.getCampaignId()); expect(eventparamsDeserialized.getLinkedPublicationsCount()).to.deep.equal( eventparams1.getLinkedPublicationsCount()); + expect(eventparamsDeserialized.getCtaMode()).to.deep.equal( + eventparams1.getCtaMode()); // Verify includeLabel true // Verify serialized arrays. @@ -996,6 +1000,8 @@ eventparams1.getCampaignId()); expect(eventparamsDeserialized.getLinkedPublicationsCount()).to.deep.equal( eventparams1.getLinkedPublicationsCount()); + expect(eventparamsDeserialized.getCtaMode()).to.deep.equal( + eventparams1.getCtaMode()); // Verify includeLabel false // Verify serialized arrays. @@ -1024,6 +1030,8 @@ eventparams1.getCampaignId()); expect(eventparamsDeserialized.getLinkedPublicationsCount()).to.deep.equal( eventparams1.getLinkedPublicationsCount()); + expect(eventparamsDeserialized.getCtaMode()).to.deep.equal( + eventparams1.getCtaMode()); }); }); diff --git a/src/proto/api_messages.ts b/src/proto/api_messages.ts index 3ed055d146..87cee3f54f 100644 --- a/src/proto/api_messages.ts +++ b/src/proto/api_messages.ts @@ -309,6 +309,13 @@ export enum ReaderSurfaceType { READER_SURFACE_TENOR = 3, } +/** CTA rendering mode (e.g. inline, pop-up) */ +export enum CtaMode { + CTA_MODE_UNSPECIFIED = 0, + CTA_MODE_POPUP = 1, + CTA_MODE_INLINE = 2, +} + /** */ export class AccountCreationRequest implements Message { private complete_: boolean | null; @@ -1260,6 +1267,7 @@ export class EventParams implements Message { private subscriptionTimestamp_: Timestamp | null; private campaignId_: string | null; private linkedPublicationsCount_: number | null; + private ctaMode_: CtaMode | null; constructor(data: unknown[] = [], includesLabel = true) { const base = includesLabel ? 1 : 0; @@ -1286,6 +1294,8 @@ export class EventParams implements Message { this.campaignId_ = data[8 + base] == null ? null : (data[8 + base] as string); this.linkedPublicationsCount_ = data[9 + base] == null ? null : (data[9 + base] as number); + + this.ctaMode_ = data[10 + base] == null ? null : (data[10 + base] as number); } getSmartboxMessage(): string | null { @@ -1368,6 +1378,14 @@ export class EventParams implements Message { this.linkedPublicationsCount_ = value; } + getCtaMode(): CtaMode | null { + return this.ctaMode_; + } + + setCtaMode(value: CtaMode): void { + this.ctaMode_ = value; + } + toArray(includeLabel = true): unknown[] { const arr: unknown[] = [ this.smartboxMessage_, // field 1 - smartbox_message @@ -1380,6 +1398,7 @@ export class EventParams implements Message { this.subscriptionTimestamp_ ? this.subscriptionTimestamp_.toArray(includeLabel) : [], // field 8 - subscription_timestamp this.campaignId_, // field 9 - campaign_id this.linkedPublicationsCount_, // field 10 - linked_publications_count + this.ctaMode_, // field 11 - cta_mode ]; if (includeLabel) { arr.unshift(this.label()); diff --git a/src/runtime/analytics-service-test.js b/src/runtime/analytics-service-test.js index 63fd7452c0..662188607c 100644 --- a/src/runtime/analytics-service-test.js +++ b/src/runtime/analytics-service-test.js @@ -223,6 +223,8 @@ describes.realWin('AnalyticsService', (env) => { eventOriginator: EventOriginator.UNKNOWN_CLIENT, isFromUserAction: null, additionalParameters: null, + configurationId: null, + label: ['label1', 'CTA_MODE_INLINE'], }); // These wait for analytics server to be ready to send data. @@ -240,6 +242,11 @@ describes.realWin('AnalyticsService', (env) => { ); expect(request1.getMeta().getIsFromUserAction()).to.be.false; expect(request1.getMeta().getConfigurationId()).to.be.null; + const context1 = request1.getContext(); + const labels1 = context1.getLabelList(); + expect(labels1.length).to.equal(2); + expect(labels1[0]).to.equal('label1'); + expect(labels1[1]).to.equal('CTA_MODE_INLINE'); // This sends another event and waits for it to be sent eventManagerCallback({ eventType: AnalyticsEvent.IMPRESSION_PAYWALL, @@ -247,6 +254,7 @@ describes.realWin('AnalyticsService', (env) => { isFromUserAction: true, additionalParameters: {droppedData: true}, configurationId: 'configurationId', + label: null, }); expect(analyticsService.lastAction).to.not.be.null; await analyticsService.lastAction; @@ -260,6 +268,10 @@ describes.realWin('AnalyticsService', (env) => { expect(meta.getEventOriginator()).to.equal(EventOriginator.SWG_CLIENT); expect(meta.getIsFromUserAction()).to.be.true; expect(meta.getConfigurationId()).to.equal('configurationId'); + const context2 = request2.getContext(); + const labels2 = context2.getLabelList(); + expect(labels2.length).to.equal(1); + expect(labels2[0]).to.equal('label1'); // It should have a working logging promise const p = analyticsService.getLoggingPromise(); diff --git a/src/runtime/analytics-service.ts b/src/runtime/analytics-service.ts index 0ff9c8127f..3e99e4e0bf 100644 --- a/src/runtime/analytics-service.ts +++ b/src/runtime/analytics-service.ts @@ -64,6 +64,9 @@ const MAX_WAIT = 200; */ const TIMEOUT_ERROR = 'AnalyticsService timed out waiting for a response'; +/** Context label for inline CTA, should be removed when not the case */ +const INLINE_CTA_LABEL = 'CTA_MODE_INLINE'; + function createErrorResponse(error: string): FinishedLoggingResponse { const response = new FinishedLoggingResponse(); response.setComplete(false); @@ -305,6 +308,11 @@ export class AnalyticsService { if (!!event.configurationId) { meta.setConfigurationId(event.configurationId); } + if (!!event.label) { + this.addLabels(event.label); + } else { + this.removeLabels([INLINE_CTA_LABEL]); + } // Update the request's timestamp. this.context_.setClientTimestamp(toTimestamp(event.timestamp!)); const loadEventStartDelay = this.getLoadEventStartDelay_(); diff --git a/src/runtime/audience-action-flow-test.js b/src/runtime/audience-action-flow-test.js index ac991ad255..9aa9c48b35 100644 --- a/src/runtime/audience-action-flow-test.js +++ b/src/runtime/audience-action-flow-test.js @@ -1043,6 +1043,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1106,6 +1107,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1128,6 +1130,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1153,6 +1156,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1187,6 +1191,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1207,6 +1212,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1267,6 +1273,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -1323,6 +1330,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined diff --git a/src/runtime/auto-prompt-manager-test.js b/src/runtime/auto-prompt-manager-test.js index ea44e74c21..0b05b1adc5 100644 --- a/src/runtime/auto-prompt-manager-test.js +++ b/src/runtime/auto-prompt-manager-test.js @@ -2157,6 +2157,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -2253,6 +2254,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -2300,6 +2302,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2340,6 +2343,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2427,6 +2431,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2471,6 +2476,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2557,6 +2563,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -2565,6 +2572,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2632,6 +2640,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2680,6 +2689,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2747,6 +2757,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -2755,6 +2766,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2833,6 +2845,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -2841,6 +2854,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2928,6 +2942,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -2936,6 +2951,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -2971,6 +2987,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -3064,6 +3081,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_GLOBAL_FREQUENCY_CAP_MET, @@ -3072,6 +3090,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -3151,6 +3170,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3159,6 +3179,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3167,6 +3188,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -3246,6 +3268,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3254,6 +3277,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3262,6 +3286,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -3379,6 +3404,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3387,6 +3413,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -3395,6 +3422,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -3923,6 +3951,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -4004,6 +4033,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -4051,6 +4081,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4091,6 +4122,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4192,6 +4224,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4236,6 +4269,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4340,6 +4374,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4348,6 +4383,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4415,6 +4451,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4467,6 +4504,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4534,6 +4572,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4542,6 +4581,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4620,6 +4660,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4628,6 +4669,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4709,6 +4751,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4717,6 +4760,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -4752,6 +4796,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -4859,6 +4904,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_GLOBAL_FREQUENCY_CAP_MET, @@ -4867,6 +4913,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -4958,6 +5005,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4966,6 +5014,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -4974,6 +5023,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -5065,6 +5115,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5073,6 +5124,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5081,6 +5133,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -5221,6 +5274,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5229,6 +5283,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5237,6 +5292,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -5389,6 +5445,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -5448,6 +5505,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); }); @@ -5487,6 +5545,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5523,6 +5582,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5620,6 +5680,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5664,6 +5725,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5758,6 +5820,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5766,6 +5829,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5813,6 +5877,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5855,6 +5920,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5902,6 +5968,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5910,6 +5977,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -5968,6 +6036,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -5976,6 +6045,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -6033,6 +6103,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6041,6 +6112,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(startSpy).to.have.been.calledOnce; expect(actionFlowSpy).to.have.been.calledWith(deps, { @@ -6072,6 +6144,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -6169,6 +6242,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_GLOBAL_FREQUENCY_CAP_MET, @@ -6177,6 +6251,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -6236,6 +6311,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6244,6 +6320,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6252,6 +6329,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -6311,6 +6389,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6319,6 +6398,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6327,6 +6407,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -6433,6 +6514,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6441,6 +6523,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(logEventSpy).to.be.calledWith({ eventType: AnalyticsEvent.EVENT_PROMPT_FREQUENCY_CAP_MET, @@ -6449,6 +6532,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(contributionPromptFnSpy).to.not.have.been.called; expect(startSpy).to.not.have.been.called; @@ -6546,6 +6630,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(isEligible).to.be.false; }); @@ -6568,6 +6653,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(isEligible).to.be.true; }); @@ -6590,6 +6676,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(isEligible).to.be.false; }); @@ -6612,6 +6699,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(isEligible).to.be.true; }); @@ -7108,6 +7196,7 @@ describes.realWin('AutoPromptManager', (env) => { additionalParameters: null, timestamp: sandbox.match.number, configurationId: null, + label: null, }); expect(isEligible).to.equal(true); diff --git a/src/runtime/client-event-manager-test.js b/src/runtime/client-event-manager-test.js index 8dd3b9f98e..7ef4051b7d 100644 --- a/src/runtime/client-event-manager-test.js +++ b/src/runtime/client-event-manager-test.js @@ -344,6 +344,7 @@ describes.sandboxed('EventManager', () => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }); }); @@ -360,6 +361,7 @@ describes.sandboxed('EventManager', () => { isFromUserAction, additionalParameters: null, configurationId: null, + label: null, }); } }); @@ -378,6 +380,7 @@ describes.sandboxed('EventManager', () => { isFromUserAction: null, additionalParameters, configurationId: null, + label: null, }); } }); @@ -398,6 +401,29 @@ describes.sandboxed('EventManager', () => { isFromUserAction: null, additionalParameters: null, configurationId, + label: null, + }); + } + }); + + it('should respect label', () => { + const possibleValues = [null, ['context_label']]; + for (const label of possibleValues) { + eventManager.logSwgEvent( + AnalyticsEvent.ACTION_ACCOUNT_CREATED, + null, + null, + null, + null, + label + ); + expect(event).to.deep.equal({ + eventType: AnalyticsEvent.ACTION_ACCOUNT_CREATED, + eventOriginator: EventOriginator.SWG_CLIENT, + isFromUserAction: null, + additionalParameters: null, + configurationId: null, + label, }); } }); diff --git a/src/runtime/client-event-manager.ts b/src/runtime/client-event-manager.ts index 5abc3eb6d1..e2006bc9f1 100644 --- a/src/runtime/client-event-manager.ts +++ b/src/runtime/client-event-manager.ts @@ -164,7 +164,8 @@ export class ClientEventManager implements ClientEventManagerApi { isFromUserAction: boolean | null = false, eventParams: EventParams | null = null, eventTime?: number, - configurationId: string | null = null + configurationId: string | null = null, + label: string[] | null = null ) { this.logEvent( { @@ -173,6 +174,7 @@ export class ClientEventManager implements ClientEventManagerApi { isFromUserAction, additionalParameters: eventParams, configurationId, + label, }, undefined, eventTime diff --git a/src/runtime/runtime-test.js b/src/runtime/runtime-test.js index 7c564a1a85..976aa5315f 100644 --- a/src/runtime/runtime-test.js +++ b/src/runtime/runtime-test.js @@ -357,6 +357,7 @@ describes.realWin('Runtime', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }); expect(logger).to.be.instanceOf(Logger); }); diff --git a/src/utils/survey-utils-test.js b/src/utils/survey-utils-test.js index 669c3ebfba..91a2dff6ce 100644 --- a/src/utils/survey-utils-test.js +++ b/src/utils/survey-utils-test.js @@ -217,6 +217,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -261,6 +262,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -366,6 +368,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -410,6 +413,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -444,6 +448,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -486,6 +491,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -532,6 +538,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: false, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined @@ -594,6 +601,7 @@ describes.realWin('Survey utils', (env) => { isFromUserAction: true, additionalParameters: null, configurationId: null, + label: null, }, undefined, undefined diff --git a/src/utils/url-test.js b/src/utils/url-test.js index dffef924d5..907001ee32 100644 --- a/src/utils/url-test.js +++ b/src/utils/url-test.js @@ -286,6 +286,7 @@ describe('serializeProtoMessageForUrl', () => { ['Timestamp', 12345, 0], null, null, + null, ]; const analyticsRequestArray = [ 'AnalyticsRequest',