@blotoutio/edgetag-sdk-js 0.34.0 → 0.35.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.
Files changed (3) hide show
  1. package/index.cjs.js +29 -6
  2. package/index.mjs +29 -7
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -4,6 +4,7 @@ var api = /*#__PURE__*/Object.freeze({
4
4
  __proto__: null,
5
5
  get consent () { return consent; },
6
6
  get data () { return data; },
7
+ get getConsent () { return getConsent; },
7
8
  get getData () { return getData; },
8
9
  get getUserId () { return getUserId; },
9
10
  get init () { return init; },
@@ -334,7 +335,7 @@ const getStandardPayload = (payload) => {
334
335
  referrer: getReferrer(),
335
336
  search: getSearch(),
336
337
  locale: getLocale(),
337
- sdkVersion: "0.34.0" ,
338
+ sdkVersion: "0.35.0" ,
338
339
  ...(payload || {}),
339
340
  };
340
341
  let storage = {};
@@ -438,7 +439,7 @@ const handleConsent = (consent, options) => {
438
439
  const setConsent = (newConsent) => {
439
440
  memoryConsent = newConsent;
440
441
  };
441
- const getConsent = () => {
442
+ const getConsent$1 = () => {
442
443
  const storageConsent = getDataPerKey('local', tagStorage, consentKey);
443
444
  if (storageConsent) {
444
445
  return storageConsent;
@@ -614,7 +615,7 @@ const handleTag = (eventName, data = {}, providers, options) => {
614
615
  const configuredTags = getConfiguredTags();
615
616
  const userId = handleGetUserId();
616
617
  const providerData = {};
617
- const consent = getConsent();
618
+ const consent = getConsent$1();
618
619
  for (const pkg of Object.values(providerPackages)) {
619
620
  if (!pkg || !pkg.name || !pkg.tag) {
620
621
  continue;
@@ -681,7 +682,7 @@ const handleData = (data, providers, options) => {
681
682
  const providerPackages = getProvidersPackage();
682
683
  const configuredTags = getConfiguredTags();
683
684
  const userId = handleGetUserId();
684
- const consent = getConsent();
685
+ const consent = getConsent$1();
685
686
  for (const pkg of Object.values(providerPackages)) {
686
687
  if (!pkg || !pkg.user || !pkg.name) {
687
688
  continue;
@@ -880,7 +881,7 @@ const handleInit = (preferences) => {
880
881
  if (result.userId) {
881
882
  setUserId(result.userId);
882
883
  }
883
- const consent = getConsent();
884
+ const consent = getConsent$1();
884
885
  if (result.consent && !consent) {
885
886
  saveConsent(result.consent);
886
887
  }
@@ -899,7 +900,7 @@ const handleUser = (key, value, providers, options) => {
899
900
  });
900
901
  const providerPackages = getProvidersPackage();
901
902
  const configuredTags = getConfiguredTags();
902
- const consent = getConsent();
903
+ const consent = getConsent$1();
903
904
  const userId = handleGetUserId();
904
905
  for (const pkg of Object.values(providerPackages)) {
905
906
  if (!pkg || !pkg.name || !pkg.user) {
@@ -941,6 +942,24 @@ const handleKeys = (callback) => {
941
942
  .catch(error);
942
943
  };
943
944
 
945
+ const handleGetConsent = (callback) => {
946
+ getRequest(getConsentURL())
947
+ .then((result) => {
948
+ // this will try to return the consent data stored in Edge
949
+ return result === null || result === void 0 ? void 0 : result.result;
950
+ })
951
+ .catch(() => undefined)
952
+ .then((result) => {
953
+ const consent = result !== null && result !== void 0 ? result : getConsent$1(); // this is a default value i.e. value from local storage and memory incase Edge doesn't have consent
954
+ if (consent) {
955
+ callback(consent);
956
+ }
957
+ else {
958
+ callback(null, new Error('Consent not found for Current User!'));
959
+ }
960
+ });
961
+ };
962
+
944
963
  const init = (preferences) => {
945
964
  handleInit(preferences);
946
965
  };
@@ -965,9 +984,13 @@ const keys = (callback) => {
965
984
  const getUserId = () => {
966
985
  return handleGetUserId();
967
986
  };
987
+ const getConsent = (callback) => {
988
+ handleGetConsent(callback);
989
+ };
968
990
 
969
991
  exports.consent = consent;
970
992
  exports.data = data;
993
+ exports.getConsent = getConsent;
971
994
  exports.getData = getData;
972
995
  exports.getUserId = getUserId;
973
996
  exports.init = init;
package/index.mjs CHANGED
@@ -2,6 +2,7 @@ var api = /*#__PURE__*/Object.freeze({
2
2
  __proto__: null,
3
3
  get consent () { return consent; },
4
4
  get data () { return data; },
5
+ get getConsent () { return getConsent; },
5
6
  get getData () { return getData; },
6
7
  get getUserId () { return getUserId; },
7
8
  get init () { return init; },
@@ -332,7 +333,7 @@ const getStandardPayload = (payload) => {
332
333
  referrer: getReferrer(),
333
334
  search: getSearch(),
334
335
  locale: getLocale(),
335
- sdkVersion: "0.34.0" ,
336
+ sdkVersion: "0.35.0" ,
336
337
  ...(payload || {}),
337
338
  };
338
339
  let storage = {};
@@ -436,7 +437,7 @@ const handleConsent = (consent, options) => {
436
437
  const setConsent = (newConsent) => {
437
438
  memoryConsent = newConsent;
438
439
  };
439
- const getConsent = () => {
440
+ const getConsent$1 = () => {
440
441
  const storageConsent = getDataPerKey('local', tagStorage, consentKey);
441
442
  if (storageConsent) {
442
443
  return storageConsent;
@@ -612,7 +613,7 @@ const handleTag = (eventName, data = {}, providers, options) => {
612
613
  const configuredTags = getConfiguredTags();
613
614
  const userId = handleGetUserId();
614
615
  const providerData = {};
615
- const consent = getConsent();
616
+ const consent = getConsent$1();
616
617
  for (const pkg of Object.values(providerPackages)) {
617
618
  if (!pkg || !pkg.name || !pkg.tag) {
618
619
  continue;
@@ -679,7 +680,7 @@ const handleData = (data, providers, options) => {
679
680
  const providerPackages = getProvidersPackage();
680
681
  const configuredTags = getConfiguredTags();
681
682
  const userId = handleGetUserId();
682
- const consent = getConsent();
683
+ const consent = getConsent$1();
683
684
  for (const pkg of Object.values(providerPackages)) {
684
685
  if (!pkg || !pkg.user || !pkg.name) {
685
686
  continue;
@@ -878,7 +879,7 @@ const handleInit = (preferences) => {
878
879
  if (result.userId) {
879
880
  setUserId(result.userId);
880
881
  }
881
- const consent = getConsent();
882
+ const consent = getConsent$1();
882
883
  if (result.consent && !consent) {
883
884
  saveConsent(result.consent);
884
885
  }
@@ -897,7 +898,7 @@ const handleUser = (key, value, providers, options) => {
897
898
  });
898
899
  const providerPackages = getProvidersPackage();
899
900
  const configuredTags = getConfiguredTags();
900
- const consent = getConsent();
901
+ const consent = getConsent$1();
901
902
  const userId = handleGetUserId();
902
903
  for (const pkg of Object.values(providerPackages)) {
903
904
  if (!pkg || !pkg.name || !pkg.user) {
@@ -939,6 +940,24 @@ const handleKeys = (callback) => {
939
940
  .catch(error);
940
941
  };
941
942
 
943
+ const handleGetConsent = (callback) => {
944
+ getRequest(getConsentURL())
945
+ .then((result) => {
946
+ // this will try to return the consent data stored in Edge
947
+ return result === null || result === void 0 ? void 0 : result.result;
948
+ })
949
+ .catch(() => undefined)
950
+ .then((result) => {
951
+ const consent = result !== null && result !== void 0 ? result : getConsent$1(); // this is a default value i.e. value from local storage and memory incase Edge doesn't have consent
952
+ if (consent) {
953
+ callback(consent);
954
+ }
955
+ else {
956
+ callback(null, new Error('Consent not found for Current User!'));
957
+ }
958
+ });
959
+ };
960
+
942
961
  const init = (preferences) => {
943
962
  handleInit(preferences);
944
963
  };
@@ -963,5 +982,8 @@ const keys = (callback) => {
963
982
  const getUserId = () => {
964
983
  return handleGetUserId();
965
984
  };
985
+ const getConsent = (callback) => {
986
+ handleGetConsent(callback);
987
+ };
966
988
 
967
- export { consent, data, getData, getUserId, init, keys, tag, user };
989
+ export { consent, data, getConsent, getData, getUserId, init, keys, tag, user };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",