@schibsted/sps-sdk 4.0.0-CBT-18545.2 → 4.0.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/actions/dismiss.d.ts +1 -2
- package/dist/cjs/actions/dismiss.js +4 -15
- package/dist/cjs/actions/dismiss.js.map +1 -1
- package/dist/cjs/apiClient.d.ts +4 -0
- package/dist/cjs/apiClient.js.map +1 -1
- package/dist/cjs/sps/placement.d.ts +0 -14
- package/dist/cjs/sps.d.ts +1 -7
- package/dist/cjs/sps.js +3 -3
- package/dist/cjs/sps.js.map +1 -1
- package/dist/cjs/tracking/create-tracking-params.d.ts +1 -1
- package/dist/cjs/utils/offerCodes.d.ts +2 -2
- package/dist/cjs/utils/offerCodes.js +2 -2
- package/dist/cjs/utils/offerType.d.ts +2 -2
- package/dist/cjs/utils/offerType.js +2 -2
- package/dist/cjs/utils/pulseProxy.d.ts +2 -2
- package/dist/cjs/utils/pulseProxy.js.map +1 -1
- package/dist/cjs/utils/utm.js +14 -9
- package/dist/cjs/utils/utm.js.map +1 -1
- package/dist/esm/actions/dismiss.d.ts +1 -2
- package/dist/esm/actions/dismiss.js +4 -15
- package/dist/esm/actions/dismiss.js.map +1 -1
- package/dist/esm/apiClient.d.ts +4 -0
- package/dist/esm/apiClient.js.map +1 -1
- package/dist/esm/sps/placement.d.ts +0 -14
- package/dist/esm/sps.d.ts +1 -7
- package/dist/esm/sps.js +3 -3
- package/dist/esm/sps.js.map +1 -1
- package/dist/esm/tracking/create-tracking-params.d.ts +1 -1
- package/dist/esm/utils/offerCodes.d.ts +2 -2
- package/dist/esm/utils/offerCodes.js +2 -2
- package/dist/esm/utils/offerType.d.ts +2 -2
- package/dist/esm/utils/offerType.js +2 -2
- package/dist/esm/utils/pulseProxy.d.ts +2 -2
- package/dist/esm/utils/pulseProxy.js.map +1 -1
- package/dist/esm/utils/utm.js +14 -9
- package/dist/esm/utils/utm.js.map +1 -1
- package/dist/public-scripts/sps-pulse-helpers.v2.0.0.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PlacementType } from "../sps/placement.js";
|
|
2
2
|
import type { Environment } from "../sps/endpoint.js";
|
|
3
|
-
import type { DismissTimeOptions } from "../sps.js";
|
|
4
3
|
export declare const isDismissed: (placementType: PlacementType, iframeId: string) => boolean;
|
|
5
|
-
export declare const addDismiss: (placementType: PlacementType, iframeId: string,
|
|
4
|
+
export declare const addDismiss: (placementType: PlacementType, iframeId: string, hideDuration: number) => void;
|
|
6
5
|
export declare const getDismissScript: (publication: string, environment: Environment, placementType: string) => string;
|
|
@@ -27,7 +27,7 @@ const isDismissed = (placementType, iframeId) => {
|
|
|
27
27
|
};
|
|
28
28
|
exports.isDismissed = isDismissed;
|
|
29
29
|
const dismissListenerKeys = new Set();
|
|
30
|
-
const addDismiss = (placementType, iframeId,
|
|
30
|
+
const addDismiss = (placementType, iframeId, hideDuration) => {
|
|
31
31
|
const key = `${placementType}:${iframeId}`;
|
|
32
32
|
if (dismissListenerKeys.has(key)) {
|
|
33
33
|
return;
|
|
@@ -40,7 +40,7 @@ const addDismiss = (placementType, iframeId, dismissTime) => {
|
|
|
40
40
|
if (event.data.type === `${DISMISS_KEY}:${placementType}`) {
|
|
41
41
|
console.log("[SPS sdk] - Dismiss issued by user", event);
|
|
42
42
|
const data = {
|
|
43
|
-
ttl: calculateTtl(
|
|
43
|
+
ttl: calculateTtl(hideDuration),
|
|
44
44
|
status: "dismissed",
|
|
45
45
|
};
|
|
46
46
|
localStorage.setItem(`sps-dismissed-${placementType}-${iframeId}`, JSON.stringify(data));
|
|
@@ -49,20 +49,9 @@ const addDismiss = (placementType, iframeId, dismissTime) => {
|
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
exports.addDismiss = addDismiss;
|
|
52
|
-
const calculateTtl = (
|
|
52
|
+
const calculateTtl = (hideDuration) => {
|
|
53
53
|
const now = Date.now();
|
|
54
|
-
|
|
55
|
-
"1day": 24,
|
|
56
|
-
"2days": 48,
|
|
57
|
-
"3days": 72,
|
|
58
|
-
"4days": 96,
|
|
59
|
-
"5days": 120,
|
|
60
|
-
"6days": 144,
|
|
61
|
-
"1week": 7 * 24,
|
|
62
|
-
"2week": 14 * 24,
|
|
63
|
-
"1month": 30 * 24,
|
|
64
|
-
};
|
|
65
|
-
return now + (timeMap[dismissTime ?? 24] || 24) * 60 * 60 * 1000;
|
|
54
|
+
return now + hideDuration;
|
|
66
55
|
};
|
|
67
56
|
const getDismissScript = (publication, environment, placementType) => `
|
|
68
57
|
document.addEventListener("click", function (event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dismiss.js","sourceRoot":"","sources":["../../../src/actions/dismiss.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"dismiss.js","sourceRoot":"","sources":["../../../src/actions/dismiss.ts"],"names":[],"mappings":";;;AAEA,oDAAoD;AAEpD,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAEjC,MAAM,WAAW,GAAG,CAAC,aAA4B,EAAE,QAAgB,EAAW,EAAE;IACrF,MAAM,UAAU,GAAG,iBAAiB,aAAa,IAAI,QAAQ,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;I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AAM,YAAY,GAAG,CAAC,YAAoB,EAAU,EAAE;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO,GAAG,GAAG,YAAY,CAAC;AAC5B,CAAC,CAAC;AAEK,MAAM,gBAAgB,GAAG,CAC9B,WAAmB,EACnB,WAAwB,EACxB,aAAqB,EACrB,EAAE,CACF;;;;;;;;;qBASmB,WAAW,IAAI,aAAa;;aAEpC,sBAAsB,CAAC,WAAW,EAAE,WAAW,CAAC;;;;GAI1D,CAAC;AApBS,QAAA,gBAAgB,oBAoBzB;AAEJ,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAE,WAAwB,EAAU,EAAE;IACvF,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,4BAAc,CAAC,WAAW;YAC7B,OAAO,gBAAgB,CAAC;QAC1B,KAAK,4BAAc,CAAC,EAAE;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,4BAAc,CAAC,EAAE;YACpB,OAAO,gBAAgB,CAAC;QAC1B,KAAK,4BAAc,CAAC,EAAE;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,4BAAc,CAAC,GAAG;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,4BAAc,CAAC,GAAG;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,4BAAc,CAAC,EAAE;YACpB,OAAO,gBAAgB,CAAC;QAC1B;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
|
package/dist/cjs/apiClient.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export type SPSPosterResponse<T extends PlacementType> = {
|
|
|
44
44
|
* A string describing why a fallback or non-standard response was returned, if applicable.
|
|
45
45
|
*/
|
|
46
46
|
failReason?: string;
|
|
47
|
+
/**
|
|
48
|
+
* A number in milliseconds representating the time a given placement should be hidden before appearing for the user again.
|
|
49
|
+
*/
|
|
50
|
+
hideDuration?: number;
|
|
47
51
|
};
|
|
48
52
|
/**
|
|
49
53
|
* Returned by the SPS API when there is no content to display for the given placement.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../src/apiClient.ts"],"names":[],"mappings":";;;AAAA,qDAK4B;AAC5B,qCAA8C;
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../src/apiClient.ts"],"names":[],"mappings":";;;AAAA,qDAK4B;AAC5B,qCAA8C;AAwE9C;;;;;;;;;;;;GAYG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,GAAW,EACX,MAAS,EACT,cAAqC,EACrC,6BAA6B,GAAG,KAAK,EACe,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,IAAA,oCAAqB,GAAE,CAAC;QACnD,MAAM,WAAW,GAAG,IAAA,yCAA0B,EAAC;YAC7C,GAAG,kBAAkB;YACrB,GAAG,MAAM;SACV,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,IAAA,qBAAe,EAAC,GAAG,EAAE,WAAW,CAAC,EAAE;YACpE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;YACvB,IAAI,cAAc,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAClC,IAAI,cAAc,EAAE,CAAC;oBACnB,OAAO;wBACL,cAAc,EAAE,cAAc;wBAC9B,UAAU,EAAE,gEAAgE;qBAC7E,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,IAAI,KAAK,CACb,mCAAmC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,UAAU,EAAE,CACxF,CAAC;QACJ,CAAC;QAED,MAAM,cAAc,GAAgD,MAA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CAAC;IAED,OAAO,gBAAgB,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC,CAAC;AAvBW,QAAA,aAAa,iBAuBxB"}
|
|
@@ -25,8 +25,6 @@ export declare const isLandingPagePlacement: (placementType: PlacementType) => b
|
|
|
25
25
|
*/
|
|
26
26
|
export type PlacementContentMap = {
|
|
27
27
|
kyststripe: Kyststripe;
|
|
28
|
-
kystbenefit: Record<string, string>;
|
|
29
|
-
benefit: Benefit;
|
|
30
28
|
coreheader: Record<string, string>;
|
|
31
29
|
bottombar: string;
|
|
32
30
|
foldup: string;
|
|
@@ -57,15 +55,3 @@ export type Kyststripe = {
|
|
|
57
55
|
buttonTxtColor: string;
|
|
58
56
|
buttonId: string;
|
|
59
57
|
};
|
|
60
|
-
export type Benefit = {
|
|
61
|
-
disclaimerText: string;
|
|
62
|
-
disclaimerTextColor: string;
|
|
63
|
-
backgroundColor: string;
|
|
64
|
-
buttonText: string;
|
|
65
|
-
buttonColor: string;
|
|
66
|
-
textButtonColor: string;
|
|
67
|
-
headline: string;
|
|
68
|
-
headlineColor: string;
|
|
69
|
-
kicker: string;
|
|
70
|
-
URL: string;
|
|
71
|
-
};
|
package/dist/cjs/sps.d.ts
CHANGED
|
@@ -91,10 +91,6 @@ export type SpsRequestOptionsWithFallback<T extends PlacementType> = SpsRequestO
|
|
|
91
91
|
fallbackPoster: SPSPosterResponse<T>;
|
|
92
92
|
showFallbackPosterOnNoContent: true;
|
|
93
93
|
};
|
|
94
|
-
/**
|
|
95
|
-
* Duration strings controlling how long a dismissed placement stays hidden.
|
|
96
|
-
*/
|
|
97
|
-
export type DismissTimeOptions = "1day" | "2days" | "3days" | "4days" | "5days" | "6days" | "1week" | "2week" | "1month";
|
|
98
94
|
/**
|
|
99
95
|
* Options for the dismiss functionality, enabling a placement to be hidden when
|
|
100
96
|
* an element with `data-dismiss-on-click` is clicked inside the placement.
|
|
@@ -102,8 +98,6 @@ export type DismissTimeOptions = "1day" | "2days" | "3days" | "4days" | "5days"
|
|
|
102
98
|
interface DismissOptions {
|
|
103
99
|
/** The HTML `id` attribute of the iframe element containing the placement. */
|
|
104
100
|
elementId: string;
|
|
105
|
-
/** How long the placement should remain suppressed after being dismissed. */
|
|
106
|
-
dismissTime: DismissTimeOptions;
|
|
107
101
|
}
|
|
108
102
|
/**
|
|
109
103
|
* Mapping of placement types to their required parameters.
|
|
@@ -200,7 +194,7 @@ export declare class SPS {
|
|
|
200
194
|
*
|
|
201
195
|
* @param placementType - The SPS placement to request (e.g. `"salesposter"`, `"bottombar"`).
|
|
202
196
|
* @param props - Request options including decisioning params and tracking context.
|
|
203
|
-
* @param
|
|
197
|
+
* @param dismissOptions - Optional dismiss configuration for hiding the placement on user interaction.
|
|
204
198
|
* @returns The enriched poster response, or `null` when no content is available.
|
|
205
199
|
*/
|
|
206
200
|
getPoster: GetPoster;
|
package/dist/cjs/sps.js
CHANGED
|
@@ -48,7 +48,7 @@ class SPS {
|
|
|
48
48
|
*
|
|
49
49
|
* @param placementType - The SPS placement to request (e.g. `"salesposter"`, `"bottombar"`).
|
|
50
50
|
* @param props - Request options including decisioning params and tracking context.
|
|
51
|
-
* @param
|
|
51
|
+
* @param dismissOptions - Optional dismiss configuration for hiding the placement on user interaction.
|
|
52
52
|
* @returns The enriched poster response, or `null` when no content is available.
|
|
53
53
|
*/
|
|
54
54
|
getPoster = async (placementType, props = {}, dismissOptions) => {
|
|
@@ -104,7 +104,7 @@ class SPS {
|
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
if (dismissOptions) {
|
|
107
|
-
(0, dismiss_1.addDismiss)(placementType, dismissOptions.elementId,
|
|
107
|
+
(0, dismiss_1.addDismiss)(placementType, dismissOptions.elementId, posterResponse.hideDuration || 86400); // Default 1 day.
|
|
108
108
|
}
|
|
109
109
|
return {
|
|
110
110
|
...posterResponse,
|
|
@@ -212,7 +212,7 @@ class SPS {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
if (dismissOptions) {
|
|
215
|
-
(0, dismiss_1.addDismiss)(placementType, dismissOptions.elementId,
|
|
215
|
+
(0, dismiss_1.addDismiss)(placementType, dismissOptions.elementId, poster.posterResponse.hideDuration || 86400);
|
|
216
216
|
}
|
|
217
217
|
return {
|
|
218
218
|
...poster.posterResponse,
|
package/dist/cjs/sps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sps.js","sourceRoot":"","sources":["../../src/sps.ts"],"names":[],"mappings":";;;AAAA,wBASW;AACX,8EAK2C;AAC3C,uFAG6C;AAE7C,2CAAiF;AAOjF,+CAA4D;
|
|
1
|
+
{"version":3,"file":"sps.js","sourceRoot":"","sources":["../../src/sps.ts"],"names":[],"mappings":";;;AAAA,wBASW;AACX,8EAK2C;AAC3C,uFAG6C;AAE7C,2CAAiF;AAOjF,+CAA4D;AAqN5D;;;GAGG;AACH,MAAa,GAAG;IACd,2DAA2D;IAC3D,WAAW,CAAS;IACpB,8CAA8C;IAC9C,QAAQ,CAAS;IACjB,oDAAoD;IACpD,WAAW,CAAc;IAEzB;;;OAGG;IACH,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,EAAE,WAAW,GAAG,YAAY,EAAc;QAC5F,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAA,cAAW,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,yBAAyB;QACrC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CACb,4FAA4F,CAC7F,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,yBAAyB;QACrC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK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MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ;gBACnD,YAAY;gBACZ,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,IAAI;gBACpD,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,aAAa,EAAE,aAA+C;gBAC9D,WAAW;gBACX,SAAS,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE;gBACrC,WAAW;aACZ,CAC2C,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAA,0DAA0B,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,EACR,aAAa,EACb,cAAc,CAAC,SAAS,EACxB,MAAM,CAAC,cAAc,CAAC,YAAY,IAAI,KAAK,CAC5C,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,MAAM,CAAC,cAAc;YACxB,YAAY;YACZ,OAAO;YACP,YAAY;YACZ,WAAW;YACX,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC;CACH;AA5RD,kBA4RC"}
|
|
@@ -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" | "other";
|
|
5
|
+
export type ContentType = "article" | "podcast" | "video" | "page" | "other";
|
|
6
6
|
export type DeviceType = "mobile" | "tablet" | "desktop";
|
|
7
7
|
/**
|
|
8
8
|
* Input options for {@link createTrackingParams}.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
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.
|
|
4
|
-
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
3
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute.
|
|
4
|
+
* @returns an array of offer codes or an empty array if no offer codes are found, or if the href is missing or invalid.
|
|
5
5
|
*/
|
|
6
6
|
export declare const getOfferCodes: (link: Element) => string[];
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOfferCodes = void 0;
|
|
4
4
|
/**
|
|
5
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.
|
|
7
|
-
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
6
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute.
|
|
7
|
+
* @returns an array of offer codes or an empty array if no offer codes are found, or if the href is missing or invalid.
|
|
8
8
|
*/
|
|
9
9
|
const getOfferCodes = (link) => {
|
|
10
10
|
try {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type OfferType = "Meter" | "Paid" | "Login";
|
|
2
2
|
/**
|
|
3
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
|
|
5
|
-
* @returns "Meter", "Paid", or "Login" 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 returns undefined.
|
|
5
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Returns undefined if the article type is not provided or does not match any known offer types.
|
|
6
6
|
*/
|
|
7
7
|
export declare const getOfferType: (articleType?: string) => OfferType | undefined;
|
|
8
8
|
export {};
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOfferType = void 0;
|
|
4
4
|
/**
|
|
5
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
|
|
7
|
-
* @returns "Meter", "Paid", or "Login" 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 returns undefined.
|
|
7
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Returns undefined if the article type is not provided or does not match any known offer types.
|
|
8
8
|
*/
|
|
9
9
|
const getOfferType = (articleType) => {
|
|
10
10
|
const lower = articleType?.toLowerCase() ?? "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Environment } from "../sps/endpoint.js";
|
|
2
2
|
import type { PlacementType } from "../sps/placement.js";
|
|
3
3
|
import type { OfferTrackingData } from "../tracking/create-tracking-params.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { PulseOrigin } from "../tracking/tracking-to-pulse-origin.js";
|
|
5
5
|
export interface PulseConfig {
|
|
6
6
|
/**
|
|
7
7
|
* Environment for loading pulse proxy scripts, set by the environment argument when initializing the SPS instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"mappings":";;;AAAA,sEAAmE;AACnE,8CAA8D;AAkE9D,MAAM,yBAAyB,GAAG,CAAC,MAAmB,EAAU,EAAE;IAChE,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,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;SACtC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,wCAAwC;SACjE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,gCAAgC;SACzD,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,yBAAyB;SAClD,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,wDAAwD;SACtF,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,mCAAmC;IAErE,OAAO,CACL,gEAAgE,UAAU,WAAW;QACrF,gBAAgB,SAAS,aAAa;QACtC,gBAAgB,WAAW,aAAa,CACzC,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,uBAAuB,GAAG,CAAC,IAAiB,EAAE,MAAmB,EAAQ,EAAE;IACtF,MAAM,QAAQ,GAAG,QAAQ;SACtB,WAAW,EAAE;SACb,wBAAwB,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC,CAAC;AALW,QAAA,uBAAuB,2BAKlC;AAEF;;;;GAIG;AACI,MAAM,uBAAuB,GAAG,CAAC,MAAmB,EAAU,EAAE,CACrE,yBAAyB,CAAC,MAAM,CAAC,CAAC;AADvB,QAAA,uBAAuB,2BACA"}
|
package/dist/cjs/utils/utm.js
CHANGED
|
@@ -17,14 +17,19 @@ const UTM_ALLOWLIST = [
|
|
|
17
17
|
* @returns UtmTags object with the UTM tags from the URL
|
|
18
18
|
*/
|
|
19
19
|
function getUtmFromUrl(url) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
try {
|
|
21
|
+
const urlObject = new URL(url);
|
|
22
|
+
const utmTags = new URLSearchParams(urlObject.search);
|
|
23
|
+
const result = {};
|
|
24
|
+
UTM_ALLOWLIST.forEach((key) => {
|
|
25
|
+
if (utmTags.has(key)) {
|
|
26
|
+
result[key] = utmTags.get(key);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
//# sourceMappingURL=utm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utm.js","sourceRoot":"","sources":["../../../src/utils/utm.ts"],"names":[],"mappings":";;AA4BA,
|
|
1
|
+
{"version":3,"file":"utm.js","sourceRoot":"","sources":["../../../src/utils/utm.ts"],"names":[],"mappings":";;AA4BA,sCAgBC;AAhCD,MAAM,aAAa,GAAsB;IACvC,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,aAAa;IACb,UAAU;IACV,SAAS;CACV,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PlacementType } from "../sps/placement.js";
|
|
2
2
|
import type { Environment } from "../sps/endpoint.js";
|
|
3
|
-
import type { DismissTimeOptions } from "../sps.js";
|
|
4
3
|
export declare const isDismissed: (placementType: PlacementType, iframeId: string) => boolean;
|
|
5
|
-
export declare const addDismiss: (placementType: PlacementType, iframeId: string,
|
|
4
|
+
export declare const addDismiss: (placementType: PlacementType, iframeId: string, hideDuration: number) => void;
|
|
6
5
|
export declare const getDismissScript: (publication: string, environment: Environment, placementType: string) => string;
|
|
@@ -23,7 +23,7 @@ export const isDismissed = (placementType, iframeId) => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
const dismissListenerKeys = new Set();
|
|
26
|
-
export const addDismiss = (placementType, iframeId,
|
|
26
|
+
export const addDismiss = (placementType, iframeId, hideDuration) => {
|
|
27
27
|
const key = `${placementType}:${iframeId}`;
|
|
28
28
|
if (dismissListenerKeys.has(key)) {
|
|
29
29
|
return;
|
|
@@ -36,7 +36,7 @@ export const addDismiss = (placementType, iframeId, dismissTime) => {
|
|
|
36
36
|
if (event.data.type === `${DISMISS_KEY}:${placementType}`) {
|
|
37
37
|
console.log("[SPS sdk] - Dismiss issued by user", event);
|
|
38
38
|
const data = {
|
|
39
|
-
ttl: calculateTtl(
|
|
39
|
+
ttl: calculateTtl(hideDuration),
|
|
40
40
|
status: "dismissed",
|
|
41
41
|
};
|
|
42
42
|
localStorage.setItem(`sps-dismissed-${placementType}-${iframeId}`, JSON.stringify(data));
|
|
@@ -44,20 +44,9 @@ export const addDismiss = (placementType, iframeId, dismissTime) => {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
-
const calculateTtl = (
|
|
47
|
+
const calculateTtl = (hideDuration) => {
|
|
48
48
|
const now = Date.now();
|
|
49
|
-
|
|
50
|
-
"1day": 24,
|
|
51
|
-
"2days": 48,
|
|
52
|
-
"3days": 72,
|
|
53
|
-
"4days": 96,
|
|
54
|
-
"5days": 120,
|
|
55
|
-
"6days": 144,
|
|
56
|
-
"1week": 7 * 24,
|
|
57
|
-
"2week": 14 * 24,
|
|
58
|
-
"1month": 30 * 24,
|
|
59
|
-
};
|
|
60
|
-
return now + (timeMap[dismissTime ?? 24] || 24) * 60 * 60 * 1000;
|
|
49
|
+
return now + hideDuration;
|
|
61
50
|
};
|
|
62
51
|
export const getDismissScript = (publication, environment, placementType) => `
|
|
63
52
|
document.addEventListener("click", function (event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dismiss.js","sourceRoot":"","sources":["../../../src/actions/dismiss.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dismiss.js","sourceRoot":"","sources":["../../../src/actions/dismiss.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,aAA4B,EAAE,QAAgB,EAAW,EAAE;IACrF,MAAM,UAAU,GAAG,iBAAiB,aAAa,IAAI,QAAQ,EAAE,CAAC;IAChE,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACzD,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OA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,GAAG,EAAE,CAAC;IACvB,OAAO,GAAG,GAAG,YAAY,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAAmB,EACnB,WAAwB,EACxB,aAAqB,EACrB,EAAE,CACF;;;;;;;;;qBASmB,WAAW,IAAI,aAAa;;aAEpC,sBAAsB,CAAC,WAAW,EAAE,WAAW,CAAC;;;;GAI1D,CAAC;AAEJ,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAE,WAAwB,EAAU,EAAE;IACvF,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,cAAc,CAAC,WAAW;YAC7B,OAAO,gBAAgB,CAAC;QAC1B,KAAK,cAAc,CAAC,EAAE;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,cAAc,CAAC,EAAE;YACpB,OAAO,gBAAgB,CAAC;QAC1B,KAAK,cAAc,CAAC,EAAE;YACpB,OAAO,OAAO,CAAC;QACjB,KAAK,cAAc,CAAC,GAAG;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc,CAAC,GAAG;YACrB,OAAO,QAAQ,CAAC;QAClB,KAAK,cAAc,CAAC,EAAE;YACpB,OAAO,gBAAgB,CAAC;QAC1B;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
|
package/dist/esm/apiClient.d.ts
CHANGED
|
@@ -44,6 +44,10 @@ export type SPSPosterResponse<T extends PlacementType> = {
|
|
|
44
44
|
* A string describing why a fallback or non-standard response was returned, if applicable.
|
|
45
45
|
*/
|
|
46
46
|
failReason?: string;
|
|
47
|
+
/**
|
|
48
|
+
* A number in milliseconds representating the time a given placement should be hidden before appearing for the user again.
|
|
49
|
+
*/
|
|
50
|
+
hideDuration?: number;
|
|
47
51
|
};
|
|
48
52
|
/**
|
|
49
53
|
* Returned by the SPS API when there is no content to display for the given placement.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../src/apiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../src/apiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,GAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwE9C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,GAAW,EACX,MAAS,EACT,cAAqC,EACrC,6BAA6B,GAAG,KAAK,EACe,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;QACnD,MAAM,WAAW,GAAG,0BAA0B,CAAC;YAC7C,GAAG,kBAAkB;YACrB,GAAG,MAAM;SACV,CAAC,CAAC;QAEH,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,eAAe,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE;YACpE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,WAAW,EAAE,SAAS;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC;YACvB,IAAI,cAAc,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAClC,IAAI,cAAc,EAAE,CAAC;oBACnB,OAAO;wBACL,cAAc,EAAE,cAAc;wBAC9B,UAAU,EAAE,gEAAgE;qBAC7E,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,IAAI,KAAK,CACb,mCAAmC,cAAc,CAAC,MAAM,IAAI,cAAc,CAAC,UAAU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AAU,EAAE,CAC9F,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC,CAAC"}
|
|
@@ -25,8 +25,6 @@ export declare const isLandingPagePlacement: (placementType: PlacementType) => b
|
|
|
25
25
|
*/
|
|
26
26
|
export type PlacementContentMap = {
|
|
27
27
|
kyststripe: Kyststripe;
|
|
28
|
-
kystbenefit: Record<string, string>;
|
|
29
|
-
benefit: Benefit;
|
|
30
28
|
coreheader: Record<string, string>;
|
|
31
29
|
bottombar: string;
|
|
32
30
|
foldup: string;
|
|
@@ -57,15 +55,3 @@ export type Kyststripe = {
|
|
|
57
55
|
buttonTxtColor: string;
|
|
58
56
|
buttonId: string;
|
|
59
57
|
};
|
|
60
|
-
export type Benefit = {
|
|
61
|
-
disclaimerText: string;
|
|
62
|
-
disclaimerTextColor: string;
|
|
63
|
-
backgroundColor: string;
|
|
64
|
-
buttonText: string;
|
|
65
|
-
buttonColor: string;
|
|
66
|
-
textButtonColor: string;
|
|
67
|
-
headline: string;
|
|
68
|
-
headlineColor: string;
|
|
69
|
-
kicker: string;
|
|
70
|
-
URL: string;
|
|
71
|
-
};
|
package/dist/esm/sps.d.ts
CHANGED
|
@@ -91,10 +91,6 @@ export type SpsRequestOptionsWithFallback<T extends PlacementType> = SpsRequestO
|
|
|
91
91
|
fallbackPoster: SPSPosterResponse<T>;
|
|
92
92
|
showFallbackPosterOnNoContent: true;
|
|
93
93
|
};
|
|
94
|
-
/**
|
|
95
|
-
* Duration strings controlling how long a dismissed placement stays hidden.
|
|
96
|
-
*/
|
|
97
|
-
export type DismissTimeOptions = "1day" | "2days" | "3days" | "4days" | "5days" | "6days" | "1week" | "2week" | "1month";
|
|
98
94
|
/**
|
|
99
95
|
* Options for the dismiss functionality, enabling a placement to be hidden when
|
|
100
96
|
* an element with `data-dismiss-on-click` is clicked inside the placement.
|
|
@@ -102,8 +98,6 @@ export type DismissTimeOptions = "1day" | "2days" | "3days" | "4days" | "5days"
|
|
|
102
98
|
interface DismissOptions {
|
|
103
99
|
/** The HTML `id` attribute of the iframe element containing the placement. */
|
|
104
100
|
elementId: string;
|
|
105
|
-
/** How long the placement should remain suppressed after being dismissed. */
|
|
106
|
-
dismissTime: DismissTimeOptions;
|
|
107
101
|
}
|
|
108
102
|
/**
|
|
109
103
|
* Mapping of placement types to their required parameters.
|
|
@@ -200,7 +194,7 @@ export declare class SPS {
|
|
|
200
194
|
*
|
|
201
195
|
* @param placementType - The SPS placement to request (e.g. `"salesposter"`, `"bottombar"`).
|
|
202
196
|
* @param props - Request options including decisioning params and tracking context.
|
|
203
|
-
* @param
|
|
197
|
+
* @param dismissOptions - Optional dismiss configuration for hiding the placement on user interaction.
|
|
204
198
|
* @returns The enriched poster response, or `null` when no content is available.
|
|
205
199
|
*/
|
|
206
200
|
getPoster: GetPoster;
|
package/dist/esm/sps.js
CHANGED
|
@@ -46,7 +46,7 @@ export class SPS {
|
|
|
46
46
|
*
|
|
47
47
|
* @param placementType - The SPS placement to request (e.g. `"salesposter"`, `"bottombar"`).
|
|
48
48
|
* @param props - Request options including decisioning params and tracking context.
|
|
49
|
-
* @param
|
|
49
|
+
* @param dismissOptions - Optional dismiss configuration for hiding the placement on user interaction.
|
|
50
50
|
* @returns The enriched poster response, or `null` when no content is available.
|
|
51
51
|
*/
|
|
52
52
|
getPoster = async (placementType, props = {}, dismissOptions) => {
|
|
@@ -102,7 +102,7 @@ export class SPS {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
if (dismissOptions) {
|
|
105
|
-
addDismiss(placementType, dismissOptions.elementId,
|
|
105
|
+
addDismiss(placementType, dismissOptions.elementId, posterResponse.hideDuration || 86400); // Default 1 day.
|
|
106
106
|
}
|
|
107
107
|
return {
|
|
108
108
|
...posterResponse,
|
|
@@ -210,7 +210,7 @@ export class SPS {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
if (dismissOptions) {
|
|
213
|
-
addDismiss(placementType, dismissOptions.elementId,
|
|
213
|
+
addDismiss(placementType, dismissOptions.elementId, poster.posterResponse.hideDuration || 86400);
|
|
214
214
|
}
|
|
215
215
|
return {
|
|
216
216
|
...poster.posterResponse,
|
package/dist/esm/sps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sps.js","sourceRoot":"","sources":["../../src/sps.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAOZ,MAAM,GAAG,CAAC;AACX,OAAO,EACL,oBAAoB,GAIrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAC;AAOjF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"sps.js","sourceRoot":"","sources":["../../src/sps.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAOZ,MAAM,GAAG,CAAC;AACX,OAAO,EACL,oBAAoB,GAIrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAC;AAOjF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqN5D;;;GAGG;AACH,MAAM,OAAO,GAAG;IACd,2DAA2D;IAC3D,WAAW,CAAS;IACpB,8CAA8C;IAC9C,QAAQ,CAAS;IACjB,oDAAoD;IACpD,WAAW,CAAc;IAEzB;;;OAGG;IACH,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,EAAE,WAAW,GAAG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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" | "other";
|
|
5
|
+
export type ContentType = "article" | "podcast" | "video" | "page" | "other";
|
|
6
6
|
export type DeviceType = "mobile" | "tablet" | "desktop";
|
|
7
7
|
/**
|
|
8
8
|
* Input options for {@link createTrackingParams}.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
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.
|
|
4
|
-
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
3
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute.
|
|
4
|
+
* @returns an array of offer codes or an empty array if no offer codes are found, or if the href is missing or invalid.
|
|
5
5
|
*/
|
|
6
6
|
export declare const getOfferCodes: (link: Element) => string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
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.
|
|
4
|
-
* @returns an array of offer codes or an empty array if no offer codes are found.
|
|
3
|
+
* @param link the clicked element, expected to be an anchor element with an href attribute.
|
|
4
|
+
* @returns an array of offer codes or an empty array if no offer codes are found, or if the href is missing or invalid.
|
|
5
5
|
*/
|
|
6
6
|
export const getOfferCodes = (link) => {
|
|
7
7
|
try {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
type OfferType = "Meter" | "Paid" | "Login";
|
|
2
2
|
/**
|
|
3
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
|
|
5
|
-
* @returns "Meter", "Paid", or "Login" 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 returns undefined.
|
|
5
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Returns undefined if the article type is not provided or does not match any known offer types.
|
|
6
6
|
*/
|
|
7
7
|
export declare const getOfferType: (articleType?: string) => OfferType | undefined;
|
|
8
8
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Determines the offer type based on the article type string.
|
|
3
|
-
* @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
|
|
4
|
-
* @returns "Meter", "Paid", or "Login" based on the article type string.
|
|
3
|
+
* @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 returns undefined.
|
|
4
|
+
* @returns "Meter", "Paid", or "Login" based on the article type string. Returns undefined if the article type is not provided or does not match any known offer types.
|
|
5
5
|
*/
|
|
6
6
|
export const getOfferType = (articleType) => {
|
|
7
7
|
const lower = articleType?.toLowerCase() ?? "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Environment } from "../sps/endpoint.js";
|
|
2
2
|
import type { PlacementType } from "../sps/placement.js";
|
|
3
3
|
import type { OfferTrackingData } from "../tracking/create-tracking-params.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { PulseOrigin } from "../tracking/tracking-to-pulse-origin.js";
|
|
5
5
|
export interface PulseConfig {
|
|
6
6
|
/**
|
|
7
7
|
* Environment for loading pulse proxy scripts, set by the environment argument when initializing the SPS instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pulseProxy.js","sourceRoot":"","sources":["../../../src/utils/pulseProxy.ts"],"names":[],"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yBAAyB,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/esm/utils/utm.js
CHANGED
|
@@ -14,14 +14,19 @@ const UTM_ALLOWLIST = [
|
|
|
14
14
|
* @returns UtmTags object with the UTM tags from the URL
|
|
15
15
|
*/
|
|
16
16
|
export function getUtmFromUrl(url) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
try {
|
|
18
|
+
const urlObject = new URL(url);
|
|
19
|
+
const utmTags = new URLSearchParams(urlObject.search);
|
|
20
|
+
const result = {};
|
|
21
|
+
UTM_ALLOWLIST.forEach((key) => {
|
|
22
|
+
if (utmTags.has(key)) {
|
|
23
|
+
result[key] = utmTags.get(key);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
//# sourceMappingURL=utm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utm.js","sourceRoot":"","sources":["../../../src/utils/utm.ts"],"names":[],"mappings":"AAYA,MAAM,aAAa,GAAsB;IACvC,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,aAAa;IACb,UAAU;IACV,SAAS;CACV,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"utm.js","sourceRoot":"","sources":["../../../src/utils/utm.ts"],"names":[],"mappings":"AAYA,MAAM,aAAa,GAAsB;IACvC,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,aAAa;IACb,UAAU;IACV,SAAS;CACV,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var SpsPulseHelpersBundle=(()=>{var
|
|
1
|
+
"use strict";var SpsPulseHelpersBundle=(()=>{var I=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of X(t))!Z.call(e,o)&&o!==r&&I(e,o,{get:()=>t[o],enumerable:!(n=z(t,o))||n.enumerable});return e};var te=e=>ee(I({},"__esModule",{value:!0}),e);var le={};var f="pulse-tracker-proxy",re=`${f}:request`,ue=`${f}:ack`,A=`${f}:invoke`,F=`${f}:return`,S=`${f}:return-error`,V=["trackAnonymousViewUIElement","trackEngagementAudio","trackEngagementForm","trackEngagementHealthUIElement","trackEngagementOffer","trackEngagementTeaser","trackEngagementUIElement","trackEngagementVideo","trackEngagementVideoAd","trackEngagementWidget","trackCompletedHealthAction","trackImpressionForm","trackImpressionHealthUIElement","trackImpressionOffer","trackImpressionPlayer","trackImpressionTeaser","trackImpressionUIElement","trackImpressionWidget","trackLeaveArticle","trackLeaveAudioPage","trackLeaveError","trackLeaveFrontpage","trackLeaveLandingpage","trackLeaveListing","trackLeaveLockedArticle","trackLeaveLockedAudioPage","trackLeaveLockedVideoPage","trackLeavePage","trackLeaveVideoPage","trackLeaveWeather","trackViewArticle","trackViewAudioPage","trackViewError","trackViewFrontpage","trackViewHealthPage","trackViewLandingpage","trackViewListing","trackViewLockedArticle","trackViewLockedAudioPage","trackViewLockedVideoPage","trackViewPage","trackViewTitle","trackViewVideoPage","trackViewWeather","trackLegacyViewArticle","trackLegacyViewLoginPoster","trackLegacyViewSalesPoster","trackLegacyViewListing","trackLegacyViewFrontpage","trackLegacyViewPage","trackLegacyViewUIElement","trackLegacyClickUIElement"];function b(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"&&e.type.startsWith(f)}function O(e,{target:t,timeout:r,debug:n=()=>{}}){return new Promise((o,c)=>{let i=new MessageChannel,p=r?setTimeout(()=>{i.port1.close(),c(new Error(`Message of type ${e.type} timed out`))},r):void 0,a=s=>{if(n("[Pulse Tracker Proxy] Received the response on the MessageChannel",s),!b(s.data)){n("[Pulse Tracker Proxy] Response was not a valid Proxy Message",s.data);return}s.data.type===S&&(n("[Pulse Tracker Proxy] Received an return error response",s.data.error),clearTimeout(p),i.port1.close(),c(new Error(s.data.error))),n("[Pulse Tracker Proxy] Received a valid response",s.data),clearTimeout(p),i.port1.close(),o(s.data)};i.port1.onmessage=a,n("[Pulse Tracker Proxy] Sending message to target window",e),t.postMessage(e,"*",[i.port2])})}var M="2.0.0-rc.5";function D(e){let t="tracker"in e&&typeof e.tracker=="object"?e.tracker:{};return{...e,tracker:{...t,proxyVersion:M}}}var E=class{constructor(t,r){this.target=t,this.debug=r}track(...t){this.debug("[Pulse Tracker Proxy] Calling `track`",t);let[r,n,...o]=t,c=[r,D(n),...o];return this.invoke({method:"track",args:c})}async invoke(t){this.debug("[Pulse Tracker Proxy] Invoking remote function",t);let r=await O({type:A,payload:t},{target:this.target});if(!b(r))throw this.debug("[Pulse Tracker Proxy] Invalid response from proxy",r),new Error("Invalid response from proxy");if(r.type===S)throw this.debug("[Pulse Tracker Proxy] Error response from proxy",r.error),new Error(r.error);if(r.type===F)return this.debug("[Pulse Tracker Proxy] Successful response from proxy",r.payload),r.payload;throw this.debug("[Pulse Tracker Proxy] Unhandled response from proxy",r),new Error("Unexpected response from proxy")}};var ne=Object.fromEntries(V.map(e=>[e,function(...t){this.debug("[Pulse Tracker Proxy] Calling `track`",t);let[r,...n]=t,o=[D(r),...n];return this.invoke({method:e,args:o})}]));function se(){return class extends E{constructor(e,t){super(e,t),t("[Pulse TPaaS Proxy] Initialized"),Object.assign(this,ne)}}}var oe=se();var ae=e=>e==="payment.schibsted.com"||e.startsWith("bestilling.")||e==="pay.pre.schibsted.digital"||e.startsWith("test-bestilling."),ie=e=>e==="login.schibsted.com"||e==="identity-pre.schibsted.com",G=e=>{var t;try{let n=new URL((t=e.getAttribute("href"))!=null?t:"").hostname;if(ie(n))return"Login";if(ae(n))return"Purchase"}catch{return}};var j=e=>{var t;try{let r=new URL((t=e.getAttribute("href"))!=null?t:""),o=new URLSearchParams(r.search).get("code");return o?o.split(","):[]}catch{return[]}};var x=e=>{var r;let t=(r=e==null?void 0:e.toLowerCase())!=null?r:"";if(t.includes("meter"))return"Meter";if(t.includes("paid")||t.includes("subscription"))return"Paid";if(t.includes("login"))return"Login"};function W(e,t,r,n){let{campaign:o,articleType:c,abTestGroup:i,placementType:p,experiment:a,legacy:s,contentName:l,pulseEvents:u}=t,g=400,y="",P=0;function m(R){var T,h,L,_,C;try{let k=R.target,d=(T=k==null?void 0:k.closest)==null?void 0:T.call(k,"a");if(!d)return;let w=d.textContent||d.getAttribute("href")||`${p} button`,U=`a|${w}`,$=Date.now();if(U===y&&$-P<g)return;y=U,P=$;let v=G(d),Q=v==="Purchase"?j(d):[];u.tpaas&&e.trackEngagementOffer({object:{objectId:n,objectSdrn:r,campaign:o,containerName:"page",name:l,offerPlacement:p,offerCodes:Q,offerType:x(c)},...a?{experiments:[{experimentSdrn:`${r}:experiment:${a}`,name:a,platform:"SPS",variant:i||""}]}:{},engagement:{action:"Click",elementName:w},page:{},provider:{stage:"Test",component:"SPS"},target:{info:{url:(h=d.getAttribute("href"))!=null?h:""}}}),u.legacy&&e.trackLegacyClickUIElement({object:{id:w,elementType:"Button",name:w,containerName:"Page",custom:{...s==null?void 0:s.offerData}},...s?{origin:s.pulseOrigin}:{},target:{url:(C=(_=(L=d.getAttribute("href"))==null?void 0:L.split("?"))==null?void 0:_[0])!=null?C:""},...v?{intent:v}:{},...a?{experiments:[{id:`experiment:${a}`,name:a,platform:"SPS",variant:i}]}:{}})}catch{}}return document.addEventListener("click",m,!0),()=>document.removeEventListener("click",m,!0)}function N(e,t,r,n,o){let{campaign:c,articleType:i,abTestGroup:p,placementType:a,experiment:s,legacy:l,contentName:u,pulseEvents:g}=t;g.tpaas&&e.trackImpressionOffer({object:{campaign:c,containerName:"page",foldPosition:o,name:u,objectId:n,objectSdrn:r,offerPlacement:a,offerCodes:[],offerType:x(i)},...s?{experiments:[{experimentSdrn:`${r}:experiment:${s}`,name:s,platform:"SPS",variant:p||""}]}:{},page:{},provider:{stage:"Test",component:"SPS"},target:{info:{}}}),g.legacy&&e.trackLegacyViewUIElement({object:{id:n,elementType:a,name:u,placement:{},custom:{...l==null?void 0:l.offerData,...l==null?void 0:l.custom}},...s?{experiments:[{id:`${r}:experiment:${s}`,name:s,platform:"SPS",variant:p}]}:{},...l?{origin:l.pulseOrigin}:{}})}async function q(e,t){var a,s;let{placementType:r,legacy:n,pulseEvents:o}=t,c=window.location.pathname,i=(c==null?void 0:c.replace((s=(a=window.__landingpages)==null?void 0:a.rootUrl)!=null?s:"","").replace(/^\/|\/$/g,""))||"",p=r==="campaignpage"?"CAMPAIGN":"STATIC";o.legacy&&await e.trackLegacyViewPage({object:{pageId:`landingpage-${p}-${i}`.toLowerCase(),name:`LPS (${p}) | View ${document.title}`,"spt:custom":{...n==null?void 0:n.offerData}},origin:n==null?void 0:n.pulseOrigin}),o.tpaas&&await e.trackViewLandingpage({object:{objectId:crypto==null?void 0:crypto.randomUUID(),objectSdrn:`sdrn:${t.publication}:page:${r}:${i}`,title:document.title},page:{},provider:{stage:"Test"}},{leaveTracking:!1})}var B=e=>e==="campaignpage"||e==="staticpage";var H=!1,K=!1,Y="script[data-sps-pulse-config='true']";async function J(){if(console.log("[SPS-Pulse-Helpers] boot initiated"),H)return;H=!0;let e=null;try{let t=document.querySelector(Y);if(!t){console.warn(`[SPS-Pulse-Helpers] Config script tag not found with selector ${Y}`);return}e=JSON.parse(t.textContent)}catch(t){console.warn("[SPS-Pulse-Helpers] Failed to parse config from script tag",t);return}try{let t=window.getPulseTrackerProxy;if(!t||typeof t!="function"){console.warn("[SPS-Pulse-Helpers] PulseTrackerProxy not available");return}let{placementType:r,publication:n,contentName:o}=e,c=`sdrn:${n}:element:offer:${r}:${o}`,i=crypto==null?void 0:crypto.randomUUID(),p=await t({});W(p,e,c,i);let a=P=>{K||(K=!0,N(p,e,c,i,P))};if(B(r)){await q(p,e),a("Above");return}let s=window.frameElement,l=window.parent.IntersectionObserver;if(!s||!l){console.warn("[SPS-Pulse-Helpers] No iframe or IntersectionObserver available. Pulse View event will not be fired.");return}let u="Unknown",g=!0,y=new l(P=>{var h;let m=P[0],R=(h=m==null?void 0:m.intersectionRatio)!=null?h:0,T=(m==null?void 0:m.isIntersecting)&&R>=1/3;g&&(g=!1,u=T?"Above":"Below"),T&&(y.disconnect(),a(u))},{root:null,threshold:[0,1/3]});y.observe(s)}catch(t){console.warn("[SPS-Pulse-Helpers] boot failed",t)}}J();return te(le);})();
|