@blotoutio/edgetag-sdk-js 0.36.2 → 0.38.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/index.cjs.js +34 -4
- package/index.d.ts +3 -0
- package/index.mjs +34 -5
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -8,6 +8,7 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
8
8
|
get getData () { return getData; },
|
|
9
9
|
get getUserId () { return getUserId; },
|
|
10
10
|
get init () { return init; },
|
|
11
|
+
get isNewUser () { return isNewUser; },
|
|
11
12
|
get keys () { return keys; },
|
|
12
13
|
get tag () { return tag; },
|
|
13
14
|
get user () { return user; }
|
|
@@ -26,7 +27,8 @@ const getReferrer = () => {
|
|
|
26
27
|
let referrer = '';
|
|
27
28
|
try {
|
|
28
29
|
const referrerUrl = new URL(document.referrer);
|
|
29
|
-
|
|
30
|
+
const pageUrl = new URL(getPageUrl());
|
|
31
|
+
if (referrerUrl.host !== pageUrl.host) {
|
|
30
32
|
referrer = referrerUrl.href;
|
|
31
33
|
}
|
|
32
34
|
return referrer;
|
|
@@ -48,7 +50,7 @@ const getPageUrl = () => {
|
|
|
48
50
|
};
|
|
49
51
|
const getSearch = () => {
|
|
50
52
|
try {
|
|
51
|
-
return
|
|
53
|
+
return new URL(getPageUrl()).search;
|
|
52
54
|
}
|
|
53
55
|
catch {
|
|
54
56
|
return '';
|
|
@@ -362,7 +364,7 @@ const getStandardPayload = (payload) => {
|
|
|
362
364
|
referrer: getReferrer(),
|
|
363
365
|
search: getSearch(),
|
|
364
366
|
locale: getLocale(),
|
|
365
|
-
sdkVersion: "0.
|
|
367
|
+
sdkVersion: "0.38.0" ,
|
|
366
368
|
...(payload || {}),
|
|
367
369
|
};
|
|
368
370
|
let storage = {};
|
|
@@ -838,7 +840,7 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
838
840
|
catch {
|
|
839
841
|
return;
|
|
840
842
|
}
|
|
841
|
-
const params = new URLSearchParams(
|
|
843
|
+
const params = new URLSearchParams(getSearch());
|
|
842
844
|
if (!params || !params.get(key)) {
|
|
843
845
|
return;
|
|
844
846
|
}
|
|
@@ -952,6 +954,17 @@ const handleManifest = (manifest, consent) => {
|
|
|
952
954
|
processStubs();
|
|
953
955
|
};
|
|
954
956
|
|
|
957
|
+
let initIsNewUser = undefined;
|
|
958
|
+
const handleIsNewUser = () => {
|
|
959
|
+
if (initIsNewUser !== undefined) {
|
|
960
|
+
return initIsNewUser;
|
|
961
|
+
}
|
|
962
|
+
return undefined;
|
|
963
|
+
};
|
|
964
|
+
const setIsNewUSer = (isNewUser) => {
|
|
965
|
+
initIsNewUser = isNewUser;
|
|
966
|
+
};
|
|
967
|
+
|
|
955
968
|
const handleInit = (preferences) => {
|
|
956
969
|
const success = setPreferences(preferences);
|
|
957
970
|
if (!success) {
|
|
@@ -982,7 +995,20 @@ const handleInit = (preferences) => {
|
|
|
982
995
|
if (result.consent && !consent) {
|
|
983
996
|
saveConsent(result.consent);
|
|
984
997
|
}
|
|
998
|
+
setIsNewUSer(result.isNewUser);
|
|
985
999
|
handleManifest(result.result, consent || result.consent);
|
|
1000
|
+
try {
|
|
1001
|
+
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
1002
|
+
detail: {
|
|
1003
|
+
userId: result.userId,
|
|
1004
|
+
isNewUser: result.isNewUser,
|
|
1005
|
+
consent: result.consent,
|
|
1006
|
+
},
|
|
1007
|
+
}));
|
|
1008
|
+
}
|
|
1009
|
+
catch {
|
|
1010
|
+
// do nothing
|
|
1011
|
+
}
|
|
986
1012
|
})
|
|
987
1013
|
.catch(error);
|
|
988
1014
|
};
|
|
@@ -1084,6 +1110,9 @@ const getUserId = () => {
|
|
|
1084
1110
|
const getConsent = (callback) => {
|
|
1085
1111
|
handleGetConsent(callback);
|
|
1086
1112
|
};
|
|
1113
|
+
const isNewUser = () => {
|
|
1114
|
+
return handleIsNewUser();
|
|
1115
|
+
};
|
|
1087
1116
|
|
|
1088
1117
|
exports.consent = consent;
|
|
1089
1118
|
exports.data = data;
|
|
@@ -1091,6 +1120,7 @@ exports.getConsent = getConsent;
|
|
|
1091
1120
|
exports.getData = getData;
|
|
1092
1121
|
exports.getUserId = getUserId;
|
|
1093
1122
|
exports.init = init;
|
|
1123
|
+
exports.isNewUser = isNewUser;
|
|
1094
1124
|
exports.keys = keys;
|
|
1095
1125
|
exports.tag = tag;
|
|
1096
1126
|
exports.user = user;
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ProvidersConfig } from '@blotoutio/cdn/types'
|
|
2
|
+
|
|
2
3
|
export {
|
|
3
4
|
InitParams,
|
|
4
5
|
TagParams,
|
|
@@ -67,6 +68,8 @@ export declare const keys: (callback: (keys: string[]) => void) => void
|
|
|
67
68
|
|
|
68
69
|
export declare const getUserId: () => string
|
|
69
70
|
|
|
71
|
+
export declare const isNewUser: () => boolean | undefined
|
|
72
|
+
|
|
70
73
|
export declare global {
|
|
71
74
|
interface Window {
|
|
72
75
|
edgetagData: Record<string, string>
|
package/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ var api = /*#__PURE__*/Object.freeze({
|
|
|
6
6
|
get getData () { return getData; },
|
|
7
7
|
get getUserId () { return getUserId; },
|
|
8
8
|
get init () { return init; },
|
|
9
|
+
get isNewUser () { return isNewUser; },
|
|
9
10
|
get keys () { return keys; },
|
|
10
11
|
get tag () { return tag; },
|
|
11
12
|
get user () { return user; }
|
|
@@ -24,7 +25,8 @@ const getReferrer = () => {
|
|
|
24
25
|
let referrer = '';
|
|
25
26
|
try {
|
|
26
27
|
const referrerUrl = new URL(document.referrer);
|
|
27
|
-
|
|
28
|
+
const pageUrl = new URL(getPageUrl());
|
|
29
|
+
if (referrerUrl.host !== pageUrl.host) {
|
|
28
30
|
referrer = referrerUrl.href;
|
|
29
31
|
}
|
|
30
32
|
return referrer;
|
|
@@ -46,7 +48,7 @@ const getPageUrl = () => {
|
|
|
46
48
|
};
|
|
47
49
|
const getSearch = () => {
|
|
48
50
|
try {
|
|
49
|
-
return
|
|
51
|
+
return new URL(getPageUrl()).search;
|
|
50
52
|
}
|
|
51
53
|
catch {
|
|
52
54
|
return '';
|
|
@@ -360,7 +362,7 @@ const getStandardPayload = (payload) => {
|
|
|
360
362
|
referrer: getReferrer(),
|
|
361
363
|
search: getSearch(),
|
|
362
364
|
locale: getLocale(),
|
|
363
|
-
sdkVersion: "0.
|
|
365
|
+
sdkVersion: "0.38.0" ,
|
|
364
366
|
...(payload || {}),
|
|
365
367
|
};
|
|
366
368
|
let storage = {};
|
|
@@ -836,7 +838,7 @@ const handleCaptureQuery = (provider, key, persistType, map) => {
|
|
|
836
838
|
catch {
|
|
837
839
|
return;
|
|
838
840
|
}
|
|
839
|
-
const params = new URLSearchParams(
|
|
841
|
+
const params = new URLSearchParams(getSearch());
|
|
840
842
|
if (!params || !params.get(key)) {
|
|
841
843
|
return;
|
|
842
844
|
}
|
|
@@ -950,6 +952,17 @@ const handleManifest = (manifest, consent) => {
|
|
|
950
952
|
processStubs();
|
|
951
953
|
};
|
|
952
954
|
|
|
955
|
+
let initIsNewUser = undefined;
|
|
956
|
+
const handleIsNewUser = () => {
|
|
957
|
+
if (initIsNewUser !== undefined) {
|
|
958
|
+
return initIsNewUser;
|
|
959
|
+
}
|
|
960
|
+
return undefined;
|
|
961
|
+
};
|
|
962
|
+
const setIsNewUSer = (isNewUser) => {
|
|
963
|
+
initIsNewUser = isNewUser;
|
|
964
|
+
};
|
|
965
|
+
|
|
953
966
|
const handleInit = (preferences) => {
|
|
954
967
|
const success = setPreferences(preferences);
|
|
955
968
|
if (!success) {
|
|
@@ -980,7 +993,20 @@ const handleInit = (preferences) => {
|
|
|
980
993
|
if (result.consent && !consent) {
|
|
981
994
|
saveConsent(result.consent);
|
|
982
995
|
}
|
|
996
|
+
setIsNewUSer(result.isNewUser);
|
|
983
997
|
handleManifest(result.result, consent || result.consent);
|
|
998
|
+
try {
|
|
999
|
+
window.dispatchEvent(new CustomEvent('edgetag-initialized', {
|
|
1000
|
+
detail: {
|
|
1001
|
+
userId: result.userId,
|
|
1002
|
+
isNewUser: result.isNewUser,
|
|
1003
|
+
consent: result.consent,
|
|
1004
|
+
},
|
|
1005
|
+
}));
|
|
1006
|
+
}
|
|
1007
|
+
catch {
|
|
1008
|
+
// do nothing
|
|
1009
|
+
}
|
|
984
1010
|
})
|
|
985
1011
|
.catch(error);
|
|
986
1012
|
};
|
|
@@ -1082,5 +1108,8 @@ const getUserId = () => {
|
|
|
1082
1108
|
const getConsent = (callback) => {
|
|
1083
1109
|
handleGetConsent(callback);
|
|
1084
1110
|
};
|
|
1111
|
+
const isNewUser = () => {
|
|
1112
|
+
return handleIsNewUser();
|
|
1113
|
+
};
|
|
1085
1114
|
|
|
1086
|
-
export { consent, data, getConsent, getData, getUserId, init, keys, tag, user };
|
|
1115
|
+
export { consent, data, getConsent, getData, getUserId, init, isNewUser, keys, tag, user };
|