@blotoutio/edgetag-sdk-js 0.45.4 → 0.46.1

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
@@ -10,10 +10,17 @@ var api = /*#__PURE__*/Object.freeze({
10
10
  get init () { return init; },
11
11
  get isNewUser () { return isNewUser; },
12
12
  get keys () { return keys; },
13
+ get setConfig () { return setConfig; },
13
14
  get tag () { return tag; },
14
15
  get user () { return user; }
15
16
  });
16
17
 
18
+ const _config = {};
19
+ const setConfig$1 = (config) => {
20
+ Object.assign(_config, config);
21
+ };
22
+ const getConfig = () => _config;
23
+
17
24
  const getUserAgent = () => {
18
25
  try {
19
26
  const nav = navigator;
@@ -39,10 +46,12 @@ const getReferrer = () => {
39
46
  };
40
47
  const getPageUrl = () => {
41
48
  try {
49
+ // we need to leave this one in for existing Custom pixel customers
42
50
  if (window.edgetagData && window.edgetagData['pageUrl']) {
43
51
  return window.edgetagData['pageUrl'];
44
52
  }
45
- return window.location.href;
53
+ const { pageUrl } = getConfig();
54
+ return pageUrl || window.location.href;
46
55
  }
47
56
  catch {
48
57
  return '';
@@ -364,7 +373,7 @@ const getStandardPayload = (payload) => {
364
373
  referrer: getReferrer(),
365
374
  search: getSearch(),
366
375
  locale: getLocale(),
367
- sdkVersion: "0.45.4" ,
376
+ sdkVersion: "0.46.1" ,
368
377
  ...(payload || {}),
369
378
  };
370
379
  let storage = {};
@@ -857,16 +866,17 @@ const saveDataToEdge = (key, value, provider) => {
857
866
  if (!value) {
858
867
  return;
859
868
  }
869
+ let updatedValue = value;
860
870
  if (typeof value !== 'string') {
861
871
  try {
862
- value = JSON.stringify(value);
872
+ updatedValue = JSON.stringify(value);
863
873
  }
864
874
  catch {
865
875
  log('Error stringify value.');
866
876
  return;
867
877
  }
868
878
  }
869
- handleData({ [`${provider}::${key}`]: value });
879
+ handleData({ [`${provider}::${key}`]: updatedValue });
870
880
  };
871
881
  const handleCaptureQuery = (provider, key, persistType, map) => {
872
882
  try {
@@ -1126,6 +1136,10 @@ const handleGetConsent = (callback) => {
1126
1136
  });
1127
1137
  };
1128
1138
 
1139
+ const handleConfig = (config) => {
1140
+ setConfig$1(config);
1141
+ };
1142
+
1129
1143
  const init = (preferences) => {
1130
1144
  handleInit(preferences);
1131
1145
  };
@@ -1156,6 +1170,9 @@ const getConsent = (callback) => {
1156
1170
  const isNewUser = () => {
1157
1171
  return handleIsNewUser();
1158
1172
  };
1173
+ const setConfig = (config) => {
1174
+ return handleConfig(config);
1175
+ };
1159
1176
 
1160
1177
  exports.consent = consent;
1161
1178
  exports.data = data;
@@ -1165,5 +1182,6 @@ exports.getUserId = getUserId;
1165
1182
  exports.init = init;
1166
1183
  exports.isNewUser = isNewUser;
1167
1184
  exports.keys = keys;
1185
+ exports.setConfig = setConfig;
1168
1186
  exports.tag = tag;
1169
1187
  exports.user = user;
package/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export {
10
10
  Data,
11
11
  EventOptions,
12
12
  PersistType,
13
+ ConfigOptions,
14
+ ConsentOptions,
13
15
  } from '@blotoutio/shared/utility-sdk'
14
16
 
15
17
  export type UserKey =
@@ -44,7 +46,7 @@ export declare const tag: (
44
46
  options?: EventOptions
45
47
  ) => void
46
48
 
47
- export declare const consent: (consent: Data) => void
49
+ export declare const consent: (consent: Data, options: ConsentOptions) => void
48
50
 
49
51
  export declare const user: (
50
52
  key: UserKey,
@@ -70,6 +72,8 @@ export declare const getUserId: () => string
70
72
 
71
73
  export declare const isNewUser: () => boolean | undefined
72
74
 
75
+ export declare const setConfig: (config: ConfigOptions) => void
76
+
73
77
  export declare global {
74
78
  interface Window {
75
79
  edgetagData: Record<string, string>
package/index.mjs CHANGED
@@ -8,10 +8,17 @@ var api = /*#__PURE__*/Object.freeze({
8
8
  get init () { return init; },
9
9
  get isNewUser () { return isNewUser; },
10
10
  get keys () { return keys; },
11
+ get setConfig () { return setConfig; },
11
12
  get tag () { return tag; },
12
13
  get user () { return user; }
13
14
  });
14
15
 
16
+ const _config = {};
17
+ const setConfig$1 = (config) => {
18
+ Object.assign(_config, config);
19
+ };
20
+ const getConfig = () => _config;
21
+
15
22
  const getUserAgent = () => {
16
23
  try {
17
24
  const nav = navigator;
@@ -37,10 +44,12 @@ const getReferrer = () => {
37
44
  };
38
45
  const getPageUrl = () => {
39
46
  try {
47
+ // we need to leave this one in for existing Custom pixel customers
40
48
  if (window.edgetagData && window.edgetagData['pageUrl']) {
41
49
  return window.edgetagData['pageUrl'];
42
50
  }
43
- return window.location.href;
51
+ const { pageUrl } = getConfig();
52
+ return pageUrl || window.location.href;
44
53
  }
45
54
  catch {
46
55
  return '';
@@ -362,7 +371,7 @@ const getStandardPayload = (payload) => {
362
371
  referrer: getReferrer(),
363
372
  search: getSearch(),
364
373
  locale: getLocale(),
365
- sdkVersion: "0.45.4" ,
374
+ sdkVersion: "0.46.1" ,
366
375
  ...(payload || {}),
367
376
  };
368
377
  let storage = {};
@@ -855,16 +864,17 @@ const saveDataToEdge = (key, value, provider) => {
855
864
  if (!value) {
856
865
  return;
857
866
  }
867
+ let updatedValue = value;
858
868
  if (typeof value !== 'string') {
859
869
  try {
860
- value = JSON.stringify(value);
870
+ updatedValue = JSON.stringify(value);
861
871
  }
862
872
  catch {
863
873
  log('Error stringify value.');
864
874
  return;
865
875
  }
866
876
  }
867
- handleData({ [`${provider}::${key}`]: value });
877
+ handleData({ [`${provider}::${key}`]: updatedValue });
868
878
  };
869
879
  const handleCaptureQuery = (provider, key, persistType, map) => {
870
880
  try {
@@ -1124,6 +1134,10 @@ const handleGetConsent = (callback) => {
1124
1134
  });
1125
1135
  };
1126
1136
 
1137
+ const handleConfig = (config) => {
1138
+ setConfig$1(config);
1139
+ };
1140
+
1127
1141
  const init = (preferences) => {
1128
1142
  handleInit(preferences);
1129
1143
  };
@@ -1154,5 +1168,8 @@ const getConsent = (callback) => {
1154
1168
  const isNewUser = () => {
1155
1169
  return handleIsNewUser();
1156
1170
  };
1171
+ const setConfig = (config) => {
1172
+ return handleConfig(config);
1173
+ };
1157
1174
 
1158
- export { consent, data, getConsent, getData, getUserId, init, isNewUser, keys, tag, user };
1175
+ export { consent, data, getConsent, getData, getUserId, init, isNewUser, keys, setConfig, tag, user };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.45.4",
3
+ "version": "0.46.1",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",