@jitsu/js 1.10.2 → 1.10.3

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.
@@ -651,7 +651,7 @@ const defaultConfig = {
651
651
  dontSend: false,
652
652
  disableUserIds: false,
653
653
  ipPolicy: "keep",
654
- consentCategories: undefined,
654
+ consentCategories: {},
655
655
  },
656
656
  };
657
657
  // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
@@ -660,11 +660,14 @@ const mergeConfig = (current, newConfig) => {
660
660
  const value = newConfig[key];
661
661
  if (key === "privacy") {
662
662
  if (typeof value === "object") {
663
- current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
663
+ current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
664
664
  }
665
- else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
666
- // explicitly set to undefined - reset to default
667
- current.privacy = Object.assign({}, defaultConfig.privacy);
665
+ else if (typeof value === "undefined") {
666
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
667
+ // explicitly set to undefined - reset to default
668
+ // or was not set at all - set to default
669
+ current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
670
+ }
668
671
  }
669
672
  }
670
673
  else if (typeof value === "undefined") {
@@ -1015,7 +1018,7 @@ function urlPath(url) {
1015
1018
  return "/" + pathMatch;
1016
1019
  }
1017
1020
  function adjustPayload(payload, config, storage, s2s) {
1018
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1021
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1019
1022
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1020
1023
  const url = runtime.pageUrl();
1021
1024
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1035,17 +1038,17 @@ function adjustPayload(payload, config, storage, s2s) {
1035
1038
  version: jitsuVersion,
1036
1039
  env: isInBrowser() ? "browser" : "node",
1037
1040
  },
1038
- consent: ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories)
1041
+ consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1039
1042
  ? {
1040
1043
  categoryPreferences: config.privacy.consentCategories,
1041
1044
  }
1042
1045
  : undefined,
1043
- userAgent: (_e = runtime.userAgent) === null || _e === void 0 ? void 0 : _e.call(runtime),
1044
- locale: (_f = runtime.language) === null || _f === void 0 ? void 0 : _f.call(runtime),
1045
- screen: (_g = runtime.screen) === null || _g === void 0 ? void 0 : _g.call(runtime),
1046
- ip: (_h = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _h === void 0 ? void 0 : _h.call(runtime),
1046
+ userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1047
+ locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1048
+ screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1049
+ ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1047
1050
  traits: payload.type != "identify" && payload.type != "group"
1048
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_j = payload === null || payload === void 0 ? void 0 : payload.options) === null || _j === void 0 ? void 0 : _j.traits) || {})) : undefined,
1051
+ ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1049
1052
  page: {
1050
1053
  path: properties.path || (parsedUrl && parsedUrl.pathname),
1051
1054
  referrer: referrer,
@@ -1056,13 +1059,13 @@ function adjustPayload(payload, config, storage, s2s) {
1056
1059
  url: properties.url || url,
1057
1060
  encoding: properties.encoding || runtime.documentEncoding(),
1058
1061
  },
1059
- clientIds: !((_k = config.privacy) === null || _k === void 0 ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1062
+ clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1060
1063
  campaign: parseUtms(query),
1061
1064
  };
1062
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_l = payload === null || payload === void 0 ? void 0 : payload.options) === null || _l === void 0 ? void 0 : _l.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1065
+ const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1063
1066
  delete withContext.meta;
1064
1067
  delete withContext.options;
1065
- if ((_p = config.privacy) === null || _p === void 0 ? void 0 : _p.disableUserIds) {
1068
+ if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1066
1069
  delete withContext.userId;
1067
1070
  delete withContext.anonymousId;
1068
1071
  delete withContext.context.traits;
@@ -1494,6 +1497,9 @@ const emptyAnalytics = {
1494
1497
  group: () => Promise.resolve({}),
1495
1498
  reset: () => Promise.resolve({}),
1496
1499
  configure: () => { },
1500
+ getConfiguration() {
1501
+ return {};
1502
+ },
1497
1503
  };
1498
1504
  function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1499
1505
  var _a, _b, _c;
@@ -1646,6 +1652,9 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1646
1652
  //However, since returned values are used for debugging purposes only, it's ok
1647
1653
  return results[0];
1648
1654
  });
1655
+ },
1656
+ getConfiguration() {
1657
+ return opts;
1649
1658
  } });
1650
1659
  if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
1651
1660
  storage.reset();
