autotel-subscribers 15.0.0 → 16.0.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/dist/mixpanel.cjs CHANGED
@@ -1312,9 +1312,9 @@ var require_dist2 = __commonJS({
1312
1312
  }
1313
1313
  });
1314
1314
 
1315
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/package.json
1315
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/package.json
1316
1316
  var require_package = __commonJS({
1317
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/package.json"(exports$1, module) {
1317
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/package.json"(exports$1, module) {
1318
1318
  module.exports = {
1319
1319
  name: "mixpanel",
1320
1320
  description: "A simple server-side API for mixpanel",
@@ -1324,7 +1324,7 @@ var require_package = __commonJS({
1324
1324
  "api",
1325
1325
  "stats"
1326
1326
  ],
1327
- version: "0.19.1",
1327
+ version: "0.20.0",
1328
1328
  homepage: "https://github.com/mixpanel/mixpanel-node",
1329
1329
  author: "Carl Sverre",
1330
1330
  license: "MIT",
@@ -1340,29 +1340,35 @@ var require_package = __commonJS({
1340
1340
  node: ">=10.0"
1341
1341
  },
1342
1342
  scripts: {
1343
- test: "vitest"
1343
+ test: "vitest",
1344
+ format: "prettier --write .",
1345
+ "check-format": "prettier --check .",
1346
+ lint: "oxlint ."
1344
1347
  },
1345
1348
  types: "./lib/mixpanel-node.d.ts",
1346
1349
  devDependencies: {
1347
1350
  "@types/node": "^24.10.1",
1348
1351
  "@vitest/coverage-v8": "^4.0.8",
1349
1352
  nock: "^14.0.10",
1353
+ oxlint: "^1.16.0",
1354
+ prettier: "^3.6.2",
1350
1355
  proxyquire: "^2.1.3",
1351
1356
  typescript: "^5.9.3",
1352
1357
  vitest: "^4.0.8"
1353
1358
  },
1354
1359
  dependencies: {
1355
- "https-proxy-agent": "7.0.6"
1360
+ "https-proxy-agent": "7.0.6",
1361
+ "json-logic-js": "2.0.5"
1356
1362
  }
1357
1363
  };
1358
1364
  }
1359
1365
  });
1360
1366
 
1361
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/utils.js
1367
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/utils.js
1362
1368
  var require_utils = __commonJS({
1363
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/utils.js"(exports$1) {
1369
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/utils.js"(exports$1) {
1364
1370
  exports$1.async_all = function(requests, handler, callback) {
1365
- var total = requests.length, errors = null, results = [], done = function(err, result) {
1371
+ let total = requests.length, errors = null, results = [], done = function(err, result) {
1366
1372
  if (err) {
1367
1373
  errors = errors || [];
1368
1374
  errors.push(err);
@@ -1375,14 +1381,16 @@ var require_utils = __commonJS({
1375
1381
  if (total === 0) {
1376
1382
  callback(errors, results);
1377
1383
  } else {
1378
- for (var i = 0, l = requests.length; i < l; i++) {
1384
+ for (let i = 0, l = requests.length; i < l; i++) {
1379
1385
  handler(requests[i], done);
1380
1386
  }
1381
1387
  }
1382
1388
  };
1383
1389
  exports$1.ensure_timestamp = function(time) {
1384
1390
  if (!(time instanceof Date || typeof time === "number")) {
1385
- throw new Error("`time` property must be a Date or Unix timestamp and is only required for `import` endpoint");
1391
+ throw new Error(
1392
+ "`time` property must be a Date or Unix timestamp and is only required for `import` endpoint"
1393
+ );
1386
1394
  }
1387
1395
  return time instanceof Date ? time.getTime() : time;
1388
1396
  };
@@ -1399,9 +1407,9 @@ var require_utils = __commonJS({
1399
1407
  }
1400
1408
  });
1401
1409
 
1402
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/profile_helpers.js
1410
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/profile_helpers.js
1403
1411
  var require_profile_helpers = __commonJS({
1404
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/profile_helpers.js"(exports$1) {
1412
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/profile_helpers.js"(exports$1) {
1405
1413
  var { ensure_timestamp } = require_utils();
1406
1414
  function merge_modifiers(data, modifiers) {
1407
1415
  if (modifiers) {
@@ -1449,7 +1457,7 @@ var require_profile_helpers = __commonJS({
1449
1457
  }
1450
1458
  }
1451
1459
  let data = {
1452
- "$token": this.token,
1460
+ $token: this.token,
1453
1461
  ...identifiers
1454
1462
  };
1455
1463
  const set_key = set_once ? "$set_once" : "$set";
@@ -1464,14 +1472,20 @@ var require_profile_helpers = __commonJS({
1464
1472
  }
1465
1473
  data = merge_modifiers(data, modifiers);
1466
1474
  if (this.config.debug) {
1467
- this.mixpanel.config.logger.debug(`Sending the following data to Mixpanel (${this.endpoint})`, { data });
1475
+ this.mixpanel.config.logger.debug(
1476
+ `Sending the following data to Mixpanel (${this.endpoint})`,
1477
+ { data }
1478
+ );
1468
1479
  }
1469
- this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
1480
+ this.mixpanel.send_request(
1481
+ { method: "GET", endpoint: this.endpoint, data },
1482
+ callback
1483
+ );
1470
1484
  }
1471
1485
  _delete_profile({ identifiers, modifiers, callback }) {
1472
1486
  let data = {
1473
- "$delete": "",
1474
- "$token": this.token,
1487
+ $delete: "",
1488
+ $token: this.token,
1475
1489
  ...identifiers
1476
1490
  };
1477
1491
  if (typeof modifiers === "function") {
@@ -1481,13 +1495,18 @@ var require_profile_helpers = __commonJS({
1481
1495
  if (this.config.debug) {
1482
1496
  this.mixpanel.config.logger.debug("Deleting profile", { identifiers });
1483
1497
  }
1484
- this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
1498
+ this.mixpanel.send_request(
1499
+ { method: "GET", endpoint: this.endpoint, data },
1500
+ callback
1501
+ );
1485
1502
  }
1486
1503
  _remove({ identifiers, data, modifiers, callback }) {
1487
1504
  let $remove = {};
1488
1505
  if (typeof data !== "object" || Array.isArray(data)) {
1489
1506
  if (this.config.debug) {
1490
- this.mixpanel.config.logger.error("Invalid value passed to #remove - data must be an object with scalar values");
1507
+ this.mixpanel.config.logger.error(
1508
+ "Invalid value passed to #remove - data must be an object with scalar values"
1509
+ );
1491
1510
  }
1492
1511
  return;
1493
1512
  }
@@ -1508,8 +1527,8 @@ var require_profile_helpers = __commonJS({
1508
1527
  return;
1509
1528
  }
1510
1529
  data = {
1511
- "$remove": $remove,
1512
- "$token": this.token,
1530
+ $remove,
1531
+ $token: this.token,
1513
1532
  ...identifiers
1514
1533
  };
1515
1534
  if (typeof modifiers === "function") {
@@ -1522,19 +1541,24 @@ var require_profile_helpers = __commonJS({
1522
1541
  { data }
1523
1542
  );
1524
1543
  }
1525
- this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
1544
+ this.mixpanel.send_request(
1545
+ { method: "GET", endpoint: this.endpoint, data },
1546
+ callback
1547
+ );
1526
1548
  }
1527
1549
  _union({ identifiers, data, modifiers, callback }) {
1528
1550
  let $union = {};
1529
1551
  if (typeof data !== "object" || Array.isArray(data)) {
1530
1552
  if (this.config.debug) {
1531
- this.mixpanel.config.logger.error("Invalid value passed to #union - data must be an object with scalar or array values");
1553
+ this.mixpanel.config.logger.error(
1554
+ "Invalid value passed to #union - data must be an object with scalar or array values"
1555
+ );
1532
1556
  }
1533
1557
  return;
1534
1558
  }
1535
1559
  for (const [key, val] of Object.entries(data)) {
1536
1560
  if (Array.isArray(val)) {
1537
- var merge_values = val.filter(function(v) {
1561
+ const merge_values = val.filter(function(v) {
1538
1562
  return typeof v === "string" || typeof v === "number";
1539
1563
  });
1540
1564
  if (merge_values.length > 0) {
@@ -1555,8 +1579,8 @@ var require_profile_helpers = __commonJS({
1555
1579
  return;
1556
1580
  }
1557
1581
  data = {
1558
- "$union": $union,
1559
- "$token": this.token,
1582
+ $union,
1583
+ $token: this.token,
1560
1584
  ...identifiers
1561
1585
  };
1562
1586
  if (typeof modifiers === "function") {
@@ -1569,7 +1593,10 @@ var require_profile_helpers = __commonJS({
1569
1593
  { data }
1570
1594
  );
1571
1595
  }
1572
- this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
1596
+ this.mixpanel.send_request(
1597
+ { method: "GET", endpoint: this.endpoint, data },
1598
+ callback
1599
+ );
1573
1600
  }
1574
1601
  _unset({ identifiers, prop, modifiers, callback }) {
1575
1602
  let $unset = [];
@@ -1587,8 +1614,8 @@ var require_profile_helpers = __commonJS({
1587
1614
  return;
1588
1615
  }
1589
1616
  let data = {
1590
- "$unset": $unset,
1591
- "$token": this.token,
1617
+ $unset,
1618
+ $token: this.token,
1592
1619
  ...identifiers
1593
1620
  };
1594
1621
  if (typeof modifiers === "function") {
@@ -1601,15 +1628,18 @@ var require_profile_helpers = __commonJS({
1601
1628
  { data }
1602
1629
  );
1603
1630
  }
1604
- this.mixpanel.send_request({ method: "GET", endpoint: this.endpoint, data }, callback);
1631
+ this.mixpanel.send_request(
1632
+ { method: "GET", endpoint: this.endpoint, data },
1633
+ callback
1634
+ );
1605
1635
  }
1606
1636
  };
1607
1637
  }
1608
1638
  });
1609
1639
 
1610
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/groups.js
1640
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/groups.js
1611
1641
  var require_groups = __commonJS({
1612
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/groups.js"(exports$1) {
1642
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/groups.js"(exports$1) {
1613
1643
  var { ProfileHelpers } = require_profile_helpers();
1614
1644
  var MixpanelGroups = class extends ProfileHelpers() {
1615
1645
  constructor(mp_instance) {
@@ -1618,9 +1648,9 @@ var require_groups = __commonJS({
1618
1648
  this.endpoint = "/groups";
1619
1649
  }
1620
1650
  /** groups.set_once(group_key, group_id, prop, to, modifiers, callback)
1621
- ---
1622
- The same as groups.set, but adds a property value to a group only if it has not been set before.
1623
- */
1651
+ ---
1652
+ The same as groups.set, but adds a property value to a group only if it has not been set before.
1653
+ */
1624
1654
  set_once(group_key, group_id, prop, to, modifiers, callback) {
1625
1655
  const identifiers = { $group_key: group_key, $group_id: group_id };
1626
1656
  this._set(prop, to, modifiers, callback, { identifiers, set_once: true });
@@ -1709,9 +1739,9 @@ var require_groups = __commonJS({
1709
1739
  }
1710
1740
  });
1711
1741
 
1712
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/people.js
1742
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/people.js
1713
1743
  var require_people = __commonJS({
1714
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/people.js"(exports$1) {
1744
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/people.js"(exports$1) {
1715
1745
  var { merge_modifiers, ProfileHelpers } = require_profile_helpers();
1716
1746
  var MixpanelPeople = class extends ProfileHelpers() {
1717
1747
  constructor(mp_instance) {
@@ -1777,7 +1807,7 @@ var require_people = __commonJS({
1777
1807
  });
1778
1808
  */
1779
1809
  increment(distinct_id, prop, by, modifiers, callback) {
1780
- var $add = {};
1810
+ const $add = {};
1781
1811
  if (typeof prop === "object") {
1782
1812
  if (typeof by === "object") {
1783
1813
  callback = modifiers;
@@ -1813,16 +1843,22 @@ var require_people = __commonJS({
1813
1843
  $add[prop] = 1;
1814
1844
  }
1815
1845
  }
1816
- var data = {
1817
- "$add": $add,
1818
- "$token": this.mixpanel.token,
1819
- "$distinct_id": distinct_id
1846
+ let data = {
1847
+ $add,
1848
+ $token: this.mixpanel.token,
1849
+ $distinct_id: distinct_id
1820
1850
  };
1821
1851
  data = merge_modifiers(data, modifiers);
1822
1852
  if (this.mixpanel.config.debug) {
1823
- this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
1853
+ this.mixpanel.config.logger.debug(
1854
+ "Sending the following data to Mixpanel (Engage)",
1855
+ { data }
1856
+ );
1824
1857
  }
1825
- this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
1858
+ this.mixpanel.send_request(
1859
+ { method: "GET", endpoint: "/engage", data },
1860
+ callback
1861
+ );
1826
1862
  }
1827
1863
  /**
1828
1864
  people.append(distinct_id, prop, value, modifiers, callback)
@@ -1841,7 +1877,7 @@ var require_people = __commonJS({
1841
1877
  });
1842
1878
  */
1843
1879
  append(distinct_id, prop, value, modifiers, callback) {
1844
- var $append = {};
1880
+ const $append = {};
1845
1881
  if (typeof prop === "object") {
1846
1882
  if (typeof value === "object") {
1847
1883
  callback = modifiers;
@@ -1858,16 +1894,22 @@ var require_people = __commonJS({
1858
1894
  callback = modifiers;
1859
1895
  }
1860
1896
  }
1861
- var data = {
1862
- "$append": $append,
1863
- "$token": this.mixpanel.token,
1864
- "$distinct_id": distinct_id
1897
+ let data = {
1898
+ $append,
1899
+ $token: this.mixpanel.token,
1900
+ $distinct_id: distinct_id
1865
1901
  };
1866
1902
  data = merge_modifiers(data, modifiers);
1867
1903
  if (this.mixpanel.config.debug) {
1868
- this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
1904
+ this.mixpanel.config.logger.debug(
1905
+ "Sending the following data to Mixpanel (Engage)",
1906
+ { data }
1907
+ );
1869
1908
  }
1870
- this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
1909
+ this.mixpanel.send_request(
1910
+ { method: "GET", endpoint: "/engage", data },
1911
+ callback
1912
+ );
1871
1913
  }
1872
1914
  /**
1873
1915
  people.track_charge(distinct_id, amount, properties, modifiers, callback)
@@ -1902,27 +1944,35 @@ var require_people = __commonJS({
1902
1944
  if (typeof amount !== "number") {
1903
1945
  amount = parseFloat(amount);
1904
1946
  if (isNaN(amount)) {
1905
- this.mixpanel.config.logger.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
1947
+ this.mixpanel.config.logger.error(
1948
+ "Invalid value passed to mixpanel.people.track_charge - must be a number"
1949
+ );
1906
1950
  return;
1907
1951
  }
1908
1952
  }
1909
1953
  properties.$amount = amount;
1910
1954
  if (properties.hasOwnProperty("$time")) {
1911
- var time = properties.$time;
1955
+ const time = properties.$time;
1912
1956
  if (Object.prototype.toString.call(time) === "[object Date]") {
1913
1957
  properties.$time = time.toISOString();
1914
1958
  }
1915
1959
  }
1916
- var data = {
1917
- "$append": { "$transactions": properties },
1918
- "$token": this.mixpanel.token,
1919
- "$distinct_id": distinct_id
1960
+ let data = {
1961
+ $append: { $transactions: properties },
1962
+ $token: this.mixpanel.token,
1963
+ $distinct_id: distinct_id
1920
1964
  };
1921
1965
  data = merge_modifiers(data, modifiers);
1922
1966
  if (this.mixpanel.config.debug) {
1923
- this.mixpanel.config.logger.debug("Sending the following data to Mixpanel (Engage)", { data });
1967
+ this.mixpanel.config.logger.debug(
1968
+ "Sending the following data to Mixpanel (Engage)",
1969
+ { data }
1970
+ );
1924
1971
  }
1925
- this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
1972
+ this.mixpanel.send_request(
1973
+ { method: "GET", endpoint: "/engage", data },
1974
+ callback
1975
+ );
1926
1976
  }
1927
1977
  /**
1928
1978
  people.clear_charges(distinct_id, modifiers, callback)
@@ -1934,19 +1984,24 @@ var require_people = __commonJS({
1934
1984
  mixpanel.people.clear_charges('bob');
1935
1985
  */
1936
1986
  clear_charges(distinct_id, modifiers, callback) {
1937
- var data = {
1938
- "$set": { "$transactions": [] },
1939
- "$token": this.mixpanel.token,
1940
- "$distinct_id": distinct_id
1987
+ let data = {
1988
+ $set: { $transactions: [] },
1989
+ $token: this.mixpanel.token,
1990
+ $distinct_id: distinct_id
1941
1991
  };
1942
1992
  if (typeof modifiers === "function") {
1943
1993
  callback = modifiers;
1944
1994
  }
1945
1995
  data = merge_modifiers(data, modifiers);
1946
1996
  if (this.mixpanel.config.debug) {
1947
- this.mixpanel.config.logger.debug("Clearing this user's charges", { "$distinct_id": distinct_id });
1997
+ this.mixpanel.config.logger.debug("Clearing this user's charges", {
1998
+ $distinct_id: distinct_id
1999
+ });
1948
2000
  }
1949
- this.mixpanel.send_request({ method: "GET", endpoint: "/engage", data }, callback);
2001
+ this.mixpanel.send_request(
2002
+ { method: "GET", endpoint: "/engage", data },
2003
+ callback
2004
+ );
1950
2005
  }
1951
2006
  /**
1952
2007
  people.delete_user(distinct_id, modifiers, callback)
@@ -1973,7 +2028,7 @@ var require_people = __commonJS({
1973
2028
  mixpanel.people.remove('bob', {'browsers': 'chrome', 'os': 'linux'});
1974
2029
  */
1975
2030
  remove(distinct_id, data, modifiers, callback) {
1976
- const identifiers = { "$distinct_id": distinct_id };
2031
+ const identifiers = { $distinct_id: distinct_id };
1977
2032
  this._remove({ identifiers, data, modifiers, callback });
1978
2033
  }
1979
2034
  /**
@@ -2011,9 +2066,9 @@ var require_people = __commonJS({
2011
2066
  }
2012
2067
  });
2013
2068
 
2014
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/utils.js
2069
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/utils.js
2015
2070
  var require_utils2 = __commonJS({
2016
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/utils.js"(exports$1, module) {
2071
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/utils.js"(exports$1, module) {
2017
2072
  var crypto = __require("crypto");
2018
2073
  var EXPOSURE_EVENT = "$experiment_started";
2019
2074
  var REQUEST_HEADERS = {
@@ -2048,22 +2103,55 @@ var require_utils2 = __commonJS({
2048
2103
  const traceFlags = "01";
2049
2104
  return `${version}-${traceId}-${parentId}-${traceFlags}`;
2050
2105
  }
2106
+ function lowercaseJson(obj, lowercaseKeys) {
2107
+ if (obj === null || obj === void 0) {
2108
+ return obj;
2109
+ } else if (typeof obj === "string") {
2110
+ return obj.toLowerCase();
2111
+ } else if (typeof obj === "object") {
2112
+ if (Array.isArray(obj)) {
2113
+ return obj.map((item) => lowercaseJson(item, lowercaseKeys));
2114
+ } else {
2115
+ return Object.fromEntries(
2116
+ Object.entries(obj).map(([k, v]) => [
2117
+ lowercaseKeys ? k.toLowerCase() : k,
2118
+ lowercaseJson(v, lowercaseKeys)
2119
+ ])
2120
+ );
2121
+ }
2122
+ } else {
2123
+ return obj;
2124
+ }
2125
+ }
2126
+ function lowercaseAllKeysAndValues(obj) {
2127
+ return lowercaseJson(obj, true);
2128
+ }
2129
+ function lowercaseLeafNodes(obj) {
2130
+ return lowercaseJson(obj, false);
2131
+ }
2051
2132
  module.exports = {
2052
2133
  EXPOSURE_EVENT,
2053
2134
  REQUEST_HEADERS,
2054
2135
  normalizedHash,
2055
2136
  prepareCommonQueryParams,
2056
- generateTraceparent
2137
+ generateTraceparent,
2138
+ lowercaseAllKeysAndValues,
2139
+ lowercaseLeafNodes
2057
2140
  };
2058
2141
  }
2059
2142
  });
2060
2143
 
2061
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/flags.js
2144
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/flags.js
2062
2145
  var require_flags = __commonJS({
2063
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/flags.js"(exports$1, module) {
2146
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/flags.js"(exports$1, module) {
2064
2147
  var https = __require("https");
2065
2148
  var packageInfo = require_package();
2066
- var { prepareCommonQueryParams, generateTraceparent, EXPOSURE_EVENT, REQUEST_HEADERS } = require_utils2();
2149
+ var {
2150
+ prepareCommonQueryParams,
2151
+ generateTraceparent,
2152
+ EXPOSURE_EVENT,
2153
+ REQUEST_HEADERS
2154
+ } = require_utils2();
2067
2155
  var FeatureFlagsProvider = class {
2068
2156
  /**
2069
2157
  * @param {Object} providerConfig - Configuration object with token, api_host, request_timeout_in_seconds
@@ -2086,7 +2174,10 @@ var require_flags = __commonJS({
2086
2174
  */
2087
2175
  async callFlagsEndpoint(additionalParams = null) {
2088
2176
  return new Promise((resolve, reject) => {
2089
- const commonParams = prepareCommonQueryParams(this.providerConfig.token, packageInfo.version);
2177
+ const commonParams = prepareCommonQueryParams(
2178
+ this.providerConfig.token,
2179
+ packageInfo.version
2180
+ );
2090
2181
  const params = new URLSearchParams(commonParams);
2091
2182
  if (additionalParams) {
2092
2183
  for (const [key, value] of Object.entries(additionalParams)) {
@@ -2101,8 +2192,8 @@ var require_flags = __commonJS({
2101
2192
  method: "GET",
2102
2193
  headers: {
2103
2194
  ...REQUEST_HEADERS,
2104
- "Authorization": "Basic " + Buffer.from(this.providerConfig.token + ":").toString("base64"),
2105
- "traceparent": generateTraceparent()
2195
+ Authorization: "Basic " + Buffer.from(this.providerConfig.token + ":").toString("base64"),
2196
+ traceparent: generateTraceparent()
2106
2197
  },
2107
2198
  timeout: this.providerConfig.request_timeout_in_seconds * 1e3
2108
2199
  };
@@ -2113,20 +2204,26 @@ var require_flags = __commonJS({
2113
2204
  });
2114
2205
  res.on("end", () => {
2115
2206
  if (res.statusCode !== 200) {
2116
- this.logger?.error(`HTTP ${res.statusCode} error calling flags endpoint: ${data}`);
2207
+ this.logger?.error(
2208
+ `HTTP ${res.statusCode} error calling flags endpoint: ${data}`
2209
+ );
2117
2210
  return reject(new Error(`HTTP ${res.statusCode}: ${data}`));
2118
2211
  }
2119
2212
  try {
2120
2213
  const result = JSON.parse(data);
2121
2214
  resolve(result);
2122
2215
  } catch (parseErr) {
2123
- this.logger?.error(`Failed to parse JSON response: ${parseErr.message}`);
2216
+ this.logger?.error(
2217
+ `Failed to parse JSON response: ${parseErr.message}`
2218
+ );
2124
2219
  reject(parseErr);
2125
2220
  }
2126
2221
  });
2127
2222
  });
2128
2223
  request.on("error", (err) => {
2129
- this.logger?.error(`Network error calling flags endpoint: ${err.message}`);
2224
+ this.logger?.error(
2225
+ `Network error calling flags endpoint: ${err.message}`
2226
+ );
2130
2227
  reject(err);
2131
2228
  });
2132
2229
  request.on("timeout", () => {
@@ -2148,14 +2245,16 @@ var require_flags = __commonJS({
2148
2245
  */
2149
2246
  trackExposureEvent(flagKey, selectedVariant, context, latencyMs = null) {
2150
2247
  if (!context.distinct_id) {
2151
- this.logger?.error("Cannot track exposure event without a distinct_id in the context");
2248
+ this.logger?.error(
2249
+ "Cannot track exposure event without a distinct_id in the context"
2250
+ );
2152
2251
  return;
2153
2252
  }
2154
2253
  const properties = {
2155
- "distinct_id": context.distinct_id,
2254
+ distinct_id: context.distinct_id,
2156
2255
  "Experiment name": flagKey,
2157
2256
  "Variant name": selectedVariant.variant_key,
2158
- "$experiment_type": "feature_flag",
2257
+ $experiment_type: "feature_flag",
2159
2258
  "Flag evaluation mode": this.evaluationMode
2160
2259
  };
2161
2260
  if (latencyMs !== null && latencyMs !== void 0) {
@@ -2172,7 +2271,9 @@ var require_flags = __commonJS({
2172
2271
  }
2173
2272
  this.tracker(EXPOSURE_EVENT, properties, (err) => {
2174
2273
  if (err) {
2175
- this.logger?.error(`[flags]Failed to track exposure event for flag '${flagKey}': ${err.message}`);
2274
+ this.logger?.error(
2275
+ `[flags]Failed to track exposure event for flag '${flagKey}': ${err.message}`
2276
+ );
2176
2277
  }
2177
2278
  });
2178
2279
  }
@@ -2181,11 +2282,392 @@ var require_flags = __commonJS({
2181
2282
  }
2182
2283
  });
2183
2284
 
2184
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/local_flags.js
2285
+ // ../../node_modules/.pnpm/json-logic-js@2.0.5/node_modules/json-logic-js/logic.js
2286
+ var require_logic = __commonJS({
2287
+ "../../node_modules/.pnpm/json-logic-js@2.0.5/node_modules/json-logic-js/logic.js"(exports$1, module) {
2288
+ (function(root, factory) {
2289
+ if (typeof define === "function" && define.amd) {
2290
+ define(factory);
2291
+ } else if (typeof exports$1 === "object") {
2292
+ module.exports = factory();
2293
+ } else {
2294
+ root.jsonLogic = factory();
2295
+ }
2296
+ })(exports$1, function() {
2297
+ if (!Array.isArray) {
2298
+ Array.isArray = function(arg) {
2299
+ return Object.prototype.toString.call(arg) === "[object Array]";
2300
+ };
2301
+ }
2302
+ function arrayUnique(array) {
2303
+ var a = [];
2304
+ for (var i = 0, l = array.length; i < l; i++) {
2305
+ if (a.indexOf(array[i]) === -1) {
2306
+ a.push(array[i]);
2307
+ }
2308
+ }
2309
+ return a;
2310
+ }
2311
+ var jsonLogic = {};
2312
+ var operations = {
2313
+ "==": function(a, b) {
2314
+ return a == b;
2315
+ },
2316
+ "===": function(a, b) {
2317
+ return a === b;
2318
+ },
2319
+ "!=": function(a, b) {
2320
+ return a != b;
2321
+ },
2322
+ "!==": function(a, b) {
2323
+ return a !== b;
2324
+ },
2325
+ ">": function(a, b) {
2326
+ return a > b;
2327
+ },
2328
+ ">=": function(a, b) {
2329
+ return a >= b;
2330
+ },
2331
+ "<": function(a, b, c) {
2332
+ return c === void 0 ? a < b : a < b && b < c;
2333
+ },
2334
+ "<=": function(a, b, c) {
2335
+ return c === void 0 ? a <= b : a <= b && b <= c;
2336
+ },
2337
+ "!!": function(a) {
2338
+ return jsonLogic.truthy(a);
2339
+ },
2340
+ "!": function(a) {
2341
+ return !jsonLogic.truthy(a);
2342
+ },
2343
+ "%": function(a, b) {
2344
+ return a % b;
2345
+ },
2346
+ "log": function(a) {
2347
+ console.log(a);
2348
+ return a;
2349
+ },
2350
+ "in": function(a, b) {
2351
+ if (!b || typeof b.indexOf === "undefined") return false;
2352
+ return b.indexOf(a) !== -1;
2353
+ },
2354
+ "cat": function() {
2355
+ return Array.prototype.join.call(arguments, "");
2356
+ },
2357
+ "substr": function(source, start, end) {
2358
+ if (end < 0) {
2359
+ var temp = String(source).substr(start);
2360
+ return temp.substr(0, temp.length + end);
2361
+ }
2362
+ return String(source).substr(start, end);
2363
+ },
2364
+ "+": function() {
2365
+ return Array.prototype.reduce.call(arguments, function(a, b) {
2366
+ return parseFloat(a, 10) + parseFloat(b, 10);
2367
+ }, 0);
2368
+ },
2369
+ "*": function() {
2370
+ return Array.prototype.reduce.call(arguments, function(a, b) {
2371
+ return parseFloat(a, 10) * parseFloat(b, 10);
2372
+ });
2373
+ },
2374
+ "-": function(a, b) {
2375
+ if (b === void 0) {
2376
+ return -a;
2377
+ } else {
2378
+ return a - b;
2379
+ }
2380
+ },
2381
+ "/": function(a, b) {
2382
+ return a / b;
2383
+ },
2384
+ "min": function() {
2385
+ return Math.min.apply(this, arguments);
2386
+ },
2387
+ "max": function() {
2388
+ return Math.max.apply(this, arguments);
2389
+ },
2390
+ "merge": function() {
2391
+ return Array.prototype.reduce.call(arguments, function(a, b) {
2392
+ return a.concat(b);
2393
+ }, []);
2394
+ },
2395
+ "var": function(a, b) {
2396
+ var not_found = b === void 0 ? null : b;
2397
+ var data = this;
2398
+ if (typeof a === "undefined" || a === "" || a === null) {
2399
+ return data;
2400
+ }
2401
+ var sub_props = String(a).split(".");
2402
+ for (var i = 0; i < sub_props.length; i++) {
2403
+ if (data === null || data === void 0) {
2404
+ return not_found;
2405
+ }
2406
+ data = data[sub_props[i]];
2407
+ if (data === void 0) {
2408
+ return not_found;
2409
+ }
2410
+ }
2411
+ return data;
2412
+ },
2413
+ "missing": function() {
2414
+ var missing = [];
2415
+ var keys = Array.isArray(arguments[0]) ? arguments[0] : arguments;
2416
+ for (var i = 0; i < keys.length; i++) {
2417
+ var key = keys[i];
2418
+ var value = jsonLogic.apply({ "var": key }, this);
2419
+ if (value === null || value === "") {
2420
+ missing.push(key);
2421
+ }
2422
+ }
2423
+ return missing;
2424
+ },
2425
+ "missing_some": function(need_count, options) {
2426
+ var are_missing = jsonLogic.apply({ "missing": options }, this);
2427
+ if (options.length - are_missing.length >= need_count) {
2428
+ return [];
2429
+ } else {
2430
+ return are_missing;
2431
+ }
2432
+ }
2433
+ };
2434
+ jsonLogic.is_logic = function(logic) {
2435
+ return typeof logic === "object" && // An object
2436
+ logic !== null && // but not null
2437
+ !Array.isArray(logic) && // and not an array
2438
+ Object.keys(logic).length === 1;
2439
+ };
2440
+ jsonLogic.truthy = function(value) {
2441
+ if (Array.isArray(value) && value.length === 0) {
2442
+ return false;
2443
+ }
2444
+ return !!value;
2445
+ };
2446
+ jsonLogic.get_operator = function(logic) {
2447
+ return Object.keys(logic)[0];
2448
+ };
2449
+ jsonLogic.get_values = function(logic) {
2450
+ return logic[jsonLogic.get_operator(logic)];
2451
+ };
2452
+ jsonLogic.apply = function(logic, data) {
2453
+ if (Array.isArray(logic)) {
2454
+ return logic.map(function(l) {
2455
+ return jsonLogic.apply(l, data);
2456
+ });
2457
+ }
2458
+ if (!jsonLogic.is_logic(logic)) {
2459
+ return logic;
2460
+ }
2461
+ var op = jsonLogic.get_operator(logic);
2462
+ var values = logic[op];
2463
+ var i;
2464
+ var current;
2465
+ var scopedLogic;
2466
+ var scopedData;
2467
+ var initial;
2468
+ if (!Array.isArray(values)) {
2469
+ values = [values];
2470
+ }
2471
+ if (op === "if" || op == "?:") {
2472
+ for (i = 0; i < values.length - 1; i += 2) {
2473
+ if (jsonLogic.truthy(jsonLogic.apply(values[i], data))) {
2474
+ return jsonLogic.apply(values[i + 1], data);
2475
+ }
2476
+ }
2477
+ if (values.length === i + 1) {
2478
+ return jsonLogic.apply(values[i], data);
2479
+ }
2480
+ return null;
2481
+ } else if (op === "and") {
2482
+ for (i = 0; i < values.length; i += 1) {
2483
+ current = jsonLogic.apply(values[i], data);
2484
+ if (!jsonLogic.truthy(current)) {
2485
+ return current;
2486
+ }
2487
+ }
2488
+ return current;
2489
+ } else if (op === "or") {
2490
+ for (i = 0; i < values.length; i += 1) {
2491
+ current = jsonLogic.apply(values[i], data);
2492
+ if (jsonLogic.truthy(current)) {
2493
+ return current;
2494
+ }
2495
+ }
2496
+ return current;
2497
+ } else if (op === "filter") {
2498
+ scopedData = jsonLogic.apply(values[0], data);
2499
+ scopedLogic = values[1];
2500
+ if (!Array.isArray(scopedData)) {
2501
+ return [];
2502
+ }
2503
+ return scopedData.filter(function(datum) {
2504
+ return jsonLogic.truthy(jsonLogic.apply(scopedLogic, datum));
2505
+ });
2506
+ } else if (op === "map") {
2507
+ scopedData = jsonLogic.apply(values[0], data);
2508
+ scopedLogic = values[1];
2509
+ if (!Array.isArray(scopedData)) {
2510
+ return [];
2511
+ }
2512
+ return scopedData.map(function(datum) {
2513
+ return jsonLogic.apply(scopedLogic, datum);
2514
+ });
2515
+ } else if (op === "reduce") {
2516
+ scopedData = jsonLogic.apply(values[0], data);
2517
+ scopedLogic = values[1];
2518
+ initial = typeof values[2] !== "undefined" ? jsonLogic.apply(values[2], data) : null;
2519
+ if (!Array.isArray(scopedData)) {
2520
+ return initial;
2521
+ }
2522
+ return scopedData.reduce(
2523
+ function(accumulator, current2) {
2524
+ return jsonLogic.apply(
2525
+ scopedLogic,
2526
+ { current: current2, accumulator }
2527
+ );
2528
+ },
2529
+ initial
2530
+ );
2531
+ } else if (op === "all") {
2532
+ scopedData = jsonLogic.apply(values[0], data);
2533
+ scopedLogic = values[1];
2534
+ if (!Array.isArray(scopedData) || !scopedData.length) {
2535
+ return false;
2536
+ }
2537
+ for (i = 0; i < scopedData.length; i += 1) {
2538
+ if (!jsonLogic.truthy(jsonLogic.apply(scopedLogic, scopedData[i]))) {
2539
+ return false;
2540
+ }
2541
+ }
2542
+ return true;
2543
+ } else if (op === "none") {
2544
+ scopedData = jsonLogic.apply(values[0], data);
2545
+ scopedLogic = values[1];
2546
+ if (!Array.isArray(scopedData) || !scopedData.length) {
2547
+ return true;
2548
+ }
2549
+ for (i = 0; i < scopedData.length; i += 1) {
2550
+ if (jsonLogic.truthy(jsonLogic.apply(scopedLogic, scopedData[i]))) {
2551
+ return false;
2552
+ }
2553
+ }
2554
+ return true;
2555
+ } else if (op === "some") {
2556
+ scopedData = jsonLogic.apply(values[0], data);
2557
+ scopedLogic = values[1];
2558
+ if (!Array.isArray(scopedData) || !scopedData.length) {
2559
+ return false;
2560
+ }
2561
+ for (i = 0; i < scopedData.length; i += 1) {
2562
+ if (jsonLogic.truthy(jsonLogic.apply(scopedLogic, scopedData[i]))) {
2563
+ return true;
2564
+ }
2565
+ }
2566
+ return false;
2567
+ }
2568
+ values = values.map(function(val) {
2569
+ return jsonLogic.apply(val, data);
2570
+ });
2571
+ if (operations.hasOwnProperty(op) && typeof operations[op] === "function") {
2572
+ return operations[op].apply(data, values);
2573
+ } else if (op.indexOf(".") > 0) {
2574
+ var sub_ops = String(op).split(".");
2575
+ var operation = operations;
2576
+ for (i = 0; i < sub_ops.length; i++) {
2577
+ if (!operation.hasOwnProperty(sub_ops[i])) {
2578
+ throw new Error("Unrecognized operation " + op + " (failed at " + sub_ops.slice(0, i + 1).join(".") + ")");
2579
+ }
2580
+ operation = operation[sub_ops[i]];
2581
+ }
2582
+ return operation.apply(data, values);
2583
+ }
2584
+ throw new Error("Unrecognized operation " + op);
2585
+ };
2586
+ jsonLogic.uses_data = function(logic) {
2587
+ var collection = [];
2588
+ if (jsonLogic.is_logic(logic)) {
2589
+ var op = jsonLogic.get_operator(logic);
2590
+ var values = logic[op];
2591
+ if (!Array.isArray(values)) {
2592
+ values = [values];
2593
+ }
2594
+ if (op === "var") {
2595
+ collection.push(values[0]);
2596
+ } else {
2597
+ values.forEach(function(val) {
2598
+ collection.push.apply(collection, jsonLogic.uses_data(val));
2599
+ });
2600
+ }
2601
+ }
2602
+ return arrayUnique(collection);
2603
+ };
2604
+ jsonLogic.add_operation = function(name, code) {
2605
+ operations[name] = code;
2606
+ };
2607
+ jsonLogic.rm_operation = function(name) {
2608
+ delete operations[name];
2609
+ };
2610
+ jsonLogic.rule_like = function(rule, pattern) {
2611
+ if (pattern === rule) {
2612
+ return true;
2613
+ }
2614
+ if (pattern === "@") {
2615
+ return true;
2616
+ }
2617
+ if (pattern === "number") {
2618
+ return typeof rule === "number";
2619
+ }
2620
+ if (pattern === "string") {
2621
+ return typeof rule === "string";
2622
+ }
2623
+ if (pattern === "array") {
2624
+ return Array.isArray(rule) && !jsonLogic.is_logic(rule);
2625
+ }
2626
+ if (jsonLogic.is_logic(pattern)) {
2627
+ if (jsonLogic.is_logic(rule)) {
2628
+ var pattern_op = jsonLogic.get_operator(pattern);
2629
+ var rule_op = jsonLogic.get_operator(rule);
2630
+ if (pattern_op === "@" || pattern_op === rule_op) {
2631
+ return jsonLogic.rule_like(
2632
+ jsonLogic.get_values(rule, false),
2633
+ jsonLogic.get_values(pattern, false)
2634
+ );
2635
+ }
2636
+ }
2637
+ return false;
2638
+ }
2639
+ if (Array.isArray(pattern)) {
2640
+ if (Array.isArray(rule)) {
2641
+ if (pattern.length !== rule.length) {
2642
+ return false;
2643
+ }
2644
+ for (var i = 0; i < pattern.length; i += 1) {
2645
+ if (!jsonLogic.rule_like(rule[i], pattern[i])) {
2646
+ return false;
2647
+ }
2648
+ }
2649
+ return true;
2650
+ } else {
2651
+ return false;
2652
+ }
2653
+ }
2654
+ return false;
2655
+ };
2656
+ return jsonLogic;
2657
+ });
2658
+ }
2659
+ });
2660
+
2661
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/local_flags.js
2185
2662
  var require_local_flags = __commonJS({
2186
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/local_flags.js"(exports$1, module) {
2663
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/local_flags.js"(exports$1, module) {
2187
2664
  var FeatureFlagsProvider = require_flags();
2188
- var { normalizedHash } = require_utils2();
2665
+ var {
2666
+ normalizedHash,
2667
+ lowercaseAllKeysAndValues,
2668
+ lowercaseLeafNodes
2669
+ } = require_utils2();
2670
+ var { apply } = require_logic();
2189
2671
  var LocalFeatureFlagsProvider = class extends FeatureFlagsProvider {
2190
2672
  /**
2191
2673
  * @param {string} token - Mixpanel project token
@@ -2224,12 +2706,16 @@ var require_local_flags = __commonJS({
2224
2706
  try {
2225
2707
  await this._fetchFlagDefinitions();
2226
2708
  } catch (err) {
2227
- this.logger?.error(`Error polling for flag definition: ${err.message}`);
2709
+ this.logger?.error(
2710
+ `Error polling for flag definition: ${err.message}`
2711
+ );
2228
2712
  }
2229
2713
  }, this.config.polling_interval_in_seconds * 1e3);
2230
2714
  }
2231
2715
  } catch (err) {
2232
- this.logger?.error(`Initial flag definitions fetch failed: ${err.message}`);
2716
+ this.logger?.error(
2717
+ `Initial flag definitions fetch failed: ${err.message}`
2718
+ );
2233
2719
  }
2234
2720
  }
2235
2721
  /**
@@ -2240,7 +2726,9 @@ var require_local_flags = __commonJS({
2240
2726
  clearInterval(this.pollingInterval);
2241
2727
  this.pollingInterval = null;
2242
2728
  } else {
2243
- this.logger?.warn("stopPollingForDefinitions called but polling was not active");
2729
+ this.logger?.warn(
2730
+ "stopPollingForDefinitions called but polling was not active"
2731
+ );
2244
2732
  }
2245
2733
  }
2246
2734
  /**
@@ -2265,7 +2753,12 @@ var require_local_flags = __commonJS({
2265
2753
  * @returns {*} The variant value
2266
2754
  */
2267
2755
  getVariantValue(flagKey, fallbackValue, context, reportExposure = true) {
2268
- const result = this.getVariant(flagKey, { variant_value: fallbackValue }, context, reportExposure);
2756
+ const result = this.getVariant(
2757
+ flagKey,
2758
+ { variant_value: fallbackValue },
2759
+ context,
2760
+ reportExposure
2761
+ );
2269
2762
  return result.variant_value;
2270
2763
  }
2271
2764
  /**
@@ -2296,7 +2789,12 @@ var require_local_flags = __commonJS({
2296
2789
  } else {
2297
2790
  const rollout = this._getAssignedRollout(flag, contextValue, context);
2298
2791
  if (rollout) {
2299
- selectedVariant = this._getAssignedVariant(flag, contextValue, flagKey, rollout);
2792
+ selectedVariant = this._getAssignedVariant(
2793
+ flag,
2794
+ contextValue,
2795
+ flagKey,
2796
+ rollout
2797
+ );
2300
2798
  }
2301
2799
  }
2302
2800
  if (selectedVariant) {
@@ -2391,7 +2889,10 @@ var require_local_flags = __commonJS({
2391
2889
  }
2392
2890
  _getAssignedVariant(flag, contextValue, flagKey, rollout) {
2393
2891
  if (rollout.variant_override) {
2394
- const variant = this._getMatchingVariant(rollout.variant_override.key, flag);
2892
+ const variant = this._getMatchingVariant(
2893
+ rollout.variant_override.key,
2894
+ flag
2895
+ );
2395
2896
  if (variant) {
2396
2897
  return { ...variant, is_qa_tester: false };
2397
2898
  }
@@ -2424,15 +2925,41 @@ var require_local_flags = __commonJS({
2424
2925
  is_qa_tester: false
2425
2926
  };
2426
2927
  }
2928
+ _extractRuntimeParameters(context) {
2929
+ const customProperties = context.custom_properties;
2930
+ if (!customProperties || typeof customProperties !== "object") {
2931
+ return null;
2932
+ }
2933
+ return lowercaseAllKeysAndValues(customProperties);
2934
+ }
2935
+ _isRuntimeRuleSatisfied(rollout, context) {
2936
+ try {
2937
+ return apply(
2938
+ lowercaseLeafNodes(rollout.runtime_evaluation_rule),
2939
+ this._extractRuntimeParameters(context)
2940
+ );
2941
+ } catch (error) {
2942
+ this.logger?.error(`Error evaluating runtime rule: ${error.message}`);
2943
+ return false;
2944
+ }
2945
+ }
2427
2946
  _isRuntimeEvaluationSatisfied(rollout, context) {
2428
- if (!rollout.runtime_evaluation_definition) {
2947
+ if (rollout.runtime_evaluation_rule) {
2948
+ return this._isRuntimeRuleSatisfied(rollout, context);
2949
+ } else if (rollout.runtime_evaluation_definition) {
2950
+ return this._isLegacyRuntimeEvaluationSatisfied(rollout, context);
2951
+ } else {
2429
2952
  return true;
2430
2953
  }
2431
- const customProperties = context.custom_properties;
2432
- if (!customProperties || typeof customProperties !== "object") {
2954
+ }
2955
+ _isLegacyRuntimeEvaluationSatisfied(rollout, context) {
2956
+ const customProperties = this._extractRuntimeParameters(context);
2957
+ if (!customProperties) {
2433
2958
  return false;
2434
2959
  }
2435
- for (const [key, expectedValue] of Object.entries(rollout.runtime_evaluation_definition)) {
2960
+ for (const [key, expectedValue] of Object.entries(
2961
+ rollout.runtime_evaluation_definition
2962
+ )) {
2436
2963
  if (!(key in customProperties)) {
2437
2964
  return false;
2438
2965
  }
@@ -2448,9 +2975,9 @@ var require_local_flags = __commonJS({
2448
2975
  }
2449
2976
  });
2450
2977
 
2451
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/remote_flags.js
2978
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/remote_flags.js
2452
2979
  var require_remote_flags = __commonJS({
2453
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/remote_flags.js"(exports$1, module) {
2980
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/remote_flags.js"(exports$1, module) {
2454
2981
  var FeatureFlagsProvider = require_flags();
2455
2982
  var RemoteFeatureFlagsProvider = class extends FeatureFlagsProvider {
2456
2983
  /**
@@ -2484,10 +3011,17 @@ var require_remote_flags = __commonJS({
2484
3011
  */
2485
3012
  async getVariantValue(flagKey, fallbackValue, context, reportExposure = true) {
2486
3013
  try {
2487
- const selectedVariant = await this.getVariant(flagKey, { variant_value: fallbackValue }, context, reportExposure);
3014
+ const selectedVariant = await this.getVariant(
3015
+ flagKey,
3016
+ { variant_value: fallbackValue },
3017
+ context,
3018
+ reportExposure
3019
+ );
2488
3020
  return selectedVariant.variant_value;
2489
3021
  } catch (err) {
2490
- this.logger?.error(`Failed to get variant value for flag '${flagKey}': ${err.message}`);
3022
+ this.logger?.error(
3023
+ `Failed to get variant value for flag '${flagKey}': ${err.message}`
3024
+ );
2491
3025
  return fallbackValue;
2492
3026
  }
2493
3027
  }
@@ -2516,7 +3050,9 @@ var require_remote_flags = __commonJS({
2516
3050
  }
2517
3051
  return selectedVariant;
2518
3052
  } catch (err) {
2519
- this.logger?.error(`Failed to get variant for flag '${flagKey}': ${err.message}`);
3053
+ this.logger?.error(
3054
+ `Failed to get variant for flag '${flagKey}': ${err.message}`
3055
+ );
2520
3056
  return fallbackVariant;
2521
3057
  }
2522
3058
  }
@@ -2533,7 +3069,9 @@ var require_remote_flags = __commonJS({
2533
3069
  const value = await this.getVariantValue(flagKey, false, context);
2534
3070
  return value === true;
2535
3071
  } catch (err) {
2536
- this.logger?.error(`Failed to check if flag '${flagKey}' is enabled: ${err.message}`);
3072
+ this.logger?.error(
3073
+ `Failed to check if flag '${flagKey}' is enabled: ${err.message}`
3074
+ );
2537
3075
  return false;
2538
3076
  }
2539
3077
  }
@@ -2572,9 +3110,9 @@ var require_remote_flags = __commonJS({
2572
3110
  }
2573
3111
  });
2574
3112
 
2575
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/index.js
3113
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/index.js
2576
3114
  var require_flags2 = __commonJS({
2577
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/flags/index.js"(exports$1, module) {
3115
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/flags/index.js"(exports$1, module) {
2578
3116
  var LocalFeatureFlagsProvider = require_local_flags();
2579
3117
  var RemoteFeatureFlagsProvider = require_remote_flags();
2580
3118
  module.exports = {
@@ -2584,9 +3122,9 @@ var require_flags2 = __commonJS({
2584
3122
  }
2585
3123
  });
2586
3124
 
2587
- // ../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/mixpanel-node.js
3125
+ // ../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/mixpanel-node.js
2588
3126
  var require_mixpanel_node = __commonJS({
2589
- "../../node_modules/.pnpm/mixpanel@0.19.1/node_modules/mixpanel/lib/mixpanel-node.js"(exports$1, module) {
3127
+ "../../node_modules/.pnpm/mixpanel@0.20.0/node_modules/mixpanel/lib/mixpanel-node.js"(exports$1, module) {
2590
3128
  var querystring = __require("querystring");
2591
3129
  var Buffer2 = __require("buffer").Buffer;
2592
3130
  var http = __require("http");
@@ -2597,7 +3135,10 @@ var require_mixpanel_node = __commonJS({
2597
3135
  var { async_all, ensure_timestamp, assert_logger } = require_utils();
2598
3136
  var { MixpanelGroups } = require_groups();
2599
3137
  var { MixpanelPeople } = require_people();
2600
- var { LocalFeatureFlagsProvider, RemoteFeatureFlagsProvider } = require_flags2();
3138
+ var {
3139
+ LocalFeatureFlagsProvider,
3140
+ RemoteFeatureFlagsProvider
3141
+ } = require_flags2();
2601
3142
  var DEFAULT_CONFIG = {
2602
3143
  test: false,
2603
3144
  debug: false,
@@ -2613,7 +3154,9 @@ var require_mixpanel_node = __commonJS({
2613
3154
  };
2614
3155
  var create_client = function(token, config) {
2615
3156
  if (!token) {
2616
- throw new Error("The Mixpanel Client needs a Mixpanel token: `init(token)`");
3157
+ throw new Error(
3158
+ "The Mixpanel Client needs a Mixpanel token: `init(token)`"
3159
+ );
2617
3160
  }
2618
3161
  const metrics = {
2619
3162
  token,
@@ -2627,9 +3170,11 @@ var require_mixpanel_node = __commonJS({
2627
3170
  https: new https.Agent({ keepAlive })
2628
3171
  };
2629
3172
  const proxyPath = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
2630
- const proxyAgent = proxyPath ? new HttpsProxyAgent(Object.assign(url.parse(proxyPath), {
2631
- keepAlive
2632
- })) : null;
3173
+ const proxyAgent = proxyPath ? new HttpsProxyAgent(
3174
+ Object.assign(url.parse(proxyPath), {
3175
+ keepAlive
3176
+ })
3177
+ ) : null;
2633
3178
  metrics.send_request = function(options, callback) {
2634
3179
  callback = callback || function() {
2635
3180
  };
@@ -2637,8 +3182,8 @@ var require_mixpanel_node = __commonJS({
2637
3182
  const endpoint = options.endpoint;
2638
3183
  const method = (options.method || "GET").toUpperCase();
2639
3184
  let query_params = {
2640
- "ip": metrics.config.geolocate ? 1 : 0,
2641
- "verbose": metrics.config.verbose ? 1 : 0
3185
+ ip: metrics.config.geolocate ? 1 : 0,
3186
+ verbose: metrics.config.verbose ? 1 : 0
2642
3187
  };
2643
3188
  const key = metrics.config.key;
2644
3189
  const secret = metrics.config.secret;
@@ -2671,7 +3216,9 @@ var require_mixpanel_node = __commonJS({
2671
3216
  } else if (key) {
2672
3217
  query_params.api_key = key;
2673
3218
  } else if (endpoint === "/import") {
2674
- throw new Error("The Mixpanel Client needs a Mixpanel API Secret when importing old events: `init(token, { secret: ... })`");
3219
+ throw new Error(
3220
+ "The Mixpanel Client needs a Mixpanel API Secret when importing old events: `init(token, { secret: ... })`"
3221
+ );
2675
3222
  }
2676
3223
  request_options.agent = proxyAgent || REQUEST_AGENTS[metrics.config.protocol];
2677
3224
  if (metrics.config.test) {
@@ -2679,20 +3226,22 @@ var require_mixpanel_node = __commonJS({
2679
3226
  }
2680
3227
  request_options.path = metrics.config.path + endpoint + "?" + querystring.stringify(query_params);
2681
3228
  request = request_lib.request(request_options, function(res) {
2682
- var data = "";
3229
+ let data = "";
2683
3230
  res.on("data", function(chunk2) {
2684
3231
  data += chunk2;
2685
3232
  });
2686
3233
  res.on("end", function() {
2687
- var e;
3234
+ let e;
2688
3235
  if (metrics.config.verbose) {
2689
3236
  try {
2690
- var result = JSON.parse(data);
3237
+ const result = JSON.parse(data);
2691
3238
  if (result.status != 1) {
2692
3239
  e = new Error("Mixpanel Server Error: " + result.error);
2693
3240
  }
2694
3241
  } catch (ex) {
2695
- e = new Error("Could not parse response from Mixpanel");
3242
+ e = new Error(
3243
+ "Could not parse response from Mixpanel " + ex.message
3244
+ );
2696
3245
  }
2697
3246
  } else {
2698
3247
  e = data !== "1" ? new Error("Mixpanel Server Error: " + data) : void 0;
@@ -2715,39 +3264,46 @@ var require_mixpanel_node = __commonJS({
2715
3264
  properties.token = metrics.token;
2716
3265
  properties.mp_lib = "node";
2717
3266
  properties.$lib_version = packageInfo.version;
2718
- var data = {
3267
+ const data = {
2719
3268
  event,
2720
3269
  properties
2721
3270
  };
2722
3271
  if (metrics.config.debug) {
2723
- metrics.config.logger.debug("Sending the following event to Mixpanel", { data });
3272
+ metrics.config.logger.debug("Sending the following event to Mixpanel", {
3273
+ data
3274
+ });
2724
3275
  }
2725
- metrics.send_request({ method: "GET", endpoint, data }, callback);
3276
+ metrics.send_request(
3277
+ { method: "GET", endpoint, data },
3278
+ callback
3279
+ );
2726
3280
  };
2727
- var chunk = function(arr, size) {
2728
- var chunks = [], i = 0, total = arr.length;
3281
+ const chunk = function(arr, size) {
3282
+ let chunks = [], i = 0, total = arr.length;
2729
3283
  while (i < total) {
2730
3284
  chunks.push(arr.slice(i, i += size));
2731
3285
  }
2732
3286
  return chunks;
2733
3287
  };
2734
- var send_batch_requests = function(options, callback) {
2735
- var event_list = options.event_list, endpoint = options.endpoint, max_batch_size = options.max_batch_size ? Math.min(MAX_BATCH_SIZE, options.max_batch_size) : MAX_BATCH_SIZE, max_concurrent_requests = options.max_concurrent_requests || options.max_batch_size > MAX_BATCH_SIZE && Math.ceil(options.max_batch_size / MAX_BATCH_SIZE), event_batches = chunk(event_list, max_batch_size), request_batches = max_concurrent_requests ? chunk(event_batches, max_concurrent_requests) : [event_batches], total_event_batches = event_batches.length, total_request_batches = request_batches.length;
3288
+ const send_batch_requests = function(options, callback) {
3289
+ const event_list = options.event_list, endpoint = options.endpoint, max_batch_size = options.max_batch_size ? Math.min(MAX_BATCH_SIZE, options.max_batch_size) : MAX_BATCH_SIZE, max_concurrent_requests = options.max_concurrent_requests || options.max_batch_size > MAX_BATCH_SIZE && Math.ceil(options.max_batch_size / MAX_BATCH_SIZE), event_batches = chunk(event_list, max_batch_size), request_batches = max_concurrent_requests ? chunk(event_batches, max_concurrent_requests) : [event_batches], total_event_batches = event_batches.length, total_request_batches = request_batches.length;
2736
3290
  function send_event_batch(batch, cb) {
2737
3291
  if (batch.length > 0) {
2738
3292
  batch = batch.map(function(event) {
2739
- event.properties;
2740
3293
  if (endpoint === "/import" || event.properties.time) {
2741
3294
  event.properties.time = ensure_timestamp(event.properties.time);
2742
3295
  }
2743
3296
  event.properties.token = event.properties.token || metrics.token;
2744
3297
  return event;
2745
3298
  });
2746
- metrics.send_request({ method: "POST", endpoint, data: batch }, cb);
3299
+ metrics.send_request(
3300
+ { method: "POST", endpoint, data: batch },
3301
+ cb
3302
+ );
2747
3303
  }
2748
3304
  }
2749
3305
  function send_next_request_batch(index) {
2750
- var request_batch = request_batches[index], cb = function(errors, results) {
3306
+ const request_batch = request_batches[index], cb = function(errors, results) {
2751
3307
  index += 1;
2752
3308
  if (index === total_request_batches) {
2753
3309
  callback && callback(errors, results);
@@ -2780,7 +3336,7 @@ var require_mixpanel_node = __commonJS({
2780
3336
  callback = options;
2781
3337
  options = {};
2782
3338
  }
2783
- var batch_options = {
3339
+ const batch_options = {
2784
3340
  event_list,
2785
3341
  endpoint: "/track",
2786
3342
  max_concurrent_requests: options.max_concurrent_requests,
@@ -2797,7 +3353,7 @@ var require_mixpanel_node = __commonJS({
2797
3353
  metrics.send_event_request("/import", event, properties, callback);
2798
3354
  };
2799
3355
  metrics.import_batch = function(event_list, options, callback) {
2800
- var batch_options;
3356
+ let batch_options;
2801
3357
  if (typeof options === "function" || !options) {
2802
3358
  callback = options;
2803
3359
  options = {};
@@ -2811,7 +3367,7 @@ var require_mixpanel_node = __commonJS({
2811
3367
  send_batch_requests(batch_options, callback);
2812
3368
  };
2813
3369
  metrics.alias = function(distinct_id, alias, callback) {
2814
- var properties = {
3370
+ const properties = {
2815
3371
  distinct_id,
2816
3372
  alias
2817
3373
  };