@financial-times/cmp-client 3.1.2 → 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/README.md +41 -6
- package/dist/index.cjs +44 -1
- package/dist/index.js +44 -1
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/lib/enableNonEssentialCookiesOption.d.ts +2 -0
- package/dist/src/lib/enableNonEssentialCookiesOption.d.ts.map +1 -0
- package/dist/src/utils/cookie.d.ts +2 -0
- package/dist/src/utils/cookie.d.ts.map +1 -0
- package/package.json +1 -1
- package/typings/types.d.ts +1 -0
package/README.md
CHANGED
|
@@ -21,21 +21,56 @@ npm install @financial-times/cmp-client
|
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
|
+
> [!Note]
|
|
25
|
+
> We will be adding new properties (i.e. websites under FT group) and their configs as we start rolling out.
|
|
26
|
+
>
|
|
27
|
+
> Please reach out to the Ads & Privacy team if you think your domain needs a new property config
|
|
28
|
+
|
|
29
|
+
### Usage on non-FT.com properties
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import { initSourcepointCmp, properties, debug } from "@financial-times/cmp-client";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Optionally enable debug mode to see CMP events in the console
|
|
36
|
+
*/
|
|
37
|
+
debug.logCmpEvents();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Import your domain's CMP configuration from the `properties` module:
|
|
41
|
+
* e.g. properties.MM_IGNITES_ASIA, properties.SP_THE_BANKER, etc.
|
|
42
|
+
*
|
|
43
|
+
* We will add more domains as we create new properties in Sourcepoint
|
|
44
|
+
*
|
|
45
|
+
* See below for the full list of initialisation options
|
|
46
|
+
*/
|
|
47
|
+
initSourcepointCmp({
|
|
48
|
+
propertyConfig: properties["YOUR_PROPERTY_CONFIG_KEY"],
|
|
49
|
+
useConsentStore: false, // Specialist Titles _must_ opt out of Single Consent Store
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Usage on FT.com
|
|
54
|
+
|
|
24
55
|
```js
|
|
25
|
-
import { initSourcepointCmp } from "@financial-times/cmp-client
|
|
26
|
-
import { FT_DOTCOM_TEST } from "@financial-times/cmp-client/properties";
|
|
56
|
+
import { initSourcepointCmp, properties, debug } from "@financial-times/cmp-client";
|
|
27
57
|
|
|
28
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Optionally enable debug mode to see CMP events in the console
|
|
60
|
+
*/
|
|
61
|
+
debug.logCmpEvents();
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* We suggest using a feature flag to disable the existing cookie banner
|
|
65
|
+
* and enable the new one
|
|
66
|
+
*/
|
|
29
67
|
if (flagsClient.get("adsDisableInternalCMP")) {
|
|
30
68
|
initSourcepointCmp({
|
|
31
69
|
propertyConfig: FT_DOTCOM_TEST,
|
|
32
|
-
// useConsentStore: false (set to false for non-FT.com properties or websites)
|
|
33
70
|
});
|
|
34
71
|
}
|
|
35
72
|
```
|
|
36
73
|
|
|
37
|
-
We will be adding new properties (websites under FT group) and their configs as we start rolling out. Please reach out to the Ads & Privacy team if you think you need to create a new property for your domain - for example, if it is on a different domain from the `ft.com` domain.
|
|
38
|
-
|
|
39
74
|
### CMP configuration options:
|
|
40
75
|
|
|
41
76
|
<table>
|
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.
|
|
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.
|
|
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;
|
package/dist/src/client.d.ts.map
CHANGED
|
@@ -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;
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"enableNonEssentialCookiesOption.d.ts","sourceRoot":"","sources":["../../../src/lib/enableNonEssentialCookiesOption.ts"],"names":[],"mappings":"AACA,wBAAgB,+BAA+B,SAuB9C"}
|
|
@@ -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