@jitsu/js 1.9.7-canary.903.20240731114701 → 1.9.8

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/dist/jitsu.cjs.js CHANGED
@@ -1051,6 +1051,37 @@ const defaultConfig = {
1051
1051
  fetchTimeoutMs: undefined,
1052
1052
  s2s: undefined,
1053
1053
  idEndpoint: undefined,
1054
+ privacy: {
1055
+ dontSend: false,
1056
+ disableUserIds: false,
1057
+ ipPolicy: "keep",
1058
+ consentCategories: undefined,
1059
+ },
1060
+ };
1061
+ // mergeConfig merges newConfig into currentConfig also making sure that all undefined values are replaced with defaultConfig values
1062
+ const mergeConfig = (current, newConfig) => {
1063
+ for (const key of Object.keys(defaultConfig)) {
1064
+ const value = newConfig[key];
1065
+ if (key === "privacy") {
1066
+ if (typeof value === "object") {
1067
+ current.privacy = Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), current.privacy), value);
1068
+ }
1069
+ else if (newConfig.hasOwnProperty("privacy") && typeof value === "undefined") {
1070
+ // explicitly set to undefined - reset to default
1071
+ current.privacy = Object.assign({}, defaultConfig.privacy);
1072
+ }
1073
+ }
1074
+ else if (typeof value === "undefined") {
1075
+ if (newConfig.hasOwnProperty(key) || !current.hasOwnProperty(key)) {
1076
+ // explicitly set to undefined - reset to default
1077
+ // or was not set at all - set to default
1078
+ current[key] = defaultConfig[key];
1079
+ }
1080
+ }
1081
+ else {
1082
+ current[key] = value;
1083
+ }
1084
+ }
1054
1085
  };
