@blotoutio/edgetag-sdk-js 0.37.0 → 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 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; }
@@ -363,7 +364,7 @@ const getStandardPayload = (payload) => {
363
364
  referrer: getReferrer(),
364
365
  search: getSearch(),
365
366
  locale: getLocale(),
366
- sdkVersion: "0.37.0" ,
367
+ sdkVersion: "0.38.0" ,
367
368
  ...(payload || {}),
368
369
  };
369
370
  let storage = {};
@@ -953,6 +954,17 @@ const handleManifest = (manifest, consent) => {
953
954
  processStubs();
954
955
  };
955
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
+
956
968
  const handleInit = (preferences) => {
957
969
  const success = setPreferences(preferences);
958
970
  if (!success) {
@@ -983,7 +995,20 @@ const handleInit = (preferences) => {
983
995
  if (result.consent && !consent) {
984
996
  saveConsent(result.consent);
985
997
  }
998
+ setIsNewUSer(result.isNewUser);
986
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
+ }
987
1012
  })
988
1013
  .catch(error);
989
1014
  };
@@ -1085,6 +1110,9 @@ const getUserId = () => {
1085
1110
  const getConsent = (callback) => {
1086
1111
  handleGetConsent(callback);
1087
1112
  };
1113
+ const isNewUser = () => {
1114
+ return handleIsNewUser();
1115
+ };
1088
1116
 
1089
1117
  exports.consent = consent;
1090
1118
  exports.data = data;
@@ -1092,6 +1120,7 @@ exports.getConsent = getConsent;
1092
1120
  exports.getData = getData;
1093
1121
  exports.getUserId = getUserId;
1094
1122
  exports.init = init;
1123
+ exports.isNewUser = isNewUser;
1095
1124
  exports.keys = keys;
1096
1125
  exports.tag = tag;
1097
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; }
@@ -361,7 +362,7 @@ const getStandardPayload = (payload) => {
361
362
  referrer: getReferrer(),
362
363
  search: getSearch(),
363
364
  locale: getLocale(),
364
- sdkVersion: "0.37.0" ,
365
+ sdkVersion: "0.38.0" ,
365
366
  ...(payload || {}),
366
367
  };
367
368
  let storage = {};
@@ -951,6 +952,17 @@ const handleManifest = (manifest, consent) => {
951
952
  processStubs();
952
953
  };
953
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
+
954
966
  const handleInit = (preferences) => {
955
967
  const success = setPreferences(preferences);
956
968
  if (!success) {
@@ -981,7 +993,20 @@ const handleInit = (preferences) => {
981
993
  if (result.consent && !consent) {
982
994
  saveConsent(result.consent);
983
995
  }
996
+ setIsNewUSer(result.isNewUser);
984
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
+ }
985
1010
  })
986
1011
  .catch(error);
987
1012
  };
@@ -1083,5 +1108,8 @@ const getUserId = () => {
1083
1108
  const getConsent = (callback) => {
1084
1109
  handleGetConsent(callback);
1085
1110
  };
1111
+ const isNewUser = () => {
1112
+ return handleIsNewUser();
1113
+ };
1086
1114
 
1087
- export { consent, data, getConsent, getData, getUserId, init, keys, tag, user };
1115
+ export { consent, data, getConsent, getData, getUserId, init, isNewUser, keys, tag, user };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",