From 77a127c5d17d6f85f9dd36be1b4da7cb4ff515d5 Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Fri, 11 Jul 2025 18:20:59 +0000
Subject: [PATCH 1/7] add labels for logging
---
src/api/client-event-manager-api.ts | 2 ++
src/components/activities.ts | 1 +
src/runtime/analytics-service.ts | 3 +++
src/runtime/auto-prompt-manager-test.js | 2 ++
src/runtime/client-event-manager-test.js | 22 ++++++++++++++++++++++
src/runtime/client-event-manager.ts | 4 +++-
6 files changed, 33 insertions(+), 1 deletion(-)
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/runtime/analytics-service.ts b/src/runtime/analytics-service.ts
index 0ff9c8127f..1bcb9167de 100644
--- a/src/runtime/analytics-service.ts
+++ b/src/runtime/analytics-service.ts
@@ -305,6 +305,9 @@ export class AnalyticsService {
if (!!event.configurationId) {
meta.setConfigurationId(event.configurationId);
}
+ if (!!event.label) {
+ this.addLabels(event.label);
+ }
// Update the request's timestamp.
this.context_.setClientTimestamp(toTimestamp(event.timestamp!));
const loadEventStartDelay = this.getLoadEventStartDelay_();
diff --git a/src/runtime/auto-prompt-manager-test.js b/src/runtime/auto-prompt-manager-test.js
index ea44e74c21..f887344d6f 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,
});
});
diff --git a/src/runtime/client-event-manager-test.js b/src/runtime/client-event-manager-test.js
index 8dd3b9f98e..250bf04d8a 100644
--- a/src/runtime/client-event-manager-test.js
+++ b/src/runtime/client-event-manager-test.js
@@ -401,6 +401,28 @@ describes.sandboxed('EventManager', () => {
});
}
});
+
+ it('should respect label', () => {
+ const possibleValues = [null, ['inline_cta']];
+ 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..3f127d05c6 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
) {
this.logEvent(
{
@@ -173,6 +174,7 @@ export class ClientEventManager implements ClientEventManagerApi {
isFromUserAction,
additionalParameters: eventParams,
configurationId,
+ label,
},
undefined,
eventTime
From 0bee2967eae932e3a0354ef042cb399c983eb7e2 Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Fri, 11 Jul 2025 20:13:47 +0000
Subject: [PATCH 2/7] only update logevent for now
---
src/runtime/auto-prompt-manager-test.js | 2 --
src/runtime/client-event-manager-test.js | 22 ----------------------
src/runtime/client-event-manager.ts | 4 +---
3 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/src/runtime/auto-prompt-manager-test.js b/src/runtime/auto-prompt-manager-test.js
index f887344d6f..ea44e74c21 100644
--- a/src/runtime/auto-prompt-manager-test.js
+++ b/src/runtime/auto-prompt-manager-test.js
@@ -2157,7 +2157,6 @@ describes.realWin('AutoPromptManager', (env) => {
additionalParameters: null,
timestamp: sandbox.match.number,
configurationId: null,
- label: null,
});
});
@@ -2254,7 +2253,6 @@ describes.realWin('AutoPromptManager', (env) => {
additionalParameters: null,
timestamp: sandbox.match.number,
configurationId: null,
- label: null,
});
});
diff --git a/src/runtime/client-event-manager-test.js b/src/runtime/client-event-manager-test.js
index 250bf04d8a..8dd3b9f98e 100644
--- a/src/runtime/client-event-manager-test.js
+++ b/src/runtime/client-event-manager-test.js
@@ -401,28 +401,6 @@ describes.sandboxed('EventManager', () => {
});
}
});
-
- it('should respect label', () => {
- const possibleValues = [null, ['inline_cta']];
- 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 3f127d05c6..5abc3eb6d1 100644
--- a/src/runtime/client-event-manager.ts
+++ b/src/runtime/client-event-manager.ts
@@ -164,8 +164,7 @@ export class ClientEventManager implements ClientEventManagerApi {
isFromUserAction: boolean | null = false,
eventParams: EventParams | null = null,
eventTime?: number,
- configurationId: string | null = null,
- label?: string[] | null
+ configurationId: string | null = null
) {
this.logEvent(
{
@@ -174,7 +173,6 @@ export class ClientEventManager implements ClientEventManagerApi {
isFromUserAction,
additionalParameters: eventParams,
configurationId,
- label,
},
undefined,
eventTime
From 5526c66b6215d36c0d645435773e06dd1e4e6dee Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Mon, 14 Jul 2025 13:02:41 +0000
Subject: [PATCH 3/7] update tests
---
demos/public/autoprompt-paywalled.html | 8 +--
src/runtime/audience-action-flow-test.js | 8 +++
src/runtime/auto-prompt-manager-test.js | 89 ++++++++++++++++++++++++
src/runtime/client-event-manager-test.js | 26 +++++++
src/runtime/client-event-manager.ts | 4 +-
src/runtime/runtime-test.js | 1 +
src/utils/survey-utils-test.js | 8 +++
7 files changed, 139 insertions(+), 5 deletions(-)
diff --git a/demos/public/autoprompt-paywalled.html b/demos/public/autoprompt-paywalled.html
index dbf31815d4..6bcacb0b49 100644
--- a/demos/public/autoprompt-paywalled.html
+++ b/demos/public/autoprompt-paywalled.html
@@ -16,11 +16,10 @@
(self.SWG_BASIC = self.SWG_BASIC || []).push(basicSubscriptions => {
basicSubscriptions.init({
type: "NewsArticle",
- isAccessibleForFree: false,
isPartOfType: ["Product"],
- isPartOfProductId: "CAowz7enCw:cool",
- autoPromptType: "contribution",
- clientOptions: { theme: "dark", lang: "en" },
+ isPartOfProductId: "CAowv9rUCw:premium",
+ autoPromptType: 'none',
+ clientOptions: { theme: "light", lang: "en" },
});
});
@@ -35,6 +34,7 @@ Autoprompt (Paywalled Article)
Macaroon chocolate wafer cake chocolate cake gummies soufflé lollipop pie. Cheesecake cotton candy macaroon
caramels pie.
+
diff --git a/src/runtime/audience-action-flow-test.js b/src/runtime/audience-action-flow-test.js
index 0379ee08f5..946c6e1481 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
@@ -1126,6 +1128,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
isFromUserAction: false,
additionalParameters: null,
configurationId: null,
+ label: null,
},
undefined,
undefined
@@ -1151,6 +1154,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
isFromUserAction: false,
additionalParameters: null,
configurationId: null,
+ label: null,
},
undefined,
undefined
@@ -1185,6 +1189,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
isFromUserAction: false,
additionalParameters: null,
configurationId: null,
+ label: null,
},
undefined,
undefined
@@ -1205,6 +1210,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
isFromUserAction: false,
additionalParameters: null,
configurationId: null,
+ label: null,
},
undefined,
undefined
@@ -1265,6 +1271,7 @@ describes.realWin('AudienceActionIframeFlow', (env) => {
isFromUserAction: false,
additionalParameters: null,
configurationId: null,
+ label: null,
},
undefined,
undefined
@@ -1321,6 +1328,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
From a42c0d15b771719ceb6229f4fbc00ce84cfee92d Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Mon, 14 Jul 2025 14:04:24 +0000
Subject: [PATCH 4/7] add unit test
---
demos/public/autoprompt-paywalled.html | 8 ++++----
src/runtime/analytics-service-test.js | 5 +++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/demos/public/autoprompt-paywalled.html b/demos/public/autoprompt-paywalled.html
index 6bcacb0b49..dbf31815d4 100644
--- a/demos/public/autoprompt-paywalled.html
+++ b/demos/public/autoprompt-paywalled.html
@@ -16,10 +16,11 @@
(self.SWG_BASIC = self.SWG_BASIC || []).push(basicSubscriptions => {
basicSubscriptions.init({
type: "NewsArticle",
+ isAccessibleForFree: false,
isPartOfType: ["Product"],
- isPartOfProductId: "CAowv9rUCw:premium",
- autoPromptType: 'none',
- clientOptions: { theme: "light", lang: "en" },
+ isPartOfProductId: "CAowz7enCw:cool",
+ autoPromptType: "contribution",
+ clientOptions: { theme: "dark", lang: "en" },
});
});
@@ -34,7 +35,6 @@ Autoprompt (Paywalled Article)
Macaroon chocolate wafer cake chocolate cake gummies soufflé lollipop pie. Cheesecake cotton candy macaroon
caramels pie.
-
diff --git a/src/runtime/analytics-service-test.js b/src/runtime/analytics-service-test.js
index 63fd7452c0..52061754c5 100644
--- a/src/runtime/analytics-service-test.js
+++ b/src/runtime/analytics-service-test.js
@@ -247,6 +247,7 @@ describes.realWin('AnalyticsService', (env) => {
isFromUserAction: true,
additionalParameters: {droppedData: true},
configurationId: 'configurationId',
+ label: ['label1', 'label2'],
});
expect(analyticsService.lastAction).to.not.be.null;
await analyticsService.lastAction;
@@ -260,6 +261,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 labels = context.getLabelList();
+ expect(labels.length).to.equal(2);
+ expect(labels[0]).to.equal('label1');
+ expect(labels[0]).to.equal('label2');
// It should have a working logging promise
const p = analyticsService.getLoggingPromise();
From f712b53e5235d3ea157c6e4188f6350207bcf6da Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Mon, 14 Jul 2025 14:25:50 +0000
Subject: [PATCH 5/7] change tests
---
src/runtime/analytics-service-test.js | 17 ++++++++++++-----
src/runtime/analytics-service.ts | 5 +++++
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/runtime/analytics-service-test.js b/src/runtime/analytics-service-test.js
index 52061754c5..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,7 +254,7 @@ describes.realWin('AnalyticsService', (env) => {
isFromUserAction: true,
additionalParameters: {droppedData: true},
configurationId: 'configurationId',
- label: ['label1', 'label2'],
+ label: null,
});
expect(analyticsService.lastAction).to.not.be.null;
await analyticsService.lastAction;
@@ -261,10 +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 labels = context.getLabelList();
- expect(labels.length).to.equal(2);
- expect(labels[0]).to.equal('label1');
- expect(labels[0]).to.equal('label2');
+ 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 1bcb9167de..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);
@@ -307,6 +310,8 @@ export class AnalyticsService {
}
if (!!event.label) {
this.addLabels(event.label);
+ } else {
+ this.removeLabels([INLINE_CTA_LABEL]);
}
// Update the request's timestamp.
this.context_.setClientTimestamp(toTimestamp(event.timestamp!));
From a74d31b31754d2f1c53d9f154d61853f3879a86f Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Tue, 22 Jul 2025 19:39:31 +0000
Subject: [PATCH 6/7] Add cta mode in event params
---
src/proto/api_messages-test.js | 10 +++++++++-
src/proto/api_messages.ts | 19 +++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
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());
From 86b8162bbf3cd6905e9f534a9bca2de656a732f6 Mon Sep 17 00:00:00 2001
From: Kristen W
Date: Tue, 22 Jul 2025 19:46:09 +0000
Subject: [PATCH 7/7] unit test
---
src/utils/url-test.js | 1 +
1 file changed, 1 insertion(+)
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',