Skip to content

Commit

Permalink
Merge branch 'main' into exper
Browse files Browse the repository at this point in the history
  • Loading branch information
mborof authored Mar 26, 2024
2 parents 83defc7 + 6c4df23 commit d236963
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 30 deletions.
11 changes: 11 additions & 0 deletions src/proto/api_messages-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ describe('AnalyticsContext', () => {
timestamp3.setSeconds(0);
timestamp3.setNanos(0);
analyticscontext1.setRuntimeCreationTimestamp(timestamp3);
analyticscontext1.setIsLockedContent(false);

let analyticscontextDeserialized;

Expand Down Expand Up @@ -338,6 +339,9 @@ describe('AnalyticsContext', () => {
expect(
analyticscontextDeserialized.getRuntimeCreationTimestamp()
).to.deep.equal(analyticscontext1.getRuntimeCreationTimestamp());
expect(analyticscontextDeserialized.getIsLockedContent()).to.deep.equal(
analyticscontext1.getIsLockedContent()
);

// Verify includeLabel true
// Verify serialized arrays.
Expand Down Expand Up @@ -398,6 +402,9 @@ describe('AnalyticsContext', () => {
expect(
analyticscontextDeserialized.getRuntimeCreationTimestamp()
).to.deep.equal(analyticscontext1.getRuntimeCreationTimestamp());
expect(analyticscontextDeserialized.getIsLockedContent()).to.deep.equal(
analyticscontext1.getIsLockedContent()
);

// Verify includeLabel false
// Verify serialized arrays.
Expand Down Expand Up @@ -461,6 +468,9 @@ describe('AnalyticsContext', () => {
expect(
analyticscontextDeserialized.getRuntimeCreationTimestamp()
).to.deep.equal(analyticscontext1.getRuntimeCreationTimestamp());
expect(analyticscontextDeserialized.getIsLockedContent()).to.deep.equal(
analyticscontext1.getIsLockedContent()
);
});
});

Expand Down Expand Up @@ -562,6 +572,7 @@ describe('AnalyticsRequest', () => {
timestamp3.setSeconds(0);
timestamp3.setNanos(0);
analyticscontext1.setRuntimeCreationTimestamp(timestamp3);
analyticscontext1.setIsLockedContent(false);
analyticsrequest1.setContext(analyticscontext1);
analyticsrequest1.setEvent(AnalyticsEvent.UNKNOWN);
const /** !AnalyticsEventMeta */ analyticseventmeta1 =
Expand Down
72 changes: 43 additions & 29 deletions src/proto/api_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

/* tslint:disable:enforce-name-casing */
/* tslint:disable:strip-private-property-underscore */

// clang-format off

/** Carries information relating to RRM. */
Expand Down Expand Up @@ -418,6 +419,7 @@ export class AnalyticsContext implements Message {
private pageLoadBeginTimestamp_: Timestamp | null;
private loadEventStartDelay_: Duration | null;
private runtimeCreationTimestamp_: Timestamp | null;
private isLockedContent_: boolean | null;

constructor(data: unknown[] = [], includesLabel = true) {
const base = includesLabel ? 1 : 0;
Expand Down Expand Up @@ -476,6 +478,9 @@ export class AnalyticsContext implements Message {
data[16 + base] == null
? null
: new Timestamp(data[16 + base] as unknown[], includesLabel);

this.isLockedContent_ =
data[17 + base] == null ? null : (data[17 + base] as boolean);
}

getEmbedderOrigin(): string | null {
Expand Down Expand Up @@ -614,6 +619,14 @@ export class AnalyticsContext implements Message {
this.runtimeCreationTimestamp_ = value;
}

getIsLockedContent(): boolean | null {
return this.isLockedContent_;
}

setIsLockedContent(value: boolean): void {
this.isLockedContent_ = value;
}

toArray(includeLabel = true): unknown[] {
const arr: unknown[] = [
this.embedderOrigin_, // field 1 - embedder_origin
Expand All @@ -639,6 +652,7 @@ export class AnalyticsContext implements Message {
this.runtimeCreationTimestamp_
? this.runtimeCreationTimestamp_.toArray(includeLabel)
: [], // field 17 - runtime_creation_timestamp
this.isLockedContent_, // field 18 - is_locked_content
];
if (includeLabel) {
arr.unshift(this.label());
Expand Down Expand Up @@ -2029,35 +2043,35 @@ export class ViewSubscriptionsResponse implements Message {
}

const PROTO_MAP: {[key: string]: MessageConstructor} = {
AccountCreationRequest,
ActionRequest,
AlreadySubscribedResponse,
AnalyticsContext,
AnalyticsEventMeta,
AnalyticsRequest,
AudienceActivityClientLogsRequest,
CompleteAudienceActionResponse,
Duration,
EntitlementJwt,
EntitlementsRequest,
EntitlementsResponse,
EventParams,
FinishedLoggingResponse,
LinkSaveTokenRequest,
LinkingInfoResponse,
OpenDialogRequest,
SkuSelectedResponse,
SmartBoxMessage,
SubscribeResponse,
SubscriptionLinkingCompleteResponse,
SubscriptionLinkingResponse,
SurveyAnswer,
SurveyDataTransferRequest,
SurveyDataTransferResponse,
SurveyQuestion,
Timestamp,
ToastCloseRequest,
ViewSubscriptionsResponse,
'AccountCreationRequest': AccountCreationRequest,
'ActionRequest': ActionRequest,
'AlreadySubscribedResponse': AlreadySubscribedResponse,
'AnalyticsContext': AnalyticsContext,
'AnalyticsEventMeta': AnalyticsEventMeta,
'AnalyticsRequest': AnalyticsRequest,
'AudienceActivityClientLogsRequest': AudienceActivityClientLogsRequest,
'CompleteAudienceActionResponse': CompleteAudienceActionResponse,
'Duration': Duration,
'EntitlementJwt': EntitlementJwt,
'EntitlementsRequest': EntitlementsRequest,
'EntitlementsResponse': EntitlementsResponse,
'EventParams': EventParams,
'FinishedLoggingResponse': FinishedLoggingResponse,
'LinkSaveTokenRequest': LinkSaveTokenRequest,
'LinkingInfoResponse': LinkingInfoResponse,
'OpenDialogRequest': OpenDialogRequest,
'SkuSelectedResponse': SkuSelectedResponse,
'SmartBoxMessage': SmartBoxMessage,
'SubscribeResponse': SubscribeResponse,
'SubscriptionLinkingCompleteResponse': SubscriptionLinkingCompleteResponse,
'SubscriptionLinkingResponse': SubscriptionLinkingResponse,
'SurveyAnswer': SurveyAnswer,
'SurveyDataTransferRequest': SurveyDataTransferRequest,
'SurveyDataTransferResponse': SurveyDataTransferResponse,
'SurveyQuestion': SurveyQuestion,
'Timestamp': Timestamp,
'ToastCloseRequest': ToastCloseRequest,
'ViewSubscriptionsResponse': ViewSubscriptionsResponse,
};

/**
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/analytics-service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describes.realWin('AnalyticsService', (env) => {
.callsFake((callback) => (eventManagerCallback = callback));

src = '/serviceiframe';
pageConfig = new PageConfig(productId);
pageConfig = new PageConfig(productId, true);
runtime = new ConfiguredRuntime(env.win, pageConfig);
const mockGetCreationTimestamp = sandbox.spy(() => {
return 22222;
Expand Down Expand Up @@ -144,6 +144,7 @@ describes.realWin('AnalyticsService', (env) => {
analyticsService.setTransactionId(txId);
expect(analyticsService.getTransactionId()).to.equal(txId);
expect(analyticsService.getContext().getUrl()).to.equal(URL);
expect(analyticsService.getContext().getIsLockedContent()).to.be.true;
});

it('should close', () => {
Expand Down Expand Up @@ -433,6 +434,7 @@ describes.realWin('AnalyticsService', (env) => {
expect(context.getUtmCampaign()).to.equal('campaign');
expect(context.getSku()).to.equal('basic');
expect(context.getUrl()).to.equal(URL);
expect(context.getIsLockedContent()).to.be.true;
expect(context.getReadyToPay()).to.be.true;
expect(context.getTransactionId()).to.match(
/^.{8}-.{4}-.{4}-.{4}-.{12}\.swg$/g
Expand Down
1 change: 1 addition & 0 deletions src/runtime/analytics-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class AnalyticsService {
context.setReferringOrigin(parseUrl(this.getReferrer_()).origin);
context.setClientVersion(`SwG ${INTERNAL_RUNTIME_VERSION}`);
context.setUrl(getCanonicalUrl(this.doc_));
context.setIsLockedContent(this.deps_.pageConfig().isLocked());

const utmParams = parseQueryString(this.getQueryString_());
const campaign = utmParams['utm_campaign'];
Expand Down
1 change: 1 addition & 0 deletions src/utils/url-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ describe('serializeProtoMessageForUrl', () => {
['Timestamp', 11111, 0],
['Timestamp', 22222, 0],
['Duration', 100, 0],
false,
];
const analyticsEventMetaArray = ['AnalyticsEventMeta', 1, true];
const eventParamsArray = [
Expand Down

0 comments on commit d236963

Please sign in to comment.