1055
1086
  const parseQuery = (qs) => {
1056
1087
  if (!qs) {
@@ -1158,10 +1189,19 @@ const defaultCookie2Key = {
1158
1189
  __anon_id: "__eventn_id",
1159
1190
  __user_traits: "__eventn_id_usr",
1160
1191
  __user_id: "__eventn_uid",
1192
+ __group_id: "__group_id",
1193
+ __group_traits: "__group_traits",
1161
1194
  };
1162
1195
  const cookieStorage = (cookieDomain, key2cookie) => {
1163
1196
  return {
1164
1197
  setItem(key, val) {
1198
+ if (typeof val === "undefined") {
1199
+ removeCookie(key2cookie[key] || key, {
1200
+ domain: cookieDomain,
1201
+ secure: window.location.protocol === "https:",
1202
+ });
1203
+ return;
1204
+ }
1165
1205
  const strVal = typeof val === "object" && val !== null ? encodeURIComponent(JSON.stringify(val)) : val;
1166
1206
  const cookieName = key2cookie[key] || key;
1167
1207
  setCookie(cookieName, strVal, {
@@ -1269,7 +1309,12 @@ const emptyRuntime = (config) => ({
1269
1309
  if (config.debug) {
1270
1310
  console.log(`[JITSU EMPTY RUNTIME] Set storage item ${key}=${JSON.stringify(val)}`);
1271
1311
  }
1272
- storage[key] = val;
1312
+ if (typeof val === "undefined") {
1313
+ delete storage[key];
1314
+ }
1315
+ else {
1316
+ storage[key] = val;
1317
+ }
1273
1318
  },
1274
1319
  getItem(key) {
1275
1320
  const val = storage[key];
@@ -1342,7 +1387,7 @@ function urlPath(url) {
1342
1387
  return "/" + pathMatch;
1343
1388
  }
1344
1389
  function adjustPayload(payload, config, storage, s2s) {
1345
- var _a, _b;
1390
+ var _a, _b, _c, _d, _e;
1346
1391
  const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1347
1392
  const url = runtime.pageUrl();
1348
1393
  const parsedUrl = safeCall(() => new URL(url), undefined);
@@ -1359,8 +1404,13 @@ function adjustPayload(payload, config, storage, s2s) {
1359
1404
  library: {
1360
1405
  name: jitsuLibraryName,
1361
1406
  version: jitsuVersion,
1362
- env: s2s ? "node" : "browser",
1407
+ env: isInBrowser() ? "browser" : "node",
1363
1408
  },
1409
+ consent: ((_c = config.privacy) === null || _c === void 0 ? void 0 : _c.consentCategories)
1410
+ ? {
1411
+ categoryPreferences: config.privacy.consentCategories,
1412
+ }
1413
+ : undefined,
1364
1414
  userAgent: runtime.userAgent(),
1365
1415
  locale: runtime.language(),
1366
1416
  screen: runtime.screen(),
@@ -1375,12 +1425,19 @@ function adjustPayload(payload, config, storage, s2s) {
1375
1425
  url: properties.url || url,
1376
1426
  encoding: properties.encoding || runtime.documentEncoding(),
1377
1427
  },
1378
- clientIds: Object.assign({ fbc: runtime.getCookie("_fbc"), fbp: runtime.getCookie("_fbp") }, getGa4Ids(runtime)),
1428
+ clientIds: !((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.disableUserIds)
1429
+ ? Object.assign({ fbc: runtime.getCookie("_fbc"), fbp: runtime.getCookie("_fbp") }, getGa4Ids(runtime)) : undefined,
1379
1430
  campaign: parseUtms(query),
1380
1431
  };
1381
1432
  const withContext = Object.assign(Object.assign({}, payload), { timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), groupId: storage.getItem("__group_id"), context: deepMerge(context, customContext) });
1382
1433
  delete withContext.meta;
1383
1434
  delete withContext.options;
1435
+ if ((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.disableUserIds) {
1436
+ delete withContext.userId;
1437
+ delete withContext.anonymousId;
1438
+ delete withContext.context.traits;
1439
+ delete withContext.groupId;
1440
+ }
1384
1441
  return withContext;
1385
1442
  }
1386
1443
  function isDiff(obj) {
@@ -1486,11 +1543,12 @@ function maskWriteKey(writeKey) {
1486
1543
  }
1487
1544
  function send(method, payload, jitsuConfig, instance, store) {
1488
1545
  return __awaiter$1(this, void 0, void 0, function* () {
1546
+ var _a, _b;
1489
1547
  if (jitsuConfig.echoEvents) {
1490
1548
  console.log(`[JITSU DEBUG] sending '${method}' event:`, payload);
1491
1549
  return;
1492
1550
  }
1493
- const s2s = jitsuConfig.s2s === undefined ? !isInBrowser() : jitsuConfig.s2s;
1551
+ const s2s = !!jitsuConfig.s2s;
1494
1552
  const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
1495
1553
  const fetch = jitsuConfig.fetch || globalThis.fetch;
1496
1554
  if (!fetch) {
@@ -1500,7 +1558,7 @@ function send(method, payload, jitsuConfig, instance, store) {
1500
1558
  // if (jitsuConfig.debug) {
1501
1559
  // console.log(`[JITSU] Sending event to ${url}: `, JSON.stringify(payload, null, 2));
1502
1560
  // }
1503
- const adjustedPayload = adjustPayload(payload, jitsuConfig, store, s2s);
1561
+ const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
1504
1562
  const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
1505
1563
  const abortTimeout = jitsuConfig.fetchTimeoutMs
1506
1564
  ? setTimeout(() => {
@@ -1508,11 +1566,14 @@ function send(method, payload, jitsuConfig, instance, store) {
1508
1566
  }, jitsuConfig.fetchTimeoutMs)
1509
1567
  : undefined;
1510
1568
  const authHeader = jitsuConfig.writeKey ? { "X-Write-Key": jitsuConfig.writeKey } : {};
1569
+ const ipHeader = typeof ((_a = jitsuConfig.privacy) === null || _a === void 0 ? void 0 : _a.ipPolicy) === "undefined" || ((_b = jitsuConfig.privacy) === null || _b === void 0 ? void 0 : _b.ipPolicy) === "keep"
1570
+ ? {}
1571
+ : { "X-IP-Policy": jitsuConfig.privacy.ipPolicy };
1511
1572
  let fetchResult;
1512
1573
  try {
1513
1574
  fetchResult = yield fetch(url, {
1514
1575
  method: "POST",
1515
- headers: Object.assign(Object.assign({ "Content-Type": "application/json" }, authHeader), debugHeader),
1576
+ headers: Object.assign(Object.assign(Object.assign({ "Content-Type": "application/json" }, authHeader), debugHeader), ipHeader),
1516
1577
  body: JSON.stringify(adjustedPayload),
1517
1578
  signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
1518
1579
  });
@@ -1560,11 +1621,12 @@ function send(method, payload, jitsuConfig, instance, store) {
1560
1621
  return adjustedPayload;
1561
1622
  });
1562
1623
  }
1563
- const jitsuAnalyticsPlugin = (pluginConfig = {}) => {
1564
- const instanceConfig = Object.assign(Object.assign({}, defaultConfig), pluginConfig);
1624
+ const jitsuAnalyticsPlugin = (jitsuOptions = {}, storage) => {
1625
+ // just to make sure that all undefined values are replaced with defaultConfig values
1626
+ mergeConfig(jitsuOptions, jitsuOptions);
1565
1627
  return {
1566
1628
  name: "jitsu",
1567
- config: instanceConfig,
1629
+ config: jitsuOptions,
1568
1630
  initialize: (args) => __awaiter$1(void 0, void 0, void 0, function* () {
1569
1631
  const { config } = args;
1570
1632
  if (config.debug) {
@@ -1601,17 +1663,28 @@ const jitsuAnalyticsPlugin = (pluginConfig = {}) => {
1601
1663
  }
1602
1664
  }),
1603
1665
  page: args => {
1666
+ var _a;
1604
1667
  const { payload, config, instance } = args;
1605
- return send("page", payload, config, instance, pluginConfig.storageWrapper ? pluginConfig.storageWrapper(instance.storage) : instance.storage);
1668
+ if ((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) {
1669
+ return;
1670
+ }
1671
+ return send("page", payload, config, instance, storage);
1606
1672
  },
1607
1673
  track: args => {
1674
+ var _a;
1608
1675
  const { payload, config, instance } = args;
1609
- return send("track", payload, config, instance, pluginConfig.storageWrapper ? pluginConfig.storageWrapper(instance.storage) : instance.storage);
1676
+ if ((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) {
1677
+ return;
1678
+ }
1679
+ return send("track", payload, config, instance, storage);
1610
1680
  },
1611
1681
  identify: args => {
1682
+ var _a, _b;
1612
1683
  const { payload, config, instance } = args;
1684
+ if (((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = config.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1685
+ return;
1686
+ }
1613
1687
  // Store traits in cache to be able to use them in page and track events that run asynchronously with current identify.
1614
- const storage = pluginConfig.storageWrapper ? pluginConfig.storageWrapper(instance.storage) : instance.storage;
1615
1688
  storage.setItem("__user_id", payload.userId);
1616
1689
  if (payload.traits && typeof payload.traits === "object") {
1617
1690
  storage.setItem("__user_traits", payload.traits);
@@ -1620,31 +1693,50 @@ const jitsuAnalyticsPlugin = (pluginConfig = {}) => {
1620
1693
  },
1621
1694
  reset: args => {
1622
1695
  const { config, instance } = args;
1623
- const storage = pluginConfig.storageWrapper ? pluginConfig.storageWrapper(instance.storage) : instance.storage;
1624
- storage === null || storage === void 0 ? void 0 : storage.reset();
1696
+ storage.reset();
1625
1697
  if (config.debug) {
1626
1698
  console.log("[JITSU DEBUG] Resetting Jitsu plugin storage");
1627
1699
  }
1628
1700
  },
1629
1701
  methods: {
1630
1702
  //analytics doesn't support group as a base method, so we need to add it manually
1703
+ configure(newOptions) {
1704
+ var _a, _b, _c, _d;
1705
+ const idsWasDisabled = ((_a = jitsuOptions.privacy) === null || _a === void 0 ? void 0 : _a.disableUserIds) || ((_b = jitsuOptions.privacy) === null || _b === void 0 ? void 0 : _b.dontSend);
1706
+ mergeConfig(jitsuOptions, newOptions);
1707
+ const idsDisabledNow = ((_c = jitsuOptions.privacy) === null || _c === void 0 ? void 0 : _c.disableUserIds) || ((_d = jitsuOptions.privacy) === null || _d === void 0 ? void 0 : _d.dontSend);
1708
+ if (!idsDisabledNow && idsWasDisabled) {
1709
+ if (jitsuOptions.debug) {
1710
+ console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");
1711
+ }
1712
+ const instance = this.instance;
1713
+ const newAnonymousId = uuid();
1714
+ const userState = instance.user();
1715
+ if (userState) {
1716
+ userState.anonymousId = newAnonymousId;
1717
+ }
1718
+ storage.setItem("__anon_id", newAnonymousId);
1719
+ instance.setAnonymousId(newAnonymousId);
1720
+ }
1721
+ },
1631
1722
  group(groupId, traits, options, callback) {
1723
+ var _a, _b;
1724
+ if (((_a = jitsuOptions.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = jitsuOptions.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1725
+ return;
1726
+ }
1632
1727
  if (typeof groupId === "number") {
1633
1728
  //fix potential issues with group id being used incorrectly
1634
1729
  groupId = groupId + "";
1635
1730
  }
1636
- const analyticsInstance = this.instance;
1637
- const cacheWrap = pluginConfig.storageWrapper
1638
- ? pluginConfig.storageWrapper(analyticsInstance.storage)
1639
- : analyticsInstance.storage;
1640
- const user = analyticsInstance.user();
1731
+ const instance = this.instance;
1732
+ const user = instance.user();
1641
1733
  const userId = (options === null || options === void 0 ? void 0 : options.userId) || (user === null || user === void 0 ? void 0 : user.userId);
1642
- const anonymousId = (options === null || options === void 0 ? void 0 : options.anonymousId) || (user === null || user === void 0 ? void 0 : user.anonymousId) || cacheWrap.getItem("__anon_id");
1643
- cacheWrap.setItem("__group_id", groupId);
1734
+ const anonymousId = (options === null || options === void 0 ? void 0 : options.anonymousId) || (user === null || user === void 0 ? void 0 : user.anonymousId) || storage.getItem("__anon_id");
1735
+ storage.setItem("__group_id", groupId);
1644
1736
  if (traits && typeof traits === "object") {
1645
- cacheWrap.setItem("__group_traits", traits);
1737
+ storage.setItem("__group_traits", traits);
1646
1738
  }
1647
- return send("group", Object.assign(Object.assign({ type: "group", groupId, traits }, (anonymousId ? { anonymousId } : {})), (userId ? { userId } : {})), instanceConfig, analyticsInstance, cacheWrap);
1739
+ return send("group", Object.assign(Object.assign({ type: "group", groupId, traits }, (anonymousId ? { anonymousId } : {})), (userId ? { userId } : {})), jitsuOptions, instance, storage);
1648
1740
  },
1649
1741
  },
1650
1742
  };
@@ -1659,6 +1751,15 @@ function randomId(hashString = "") {
1659
1751
  return (((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", getSeed())) % Number.MAX_SAFE_INTEGER).toString(36) +
1660
1752
  ((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", getSeed())) % Number.MAX_SAFE_INTEGER).toString(36));
1661
1753
  }
1754
+ function uuid() {
1755
+ var u = "", m = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", i = 0, rb = (Math.random() * 0xffffffff) | 0;
1756
+ while (i++ < 36) {
1757
+ var c = m[i - 1], r = rb & 0xf, v = c == "x" ? r : (r & 0x3) | 0x8;
1758
+ u += c == "-" || c == "4" ? c : v.toString(16);
1759
+ rb = i % 8 == 0 ? (Math.random() * 0xffffffff) | 0 : rb >> 4;
1760
+ }
1761
+ return u;
1762
+ }
1662
1763
  function hash(str, seed = 0) {
1663
1764
  let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
1664
1765
  for (let i = 0, ch; i < str.length; i++) {
@@ -1711,15 +1812,20 @@ const emptyAnalytics = {
1711
1812
  identify: () => Promise.resolve({}),
1712
1813
  group: () => Promise.resolve({}),
1713
1814
  reset: () => Promise.resolve({}),
1815
+ configure: () => { },
1714
1816
  };
1715
1817
  function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1716
- const storage = rt.store();
1818
+ var _a, _b;
1717
1819
  const storageCache = {};
1718
1820
  // AnalyticsInstance's storage is async somewhere inside. So if we make 'page' call right after 'identify' call
1719
1821
  // 'page' call will load traits from storage before 'identify' call had a change to save them.
1720
1822
  // to avoid that we use in-memory cache for storage
1721
1823
  const cachingStorageWrapper = (persistentStorage) => ({
1722
1824
  setItem(key, val) {
1825
+ var _a, _b;
1826
+ if (((_a = opts.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1827
+ return;
1828
+ }
1723
1829
  if (opts.debug) {
1724
1830
  console.log(`[JITSU DEBUG] Caching storage setItem: ${key}=${val}`);
1725
1831
  }
@@ -1727,6 +1833,10 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1727
1833
  persistentStorage.setItem(key, val);
1728
1834
  },
1729
1835
  getItem(key) {
1836
+ var _a, _b;
1837
+ if (((_a = opts.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1838
+ return;
1839
+ }
1730
1840
  const value = storageCache[key] || persistentStorage.getItem(key);
1731
1841
  if (opts.debug) {
1732
1842
  console.log(`[JITSU DEBUG] Caching storage getItem: ${key}=${value}. Evicted from cache: ${!storageCache[key]}`);
@@ -1737,7 +1847,7 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1737
1847
  for (const key of [...Object.keys(storageCache)]) {
1738
1848
  delete storageCache[key];
1739
1849
  }
1740
- storage.reset();
1850
+ persistentStorage.reset();
1741
1851
  },
1742
1852
  removeItem(key) {
1743
1853
  if (opts.debug) {
@@ -1747,12 +1857,13 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1747
1857
  persistentStorage.removeItem(key);
1748
1858
  },
1749
1859
  });
1860
+ const storage = cachingStorageWrapper(rt.store());
1750
1861
  const analytics = analyticsLib({
1751
1862
  debug: !!opts.debug,
1752
1863
  storage,
1753
- plugins: [jitsuAnalyticsPlugin(Object.assign(Object.assign({}, opts), { storageWrapper: cachingStorageWrapper })), ...plugins],
1864
+ plugins: [jitsuAnalyticsPlugin(opts, storage), ...plugins],
1754
1865
  });
1755
- return Object.assign(Object.assign({}, analytics), { page: (...args) => {
1866
+ const a = Object.assign(Object.assign({}, analytics), { page: (...args) => {
1756
1867
  if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "object") {
1757
1868
  return analytics.page(Object.assign({ name: args[0] }, args[1]));
1758
1869
  }
@@ -1786,7 +1897,7 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1786
1897
  if (opts.debug) {
1787
1898
  console.log("[JITSU DEBUG] Setting anonymous id to " + id);
1788
1899
  }
1789
- //Workaround for analytics.js bug. Underlying setAnonymousId doesn't work set the id immediately,
1900
+ //Workaround for analytics.js bug. Underlying setAnonymousId doesn't set the id immediately,
1790
1901
  //so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060
1791
1902
  storage.setItem("__anon_id", id);
1792
1903
  const userState = analytics.user();
@@ -1807,6 +1918,22 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1807
1918
  }
1808
1919
  });
1809
1920
  },
1921
+ configure(options) {
1922
+ return __awaiter(this, void 0, void 0, function* () {
1923
+ var _a, _b;
1924
+ if (opts.debug) {
1925
+ console.log("[JITSU DEBUG] Update Jitsu config with", JSON.stringify(options));
1926
+ }
1927
+ if (((_a = options.privacy) === null || _a === void 0 ? void 0 : _a.disableUserIds) || ((_b = options.privacy) === null || _b === void 0 ? void 0 : _b.dontSend)) {
1928
+ storage.reset();
1929
+ }
1930
+ for (const plugin of Object.values(analytics.plugins)) {
1931
+ if (typeof plugin["configure"] === "function") {
1932
+ plugin["configure"](options);
1933
+ }
1934
+ }
1935
+ });
1936
+ },
1810
1937
  group(groupId, traits, options, callback) {
1811
1938
  return __awaiter(this, void 0, void 0, function* () {
1812
1939
  const results = [];
@@ -1820,13 +1947,20 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1820
1947
  return results[0];
1821
1948
  });
1822
1949
  } });
1950
+ if (((_a = opts.privacy) === null || _a === void 0 ? void 0 : _a.disableUserIds) || ((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.dontSend)) {
1951
+ storage.reset();
1952
+ }
1953
+ return a;
1823
1954
  }
1824
1955
  /**
1825
1956
  * Fix common mistakes in jitsu configuration
1826
1957
  * @param opts
1827
1958
  */
1828
1959
  function fixOptions(opts) {
1829
- return Object.assign(Object.assign({}, opts), { host: opts.host.indexOf("https://") !== 0 && opts.host.indexOf("http://") !== 0 ? `https://${opts.host}` : opts.host });
1960
+ var _a, _b;
1961
+ return Object.assign(Object.assign({}, opts), { host: ((_a = opts.host) !== null && _a !== void 0 ? _a : "").indexOf("https://") !== 0 && ((_b = opts.host) !== null && _b !== void 0 ? _b : "").indexOf("http://") !== 0
1962
+ ? `https://${opts.host}`
1963
+ : opts.host });
1830
1964
  }
1831
1965
  function jitsuAnalytics(_opts) {
1832
1966
  const opts = fixOptions(_opts);
@@ -1856,15 +1990,6 @@ function jitsuAnalytics(_opts) {
1856
1990
  // result.loaded(createUnderlyingAnalyticsInstance(opts, rt));
1857
1991
  // }
1858
1992
  }
1859
- function uuid() {
1860
- var u = "", m = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", i = 0, rb = (Math.random() * 0xffffffff) | 0;
1861
- while (i++ < 36) {
1862
- var c = m[i - 1], r = rb & 0xf, v = c == "x" ? r : (r & 0x3) | 0x8;
1863
- u += c == "-" || c == "4" ? c : v.toString(16);
1864
- rb = i % 8 == 0 ? (Math.random() * 0xffffffff) | 0 : rb >> 4;
1865
- }
1866
- return u;
1867
- }
1868
1993
 
1869
1994
  exports.emptyAnalytics = emptyAnalytics;
1870
1995
  exports.emptyRuntime = emptyRuntime;
@@ -1873,4 +1998,5 @@ exports.jitsuAnalytics = jitsuAnalytics;
1873
1998
  exports.jitsuAnalyticsPlugin = jitsuAnalyticsPlugin;
1874
1999
  exports.parseQuery = parseQuery;
1875
2000
  exports.randomId = randomId;
2001
+ exports.uuid = uuid;
1876
2002
  exports.windowRuntime = windowRuntime;
package/dist/jitsu.d.ts CHANGED
@@ -52,7 +52,12 @@ type JitsuOptions = {
52
52
  * Required to overcome Safari ITP restrictions.
53
53
  */
54
54
  idEndpoint?: string;
55
+ enabled?: boolean;
56
+ enableAnonymousId?: boolean;
57
+ enableThirdPartIds?: boolean;
58
+ ipPolicy?: "keep" | "remove" | "stripLastOctet";
55
59
  };
60
+ type DynamicJitsuOptions = Pick<JitsuOptions, "enableAnonymousId" | "enableThirdPartIds" | "ipPolicy" | "debug" | "echoEvents" | "enabled">;
56
61
  type PersistentStorage = {
57
62
  getItem: (key: string, options?: any) => any;
58
63
  setItem: (key: string, value: any, options?: any) => void;
@@ -79,4 +84,4 @@ type RuntimeFacade = {
79
84
  pageTitle(): string | undefined;
80
85
  };
81
86
  export declare function jitsuAnalytics(opts: JitsuOptions): AnalyticsInterface;
82
- export { AnalyticsInterface, JitsuOptions, PersistentStorage, RuntimeFacade };
87
+ export { AnalyticsInterface, JitsuOptions, DynamicJitsuOptions, PersistentStorage, RuntimeFacade };