@financial-times/cmp-client 3.1.3 → 3.2.0

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/index.cjs CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  };
8
8
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
9
9
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
10
- const version = "3.1.3";
10
+ const version = "3.2.0";
11
11
  const events = {
12
12
  onMessageChoiceSelect: (...args) => {
13
13
  console.log("[debug] onMessageChoiceSelect", args);
@@ -3135,6 +3135,40 @@ const trackingEventHandlers = {
3135
3135
  });
3136
3136
  }
3137
3137
  };
3138
+ function getCookie(name) {
3139
+ var _a2, _b2;
3140
+ const value = `; ${document.cookie}`;
3141
+ const parts = value.split(`; ${name}=`);
3142
+ if (parts.length === 2)
3143
+ return (_b2 = (_a2 = parts.pop()) == null ? void 0 : _a2.split(";")) == null ? void 0 : _b2.shift();
3144
+ }
3145
+ function enableNonEssentialCookiesOption() {
3146
+ window._sp_queue ?? (window._sp_queue = []);
3147
+ window._sp_queue.push(() => {
3148
+ var _a2, _b2;
3149
+ (_b2 = (_a2 = window._sp_) == null ? void 0 : _a2.addEventListener) == null ? void 0 : _b2.call(
3150
+ _a2,
3151
+ "onMessageChoiceSelect",
3152
+ (_messageType, _choiceId, choiceTypeId) => {
3153
+ if (choiceTypeId === 9) {
3154
+ document.cookie = "sp_cw=dismissed; expires=Thu, 18 Dec 2023 12:00:00 UTC";
3155
+ }
3156
+ }
3157
+ );
3158
+ });
3159
+ window._sp_queue.push(() => {
3160
+ var _a2, _b2;
3161
+ (_b2 = (_a2 = window._sp_) == null ? void 0 : _a2.addEventListener) == null ? void 0 : _b2.call(
3162
+ _a2,
3163
+ "onPrivacyManagerAction",
3164
+ (_messageType, pmData) => {
3165
+ if (pmData.purposeConsent == "none" && pmData.vendorConsent == "none") {
3166
+ document.cookie = "sp_cw=dismissed; expires=Thu, 18 Dec 2023 12:00:00 UTC";
3167
+ }
3168
+ }
3169
+ );
3170
+ });
3171
+ }
3138
3172
  async function initSourcepointCmp({
3139
3173
  propertyConfig = FT_DOTCOM_PROD,
3140
3174
  userId,
@@ -3165,6 +3199,14 @@ async function initSourcepointCmp({
3165
3199
  );
3166
3200
  delete propertyConfig.events;
3167
3201
  }
3202
+ propertyConfig = {
3203
+ ...propertyConfig,
3204
+ gdpr: {
3205
+ targetingParams: {
3206
+ cookiew: getCookie("cw")
3207
+ }
3208
+ }
3209
+ };
3168
3210
  bootstrapCmp(propertyConfig);
3169
3211
  window._sp_queue.push(() => {
3170
3212
  var _a2, _b2;
@@ -3180,6 +3222,7 @@ async function initSourcepointCmp({
3180
3222
  })
3181
3223
  );
3182
3224
  });
3225
+ enableNonEssentialCookiesOption();
3183
3226
  initTracking(trackingContext);
3184
3227
  }
3185
3228
  window.FT_CMP_CLIENT_VERSION = version;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
8
- const version = "3.1.3";
8
+ const version = "3.2.0";
9
9
  const events = {
10
10
  onMessageChoiceSelect: (...args) => {
11
11
  console.log("[debug] onMessageChoiceSelect", args);
@@ -3133,6 +3133,40 @@ const trackingEventHandlers = {
3133
3133
  });
3134
3134
  }
3135
3135
  };