@@ -649,7 +649,7 @@ const defaultConfig = {
649
649
  dontSend: false,
650
650
  disableUserIds: false,
651
651
  ipPolicy: "keep",
652
- consentCategories: undefined,
652
+ consentCategories: {},
653
653
  },
654
654
  };
655
655
  // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
@@ -658,11 +658,14 @@ const mergeConfig = (current, newConfig) => {
658
658
  const value = newConfig[key];
659
659
  if (key === "privacy") {
660
660
  if (typeof value === "object") {
661
- current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
661
+ current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
662
662
  }
663
- else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
664
- // explicitly set to undefined - reset to default
665
- current.privacy = Object.assign({}, defaultConfig.privacy);
663
+ else if (typeof value === "undefined") {
664
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
665
+ // explicitly set to undefined - reset to default
666
+ // or was not set at all - set to default
667
+ current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
668
+ }
666
669
  }
667
670
  }
668
671
  else if (typeof value === "undefined") {
@@ -1013,7 +1016,7 @@ function urlPath(url) {
1013
1016
  return "/" + pathMatch;
1014
1017
  }
1015
1018
  function adjustPayload(payload, config, storage, s2s) {
1016
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1019
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1017
1020
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1018
1021
  const url = runtime.pageUrl();
1019
1022
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1033,17 +1036,17 @@ function adjustPayload(payload, config, storage, s2s) {
1033
1036
  version: jitsuVersion,
1034
1037
  env: isInBrowser() ? "browser" : "node",
1035
1038
  },
1036
- consent: ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories)
1039
+ consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1037
1040
  ? {
1038
1041
  categoryPreferences: config.privacy.consentCategories,
1039
1042
  }
1040
1043
  : undefined,
1041
- userAgent: (_e = runtime.userAgent) === null || _e === void 0 ? void 0 : _e.call(runtime),
1042
- locale: (_f = runtime.language) === null || _f === void 0 ? void 0 : _f.call(runtime),
1043
- screen: (_g = runtime.screen) === null || _g === void 0 ? void 0 : _g.call(runtime),
1044
- ip: (_h = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _h === void 0 ? void 0 : _h.call(runtime),
1044
+ userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1045
+ locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1046
+ screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1047
+ ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1045
1048
  traits: payload.type != "identify" && payload.type != "group"
1046
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_j = payload === null || payload === void 0 ? void 0 : payload.options) === null || _j === void 0 ? void 0 : _j.traits) || {})) : undefined,
1049
+ ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1047
1050
  page: {
1048
1051
  path: properties.path || (parsedUrl && parsedUrl.pathname),
1049
1052
  referrer: referrer,
@@ -1054,13 +1057,13 @@ function adjustPayload(payload, config, storage, s2s) {
1054
1057
  url: properties.url || url,
1055
1058
  encoding: properties.encoding || runtime.documentEncoding(),
1056
1059
  },
1057
- clientIds: !((_k = config.privacy) === null || _k === void 0 ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1060
+ clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1058
1061
  campaign: parseUtms(query),
1059
1062
  };
1060
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_l = payload === null || payload === void 0 ? void 0 : payload.options) === null || _l === void 0 ? void 0 : _l.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1063
+ const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1061
1064
  delete withContext.meta;
1062
1065
  delete withContext.options;
1063
- if ((_p = config.privacy) === null || _p === void 0 ? void 0 : _p.disableUserIds) {
1066
+ if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1064
1067
  delete withContext.userId;
1065
1068
  delete withContext.anonymousId;
1066
1069
  delete withContext.context.traits;
@@ -1492,6 +1495,9 @@ const emptyAnalytics = {
1492
1495
  group: () => Promise.resolve({}),
1493
1496
  reset: () => Promise.resolve({}),
1494
1497
  configure: () => { },
1498
+ getConfiguration() {
1499
+ return {};
1500
+ },
1495
1501
  };
1496
1502
  function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1497
1503
  var _a, _b, _c;
@@ -1644,6 +1650,9 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1644
1650
  //However, since returned values are used for debugging purposes only, it's ok
1645
1651
  return results[0];
1646
1652
  });
1653
+ },
1654
+ getConfiguration() {
1655
+ return opts;
1647
1656
  } });
1648
1657
  if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
1649
1658
  storage.reset();
package/dist/jitsu.cjs.js CHANGED
@@ -1073,7 +1073,7 @@ const defaultConfig = {
1073
1073
  dontSend: false,
1074
1074
  disableUserIds: false,
1075
1075
  ipPolicy: "keep",
1076
- consentCategories: undefined,
1076
+ consentCategories: {},
1077
1077
  },
