@schibsted/sps-sdk 3.2.2 → 4.0.0-CBT-18545.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/public-script-versions.d.ts +2 -2
- package/dist/cjs/public-script-versions.js +2 -2
- package/dist/cjs/sps/placement.d.ts +15 -0
- package/dist/cjs/sps/rewrite-salesposter-variables.d.ts +36 -3
- package/dist/cjs/sps/rewrite-salesposter-variables.js +14 -3
- package/dist/cjs/sps/rewrite-salesposter-variables.js.map +1 -1
- package/dist/cjs/sps.d.ts +10 -4
- package/dist/cjs/sps.js +18 -27
- package/dist/cjs/sps.js.map +1 -1
- package/dist/cjs/tracking/create-tracking-params.d.ts +2 -2
- package/dist/cjs/tracking/create-tracking-params.js +2 -1
- package/dist/cjs/tracking/create-tracking-params.js.map +1 -1
- package/dist/cjs/utils/intent.d.ts +8 -0
- package/dist/cjs/utils/intent.js +34 -0
- package/dist/cjs/utils/intent.js.map +1 -0
- package/dist/cjs/utils/offerCodes.d.ts +6 -0
- package/dist/cjs/utils/offerCodes.js +21 -0
- package/dist/cjs/utils/offerCodes.js.map +1 -0
- package/dist/cjs/utils/offerType.d.ts +8 -0
- package/dist/cjs/utils/offerType.js +22 -0
- package/dist/cjs/utils/offerType.js.map +1 -0
- package/dist/cjs/utils/pulseProxy.d.ts +43 -12
- package/dist/cjs/utils/pulseProxy.js +6 -10
- package/dist/cjs/utils/pulseProxy.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/public-script-versions.d.ts +2 -2
- package/dist/esm/public-script-versions.js +2 -2
- package/dist/esm/sps/placement.d.ts +15 -0
- package/dist/esm/sps/rewrite-salesposter-variables.d.ts +36 -3
- package/dist/esm/sps/rewrite-salesposter-variables.js +14 -3
- package/dist/esm/sps/rewrite-salesposter-variables.js.map +1 -1
- package/dist/esm/sps.d.ts +10 -4
- package/dist/esm/sps.js +19 -28
- package/dist/esm/sps.js.map +1 -1
- package/dist/esm/tracking/create-tracking-params.d.ts +2 -2
- package/dist/esm/tracking/create-tracking-params.js +2 -1
- package/dist/esm/tracking/create-tracking-params.js.map +1 -1
- package/dist/esm/utils/intent.d.ts +8 -0
- package/dist/esm/utils/intent.js +30 -0
- package/dist/esm/utils/intent.js.map +1 -0
- package/dist/esm/utils/offerCodes.d.ts +6 -0
- package/dist/esm/utils/offerCodes.js +17 -0
- package/dist/esm/utils/offerCodes.js.map +1 -0
- package/dist/esm/utils/offerType.d.ts +8 -0
- package/dist/esm/utils/offerType.js +18 -0
- package/dist/esm/utils/offerType.js.map +1 -0
- package/dist/esm/utils/pulseProxy.d.ts +43 -12
- package/dist/esm/utils/pulseProxy.js +6 -10
- package/dist/esm/utils/pulseProxy.js.map +1 -1
- package/dist/public-scripts/pulse-tracker-proxy.v1.1.0.min.js +1 -0
- package/dist/public-scripts/sps-pulse-helpers.v2.0.0.min.js +1 -0
- package/package.json +2 -2
- package/dist/public-scripts/pulse-tracker-proxy.v1.0.0.min.js +0 -1
- package/dist/public-scripts/sps-pulse-helpers.v1.0.0.min.js +0 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./sps/queryBuilder.js";
|
|
|
5
5
|
export * from "./sps/endpoint.js";
|
|
6
6
|
export * from "./sps/publication.js";
|
|
7
7
|
export * from "./sps/placement.js";
|
|
8
|
+
export * from "./sps/rewrite-salesposter-variables.js";
|
|
8
9
|
export * from "./tracking/create-tracking-params.js";
|
|
9
10
|
export * from "./tracking/tracking-to-pulse-origin.js";
|
|
10
11
|
export * from "./tracking/poster-data-to-pulse-object.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./sps/queryBuilder.js"), exports);
|
|
|
21
21
|
__exportStar(require("./sps/endpoint.js"), exports);
|
|
22
22
|
__exportStar(require("./sps/publication.js"), exports);
|
|
23
23
|
__exportStar(require("./sps/placement.js"), exports);
|
|
24
|
+
__exportStar(require("./sps/rewrite-salesposter-variables.js"), exports);
|
|
24
25
|
__exportStar(require("./tracking/create-tracking-params.js"), exports);
|
|
25
26
|
__exportStar(require("./tracking/tracking-to-pulse-origin.js"), exports);
|
|
26
27
|
__exportStar(require("./tracking/poster-data-to-pulse-object.js"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA4B;AAE5B,wCAAsB;AACtB,8CAA4B;AAE5B,qDAAmC;AACnC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+BAA4B;AAE5B,wCAAsB;AACtB,8CAA4B;AAE5B,qDAAmC;AACnC,iDAA+B;AAC/B,oDAAkC;AAClC,kDAAgC;AAChC,sEAAoD;AAEpD,oEAAkD;AAClD,sEAAoD;AACpD,yEAAuD;AACvD,uEAAqD;AAErD,gDAA8B;AAC9B,iDAA+B;AAC/B,8CAA4B;AAC5B,8CAA4B;AAC5B,oDAAkC;AAElC,kBAAe,SAAG,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PUBLIC_SCRIPT_VERSIONS = void 0;
|
|
4
4
|
// Generated from public-script-versions.json — do not edit manually
|
|
5
5
|
exports.PUBLIC_SCRIPT_VERSIONS = {
|
|
6
|
-
"sps-pulse-helpers": "
|
|
7
|
-
"pulse-tracker-proxy": "1.
|
|
6
|
+
"sps-pulse-helpers": "2.0.0",
|
|
7
|
+
"pulse-tracker-proxy": "1.1.0"
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=public-script-versions.js.map
|
|
@@ -12,12 +12,15 @@ export type PlacementTypeWithOptionalFallback = Exclude<keyof PlacementContentMa
|
|
|
12
12
|
* Placement types that do __not__ require any parameters to be passed to SPS.
|
|
13
13
|
*/
|
|
14
14
|
export type PlacementTypeWithOptionalProps = Exclude<keyof PlacementContentMap, "salesposter" | "ip" | "bottombar">;
|
|
15
|
+
export type PlacementTypeWithStringContent = Exclude<keyof PlacementContentMap, "kyststripe" | "benefit" | "coreheader" | "kystbenefit">;
|
|
15
16
|
/**
|
|
16
17
|
* Maps each placement type string to the TypeScript type of its `content` value.
|
|
17
18
|
* HTML placements map to `string`; JSON placements map to their respective object shapes.
|
|
18
19
|
*/
|
|
19
20
|
export type PlacementContentMap = {
|
|
20
21
|
kyststripe: Kyststripe;
|
|
22
|
+
kystbenefit: Record<string, string>;
|
|
23
|
+
benefit: Benefit;
|
|
21
24
|
coreheader: Record<string, string>;
|
|
22
25
|
bottombar: string;
|
|
23
26
|
foldup: string;
|
|
@@ -46,3 +49,15 @@ export type Kyststripe = {
|
|
|
46
49
|
buttonTxtColor: string;
|
|
47
50
|
buttonId: string;
|
|
48
51
|
};
|
|
52
|
+
export type Benefit = {
|
|
53
|
+
disclaimerText: string;
|
|
54
|
+
disclaimerTextColor: string;
|
|
55
|
+
backgroundColor: string;
|
|
56
|
+
buttonText: string;
|
|
57
|
+
buttonColor: string;
|
|
58
|
+
textButtonColor: string;
|
|
59
|
+
headline: string;
|
|
60
|
+
headlineColor: string;
|
|
61
|
+
kicker: string;
|
|
62
|
+
URL: string;
|
|
63
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { JsonContent } from "../sps.js";
|
|
2
|
-
import { type SPSPulseTrackingParams } from "../utils/pulseProxy.js";
|
|
3
2
|
import type { Environment } from "./endpoint.js";
|
|
4
|
-
|
|
3
|
+
import type { SPSPosterResponse } from "../apiClient.js";
|
|
4
|
+
import type { OfferTrackingData } from "../tracking/create-tracking-params.js";
|
|
5
|
+
import type { PulseOrigin } from "../tracking/tracking-to-pulse-origin.js";
|
|
6
|
+
import type { PlacementTypeWithStringContent } from "./placement.js";
|
|
7
|
+
export interface RewritePlaceholderVariablesOptions<T extends PlacementTypeWithStringContent> {
|
|
5
8
|
/**
|
|
6
9
|
* Url that should be used to return to this article after purchase flow
|
|
7
10
|
*/
|
|
@@ -18,12 +21,42 @@ export interface RewritePlaceholderVariablesParams {
|
|
|
18
21
|
* Whether to append the provided `searchParams` to links. Defaults to true.
|
|
19
22
|
*/
|
|
20
23
|
appendSearchParams?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Publication name
|
|
26
|
+
*/
|
|
27
|
+
publication: string;
|
|
28
|
+
/**
|
|
29
|
+
* Environment for loading pulse proxy scripts
|
|
30
|
+
*/
|
|
31
|
+
environment: Environment;
|
|
32
|
+
/**
|
|
33
|
+
* Placement type for the salesposter
|
|
34
|
+
*/
|
|
35
|
+
placementType: T;
|
|
36
|
+
/**
|
|
37
|
+
* Which Pulse event families to fire
|
|
38
|
+
*/
|
|
39
|
+
pulseEvents?: {
|
|
40
|
+
tpaas?: boolean;
|
|
41
|
+
legacy?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Pulse origin and offer tracking data for legacy events
|
|
45
|
+
*/
|
|
46
|
+
pulseData?: {
|
|
47
|
+
pulseOrigin: PulseOrigin;
|
|
48
|
+
offerData: OfferTrackingData;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Article type
|
|
52
|
+
*/
|
|
53
|
+
articleType?: string;
|
|
21
54
|
}
|
|
22
55
|
/**
|
|
23
56
|
* Enriches the salesposter html links with the correct parameters
|
|
24
57
|
* @returns StructuredResponse with the updated html
|
|
25
58
|
*/
|
|
26
|
-
export declare const rewritePlaceholderVariables: (
|
|
59
|
+
export declare const rewritePlaceholderVariables: <T extends PlacementTypeWithStringContent>(posterResponse: SPSPosterResponse<T>, { redirectUrl, loginUrl, searchParams, appendSearchParams, publication, environment, placementType, pulseEvents, pulseData, articleType, }: RewritePlaceholderVariablesOptions<T>) => string;
|
|
27
60
|
export declare const rewriteJsonPosterVariables: (content: JsonContent, { searchParams, appendSearchParams, }: {
|
|
28
61
|
searchParams: URLSearchParams;
|
|
29
62
|
appendSearchParams?: boolean;
|
|
@@ -9,7 +9,8 @@ const dismiss_1 = require("../actions/dismiss.js");
|
|
|
9
9
|
* Enriches the salesposter html links with the correct parameters
|
|
10
10
|
* @returns StructuredResponse with the updated html
|
|
11
11
|
*/
|
|
12
|
-
const rewritePlaceholderVariables = (
|
|
12
|
+
const rewritePlaceholderVariables = (posterResponse, { redirectUrl, loginUrl, searchParams, appendSearchParams = true, publication, environment, placementType, pulseEvents, pulseData, articleType, }) => {
|
|
13
|
+
const { content, campaign, contentName, experiment } = posterResponse;
|
|
13
14
|
const htmlContent = new DOMParser().parseFromString(content, "text/html");
|
|
14
15
|
const vevJSON = htmlContent.querySelector("script[type='text/vev']");
|
|
15
16
|
const links = htmlContent.querySelectorAll("a");
|
|
@@ -38,8 +39,18 @@ const rewritePlaceholderVariables = (content, { redirectUrl, loginUrl, searchPar
|
|
|
38
39
|
vevJSON.textContent = vevJSON.textContent.replaceAll(href, updatedHref);
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
|
-
if (
|
|
42
|
-
(0, pulseProxy_1.injectPulseProxyScripts)(htmlContent.head,
|
|
42
|
+
if (pulseEvents) {
|
|
43
|
+
(0, pulseProxy_1.injectPulseProxyScripts)(htmlContent.head, {
|
|
44
|
+
publication,
|
|
45
|
+
placementType,
|
|
46
|
+
environment,
|
|
47
|
+
articleType,
|
|
48
|
+
campaign,
|
|
49
|
+
contentName,
|
|
50
|
+
experiment,
|
|
51
|
+
pulseEvents,
|
|
52
|
+
legacy: pulseData,
|
|
53
|
+
});
|
|
43
54
|
}
|
|
44
55
|
const dismissElements = htmlContent.querySelectorAll("[data-dismiss-on-click]");
|
|
45
56
|
if (dismissElements.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite-salesposter-variables.js","sourceRoot":"","sources":["../../../src/sps/rewrite-salesposter-variables.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"rewrite-salesposter-variables.js","sourceRoot":"","sources":["../../../src/sps/rewrite-salesposter-variables.ts"],"names":[],"mappings":";;;AAwLA,oDAwBC;AAhND,sCAAkD;AAElD,oDAA8D;AAC9D,gDAAsD;AAqDtD;;;GAGG;AACI,MAAM,2BAA2B,GAAG,CACzC,cAAoC,EACpC,EACE,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,kBAAkB,GAAG,IAAI,EACzB,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,GAC2B,EAChC,EAAE;IACV,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IACtE,MAAM,WAAW,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC1E,MAAM,OAAO,GAAG,WAAW,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,0LAA0L;IAC1L,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QACD,MAAM,IAAI,GACR,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC;YAClC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG,CAAC,EAAE;YACzC,QAAQ,KAAK,GAAG,CAAC,EAAE,CAAC;QAEtB,MAAM,mBAAmB,GAAG,IA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U,EAAE;IACrF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CACrC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,EAAE,WAAW,CAAC,EACpF,MAAM,CAAC,KAAK,CAAC,CACd,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/cjs/sps.d.ts
CHANGED
|
@@ -71,8 +71,16 @@ export type SpsRequestOptions<T extends PlacementType> = {
|
|
|
71
71
|
* @defaultValue `true`
|
|
72
72
|
*/
|
|
73
73
|
appendSearchParams?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Fine-grained control over which Pulse tracking events are fired.
|
|
76
|
+
* When omitted, all pulse tracking is disabled.
|
|
77
|
+
*/
|
|
78
|
+
pulseEvents?: {
|
|
79
|
+
/** Fire modern TPaaS offer events (`trackImpressionOffer` / `trackEngagementOffer`). @defaultValue false */
|
|
80
|
+
tpaas?: boolean;
|
|
81
|
+
/** Fire legacy UI element events (`trackLegacyViewUIElement` / `trackLegacyClickUIElement`). @defaultValue false */
|
|
82
|
+
legacy?: boolean;
|
|
83
|
+
};
|
|
76
84
|
};
|
|
77
85
|
/**
|
|
78
86
|
* Variant of {@link SpsRequestOptions} that requires a `fallbackPoster` and forces
|
|
@@ -173,8 +181,6 @@ export declare class SPS {
|
|
|
173
181
|
endpoint: string;
|
|
174
182
|
/** The active environment this instance targets. */
|
|
175
183
|
environment: Environment;
|
|
176
|
-
/** The CDN base URL for the active environment. */
|
|
177
|
-
cdnUrl: string;
|
|
178
184
|
/**
|
|
179
185
|
* Creates a new SPS SDK instance.
|
|
180
186
|
* @param options - Configuration options including publication, domain and environment.
|
package/dist/cjs/sps.js
CHANGED
|
@@ -17,8 +17,6 @@ class SPS {
|
|
|
17
17
|
endpoint;
|
|
18
18
|
/** The active environment this instance targets. */
|
|
19
19
|
environment;
|
|
20
|
-
/** The CDN base URL for the active environment. */
|
|
21
|
-
cdnUrl;
|
|
22
20
|
/**
|
|
23
21
|
* Creates a new SPS SDK instance.
|
|
24
22
|
* @param options - Configuration options including publication, domain and environment.
|
|
@@ -27,7 +25,6 @@ class SPS {
|
|
|
27
25
|
this.environment = environment;
|
|
28
26
|
this.publication = publication;
|
|
29
27
|
this.endpoint = (0, _1.getEndpoint)(environment, domain);
|
|
30
|
-
this.cdnUrl = (0, _1.getCdnUrl)(environment);
|
|
31
28
|
}
|
|
32
29
|
async validateClientEnvironment() {
|
|
33
30
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -84,24 +81,21 @@ class SPS {
|
|
|
84
81
|
let content;
|
|
85
82
|
const generateLoginUrl = props.generateLoginUrl;
|
|
86
83
|
const generateRedirectUrl = props.generateRedirectUrl;
|
|
87
|
-
const {
|
|
84
|
+
const { pulseEvents } = props;
|
|
88
85
|
if (typeof posterResponse.content === "string") {
|
|
89
|
-
content = (0, rewrite_salesposter_variables_1.rewritePlaceholderVariables)(posterResponse
|
|
86
|
+
content = (0, rewrite_salesposter_variables_1.rewritePlaceholderVariables)(posterResponse, {
|
|
90
87
|
loginUrl: (await generateLoginUrl?.(posterResponse)) ?? "",
|
|
91
88
|
redirectUrl: (await generateRedirectUrl?.(posterResponse)) ??
|
|
92
89
|
`${window.location.origin}${window.location.pathname}`,
|
|
93
90
|
searchParams,
|
|
94
91
|
appendSearchParams: props.appendSearchParams ?? true,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
experiment: posterResponse.experiment,
|
|
103
|
-
}
|
|
104
|
-
: undefined);
|
|
92
|
+
publication: this.publication,
|
|
93
|
+
environment: this.environment,
|
|
94
|
+
placementType: placementType,
|
|
95
|
+
pulseEvents,
|
|
96
|
+
pulseData: { pulseOrigin, offerData },
|
|
97
|
+
articleType: props.params?.articleType,
|
|
98
|
+
});
|
|
105
99
|
}
|
|
106
100
|
else {
|
|
107
101
|
content = (0, rewrite_salesposter_variables_1.rewriteJsonPosterVariables)(posterResponse.content, {
|
|
@@ -195,24 +189,21 @@ class SPS {
|
|
|
195
189
|
abTestGroup: poster.posterResponse.abTestGroup || undefined,
|
|
196
190
|
});
|
|
197
191
|
let content = poster.posterResponse.content;
|
|
198
|
-
const {
|
|
192
|
+
const { pulseEvents } = props;
|
|
199
193
|
if (typeof poster.posterResponse.content === "string") {
|
|
200
|
-
content = (0, rewrite_salesposter_variables_1.rewritePlaceholderVariables)(poster.posterResponse
|
|
194
|
+
content = (0, rewrite_salesposter_variables_1.rewritePlaceholderVariables)(poster.posterResponse, {
|
|
201
195
|
loginUrl: (await props.generateLoginUrl?.(poster.posterResponse)) ?? "",
|
|
202
196
|
redirectUrl: (await props.generateRedirectUrl?.(poster.posterResponse)) ??
|
|
203
197
|
window.location.origin + window.location.pathname,
|
|
204
198
|
searchParams,
|
|
205
199
|
appendSearchParams: props.appendSearchParams ?? true,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
experiment: poster.posterResponse.experiment,
|
|
214
|
-
}
|
|
215
|
-
: undefined);
|
|
200
|
+
publication: this.publication,
|
|
201
|
+
environment: this.environment,
|
|
202
|
+
placementType: placementType,
|
|
203
|
+
pulseEvents,
|
|
204
|
+
pulseData: { pulseOrigin, offerData },
|
|
205
|
+
articleType,
|
|
206
|
+
});
|
|
216
207
|
}
|
|
217
208
|
else {
|
|
218
209
|
content = (0, rewrite_salesposter_variables_1.rewriteJsonPosterVariables)(poster.posterResponse.content, {
|
package/dist/cjs/sps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sps.js","sourceRoot":"","sources":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AA0B,EAAC,MAAM,CAAC,cAAc,CAAC,OAAsB,EAAE;gBACjF,YAAY;gBACZ,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,IAAI;aACrD,CAA8C,CAAC;QAClD,CAAC;QAED,IAAI,cAAc,EAAE,CAAC;YACnB,IAAA,oBAAU,EAAC,aAAa,EAAE,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;QAClF,CAAC;QAED,OAAO;YACL,GAAG,MAAM,CAAC,cAAc;YACxB,YAAY;YACZ,OAAO;YACP,YAAY;YACZ,WAAW;YACX,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC;CACH;AAxRD,kBAwRC"}
|
|
@@ -2,7 +2,7 @@ import { type PulseTracker } from "../utils/pulse.js";
|
|
|
2
2
|
import { type UtmTags } from "../utils/utm.js";
|
|
3
3
|
import { type PulseOrigin } from "./tracking-to-pulse-origin.js";
|
|
4
4
|
import { type PulseObject } from "./poster-data-to-pulse-object.js";
|
|
5
|
-
export type ContentType = "article" | "podcast" | "video" | "
|
|
5
|
+
export type ContentType = "article" | "podcast" | "video" | "other";
|
|
6
6
|
export type DeviceType = "mobile" | "tablet" | "desktop";
|
|
7
7
|
/**
|
|
8
8
|
* Input options for {@link createTrackingParams}.
|
|
@@ -91,7 +91,7 @@ export interface TrackingData {
|
|
|
91
91
|
*/
|
|
92
92
|
export interface OfferTrackingData {
|
|
93
93
|
offer_placement?: string;
|
|
94
|
-
offer_type?:
|
|
94
|
+
offer_type?: "Login" | "Meter" | "Paid";
|
|
95
95
|
offer_campaign?: string;
|
|
96
96
|
offer_test_group?: string;
|
|
97
97
|
offer_cta?: string;
|
|
@@ -9,6 +9,7 @@ const xDomainId_1 = require("../utils/xDomainId.js");
|
|
|
9
9
|
const tracking_to_pulse_origin_1 = require("./tracking-to-pulse-origin.js");
|
|
10
10
|
const tracking_to_search_params_1 = require("./tracking-to-search-params.js");
|
|
11
11
|
const poster_data_to_pulse_object_1 = require("./poster-data-to-pulse-object.js");
|
|
12
|
+
const offerType_1 = require("../utils/offerType.js");
|
|
12
13
|
const NO_DATA = "";
|
|
13
14
|
/**
|
|
14
15
|
* Creates the tracking parameters for use towards purchase flow
|
|
@@ -44,7 +45,7 @@ async function createTrackingParams(options, posterData) {
|
|
|
44
45
|
};
|
|
45
46
|
const offerData = {
|
|
46
47
|
offer_placement: placementType,
|
|
47
|
-
offer_type: articleType,
|
|
48
|
+
offer_type: (0, offerType_1.getOfferType)(articleType),
|
|
48
49
|
offer_campaign: campaign,
|
|
49
50
|
offer_test_group: abTestGroup,
|
|
50
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tracking-params.js","sourceRoot":"","sources":["../../../src/tracking/create-tracking-params.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-tracking-params.js","sourceRoot":"","sources":["../../../src/tracking/create-tracking-params.ts"],"names":[],"mappings":";;AAgIA,oDAyEC;AAzMD,0CAA6E;AAC7E,4CAAwD;AACxD,sCAAkD;AAClD,sCAA2D;AAC3D,kDAAuD;AACvD,yEAAqF;AACrF,2EAAqE;AACrE,+EAA0F;AAC1F,kDAAkD;AAElD,MAAM,OAAO,GAAG,EAAE,CAAC;AAgHnB;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACxC,OAA4B,EAC5B,UAAuB;IAEvB,MAAM,EACJ,SAAS,EACT,WAAW,EACX,eAAe,GAAG,KAAK,EACvB,WAAW,GAAG,EAAE,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,WAAW,EAAE,iBAAiB,EAC9B,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,OAAO,GAChB,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAAuB,MAAM,IAAA,gCAAwB,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,IAAA,6BAAiB,GAAE,CAAC;IAEtC,MAAM,EAAE,QAAQ,EAAE,aAAa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kB,EAAC,YAAY,CAAC,IAAI,QAAQ,IAAI,OAAO;QACrE,QAAQ,EAAE,IAAA,wBAAkB,EAAC,QAAQ,CAAC,IAAI,OAAO;QACjD,OAAO,EAAE,IAAA,wBAAkB,EAAC,OAAO,CAAC,IAAI,OAAO;QAC/C,UAAU,EAAE,SAAS,IAAI,OAAO;QAChC,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,SAAS;QACtB,QAAQ,EAAE,MAAM,IAAI,OAAO;QAC3B,sDAAsD;KACvD,CAAC;IAEF,MAAM,SAAS,GAAsB;QACnC,eAAe,EAAE,aAAa;QAC9B,UAAU,EAAE,IAAA,wBAAY,EAAC,WAAW,CAAC;QACrC,cAAc,EAAE,QAAQ;QACxB,gBAAgB,EAAE,WAAW;KAC9B,CAAC;IAEF,MAAM,WAAW,GAAG,IAAA,gDAAqB,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,IAAA,qDAAuB,EAAC,OAAO,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAEpF,MAAM,YAAY,GAAG,IAAA,kDAAsB,EAAC,EAAE,GAAG,YAAY,EAAE,GAAG,SAAS,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAEjG,OAAO;QACL,YAAY;QACZ,WAAW;QACX,WAAW;QACX,YAAY;QACZ,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Intent = "Purchase" | "Login";
|
|
2
|
+
/**
|
|
3
|
+
* Determine the intent of a click based on the hostname of the link.
|
|
4
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute. If the href is missing or invalid, the function will return undefined.
|
|
5
|
+
* @returns "Purchase", "Login", or undefined based on the hostname of the link.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getIntent: (link: Element) => Intent | undefined;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIntent = void 0;
|
|
4
|
+
const isPurchaseHostname = (hostname) => {
|
|
5
|
+
return (hostname === "payment.schibsted.com" ||
|
|
6
|
+
hostname.startsWith("bestilling.") ||
|
|
7
|
+
hostname === "pay.pre.schibsted.digital" ||
|
|
8
|
+
hostname.startsWith("test-bestilling."));
|
|
9
|
+
};
|
|
10
|
+
const isLoginHostname = (hostname) => {
|
|
11
|
+
return hostname === "login.schibsted.com" || hostname === "identity-pre.schibsted.com";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Determine the intent of a click based on the hostname of the link.
|
|
15
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute. If the href is missing or invalid, the function will return undefined.
|
|
16
|
+
* @returns "Purchase", "Login", or undefined based on the hostname of the link.
|
|
17
|
+
*/
|
|
18
|
+
const getIntent = (link) => {
|
|
19
|
+
try {
|
|
20
|
+
const elementUrl = new URL(link.getAttribute("href") ?? "");
|
|
21
|
+
const hostname = elementUrl.hostname;
|
|
22
|
+
if (isLoginHostname(hostname)) {
|
|
23
|
+
return "Login";
|
|
24
|
+
}
|
|
25
|
+
if (isPurchaseHostname(hostname)) {
|
|
26
|
+
return "Purchase";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.getIntent = getIntent;
|
|
34
|
+
//# sourceMappingURL=intent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.js","sourceRoot":"","sources":["../../../src/utils/intent.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACvD,OAAO,CACL,QAAQ,KAAK,uBAAuB;QACpC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC;QAClC,QAAQ,KAAK,2BAA2B;QACxC,QAAQ,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAW,EAAE;IACpD,OAAO,QAAQ,KAAK,qBAAqB,IAAI,QAAQ,KAAK,4BAA4B,CAAC;AACzF,CAAC,CAAC;AAIF;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAC,IAAa,EAAsB,EAAE;IAC7D,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACrC,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAbW,QAAA,SAAS,aAapB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts offer codes from the href attribute of a clicked link.
|
|
3
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute. If the href is missing or invalid, the function will return undefined.
|
|
4
|
+
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getOfferCodes: (link: Element) => string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOfferCodes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Extracts offer codes from the href attribute of a clicked link.
|
|
6
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute. If the href is missing or invalid, the function will return undefined.
|
|
7
|
+
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
8
|
+
*/
|
|
9
|
+
const getOfferCodes = (link) => {
|
|
10
|
+
try {
|
|
11
|
+
const elementUrl = new URL(link.getAttribute("href") ?? "");
|
|
12
|
+
const queryParams = new URLSearchParams(elementUrl.search);
|
|
13
|
+
const offerCode = queryParams.get("code");
|
|
14
|
+
return offerCode ? offerCode.split(",") : [];
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.getOfferCodes = getOfferCodes;
|
|
21
|
+
//# sourceMappingURL=offerCodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerCodes.js","sourceRoot":"","sources":["../../../src/utils/offerCodes.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,IAAa,EAAY,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1C,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AATW,QAAA,aAAa,iBASxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type OfferType = "Meter" | "Paid" | "Login";
|
|
2
|
+
/**
|
|
3
|
+
* Determines the offer type based on the article type string.
|
|
4
|
+
* @param articleType the article type string passed from the client call, which may contain indicators of the offer type such as "meter" or "paid". If the string is undefined or does not contain any known indicators, the function defaults to "Login".
|
|
5
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Undefined if the article type is not provided or does not match any known offer types.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getOfferType: (articleType?: string) => OfferType | undefined;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOfferType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Determines the offer type based on the article type string.
|
|
6
|
+
* @param articleType the article type string passed from the client call, which may contain indicators of the offer type such as "meter" or "paid". If the string is undefined or does not contain any known indicators, the function defaults to "Login".
|
|
7
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Undefined if the article type is not provided or does not match any known offer types.
|
|
8
|
+
*/
|
|
9
|
+
const getOfferType = (articleType) => {
|
|
10
|
+
const lower = articleType?.toLowerCase() ?? "";
|
|
11
|
+
if (lower.includes("meter")) {
|
|
12
|
+
return "Meter";
|
|
13
|
+
}
|
|
14
|
+
if (lower.includes("paid") || lower.includes("subscription")) {
|
|
15
|
+
return "Paid";
|
|
16
|
+
}
|
|
17
|
+
if (lower.includes("login")) {
|
|
18
|
+
return "Login";
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getOfferType = getOfferType;
|
|
22
|
+
//# sourceMappingURL=offerType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerType.js","sourceRoot":"","sources":["../../../src/utils/offerType.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,WAAoB,EAAyB,EAAE;IAC1E,MAAM,KAAK,GAAG,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IAC/C,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB"}
|
|
@@ -1,30 +1,61 @@
|
|
|
1
1
|
import type { PulseOrigin } from "../tracking/tracking-to-pulse-origin.js";
|
|
2
2
|
import type { PlacementType } from "../sps/placement.js";
|
|
3
3
|
import type { OfferTrackingData } from "../tracking/create-tracking-params.js";
|
|
4
|
-
|
|
4
|
+
import { type Environment } from "../sps/endpoint.js";
|
|
5
|
+
export interface PulseConfig {
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
+
* Environment for loading pulse proxy scripts, set by the environment argument when initializing the SPS instance
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
environment: Environment;
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Campaign name for the salesposter
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
campaign: string;
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Content name for the salesposter
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
contentName: string;
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Article type
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
articleType?: string;
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* A/B test group identifier, if applicable
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
abTestGroup?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Fields forwarded as-is to legacy tracking functions only
|
|
28
|
+
* */
|
|
29
|
+
legacy?: {
|
|
30
|
+
/**
|
|
31
|
+
* Pulse origin data from tracking data
|
|
32
|
+
*/
|
|
33
|
+
pulseOrigin: PulseOrigin;
|
|
34
|
+
/**
|
|
35
|
+
* TPaaS offer tracking params
|
|
36
|
+
*/
|
|
37
|
+
offerData: OfferTrackingData;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Publication name
|
|
41
|
+
*/
|
|
42
|
+
publication: string;
|
|
43
|
+
/**
|
|
44
|
+
* Placement type for the salesposter
|
|
45
|
+
*/
|
|
46
|
+
placementType: PlacementType;
|
|
25
47
|
/**
|
|
26
48
|
* Experiment identifier from the SPS response
|
|
27
49
|
*/
|
|
28
50
|
experiment?: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Which Pulse event families to fire. When omitted, all tracking is disabled.
|
|
53
|
+
*/
|
|
54
|
+
pulseEvents?: {
|
|
55
|
+
/** Fire modern TPaaS offer events (`trackImpressionOffer` / `trackEngagementOffer`). */
|
|
56
|
+
tpaas?: boolean;
|
|
57
|
+
/** Fire legacy UI element events (`trackLegacyViewUIElement` / `trackLegacyClickUIElement`). */
|
|
58
|
+
legacy?: boolean;
|
|
59
|
+
};
|
|
29
60
|
}
|
|
30
|
-
export declare const injectPulseProxyScripts: (root: HTMLElement,
|
|
61
|
+
export declare const injectPulseProxyScripts: (root: HTMLElement, config: PulseConfig) => void;
|
|
@@ -2,19 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.injectPulseProxyScripts = void 0;
|
|
4
4
|
const public_script_versions_1 = require("../public-script-versions.js");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
5
|
+
const endpoint_1 = require("../sps/endpoint.js");
|
|
6
|
+
const injectPulseProxyScripts = (root, config) => {
|
|
7
|
+
const { environment } = config;
|
|
8
|
+
const HELPERS_SRC = `${(0, endpoint_1.getCdnUrl)(environment)}/public-scripts/sps-pulse-helpers.v${public_script_versions_1.PUBLIC_SCRIPT_VERSIONS["sps-pulse-helpers"]}.min.js`;
|
|
9
|
+
const PROXY_SRC = `${(0, endpoint_1.getCdnUrl)(environment)}/public-scripts/pulse-tracker-proxy.v${public_script_versions_1.PUBLIC_SCRIPT_VERSIONS["pulse-tracker-proxy"]}.min.js`;
|
|
8
10
|
const configScript = document.createElement("script");
|
|
9
11
|
configScript.type = "application/json";
|
|
10
12
|
configScript.setAttribute("data-sps-pulse-config", "true");
|
|
11
|
-
configScript.textContent = JSON.stringify(
|
|
12
|
-
pulseOrigin,
|
|
13
|
-
publication,
|
|
14
|
-
placementType,
|
|
15
|
-
offerData,
|
|
16
|
-
...(experiment && { experiment }),
|
|
17
|
-
});
|
|
13
|
+
configScript.textContent = JSON.stringify(config);
|
|
18
14
|
const helpersScript = document.createElement("script");
|
|
19
15
|
helpersScript.src = HELPERS_SRC;
|
|
20
16
|
const proxyScript = document.createElement("script");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"mappings":";;;AAGA,sEAAmE;
|
|
1
|
+
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"mappings":";;;AAGA,sEAAmE;AACnE,8CAA8D;AA2DvD,MAAM,uBAAuB,GAAG,CAAC,IAAiB,EAAE,MAAmB,EAAE,EAAE;IAChF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC/B,MAAM,WAAW,GAAG,GAAG,IAAA,oBAAS,EAAC,WAAW,CAAC,sCAAsC,+CAAsB,CAAC,mBAAmB,CAAC,SAAS,CAAC;IACxI,MAAM,SAAS,GAAG,GAAG,IAAA,oBAAS,EAAC,WAAW,CAAC,wCAAwC,+CAAsB,CAAC,qBAAqB,CAAC,SAAS,CAAC;IAE1I,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtD,YAAY,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACvC,YAAY,CAAC,YAAY,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAC3D,YAAY,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAElD,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvD,aAAa,CAAC,GAAG,GAAG,WAAW,CAAC;IAEhC,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACrD,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC;IAE5B,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC/B,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAC9B,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;AAClC,CAAC,CAAC;AAnBW,QAAA,uBAAuB,2BAmBlC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./sps/queryBuilder.js";
|
|
|
5
5
|
export * from "./sps/endpoint.js";
|
|
6
6
|
export * from "./sps/publication.js";
|
|
7
7
|
export * from "./sps/placement.js";
|
|
8
|
+
export * from "./sps/rewrite-salesposter-variables.js";
|
|
8
9
|
export * from "./tracking/create-tracking-params.js";
|
|
9
10
|
export * from "./tracking/tracking-to-pulse-origin.js";
|
|
10
11
|
export * from "./tracking/poster-data-to-pulse-object.js";
|