3136
+ function getCookie(name) {
3137
+ var _a2, _b2;
3138
+ const value = `; ${document.cookie}`;
3139
+ const parts = value.split(`; ${name}=`);
3140
+ if (parts.length === 2)
3141
+ return (_b2 = (_a2 = parts.pop()) == null ? void 0 : _a2.split(";")) == null ? void 0 : _b2.shift();
3142
+ }
3143
+ function enableNonEssentialCookiesOption() {
3144
+ window._sp_queue ?? (window._sp_queue = []);
3145
+ window._sp_queue.push(() => {
3146
+ var _a2, _b2;
3147
+ (_b2 = (_a2 = window._sp_) == null ? void 0 : _a2.addEventListener) == null ? void 0 : _b2.call(
3148
+ _a2,
3149
+ "onMessageChoiceSelect",
3150
+ (_messageType, _choiceId, choiceTypeId) => {
3151
+ if (choiceTypeId === 9) {
3152
+ document.cookie = "sp_cw=dismissed; expires=Thu, 18 Dec 2023 12:00:00 UTC";
3153
+ }
3154
+ }
3155
+ );
3156
+ });
3157
+ window._sp_queue.push(() => {
3158
+ var _a2, _b2;
3159
+ (_b2 = (_a2 = window._sp_) == null ? void 0 : _a2.addEventListener) == null ? void 0 : _b2.call(
3160
+ _a2,
3161
+ "onPrivacyManagerAction",
3162
+ (_messageType, pmData) => {
3163
+ if (pmData.purposeConsent == "none" && pmData.vendorConsent == "none") {
3164
+ document.cookie = "sp_cw=dismissed; expires=Thu, 18 Dec 2023 12:00:00 UTC";
3165
+ }
3166
+ }
3167
+ );
3168
+ });
3169
+ }
3136
3170
  async function initSourcepointCmp({
3137
3171
  propertyConfig = FT_DOTCOM_PROD,
3138
3172
  userId,
@@ -3163,6 +3197,14 @@ async function initSourcepointCmp({
3163
3197
  );
3164
3198
  delete propertyConfig.events;
3165
3199
  }
3200
+ propertyConfig = {
3201
+ ...propertyConfig,
3202
+ gdpr: {
3203
+ targetingParams: {
3204
+ cookiew: getCookie("cw")
3205
+ }
3206
+ }
3207
+ };
3166
3208
  bootstrapCmp(propertyConfig);
3167
3209
  window._sp_queue.push(() => {
3168
3210
  var _a2, _b2;
@@ -3178,6 +3220,7 @@ async function initSourcepointCmp({
3178
3220
  })
3179
3221
  );
3180
3222
  });
3223
+ enableNonEssentialCookiesOption();
3181
3224
  initTracking(trackingContext);
3182
3225
  }
3183
3226
  window.FT_CMP_CLIENT_VERSION = version;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAU5D,wBAAsB,kBAAkB,CAAC,EACvC,cAA+B,EAC/B,MAAM,EACN,YAAmB,EACnB,gBAAwC,EACxC,YAA+B,EAC/B,aAAkC,EAClC,eAAsB,EACtB,eAAoB,GACrB,GAAE,cAAmB,iBAyCrB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAY5D,wBAAsB,kBAAkB,CAAC,EACvC,cAA+B,EAC/B,MAAM,EACN,YAAmB,EACnB,gBAAwC,EACxC,YAA+B,EAC/B,aAAkC,EAClC,eAAsB,EACtB,eAAoB,GACrB,GAAE,cAAmB,iBAiDrB"}
@@ -0,0 +1,2 @@
1
+ export declare function enableNonEssentialCookiesOption(): void;
2
+ //# sourceMappingURL=enableNonEssentialCookiesOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enableNonEssentialCookiesOption.d.ts","sourceRoot":"","sources":["../../../src/lib/enableNonEssentialCookiesOption.ts"],"names":[],"mappings":"AACA,wBAAgB,+BAA+B,SAuB9C"}
@@ -0,0 +1,2 @@
1
+ export declare function getCookie(name: string): string | undefined;
2
+ //# sourceMappingURL=cookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/utils/cookie.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,sBAIrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/cmp-client",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -16,6 +16,7 @@ export interface SPConfig {
16
16
  joinHref?: boolean;
17
17
  events?: Partial<SPLifecycleEvents>;
18
18
  authId?: string;
19
+ targetingParams?: Record<string, unknown>;
19
20
  }
20
21
 
21
22
  export type SPEventCallback = (