1078
1078
  };
1079
1079
  // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
@@ -1082,11 +1082,14 @@ const mergeConfig = (current, newConfig) => {
1082
1082
  const value = newConfig[key];
1083
1083
  if (key === "privacy") {
1084
1084
  if (typeof value === "object") {
1085
- current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
1085
+ current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
1086
1086
  }
1087
- else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
1088
- // explicitly set to undefined - reset to default
1089
- current.privacy = Object.assign({}, defaultConfig.privacy);
1087
+ else if (typeof value === "undefined") {
1088
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
1089
+ // explicitly set to undefined - reset to default
1090
+ // or was not set at all - set to default
1091
+ current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
1092
+ }
1090
1093
  }
1091
1094
  }
1092
1095
  else if (typeof value === "undefined") {
@@ -1437,7 +1440,7 @@ function urlPath(url) {
1437
1440
  return "/" + pathMatch;
1438
1441
  }
1439
1442
  function adjustPayload(payload, config, storage, s2s) {
1440
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1443
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1441
1444
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1442
1445
  const url = runtime.pageUrl();
1443
1446
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1457,17 +1460,17 @@ function adjustPayload(payload, config, storage, s2s) {
1457
1460
  version: jitsuVersion,
1458
1461
  env: isInBrowser() ? "browser" : "node",
1459
1462
  },
1460
- consent: ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories)
1463
+ consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1461
1464
  ? {
1462
1465
  categoryPreferences: config.privacy.consentCategories,
1463
1466
  }
1464
1467
  : undefined,
1465
- userAgent: (_e = runtime.userAgent) === null || _e === void 0 ? void 0 : _e.call(runtime),
1466
- locale: (_f = runtime.language) === null || _f === void 0 ? void 0 : _f.call(runtime),
1467
- screen: (_g = runtime.screen) === null || _g === void 0 ? void 0 : _g.call(runtime),
1468
- ip: (_h = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _h === void 0 ? void 0 : _h.call(runtime),
1468
+ userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1469
+ locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1470
+ screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1471
+ ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1469
1472
  traits: payload.type != "identify" && payload.type != "group"
1470
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_j = payload === null || payload === void 0 ? void 0 : payload.options) === null || _j === void 0 ? void 0 : _j.traits) || {})) : undefined,
1473
+ ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1471
1474
  page: {
1472
1475
  path: properties.path || (parsedUrl && parsedUrl.pathname),
1473
1476
  referrer: referrer,
@@ -1478,13 +1481,13 @@ function adjustPayload(payload, config, storage, s2s) {
1478
1481
  url: properties.url || url,
1479
1482
  encoding: properties.encoding || runtime.documentEncoding(),
1480
1483
  },
1481
- clientIds: !((_k = config.privacy) === null || _k === void 0 ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1484
+ clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1482
1485
  campaign: parseUtms(query),
1483
1486
  };
1484
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_l = payload === null || payload === void 0 ? void 0 : payload.options) === null || _l === void 0 ? void 0 : _l.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1487
+ const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1485
1488
  delete withContext.meta;
1486
1489
  delete withContext.options;
1487
- if ((_p = config.privacy) === null || _p === void 0 ? void 0 : _p.disableUserIds) {
1490
+ if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1488
1491
  delete withContext.userId;
1489
1492
  delete withContext.anonymousId;
1490
1493
  delete withContext.context.traits;
@@ -1916,6 +1919,9 @@ const emptyAnalytics = {
1916
1919
  group: () => Promise.resolve({}),
1917
1920
  reset: () => Promise.resolve({}),
1918
1921
  configure: () => { },
1922
+ getConfiguration() {
1923
+ return {};
1924
+ },
1919
1925
  };
1920
1926
  function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1921
1927
  var _a, _b, _c;
@@ -2068,6 +2074,9 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
2068
2074
  //However, since returned values are used for debugging purposes only, it's ok
2069
2075
  return results[0];
2070
2076
  });
2077
+ },
2078
+ getConfiguration() {
2079
+ return opts;
2071
2080
  } });
2072
2081
  if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
2073
2082
  storage.reset();
package/dist/jitsu.es.js CHANGED
@@ -1071,7 +1071,7 @@ const defaultConfig = {
1071
1071
  dontSend: false,
1072
1072
  disableUserIds: false,
1073
1073
  ipPolicy: "keep",
1074
- consentCategories: undefined,
1074
+ consentCategories: {},
1075
1075
  },
