@blotoutio/providers-blotout-consent-sdk 1.49.2 → 1.49.3
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/index.cjs.js +33 -13
- package/index.js +33 -13
- package/index.mjs +33 -13
- package/package.json +1 -1
- package/stores/shopify/index.cjs.js +4 -3
- package/stores/shopify/index.js +4 -3
- package/stores/shopify/index.mjs +4 -3
package/index.cjs.js
CHANGED
|
@@ -845,23 +845,39 @@ const saveConsent = (BlotoutConsentAPI, storeAPI, consent) => {
|
|
|
845
845
|
logger.info('Consent auto-granted for this region');
|
|
846
846
|
};
|
|
847
847
|
|
|
848
|
+
const isPreviewMode = (variables) => {
|
|
849
|
+
var _a;
|
|
850
|
+
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
851
|
+
if (status !== 'preview') {
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
try {
|
|
855
|
+
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
856
|
+
}
|
|
857
|
+
catch {
|
|
858
|
+
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
859
|
+
return false;
|
|
860
|
+
}
|
|
861
|
+
};
|
|
848
862
|
const isEnabled = (variables) => {
|
|
849
|
-
var _a
|
|
863
|
+
var _a;
|
|
850
864
|
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
851
865
|
if (status === 'disable') {
|
|
852
866
|
return false;
|
|
853
867
|
}
|
|
854
868
|
if (status === 'preview') {
|
|
855
|
-
|
|
856
|
-
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
857
|
-
}
|
|
858
|
-
catch {
|
|
859
|
-
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
860
|
-
return false;
|
|
861
|
-
}
|
|
869
|
+
return isPreviewMode(variables);
|
|
862
870
|
}
|
|
863
|
-
return
|
|
871
|
+
return status === 'enable';
|
|
864
872
|
};
|
|
873
|
+
const shouldAutoGrantConsent = (variables) => { var _a; return (_a = (isEnabled(variables) && variables.autoGrantConsent)) !== null && _a !== void 0 ? _a : false; };
|
|
874
|
+
const shouldShowBanner = (variables) => {
|
|
875
|
+
var _a, _b;
|
|
876
|
+
return (_b = (isEnabled(variables) &&
|
|
877
|
+
((_a = variables.config) === null || _a === void 0 ? void 0 : _a.enabled) &&
|
|
878
|
+
!variables.autoGrantConsent)) !== null && _b !== void 0 ? _b : false;
|
|
879
|
+
};
|
|
880
|
+
const shouldCollectAnalytics = (variables) => isEnabled(variables);
|
|
865
881
|
/**
|
|
866
882
|
* SDK initialization entry point. Initializes the consent banner in the top-level browser window.
|
|
867
883
|
*
|
|
@@ -891,7 +907,7 @@ const init = (params) => {
|
|
|
891
907
|
logger.error('Configuration is not available');
|
|
892
908
|
return;
|
|
893
909
|
}
|
|
894
|
-
const { config, theme, defaultConsentState
|
|
910
|
+
const { config, theme, defaultConsentState } = variables;
|
|
895
911
|
const registry = window[registryKey];
|
|
896
912
|
if (!registry) {
|
|
897
913
|
logger.error('Consent registry is not available');
|
|
@@ -920,7 +936,10 @@ const init = (params) => {
|
|
|
920
936
|
logger.error('Store API is not available');
|
|
921
937
|
return;
|
|
922
938
|
}
|
|
923
|
-
if (
|
|
939
|
+
if (isPreviewMode(variables)) {
|
|
940
|
+
logger.info('Consent banner is in preview mode');
|
|
941
|
+
}
|
|
942
|
+
if (shouldShowBanner(variables)) {
|
|
924
943
|
const uiImplementation = registry.ui;
|
|
925
944
|
if (!uiImplementation) {
|
|
926
945
|
logger.error('UI implementation is missing');
|
|
@@ -939,8 +958,9 @@ const init = (params) => {
|
|
|
939
958
|
else {
|
|
940
959
|
logger.info('Consent banner is disabled');
|
|
941
960
|
}
|
|
942
|
-
|
|
943
|
-
|
|
961
|
+
if (shouldCollectAnalytics(variables))
|
|
962
|
+
collectConsentAnalytics(params.baseUrl, (_d = (_c = params.session) === null || _c === void 0 ? void 0 : _c.isNewSession) !== null && _d !== void 0 ? _d : false);
|
|
963
|
+
if (shouldAutoGrantConsent(variables)) {
|
|
944
964
|
saveConsent(blotoutConsentAPI, storeAPI, defaultConsentState);
|
|
945
965
|
}
|
|
946
966
|
}
|
package/index.js
CHANGED
|
@@ -844,23 +844,39 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
|
|
|
844
844
|
logger.info('Consent auto-granted for this region');
|
|
845
845
|
};
|
|
846
846
|
|
|
847
|
+
const isPreviewMode = (variables) => {
|
|
848
|
+
var _a;
|
|
849
|
+
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
850
|
+
if (status !== 'preview') {
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
try {
|
|
854
|
+
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
855
|
+
}
|
|
856
|
+
catch {
|
|
857
|
+
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
};
|
|
847
861
|
const isEnabled = (variables) => {
|
|
848
|
-
var _a
|
|
862
|
+
var _a;
|
|
849
863
|
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
850
864
|
if (status === 'disable') {
|
|
851
865
|
return false;
|
|
852
866
|
}
|
|
853
867
|
if (status === 'preview') {
|
|
854
|
-
|
|
855
|
-
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
856
|
-
}
|
|
857
|
-
catch {
|
|
858
|
-
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
859
|
-
return false;
|
|
860
|
-
}
|
|
868
|
+
return isPreviewMode(variables);
|
|
861
869
|
}
|
|
862
|
-
return
|
|
870
|
+
return status === 'enable';
|
|
863
871
|
};
|
|
872
|
+
const shouldAutoGrantConsent = (variables) => { var _a; return (_a = (isEnabled(variables) && variables.autoGrantConsent)) !== null && _a !== void 0 ? _a : false; };
|
|
873
|
+
const shouldShowBanner = (variables) => {
|
|
874
|
+
var _a, _b;
|
|
875
|
+
return (_b = (isEnabled(variables) &&
|
|
876
|
+
((_a = variables.config) === null || _a === void 0 ? void 0 : _a.enabled) &&
|
|
877
|
+
!variables.autoGrantConsent)) !== null && _b !== void 0 ? _b : false;
|
|
878
|
+
};
|
|
879
|
+
const shouldCollectAnalytics = (variables) => isEnabled(variables);
|
|
864
880
|
/**
|
|
865
881
|
* SDK initialization entry point. Initializes the consent banner in the top-level browser window.
|
|
866
882
|
*
|
|
@@ -890,7 +906,7 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
|
|
|
890
906
|
logger.error('Configuration is not available');
|
|
891
907
|
return;
|
|
892
908
|
}
|
|
893
|
-
const { config, theme, defaultConsentState
|
|
909
|
+
const { config, theme, defaultConsentState } = variables;
|
|
894
910
|
const registry = window[registryKey];
|
|
895
911
|
if (!registry) {
|
|
896
912
|
logger.error('Consent registry is not available');
|
|
@@ -919,7 +935,10 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
|
|
|
919
935
|
logger.error('Store API is not available');
|
|
920
936
|
return;
|
|
921
937
|
}
|
|
922
|
-
if (
|
|
938
|
+
if (isPreviewMode(variables)) {
|
|
939
|
+
logger.info('Consent banner is in preview mode');
|
|
940
|
+
}
|
|
941
|
+
if (shouldShowBanner(variables)) {
|
|
923
942
|
const uiImplementation = registry.ui;
|
|
924
943
|
if (!uiImplementation) {
|
|
925
944
|
logger.error('UI implementation is missing');
|
|
@@ -938,8 +957,9 @@ var ProvidersBlotoutConsentSdk = (function (exports) {
|
|
|
938
957
|
else {
|
|
939
958
|
logger.info('Consent banner is disabled');
|
|
940
959
|
}
|
|
941
|
-
|
|
942
|
-
|
|
960
|
+
if (shouldCollectAnalytics(variables))
|
|
961
|
+
collectConsentAnalytics(params.baseUrl, (_d = (_c = params.session) === null || _c === void 0 ? void 0 : _c.isNewSession) !== null && _d !== void 0 ? _d : false);
|
|
962
|
+
if (shouldAutoGrantConsent(variables)) {
|
|
943
963
|
saveConsent(blotoutConsentAPI, storeAPI, defaultConsentState);
|
|
944
964
|
}
|
|
945
965
|
}
|
package/index.mjs
CHANGED
|
@@ -841,23 +841,39 @@ const saveConsent = (BlotoutConsentAPI, storeAPI, consent) => {
|
|
|
841
841
|
logger.info('Consent auto-granted for this region');
|
|
842
842
|
};
|
|
843
843
|
|
|
844
|
+
const isPreviewMode = (variables) => {
|
|
845
|
+
var _a;
|
|
846
|
+
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
847
|
+
if (status !== 'preview') {
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
try {
|
|
851
|
+
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
852
|
+
}
|
|
853
|
+
catch {
|
|
854
|
+
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
};
|
|
844
858
|
const isEnabled = (variables) => {
|
|
845
|
-
var _a
|
|
859
|
+
var _a;
|
|
846
860
|
const status = (_a = variables.status) !== null && _a !== void 0 ? _a : 'disable';
|
|
847
861
|
if (status === 'disable') {
|
|
848
862
|
return false;
|
|
849
863
|
}
|
|
850
864
|
if (status === 'preview') {
|
|
851
|
-
|
|
852
|
-
return sessionStorage.getItem('blotout-consent-preview') === '1';
|
|
853
|
-
}
|
|
854
|
-
catch {
|
|
855
|
-
// sessionStorage may be unavailable in restricted contexts (e.g. sandboxed iframes)
|
|
856
|
-
return false;
|
|
857
|
-
}
|
|
865
|
+
return isPreviewMode(variables);
|
|
858
866
|
}
|
|
859
|
-
return
|
|
867
|
+
return status === 'enable';
|
|
860
868
|
};
|
|
869
|
+
const shouldAutoGrantConsent = (variables) => { var _a; return (_a = (isEnabled(variables) && variables.autoGrantConsent)) !== null && _a !== void 0 ? _a : false; };
|
|
870
|
+
const shouldShowBanner = (variables) => {
|
|
871
|
+
var _a, _b;
|
|
872
|
+
return (_b = (isEnabled(variables) &&
|
|
873
|
+
((_a = variables.config) === null || _a === void 0 ? void 0 : _a.enabled) &&
|
|
874
|
+
!variables.autoGrantConsent)) !== null && _b !== void 0 ? _b : false;
|
|
875
|
+
};
|
|
876
|
+
const shouldCollectAnalytics = (variables) => isEnabled(variables);
|
|
861
877
|
/**
|
|
862
878
|
* SDK initialization entry point. Initializes the consent banner in the top-level browser window.
|
|
863
879
|
*
|
|
@@ -887,7 +903,7 @@ const init = (params) => {
|
|
|
887
903
|
logger.error('Configuration is not available');
|
|
888
904
|
return;
|
|
889
905
|
}
|
|
890
|
-
const { config, theme, defaultConsentState
|
|
906
|
+
const { config, theme, defaultConsentState } = variables;
|
|
891
907
|
const registry = window[registryKey];
|
|
892
908
|
if (!registry) {
|
|
893
909
|
logger.error('Consent registry is not available');
|
|
@@ -916,7 +932,10 @@ const init = (params) => {
|
|
|
916
932
|
logger.error('Store API is not available');
|
|
917
933
|
return;
|
|
918
934
|
}
|
|
919
|
-
if (
|
|
935
|
+
if (isPreviewMode(variables)) {
|
|
936
|
+
logger.info('Consent banner is in preview mode');
|
|
937
|
+
}
|
|
938
|
+
if (shouldShowBanner(variables)) {
|
|
920
939
|
const uiImplementation = registry.ui;
|
|
921
940
|
if (!uiImplementation) {
|
|
922
941
|
logger.error('UI implementation is missing');
|
|
@@ -935,8 +954,9 @@ const init = (params) => {
|
|
|
935
954
|
else {
|
|
936
955
|
logger.info('Consent banner is disabled');
|
|
937
956
|
}
|
|
938
|
-
|
|
939
|
-
|
|
957
|
+
if (shouldCollectAnalytics(variables))
|
|
958
|
+
collectConsentAnalytics(params.baseUrl, (_d = (_c = params.session) === null || _c === void 0 ? void 0 : _c.isNewSession) !== null && _d !== void 0 ? _d : false);
|
|
959
|
+
if (shouldAutoGrantConsent(variables)) {
|
|
940
960
|
saveConsent(blotoutConsentAPI, storeAPI, defaultConsentState);
|
|
941
961
|
}
|
|
942
962
|
}
|
package/package.json
CHANGED
|
@@ -99,8 +99,9 @@ const toShopifyConsent = (preferences) => ({
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Reads any prior consent decision the visitor has made through Shopify's
|
|
102
|
-
* Customer Privacy API. Returns null if the API is unavailable
|
|
103
|
-
* has not yet made a consent decision (all values are 'unknown')
|
|
102
|
+
* Customer Privacy API. Returns null if the API is unavailable, the visitor
|
|
103
|
+
* has not yet made a consent decision (all values are 'unknown'), or if all
|
|
104
|
+
* consent values are empty strings.
|
|
104
105
|
*/
|
|
105
106
|
async function getShopifyPriorConsent() {
|
|
106
107
|
const api = await loadCustomerPrivacyApi();
|
|
@@ -108,7 +109,7 @@ async function getShopifyPriorConsent() {
|
|
|
108
109
|
return null;
|
|
109
110
|
}
|
|
110
111
|
const consent = api.currentVisitorConsent();
|
|
111
|
-
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown');
|
|
112
|
+
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown' && Boolean(v));
|
|
112
113
|
if (!hasAnyDecision) {
|
|
113
114
|
return null;
|
|
114
115
|
}
|
package/stores/shopify/index.js
CHANGED
|
@@ -100,8 +100,9 @@
|
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Reads any prior consent decision the visitor has made through Shopify's
|
|
103
|
-
* Customer Privacy API. Returns null if the API is unavailable
|
|
104
|
-
* has not yet made a consent decision (all values are 'unknown')
|
|
103
|
+
* Customer Privacy API. Returns null if the API is unavailable, the visitor
|
|
104
|
+
* has not yet made a consent decision (all values are 'unknown'), or if all
|
|
105
|
+
* consent values are empty strings.
|
|
105
106
|
*/
|
|
106
107
|
async function getShopifyPriorConsent() {
|
|
107
108
|
const api = await loadCustomerPrivacyApi();
|
|
@@ -109,7 +110,7 @@
|
|
|
109
110
|
return null;
|
|
110
111
|
}
|
|
111
112
|
const consent = api.currentVisitorConsent();
|
|
112
|
-
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown');
|
|
113
|
+
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown' && Boolean(v));
|
|
113
114
|
if (!hasAnyDecision) {
|
|
114
115
|
return null;
|
|
115
116
|
}
|
package/stores/shopify/index.mjs
CHANGED
|
@@ -97,8 +97,9 @@ const toShopifyConsent = (preferences) => ({
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Reads any prior consent decision the visitor has made through Shopify's
|
|
100
|
-
* Customer Privacy API. Returns null if the API is unavailable
|
|
101
|
-
* has not yet made a consent decision (all values are 'unknown')
|
|
100
|
+
* Customer Privacy API. Returns null if the API is unavailable, the visitor
|
|
101
|
+
* has not yet made a consent decision (all values are 'unknown'), or if all
|
|
102
|
+
* consent values are empty strings.
|
|
102
103
|
*/
|
|
103
104
|
async function getShopifyPriorConsent() {
|
|
104
105
|
const api = await loadCustomerPrivacyApi();
|
|
@@ -106,7 +107,7 @@ async function getShopifyPriorConsent() {
|
|
|
106
107
|
return null;
|
|
107
108
|
}
|
|
108
109
|
const consent = api.currentVisitorConsent();
|
|
109
|
-
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown');
|
|
110
|
+
const hasAnyDecision = Object.values(consent).some((v) => v !== 'unknown' && Boolean(v));
|
|
110
111
|
if (!hasAnyDecision) {
|
|
111
112
|
return null;
|
|
112
113
|
}
|