@usercentrics/cmp-browser-sdk
Advanced tools
Comparing version 4.20.2 to 4.21.0
@@ -1,1 +0,1 @@ | ||
export{c as API_COMMANDS,al as BUTTON_ALIGNMENT,at as CLOSE_OPTION,aJ as CONSENT_ACTION,aK as CONSENT_TYPE,au as Core,ak as DPS_DISPLAY_FORMAT,aM as FIRST_LAYER_VARIANT,aP as SECOND_LAYER_SIDE,ap as SECOND_LAYER_TRIGGER,aN as SECOND_LAYER_VARIANT,aQ as TCF_DECISION_UI_LAYER,aO as THEME,aL as TRACKING_EVENT_TYPE,av as UI_LAYER,aw as UI_VARIANT,as as default,ax as isCcpaData,ay as isCcpaLabels,az as isCcpaUI,aA as isDefaultData,aB as isDefaultLabels,aC as isDefaultUI,aF as isNotPrivacyButtonLabels,aE as isPrivacyButtonLabels,aD as isPrivacyButtonUI,aG as isTcfData,aH as isTcfLabels,aI as isTcfUI}from"./index-217b8615.js"; | ||
export{c as API_COMMANDS,al as BUTTON_ALIGNMENT,at as CLOSE_OPTION,aJ as CONSENT_ACTION,aK as CONSENT_TYPE,au as Core,ak as DPS_DISPLAY_FORMAT,aM as FIRST_LAYER_VARIANT,aP as SECOND_LAYER_SIDE,ap as SECOND_LAYER_TRIGGER,aN as SECOND_LAYER_VARIANT,aQ as TCF_DECISION_UI_LAYER,aO as THEME,aL as TRACKING_EVENT_TYPE,av as UI_LAYER,aw as UI_VARIANT,as as default,ax as isCcpaData,ay as isCcpaLabels,az as isCcpaUI,aA as isDefaultData,aB as isDefaultLabels,aC as isDefaultUI,aF as isNotPrivacyButtonLabels,aE as isPrivacyButtonLabels,aD as isPrivacyButtonUI,aG as isTcfData,aH as isTcfLabels,aI as isTcfUI}from"./index-3a8fa4a0.js"; |
@@ -71,3 +71,3 @@ import { DataTransferSettings } from '../../modules/helpers'; | ||
static settingsExist(): boolean; | ||
static setUserActionPerformed(): void; | ||
static setUserActionPerformed(isActionPerformed: boolean): void; | ||
static clearCcpa(): void; | ||
@@ -74,0 +74,0 @@ static clearCcpaData(): void; |
{ | ||
"name": "@usercentrics/cmp-browser-sdk", | ||
"version": "4.20.2", | ||
"version": "4.21.0", | ||
"tcfCmpVersion": "3", | ||
"author": "Usercentrics GmbH", | ||
"description": "Usercentrics CMP Browser SDK", | ||
"homepage": "https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/index.html", | ||
"homepage": "https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/index.html", | ||
"license": "SEE LICENSE IN LICENSE.md", | ||
@@ -9,0 +9,0 @@ "main": "dist/index.js", |
325
README.md
@@ -19,28 +19,27 @@ # Usercentrics CMP Browser SDK | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID'); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialUIValues) => { | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
// getCategories() returns all categories' and data processing services' information | ||
const categories = UC.getCategories(); | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
// getCategories() returns all categories' and data processing services' information | ||
const categories = UC.getCategories(); | ||
if (initialUIValues.variant === UI_VARIANT.DEFAULT) { | ||
switch (initialUIValues.initialLayer) { | ||
case UI_LAYER.FIRST_LAYER: | ||
// Show first layer (i.e. privacy banner) | ||
return; | ||
case UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
if (initialUIValues.variant === UI_VARIANT.DEFAULT) { | ||
switch (initialUIValues.initialLayer) { | ||
case UI_LAYER.FIRST_LAYER: | ||
// Show first layer (i.e. privacy banner) | ||
return; | ||
case UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
}); | ||
} | ||
``` | ||
The constructor also supports an optional [Options](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/interfaces/InitOptions.html) parameter. | ||
The constructor also supports an optional [Options](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/interfaces/InitOptions.html) parameter. | ||
@@ -65,33 +64,32 @@ ## Geolocation initialization | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID', { createTcfApiStub: true }); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialUIValues) => { | ||
const categories = UC.getCategories(); | ||
const settings = UC.getSettingsCore(); | ||
const categories = UC.getCategories(); | ||
const settings = UC.getSettingsCore(); | ||
/** | ||
* ... | ||
*/ | ||
/** | ||
* ... | ||
*/ | ||
const onAcceptAllHandler = (): void => { | ||
UC.acceptAllServices().then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
const onAcceptAllHandler = (): void => { | ||
UC.acceptAllServices().then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
const onDenyAllHandler = (): void => { | ||
UC.denyAllServices().then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
const onDenyAllHandler = (): void => { | ||
UC.denyAllServices().then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
const onSaveHandler = (userDecisions: UserDecision[]): void => { | ||
// UserDecisions needs to include all the user choices for each service that were made in your UI | ||
UC.updateServices(userDecisions).then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
}); | ||
const onSaveHandler = (userDecisions: UserDecision[]): void => { | ||
// UserDecisions needs to include all the user choices for each service that were made in your UI | ||
UC.updateServices(userDecisions).then(() => { | ||
// Remember to fetch the now updated categories | ||
const categories = UC.getCategories(); | ||
}); | ||
}; | ||
``` | ||
@@ -107,31 +105,30 @@ | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID', { createTcfApiStub: true }); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialUIValues) => { | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
// NOTE: If TCF is enabled, the ui property of the settings object will always be of type TCFUISettings, not DefaultUISettings. | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
// getTCFData() returns all TCF related data (vendors, purposes, special features etc.) | ||
const tcfData = UC.getTCFData(); | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
// NOTE: If TCF is enabled, the ui property of the settings object will always be of type TCFUISettings, not DefaultUISettings. | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
// getTCFData() returns all TCF related data (vendors, purposes, special features etc.) | ||
const tcfData = UC.getTCFData(); | ||
if (initialUIValues.variant === UI_VARIANT.TCF) { | ||
switch (initialUIValues.initialLayer) { | ||
case UI_LAYER.FIRST_LAYER: | ||
// NOTE: Remember to call setTCFUIAsOpen()! | ||
UC.setTCFUIAsOpen(); | ||
// Show TCF first layer | ||
return; | ||
case UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
if (initialUIValues.variant === UI_VARIANT.TCF) { | ||
switch (initialUIValues.initialLayer) { | ||
case UI_LAYER.FIRST_LAYER: | ||
// NOTE: Remember to call setTCFUIAsOpen()! | ||
UC.setTCFUIAsOpen(); | ||
// Show TCF first layer | ||
return; | ||
case UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
}); | ||
} | ||
``` | ||
The constructor also supports an optional [Options](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/interfaces/InitOptions.html) parameter. | ||
The constructor also supports an optional [Options](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/interfaces/InitOptions.html) parameter. | ||
@@ -151,41 +148,40 @@ For TCF, the `createTcfApiStub` option needs to be set to true in order for the \_\_tcfapi queue to initialize right away (we cannot wait for the settings request to finish). | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID', { createTcfApiStub: true }); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialUIValues) => { | ||
const settings = UC.getSettingsCore(); | ||
const tcfData = UC.getTCFData(); | ||
const settings = UC.getSettingsCore(); | ||
const tcfData = UC.getTCFData(); | ||
/** | ||
* ... | ||
*/ | ||
/** | ||
* ... | ||
*/ | ||
// The fromLayer parameter needs to identify the layer from which the acceptAll button was triggered. | ||
const onAcceptAllHandler = (fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
UC.acceptAllForTCF(fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// The fromLayer parameter needs to identify the layer from which the acceptAll button was triggered. | ||
const onAcceptAllHandler = (fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
UC.acceptAllForTCF(fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// The fromLayer parameter needs to identify the layer from which the denyAll button was triggered. | ||
const onDenyAllHandler = (fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
UC.denyAllForTCF(fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// The fromLayer parameter needs to identify the layer from which the denyAll button was triggered. | ||
const onDenyAllHandler = (fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
UC.denyAllForTCF(fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// The fromLayer parameter needs to identify the layer from which the save button was triggered. | ||
const onSaveHandler = (tcfUserDecisions: TCFUserDecisions, fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
// TCFUserDecisions needs to include all the user choices for each vendor, purpose, special feature that were made in your UI | ||
UC.updateChoicesForTCF(tcfUserDecisions, fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// The fromLayer parameter needs to identify the layer from which the save button was triggered. | ||
const onSaveHandler = (tcfUserDecisions: TCFUserDecisions, fromLayer: TCF_DECISION_UI_LAYER): void => { | ||
// TCFUserDecisions needs to include all the user choices for each vendor, purpose, special feature that were made in your UI | ||
UC.updateChoicesForTCF(tcfUserDecisions, fromLayer).then(() => { | ||
// Remember to fetch the new (updated) tcfData | ||
const tcfData = UC.getTCFData(); | ||
}); | ||
}; | ||
// Special handler for closing the TCF UI without any user changes (e.g. for any close button / click-away handler) | ||
const onTCFUICloseHandler = (): void => { | ||
UC.setTCFUIAsClosed(); | ||
}; | ||
}); | ||
// Special handler for closing the TCF UI without any user changes (e.g. for any close button / click-away handler) | ||
const onTCFUICloseHandler = (): void => { | ||
UC.setTCFUIAsClosed(); | ||
}; | ||
``` | ||
@@ -239,24 +235,22 @@ | ||
- `getServicesBaseInfo` retrieve all services with their base information, without fetching the aggregator. | ||
- Returns [BaseService](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/interfaces/BaseService.html)[] | ||
- Returns [BaseService](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/interfaces/BaseService.html)[] | ||
```js | ||
const initialUIValues = await UC.init(); | ||
// getServicesBaseInfo() returns all the services with their base information | ||
const servicesBase = UC.getServicesBaseInfo(); | ||
console.log("BASE INFO", servicesBase); | ||
``` | ||
UC.init().then((initialUIValues) => { | ||
// getServicesBaseInfo() returns all the services with their base information | ||
const servicesBase = UC.getServicesBaseInfo(); | ||
console.log("BASE INFO", servicesBase) | ||
... }); | ||
``` | ||
- `getServicesFullInfo` retrieves all services with their complete information, fetching the aggregator if necessary. | ||
- Returns Promise<[Service](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/modules.html#service)[]> | ||
- Returns Promise<[Service](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/modules.html#service)[]> | ||
```js | ||
const initialUIValues = await UC.init(); | ||
// getServicesFullInfo() returns all services with their complete information | ||
const servicesFull = UC.getServicesFullInfo() | ||
servicesFull.then(info => { | ||
console.log("FULL INFO", info); | ||
}); | ||
``` | ||
UC.init().then((initialUIValues) => { | ||
// getServicesFullInfo() returns all services with their complete information | ||
const servicesFull = UC.getServicesFullInfo() | ||
servicesFull.then(info => { | ||
console.log("FULL INFO", info) | ||
}); | ||
... }); | ||
``` | ||
@@ -268,24 +262,22 @@ ## Getting Categories Information | ||
- `getCategoriesBaseInfo` retrieves the categories and their base services info to display this information in your UI. | ||
- Returns [BaseCategory](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/interfaces/BaseCategory.html)[] | ||
- Returns [BaseCategory](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/interfaces/BaseCategory.html)[] | ||
```js | ||
const initialUIValues = await UC.init(); | ||
// getCategoriesBaseInfo() returns the categories and their base services info to display this information in your UI. | ||
const categoriesBase = UC.getCategoriesBaseInfo(); | ||
console.log("BASE CATEGORIES INFO", categoriesBase); | ||
``` | ||
UC.init().then((initialUIValues) => { | ||
// getCategoriesBaseInfo() returns the categories and their base services info to display this information in your UI. | ||
const categoriesBase = UC.getCategoriesBaseInfo(); | ||
console.log("BASE CATEGORIES INFO", categoriesBase) | ||
... }); | ||
``` | ||
- `getCategoriesFullInfo` retrieves the categories and their full services info to display this information in your UI. | ||
- Returns Promise<[Category](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/interfaces/Category.html)[]> | ||
- Returns Promise<[Category](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/interfaces/Category.html)[]> | ||
```js | ||
const initialUIValues = await UC.init(); | ||
// getCategoriesFullInfo() returns the categories and their full services info to display this information in your UI. | ||
const categoriesFull = UC.getCategoriesFullInfo(); | ||
categoriesFull.then(info => { | ||
console.log("FULL INFO", info); | ||
}); | ||
``` | ||
UC.init().then((initialUIValues) => { | ||
// getCategoriesFullInfo() returns the categories and their full services info to display this information in your UI. | ||
const categoriesFull = UC.getCategoriesFullInfo(); | ||
categoriesFull.then(info => { | ||
console.log("FULL INFO", info) | ||
}); | ||
... }); | ||
``` | ||
@@ -302,8 +294,3 @@ ## Cross-Device Consent Sharing | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID', { controllerId: 'CONTROLLER_ID_FOR_END_USER' }); | ||
UC.init().then((initialView) => { | ||
/** | ||
* ... | ||
*/ | ||
}); | ||
const initialUIValues = await UC.init(); | ||
``` | ||
@@ -317,13 +304,8 @@ | ||
const UC = new Usercentrics('YOUR_USERCENTRICS_SETTINGS_ID'); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialView) => { | ||
UC.restoreUserSession('CONTROLLER_ID_FOR_END_USER').then(() => { | ||
/** | ||
* ... | ||
*/ | ||
UC.restoreUserSession('CONTROLLER_ID_FOR_END_USER').then(() => { | ||
/** | ||
* ... | ||
*/ | ||
}); | ||
}); | ||
@@ -348,3 +330,3 @@ ``` | ||
```html | ||
<script src="https://app.usercentrics.eu/browser-sdk/4.20.2/bundle.js"></script> | ||
<script src="https://app.usercentrics.eu/browser-sdk/4.21.0/bundle.js"></script> | ||
``` | ||
@@ -356,28 +338,27 @@ | ||
const UC = new UC_SDK.default('YOUR_USERCENTRICS_SETTINGS_ID'); | ||
const initialUIValues = await UC.init(); | ||
UC.init().then((initialUIValues) => { | ||
// getCategories() returns all categories' and data processing services' information | ||
const categories = UC.getCategories(); | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
// getCategories() returns all categories' and data processing services' information | ||
const categories = UC.getCategories(); | ||
// getSettingsCore() and getSettingsLabels() returns all Usercentrics settings you need for your custom solution | ||
const settings = UC.getSettingsCore(); | ||
const labels = UC.getSettingsLabels(); | ||
if (initialUIValues.variant === UC_SDK.UI_VARIANT.DEFAULT) { | ||
switch (initialUIValues.initialLayer) { | ||
case UC_SDK.UI_LAYER.FIRST_LAYER: | ||
// Show first layer (i.e. privacy banner) | ||
return; | ||
case UC_SDK.UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UC_SDK.UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
if (initialUIValues.variant === UC_SDK.UI_VARIANT.DEFAULT) { | ||
switch (initialUIValues.initialLayer) { | ||
case UC_SDK.UI_LAYER.FIRST_LAYER: | ||
// Show first layer (i.e. privacy banner) | ||
return; | ||
case UC_SDK.UI_LAYER.PRIVACY_BUTTON: | ||
// Show privacy button | ||
return; | ||
case UC_SDK.UI_LAYER.NONE: | ||
default: | ||
// Show nothing | ||
return; | ||
} | ||
}); | ||
} | ||
``` | ||
**NOTE**: If you need Internet Explorer 11 support, you can point the `src` attribute to `https://app.usercentrics.eu/browser-sdk/4.20.2/bundle_legacy.js`. | ||
**NOTE**: If you need Internet Explorer 11 support, you can point the `src` attribute to `https://app.usercentrics.eu/browser-sdk/4.21.0/bundle_legacy.js`. | ||
@@ -392,2 +373,2 @@ ## Considerations for building your custom TCF v2.0 UI | ||
Documentation can be found on our [documentation website](https://docs.usercentrics.com/cmp_browser_sdk/4.20.2/index.html). | ||
Documentation can be found on our [documentation website](https://docs.usercentrics.com/cmp_browser_sdk/4.21.0/index.html). |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
23208
1742324
364