1076
1076
  };
1077
1077
  // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
@@ -1080,11 +1080,14 @@ const mergeConfig = (current, newConfig) => {
1080
1080
  const value = newConfig[key];
1081
1081
  if (key === "privacy") {
1082
1082
  if (typeof value === "object") {
1083
- current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
1083
+ current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
1084
1084
  }
1085
- else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
1086
- // explicitly set to undefined - reset to default
1087
- current.privacy = Object.assign({}, defaultConfig.privacy);
1085
+ else if (typeof value === "undefined") {
1086
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
1087
+ // explicitly set to undefined - reset to default
1088
+ // or was not set at all - set to default
1089
+ current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
1090
+ }
1088
1091
  }
1089
1092
  }
1090
1093
  else if (typeof value === "undefined") {
@@ -1435,7 +1438,7 @@ function urlPath(url) {
1435
1438
  return "/" + pathMatch;
1436
1439
  }
1437
1440
  function adjustPayload(payload, config, storage, s2s) {
1438
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1441
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1439
1442
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1440
1443
  const url = runtime.pageUrl();
1441
1444
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1455,17 +1458,17 @@ function adjustPayload(payload, config, storage, s2s) {
1455
1458
  version: jitsuVersion,
1456
1459
  env: isInBrowser() ? "browser" : "node",
1457
1460
  },
1458
- consent: ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories)
1461
+ consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1459
1462
  ? {
1460
1463
  categoryPreferences: config.privacy.consentCategories,
1461
1464
  }
1462
1465
  : undefined,
1463
- userAgent: (_e = runtime.userAgent) === null || _e === void 0 ? void 0 : _e.call(runtime),
1464
- locale: (_f = runtime.language) === null || _f === void 0 ? void 0 : _f.call(runtime),
1465
- screen: (_g = runtime.screen) === null || _g === void 0 ? void 0 : _g.call(runtime),
1466
- ip: (_h = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _h === void 0 ? void 0 : _h.call(runtime),
1466
+ userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1467
+ locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1468
+ screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1469
+ ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1467
1470
  traits: payload.type != "identify" && payload.type != "group"
1468
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_j = payload === null || payload === void 0 ? void 0 : payload.options) === null || _j === void 0 ? void 0 : _j.traits) || {})) : undefined,
1471
+ ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1469
1472
  page: {
1470
1473
  path: properties.path || (parsedUrl && parsedUrl.pathname),
1471
1474
  referrer: referrer,
@@ -1476,13 +1479,13 @@ function adjustPayload(payload, config, storage, s2s) {
1476
1479
  url: properties.url || url,
1477
1480
  encoding: properties.encoding || runtime.documentEncoding(),
1478
1481
  },
1479
- clientIds: !((_k = config.privacy) === null || _k === void 0 ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1482
+ clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1480
1483
  campaign: parseUtms(query),
1481
1484
  };
1482
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_l = payload === null || payload === void 0 ? void 0 : payload.options) === null || _l === void 0 ? void 0 : _l.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1485
+ const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1483
1486
  delete withContext.meta;
1484
1487
  delete withContext.options;
1485
- if ((_p = config.privacy) === null || _p === void 0 ? void 0 : _p.disableUserIds) {
1488
+ if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1486
1489
  delete withContext.userId;
1487
1490
  delete withContext.anonymousId;
1488
1491
  delete withContext.context.traits;
@@ -1914,6 +1917,9 @@ const emptyAnalytics = {
1914
1917
  group: () => Promise.resolve({}),
1915
1918
  reset: () => Promise.resolve({}),
1916
1919
  configure: () => { },
1920
+ getConfiguration() {
1921
+ return {};
1922
+ },
1917
1923
  };
1918
1924
  function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1919
1925
  var _a, _b, _c;
@@ -2066,6 +2072,9 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
2066
2072
  //However, since returned values are used for debugging purposes only, it's ok
2067
2073
  return results[0];
2068
2074
  });
2075
+ },
2076
+ getConfiguration() {
2077
+ return opts;
2069
2078
  } });
2070
2079
  if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
2071
2080
  storage.reset();
package/dist/web/p.js.txt CHANGED
@@ -1074,7 +1074,7 @@
1074
1074
  dontSend: false,
