@blotoutio/edgetag-sdk-js 0.52.1 → 0.52.2
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 +73 -74
- package/index.mjs +73 -74
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -141,11 +141,12 @@ const initSettings = (destination, options) => {
|
|
|
141
141
|
destination,
|
|
142
142
|
initialized: false,
|
|
143
143
|
stubs: [],
|
|
144
|
+
browserPackages: [],
|
|
144
145
|
channels: new Map(),
|
|
145
146
|
...options,
|
|
146
147
|
};
|
|
147
148
|
};
|
|
148
|
-
const setSetting = (
|
|
149
|
+
const setSetting = (destination, options) => {
|
|
149
150
|
if (!edgeTagSettings) {
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
@@ -172,7 +173,7 @@ const getInstances = () => {
|
|
|
172
173
|
};
|
|
173
174
|
const addChannel = (destination, pkg, tagName) => upsert(getSetting(destination, 'channels'), pkg, (names) => names.add(tagName), () => new Set());
|
|
174
175
|
const getProviderVariables = (destination, packageId) => {
|
|
175
|
-
const setting = getSetting(destination, '
|
|
176
|
+
const setting = getSetting(destination, 'manifest');
|
|
176
177
|
if (!setting) {
|
|
177
178
|
return [];
|
|
178
179
|
}
|
|
@@ -547,7 +548,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
547
548
|
referrer: getReferrer(destination),
|
|
548
549
|
search: getSearch(destination),
|
|
549
550
|
locale: getLocale(),
|
|
550
|
-
sdkVersion: "0.52.
|
|
551
|
+
sdkVersion: "0.52.2" ,
|
|
551
552
|
...(payload || {}),
|
|
552
553
|
};
|
|
553
554
|
let storage = {};
|
|
@@ -627,53 +628,6 @@ const getKeysURL = (destination) => {
|
|
|
627
628
|
return generateUrl(destination, `/keys`);
|
|
628
629
|
};
|
|
629
630
|
|
|
630
|
-
const providersPackages = {};
|
|
631
|
-
const setPreferences = (preferences) => {
|
|
632
|
-
var _a;
|
|
633
|
-
if (!preferences) {
|
|
634
|
-
return false;
|
|
635
|
-
}
|
|
636
|
-
if (!preferences.edgeURL) {
|
|
637
|
-
error('Please provide URL for EdgeTag');
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
(_a = preferences.providers) === null || _a === void 0 ? void 0 : _a.forEach((provider) => {
|
|
641
|
-
if (!provider.name) {
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
providersPackages[provider.name] = provider;
|
|
645
|
-
});
|
|
646
|
-
try {
|
|
647
|
-
if (window && Array.isArray(window.edgetagProviders)) {
|
|
648
|
-
window.edgetagProviders.forEach((provider) => {
|
|
649
|
-
if (!provider.name) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
providersPackages[provider.name] = provider;
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
catch {
|
|
657
|
-
// do nothing
|
|
658
|
-
}
|
|
659
|
-
initSettings(preferences.edgeURL, {
|
|
660
|
-
disableConsent: !!preferences.disableConsentCheck,
|
|
661
|
-
});
|
|
662
|
-
return true;
|
|
663
|
-
};
|
|
664
|
-
const getProvidersPackage = (destination) => {
|
|
665
|
-
const packages = getSetting(destination, 'packages');
|
|
666
|
-
const providers = [];
|
|
667
|
-
packages === null || packages === void 0 ? void 0 : packages.forEach((pkg) => {
|
|
668
|
-
const provider = providersPackages[pkg.package];
|
|
669
|
-
if (!provider) {
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
providers.push(provider);
|
|
673
|
-
});
|
|
674
|
-
return providers;
|
|
675
|
-
};
|
|
676
|
-
|
|
677
631
|
const getConsent$1 = (destination) => {
|
|
678
632
|
const storageConsent = getDataPerKey(destination, 'local', tagStorage, consentKey);
|
|
679
633
|
if (storageConsent) {
|
|
@@ -688,9 +642,9 @@ const processStubs = (destination) => {
|
|
|
688
642
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
689
643
|
// @ts-ignore
|
|
690
644
|
stubs.forEach((stub) => api[stub.name](...(stub.arguments || [])));
|
|
691
|
-
setSetting({
|
|
645
|
+
setSetting(destination, {
|
|
692
646
|
stubs: [],
|
|
693
|
-
}
|
|
647
|
+
});
|
|
694
648
|
}
|
|
695
649
|
catch (e) {
|
|
696
650
|
error(e);
|
|
@@ -698,9 +652,9 @@ const processStubs = (destination) => {
|
|
|
698
652
|
};
|
|
699
653
|
const addStub = (destination, stub) => {
|
|
700
654
|
const otherStubs = getSetting(destination, 'stubs') || [];
|
|
701
|
-
setSetting({
|
|
655
|
+
setSetting(destination, {
|
|
702
656
|
stubs: [...otherStubs, stub],
|
|
703
|
-
}
|
|
657
|
+
});
|
|
704
658
|
};
|
|
705
659
|
|
|
706
660
|
const sendTag = (destination, { eventName, eventId, data, providerData, providers, options }) => {
|
|
@@ -728,7 +682,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
728
682
|
if (!eventId) {
|
|
729
683
|
eventId = generateEventId(eventName);
|
|
730
684
|
}
|
|
731
|
-
const providerPackages =
|
|
685
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
732
686
|
const configuredTags = getSetting(destination, 'channels');
|
|
733
687
|
const userId = getUserId$1(destination);
|
|
734
688
|
const providerData = {};
|
|
@@ -825,7 +779,7 @@ const handleGetData = (keys, callback, options) => {
|
|
|
825
779
|
|
|
826
780
|
const processData = (destination, data, providers, options) => {
|
|
827
781
|
saveKV(destination, data);
|
|
828
|
-
const providerPackages =
|
|
782
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
829
783
|
const configuredTags = getSetting(destination, 'channels');
|
|
830
784
|
const userId = getUserId$1(destination);
|
|
831
785
|
const consent = getConsent$1(destination);
|
|
@@ -880,9 +834,9 @@ const handleConsent = (consent, options) => {
|
|
|
880
834
|
});
|
|
881
835
|
};
|
|
882
836
|
const saveConsent = (destination, consent) => {
|
|
883
|
-
setSetting({
|
|
837
|
+
setSetting(destination, {
|
|
884
838
|
consent,
|
|
885
|
-
}
|
|
839
|
+
});
|
|
886
840
|
savePerKey(destination, 'local', tagStorage, consent, consentKey);
|
|
887
841
|
};
|
|
888
842
|
const processConsent = (destination, consent, localSave) => {
|
|
@@ -898,7 +852,7 @@ const processConsent = (destination, consent, localSave) => {
|
|
|
898
852
|
postRequest(getConsentURL(destination), payload).catch(error);
|
|
899
853
|
}
|
|
900
854
|
const userId = getUserId$1(destination);
|
|
901
|
-
const providerPackages =
|
|
855
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
902
856
|
const executionContext = new Map();
|
|
903
857
|
/* Calling Init for all provider instances based on consent check */
|
|
904
858
|
for (const pkg of providerPackages) {
|
|
@@ -952,6 +906,41 @@ const processConsent = (destination, consent, localSave) => {
|
|
|
952
906
|
}
|
|
953
907
|
};
|
|
954
908
|
|
|
909
|
+
const setPreferences = (preferences) => {
|
|
910
|
+
var _a;
|
|
911
|
+
if (!preferences) {
|
|
912
|
+
return null;
|
|
913
|
+
}
|
|
914
|
+
if (!preferences.edgeURL) {
|
|
915
|
+
error('Please provide URL for EdgeTag');
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
const providersPackages = {};
|
|
919
|
+
(_a = preferences.providers) === null || _a === void 0 ? void 0 : _a.forEach((provider) => {
|
|
920
|
+
if (!provider.name) {
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
providersPackages[provider.name] = provider;
|
|
924
|
+
});
|
|
925
|
+
try {
|
|
926
|
+
if (window && Array.isArray(window.edgetagProviders)) {
|
|
927
|
+
window.edgetagProviders.forEach((provider) => {
|
|
928
|
+
if (!provider.name) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
providersPackages[provider.name] = provider;
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
catch {
|
|
936
|
+
// do nothing
|
|
937
|
+
}
|
|
938
|
+
initSettings(preferences.edgeURL, {
|
|
939
|
+
disableConsent: !!preferences.disableConsentCheck,
|
|
940
|
+
});
|
|
941
|
+
return providersPackages;
|
|
942
|
+
};
|
|
943
|
+
|
|
955
944
|
const cacheKey = `${keyPrefix}Cache`;
|
|
956
945
|
const identity = (v) => v;
|
|
957
946
|
const saveDataToEdge = (destination, key, value, provider) => {
|
|
@@ -1060,7 +1049,7 @@ const handleCapture = (destination, provider, params, capture) => {
|
|
|
1060
1049
|
};
|
|
1061
1050
|
|
|
1062
1051
|
const handleManifest = (destination, response) => {
|
|
1063
|
-
const providerPackages =
|
|
1052
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1064
1053
|
const userId = getUserId$1(destination);
|
|
1065
1054
|
const executionContext = new Map();
|
|
1066
1055
|
const manifest = response.result;
|
|
@@ -1096,21 +1085,21 @@ const handleManifest = (destination, response) => {
|
|
|
1096
1085
|
}
|
|
1097
1086
|
}
|
|
1098
1087
|
});
|
|
1099
|
-
setSetting({
|
|
1088
|
+
setSetting(destination, {
|
|
1100
1089
|
initialized: true,
|
|
1101
|
-
}
|
|
1090
|
+
});
|
|
1102
1091
|
processStubs(destination);
|
|
1103
1092
|
};
|
|
1104
1093
|
|
|
1105
1094
|
const handleInit = (preferences) => {
|
|
1106
|
-
const
|
|
1107
|
-
if (!
|
|
1095
|
+
const browserPackages = setPreferences(preferences);
|
|
1096
|
+
if (!browserPackages) {
|
|
1108
1097
|
return;
|
|
1109
1098
|
}
|
|
1110
1099
|
if (preferences.afterManifestEvents) {
|
|
1111
|
-
setSetting({
|
|
1100
|
+
setSetting(preferences.edgeURL, {
|
|
1112
1101
|
stubs: preferences.afterManifestEvents,
|
|
1113
|
-
}
|
|
1102
|
+
});
|
|
1114
1103
|
}
|
|
1115
1104
|
const url = new URL(getInitURL(preferences.edgeURL));
|
|
1116
1105
|
if (preferences.disableConsentCheck) {
|
|
@@ -1118,21 +1107,31 @@ const handleInit = (preferences) => {
|
|
|
1118
1107
|
saveConsent(preferences.edgeURL, { all: true });
|
|
1119
1108
|
}
|
|
1120
1109
|
if (preferences.userId) {
|
|
1121
|
-
setSetting({ userId: preferences.userId }
|
|
1110
|
+
setSetting(preferences.edgeURL, { userId: preferences.userId });
|
|
1122
1111
|
url.searchParams.set('userId', preferences.userId);
|
|
1123
1112
|
}
|
|
1124
1113
|
getRequest(url.href)
|
|
1125
1114
|
.then((result) => {
|
|
1115
|
+
var _a;
|
|
1126
1116
|
if (!result) {
|
|
1127
1117
|
error('Initialization failed');
|
|
1128
1118
|
return;
|
|
1129
1119
|
}
|
|
1130
|
-
|
|
1120
|
+
const providers = {};
|
|
1121
|
+
(_a = result.result) === null || _a === void 0 ? void 0 : _a.forEach((pkg) => {
|
|
1122
|
+
const provider = browserPackages[pkg.package];
|
|
1123
|
+
if (!provider) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
providers[pkg.package] = provider;
|
|
1127
|
+
});
|
|
1128
|
+
setSetting(preferences.edgeURL, {
|
|
1131
1129
|
isNewUser: result.isNewUser,
|
|
1132
1130
|
consent: getConsent$1(preferences.edgeURL) || result.consent,
|
|
1133
1131
|
userId: result.userId,
|
|
1134
|
-
|
|
1135
|
-
|
|
1132
|
+
manifest: result.result,
|
|
1133
|
+
browserPackages: Object.values(providers),
|
|
1134
|
+
});
|
|
1136
1135
|
handleManifest(preferences.edgeURL, result);
|
|
1137
1136
|
try {
|
|
1138
1137
|
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
@@ -1157,7 +1156,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1157
1156
|
saveKV(destination, {
|
|
1158
1157
|
[key]: value,
|
|
1159
1158
|
});
|
|
1160
|
-
const providerPackages =
|
|
1159
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1161
1160
|
const configuredTags = getSetting(destination, 'channels');
|
|
1162
1161
|
const consent = getConsent$1(destination);
|
|
1163
1162
|
const userId = getUserId$1(destination);
|
|
@@ -1176,7 +1175,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1176
1175
|
continue;
|
|
1177
1176
|
}
|
|
1178
1177
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
1179
|
-
log(`User
|
|
1178
|
+
log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1180
1179
|
continue;
|
|
1181
1180
|
}
|
|
1182
1181
|
pkg.user({
|
|
@@ -1271,12 +1270,12 @@ const handleIsNewUser = (options) => {
|
|
|
1271
1270
|
|
|
1272
1271
|
const processConfig = (destination, config) => {
|
|
1273
1272
|
const existingConfig = getSetting(destination, 'config');
|
|
1274
|
-
setSetting({
|
|
1273
|
+
setSetting(destination, {
|
|
1275
1274
|
config: {
|
|
1276
1275
|
...existingConfig,
|
|
1277
1276
|
...config,
|
|
1278
1277
|
},
|
|
1279
|
-
}
|
|
1278
|
+
});
|
|
1280
1279
|
};
|
|
1281
1280
|
const handleConfig = (config, options) => {
|
|
1282
1281
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|
package/index.mjs
CHANGED
|
@@ -139,11 +139,12 @@ const initSettings = (destination, options) => {
|
|
|
139
139
|
destination,
|
|
140
140
|
initialized: false,
|
|
141
141
|
stubs: [],
|
|
142
|
+
browserPackages: [],
|
|
142
143
|
channels: new Map(),
|
|
143
144
|
...options,
|
|
144
145
|
};
|
|
145
146
|
};
|
|
146
|
-
const setSetting = (
|
|
147
|
+
const setSetting = (destination, options) => {
|
|
147
148
|
if (!edgeTagSettings) {
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
@@ -170,7 +171,7 @@ const getInstances = () => {
|
|
|
170
171
|
};
|
|
171
172
|
const addChannel = (destination, pkg, tagName) => upsert(getSetting(destination, 'channels'), pkg, (names) => names.add(tagName), () => new Set());
|
|
172
173
|
const getProviderVariables = (destination, packageId) => {
|
|
173
|
-
const setting = getSetting(destination, '
|
|
174
|
+
const setting = getSetting(destination, 'manifest');
|
|
174
175
|
if (!setting) {
|
|
175
176
|
return [];
|
|
176
177
|
}
|
|
@@ -545,7 +546,7 @@ const getStandardPayload = (destination, payload) => {
|
|
|
545
546
|
referrer: getReferrer(destination),
|
|
546
547
|
search: getSearch(destination),
|
|
547
548
|
locale: getLocale(),
|
|
548
|
-
sdkVersion: "0.52.
|
|
549
|
+
sdkVersion: "0.52.2" ,
|
|
549
550
|
...(payload || {}),
|
|
550
551
|
};
|
|
551
552
|
let storage = {};
|
|
@@ -625,53 +626,6 @@ const getKeysURL = (destination) => {
|
|
|
625
626
|
return generateUrl(destination, `/keys`);
|
|
626
627
|
};
|
|
627
628
|
|
|
628
|
-
const providersPackages = {};
|
|
629
|
-
const setPreferences = (preferences) => {
|
|
630
|
-
var _a;
|
|
631
|
-
if (!preferences) {
|
|
632
|
-
return false;
|
|
633
|
-
}
|
|
634
|
-
if (!preferences.edgeURL) {
|
|
635
|
-
error('Please provide URL for EdgeTag');
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
(_a = preferences.providers) === null || _a === void 0 ? void 0 : _a.forEach((provider) => {
|
|
639
|
-
if (!provider.name) {
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
providersPackages[provider.name] = provider;
|
|
643
|
-
});
|
|
644
|
-
try {
|
|
645
|
-
if (window && Array.isArray(window.edgetagProviders)) {
|
|
646
|
-
window.edgetagProviders.forEach((provider) => {
|
|
647
|
-
if (!provider.name) {
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
providersPackages[provider.name] = provider;
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
catch {
|
|
655
|
-
// do nothing
|
|
656
|
-
}
|
|
657
|
-
initSettings(preferences.edgeURL, {
|
|
658
|
-
disableConsent: !!preferences.disableConsentCheck,
|
|
659
|
-
});
|
|
660
|
-
return true;
|
|
661
|
-
};
|
|
662
|
-
const getProvidersPackage = (destination) => {
|
|
663
|
-
const packages = getSetting(destination, 'packages');
|
|
664
|
-
const providers = [];
|
|
665
|
-
packages === null || packages === void 0 ? void 0 : packages.forEach((pkg) => {
|
|
666
|
-
const provider = providersPackages[pkg.package];
|
|
667
|
-
if (!provider) {
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
providers.push(provider);
|
|
671
|
-
});
|
|
672
|
-
return providers;
|
|
673
|
-
};
|
|
674
|
-
|
|
675
629
|
const getConsent$1 = (destination) => {
|
|
676
630
|
const storageConsent = getDataPerKey(destination, 'local', tagStorage, consentKey);
|
|
677
631
|
if (storageConsent) {
|
|
@@ -686,9 +640,9 @@ const processStubs = (destination) => {
|
|
|
686
640
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
687
641
|
// @ts-ignore
|
|
688
642
|
stubs.forEach((stub) => api[stub.name](...(stub.arguments || [])));
|
|
689
|
-
setSetting({
|
|
643
|
+
setSetting(destination, {
|
|
690
644
|
stubs: [],
|
|
691
|
-
}
|
|
645
|
+
});
|
|
692
646
|
}
|
|
693
647
|
catch (e) {
|
|
694
648
|
error(e);
|
|
@@ -696,9 +650,9 @@ const processStubs = (destination) => {
|
|
|
696
650
|
};
|
|
697
651
|
const addStub = (destination, stub) => {
|
|
698
652
|
const otherStubs = getSetting(destination, 'stubs') || [];
|
|
699
|
-
setSetting({
|
|
653
|
+
setSetting(destination, {
|
|
700
654
|
stubs: [...otherStubs, stub],
|
|
701
|
-
}
|
|
655
|
+
});
|
|
702
656
|
};
|
|
703
657
|
|
|
704
658
|
const sendTag = (destination, { eventName, eventId, data, providerData, providers, options }) => {
|
|
@@ -726,7 +680,7 @@ const processTag = (destination, eventName, data = {}, providers, options) => {
|
|
|
726
680
|
if (!eventId) {
|
|
727
681
|
eventId = generateEventId(eventName);
|
|
728
682
|
}
|
|
729
|
-
const providerPackages =
|
|
683
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
730
684
|
const configuredTags = getSetting(destination, 'channels');
|
|
731
685
|
const userId = getUserId$1(destination);
|
|
732
686
|
const providerData = {};
|
|
@@ -823,7 +777,7 @@ const handleGetData = (keys, callback, options) => {
|
|
|
823
777
|
|
|
824
778
|
const processData = (destination, data, providers, options) => {
|
|
825
779
|
saveKV(destination, data);
|
|
826
|
-
const providerPackages =
|
|
780
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
827
781
|
const configuredTags = getSetting(destination, 'channels');
|
|
828
782
|
const userId = getUserId$1(destination);
|
|
829
783
|
const consent = getConsent$1(destination);
|
|
@@ -878,9 +832,9 @@ const handleConsent = (consent, options) => {
|
|
|
878
832
|
});
|
|
879
833
|
};
|
|
880
834
|
const saveConsent = (destination, consent) => {
|
|
881
|
-
setSetting({
|
|
835
|
+
setSetting(destination, {
|
|
882
836
|
consent,
|
|
883
|
-
}
|
|
837
|
+
});
|
|
884
838
|
savePerKey(destination, 'local', tagStorage, consent, consentKey);
|
|
885
839
|
};
|
|
886
840
|
const processConsent = (destination, consent, localSave) => {
|
|
@@ -896,7 +850,7 @@ const processConsent = (destination, consent, localSave) => {
|
|
|
896
850
|
postRequest(getConsentURL(destination), payload).catch(error);
|
|
897
851
|
}
|
|
898
852
|
const userId = getUserId$1(destination);
|
|
899
|
-
const providerPackages =
|
|
853
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
900
854
|
const executionContext = new Map();
|
|
901
855
|
/* Calling Init for all provider instances based on consent check */
|
|
902
856
|
for (const pkg of providerPackages) {
|
|
@@ -950,6 +904,41 @@ const processConsent = (destination, consent, localSave) => {
|
|
|
950
904
|
}
|
|
951
905
|
};
|
|
952
906
|
|
|
907
|
+
const setPreferences = (preferences) => {
|
|
908
|
+
var _a;
|
|
909
|
+
if (!preferences) {
|
|
910
|
+
return null;
|
|
911
|
+
}
|
|
912
|
+
if (!preferences.edgeURL) {
|
|
913
|
+
error('Please provide URL for EdgeTag');
|
|
914
|
+
return null;
|
|
915
|
+
}
|
|
916
|
+
const providersPackages = {};
|
|
917
|
+
(_a = preferences.providers) === null || _a === void 0 ? void 0 : _a.forEach((provider) => {
|
|
918
|
+
if (!provider.name) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
providersPackages[provider.name] = provider;
|
|
922
|
+
});
|
|
923
|
+
try {
|
|
924
|
+
if (window && Array.isArray(window.edgetagProviders)) {
|
|
925
|
+
window.edgetagProviders.forEach((provider) => {
|
|
926
|
+
if (!provider.name) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
providersPackages[provider.name] = provider;
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
catch {
|
|
934
|
+
// do nothing
|
|
935
|
+
}
|
|
936
|
+
initSettings(preferences.edgeURL, {
|
|
937
|
+
disableConsent: !!preferences.disableConsentCheck,
|
|
938
|
+
});
|
|
939
|
+
return providersPackages;
|
|
940
|
+
};
|
|
941
|
+
|
|
953
942
|
const cacheKey = `${keyPrefix}Cache`;
|
|
954
943
|
const identity = (v) => v;
|
|
955
944
|
const saveDataToEdge = (destination, key, value, provider) => {
|
|
@@ -1058,7 +1047,7 @@ const handleCapture = (destination, provider, params, capture) => {
|
|
|
1058
1047
|
};
|
|
1059
1048
|
|
|
1060
1049
|
const handleManifest = (destination, response) => {
|
|
1061
|
-
const providerPackages =
|
|
1050
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1062
1051
|
const userId = getUserId$1(destination);
|
|
1063
1052
|
const executionContext = new Map();
|
|
1064
1053
|
const manifest = response.result;
|
|
@@ -1094,21 +1083,21 @@ const handleManifest = (destination, response) => {
|
|
|
1094
1083
|
}
|
|
1095
1084
|
}
|
|
1096
1085
|
});
|
|
1097
|
-
setSetting({
|
|
1086
|
+
setSetting(destination, {
|
|
1098
1087
|
initialized: true,
|
|
1099
|
-
}
|
|
1088
|
+
});
|
|
1100
1089
|
processStubs(destination);
|
|
1101
1090
|
};
|
|
1102
1091
|
|
|
1103
1092
|
const handleInit = (preferences) => {
|
|
1104
|
-
const
|
|
1105
|
-
if (!
|
|
1093
|
+
const browserPackages = setPreferences(preferences);
|
|
1094
|
+
if (!browserPackages) {
|
|
1106
1095
|
return;
|
|
1107
1096
|
}
|
|
1108
1097
|
if (preferences.afterManifestEvents) {
|
|
1109
|
-
setSetting({
|
|
1098
|
+
setSetting(preferences.edgeURL, {
|
|
1110
1099
|
stubs: preferences.afterManifestEvents,
|
|
1111
|
-
}
|
|
1100
|
+
});
|
|
1112
1101
|
}
|
|
1113
1102
|
const url = new URL(getInitURL(preferences.edgeURL));
|
|
1114
1103
|
if (preferences.disableConsentCheck) {
|
|
@@ -1116,21 +1105,31 @@ const handleInit = (preferences) => {
|
|
|
1116
1105
|
saveConsent(preferences.edgeURL, { all: true });
|
|
1117
1106
|
}
|
|
1118
1107
|
if (preferences.userId) {
|
|
1119
|
-
setSetting({ userId: preferences.userId }
|
|
1108
|
+
setSetting(preferences.edgeURL, { userId: preferences.userId });
|
|
1120
1109
|
url.searchParams.set('userId', preferences.userId);
|
|
1121
1110
|
}
|
|
1122
1111
|
getRequest(url.href)
|
|
1123
1112
|
.then((result) => {
|
|
1113
|
+
var _a;
|
|
1124
1114
|
if (!result) {
|
|
1125
1115
|
error('Initialization failed');
|
|
1126
1116
|
return;
|
|
1127
1117
|
}
|
|
1128
|
-
|
|
1118
|
+
const providers = {};
|
|
1119
|
+
(_a = result.result) === null || _a === void 0 ? void 0 : _a.forEach((pkg) => {
|
|
1120
|
+
const provider = browserPackages[pkg.package];
|
|
1121
|
+
if (!provider) {
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
providers[pkg.package] = provider;
|
|
1125
|
+
});
|
|
1126
|
+
setSetting(preferences.edgeURL, {
|
|
1129
1127
|
isNewUser: result.isNewUser,
|
|
1130
1128
|
consent: getConsent$1(preferences.edgeURL) || result.consent,
|
|
1131
1129
|
userId: result.userId,
|
|
1132
|
-
|
|
1133
|
-
|
|
1130
|
+
manifest: result.result,
|
|
1131
|
+
browserPackages: Object.values(providers),
|
|
1132
|
+
});
|
|
1134
1133
|
handleManifest(preferences.edgeURL, result);
|
|
1135
1134
|
try {
|
|
1136
1135
|
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
@@ -1155,7 +1154,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1155
1154
|
saveKV(destination, {
|
|
1156
1155
|
[key]: value,
|
|
1157
1156
|
});
|
|
1158
|
-
const providerPackages =
|
|
1157
|
+
const providerPackages = getSetting(destination, 'browserPackages');
|
|
1159
1158
|
const configuredTags = getSetting(destination, 'channels');
|
|
1160
1159
|
const consent = getConsent$1(destination);
|
|
1161
1160
|
const userId = getUserId$1(destination);
|
|
@@ -1174,7 +1173,7 @@ const processUser = (destination, key, value, providers, options) => {
|
|
|
1174
1173
|
continue;
|
|
1175
1174
|
}
|
|
1176
1175
|
if (!hasUserConsent(consent, pkg.name, variable.tagName)) {
|
|
1177
|
-
log(`User
|
|
1176
|
+
log(`User do not have consent for ${pkg.name} (${variable.tagName})`);
|
|
1178
1177
|
continue;
|
|
1179
1178
|
}
|
|
1180
1179
|
pkg.user({
|
|
@@ -1269,12 +1268,12 @@ const handleIsNewUser = (options) => {
|
|
|
1269
1268
|
|
|
1270
1269
|
const processConfig = (destination, config) => {
|
|
1271
1270
|
const existingConfig = getSetting(destination, 'config');
|
|
1272
|
-
setSetting({
|
|
1271
|
+
setSetting(destination, {
|
|
1273
1272
|
config: {
|
|
1274
1273
|
...existingConfig,
|
|
1275
1274
|
...config,
|
|
1276
1275
|
},
|
|
1277
|
-
}
|
|
1276
|
+
});
|
|
1278
1277
|
};
|
|
1279
1278
|
const handleConfig = (config, options) => {
|
|
1280
1279
|
if (options === null || options === void 0 ? void 0 : options.destination) {
|