1075
1075
  disableUserIds: false,
1076
1076
  ipPolicy: "keep",
1077
- consentCategories: undefined,
1077
+ consentCategories: {},
1078
1078
  },
1079
1079
  };
1080
1080
  // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
@@ -1083,11 +1083,14 @@
1083
1083
  const value = newConfig[key];
1084
1084
  if (key === "privacy") {
1085
1085
  if (typeof value === "object") {
1086
- current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
1086
+ current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
1087
1087
  }
1088
- else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
1089
- // explicitly set to undefined - reset to default
1090
- current.privacy = Object.assign({}, defaultConfig.privacy);
1088
+ else if (typeof value === "undefined") {
1089
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
1090
+ // explicitly set to undefined - reset to default
1091
+ // or was not set at all - set to default
1092
+ current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
1093
+ }
1091
1094
  }
1092
1095
  }
1093
1096
  else if (typeof value === "undefined") {
@@ -1438,7 +1441,7 @@
1438
1441
  return "/" + pathMatch;
1439
1442
  }
1440
1443
  function adjustPayload(payload, config, storage, s2s) {
1441
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1444
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1442
1445
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1443
1446
  const url = runtime.pageUrl();
1444
1447
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1458,17 +1461,17 @@
1458
1461
  version: jitsuVersion,
1459
1462
  env: isInBrowser() ? "browser" : "node",
1460
1463
  },
1461
- consent: ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories)
1464
+ consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1462
1465
  ? {
1463
1466
  categoryPreferences: config.privacy.consentCategories,
1464
1467
  }
1465
1468
  : undefined,
1466
- userAgent: (_e = runtime.userAgent) === null || _e === void 0 ? void 0 : _e.call(runtime),
1467
- locale: (_f = runtime.language) === null || _f === void 0 ? void 0 : _f.call(runtime),
1468
- screen: (_g = runtime.screen) === null || _g === void 0 ? void 0 : _g.call(runtime),
1469
- ip: (_h = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _h === void 0 ? void 0 : _h.call(runtime),
1469
+ userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1470
+ locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1471
+ screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1472
+ ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1470
1473
  traits: payload.type != "identify" && payload.type != "group"
1471
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_j = payload === null || payload === void 0 ? void 0 : payload.options) === null || _j === void 0 ? void 0 : _j.traits) || {})) : undefined,
1474
+ ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1472
1475
  page: {
1473
1476
  path: properties.path || (parsedUrl && parsedUrl.pathname),
1474
1477
  referrer: referrer,
@@ -1479,13 +1482,13 @@
1479
1482
  url: properties.url || url,
1480
1483
  encoding: properties.encoding || runtime.documentEncoding(),
1481
1484
  },
1482
- clientIds: !((_k = config.privacy) === null || _k === void 0 ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1485
+ clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1483
1486
  campaign: parseUtms(query),
1484
1487
  };
1485
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_l = payload === null || payload === void 0 ? void 0 : payload.options) === null || _l === void 0 ? void 0 : _l.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1488
+ const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1486
1489
  delete withContext.meta;
1487
1490
  delete withContext.options;
1488
- if ((_p = config.privacy) === null || _p === void 0 ? void 0 : _p.disableUserIds) {
1491
+ if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1489
1492
  delete withContext.userId;
1490
1493
  delete withContext.anonymousId;
1491
1494
  delete withContext.context.traits;
@@ -2055,6 +2058,9 @@
2055
2058
  //However, since returned values are used for debugging purposes only, it's ok
2056
2059
  return results[0];
2057
2060
  });
2061
+ },
2062
+ getConfiguration() {
2063
+ return opts;
2058
2064
  } });
2059
2065
  if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
2060
2066
  storage.reset();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jitsu/js",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "",
5
5
  "author": "Jitsu Dev Team <dev@jitsu.com>",
6
6
  "main": "dist/jitsu.cjs.js",
@@ -39,10 +39,10 @@
39
39
  "rollup": "^3.29.5",
40
40
  "ts-jest": "29.0.5",
41
41
  "typescript": "^5.6.3",
42
- "jsondiffpatch": "1.10.2"
42
+ "jsondiffpatch": "1.10.3"
43
43
  },
44
44
  "peerDependencies": {
45
- "@jitsu/protocols": "1.10.2"
45
+ "@jitsu/protocols": "1.10.3"
46
46
  },
47
47
  "dependencies": {
48
48
  "analytics": "0.8.9"