autotel-subscribers 41.0.3 → 41.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/amplitude.cjs +2 -2
  2. package/dist/amplitude.cjs.map +1 -1
  3. package/dist/amplitude.js +2 -2
  4. package/dist/architecture-snapshot.cjs +6 -6
  5. package/dist/architecture-snapshot.cjs.map +1 -1
  6. package/dist/architecture-snapshot.js +3 -3
  7. package/dist/architecture-snapshot.js.map +1 -1
  8. package/dist/{cjs-BS1fE_MP.js → cjs-Bef2t9Tr.js} +348 -109
  9. package/dist/cjs-Bef2t9Tr.js.map +1 -0
  10. package/dist/{cjs-CC1S3xV3.cjs → cjs-C2fugEI8.cjs} +169 -164
  11. package/dist/{cjs-CC1S3xV3.cjs.map → cjs-C2fugEI8.cjs.map} +1 -1
  12. package/dist/{cjs-BVWTUHeD.cjs → cjs-C5tev9Yr.cjs} +458 -219
  13. package/dist/cjs-C5tev9Yr.cjs.map +1 -0
  14. package/dist/{cjs-j3aHAiuq.js → cjs-CY69zXGd.js} +20 -15
  15. package/dist/{cjs-j3aHAiuq.js.map → cjs-CY69zXGd.js.map} +1 -1
  16. package/dist/factories.cjs +2 -2
  17. package/dist/factories.d.cts +1 -1
  18. package/dist/factories.d.ts +1 -1
  19. package/dist/factories.js +1 -1
  20. package/dist/file.cjs +2 -2
  21. package/dist/index.cjs +2 -2
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{index.node-T6N3xCyo.js → index.node-BF2WkODf.js} +368 -148
  26. package/dist/index.node-BF2WkODf.js.map +1 -0
  27. package/dist/{index.node-CVFSZNnN.cjs → index.node-DOkEUdYV.cjs} +369 -149
  28. package/dist/index.node-DOkEUdYV.cjs.map +1 -0
  29. package/dist/middleware.cjs +1 -1
  30. package/dist/{mixpanel-node-CTaHqgil.cjs → mixpanel-node-BVS2X-h7.cjs} +32 -31
  31. package/dist/{mixpanel-node-CTaHqgil.cjs.map → mixpanel-node-BVS2X-h7.cjs.map} +1 -1
  32. package/dist/{mixpanel-node-2RXHuOWK.js → mixpanel-node-BltEtoG6.js} +5 -4
  33. package/dist/{mixpanel-node-2RXHuOWK.js.map → mixpanel-node-BltEtoG6.js.map} +1 -1
  34. package/dist/mixpanel.cjs +2 -2
  35. package/dist/mixpanel.cjs.map +1 -1
  36. package/dist/mixpanel.js +2 -2
  37. package/dist/{posthog-DTpCMk3r.js → posthog-C9M1c_oG.js} +2 -2
  38. package/dist/{posthog-DTpCMk3r.js.map → posthog-C9M1c_oG.js.map} +1 -1
  39. package/dist/{posthog-DLBf2UJJ.d.ts → posthog-DCV5Arkw.d.ts} +217 -24
  40. package/dist/posthog-DCV5Arkw.d.ts.map +1 -0
  41. package/dist/{posthog-Duh9pZs7.d.cts → posthog-DRYlG5fG.d.cts} +217 -24
  42. package/dist/posthog-DRYlG5fG.d.cts.map +1 -0
  43. package/dist/{posthog-Bz9XTdX5.cjs → posthog-DZfoAW1q.cjs} +4 -4
  44. package/dist/{posthog-Bz9XTdX5.cjs.map → posthog-DZfoAW1q.cjs.map} +1 -1
  45. package/dist/posthog.cjs +2 -2
  46. package/dist/posthog.d.cts +1 -1
  47. package/dist/posthog.d.ts +1 -1
  48. package/dist/posthog.js +1 -1
  49. package/dist/{chunk-CiiB0FCw.js → rolldown-runtime-BHkdefai.js} +9 -2
  50. package/dist/{chunk-BIkA7V7q.cjs → rolldown-runtime-CfAboj1T.cjs} +8 -1
  51. package/dist/security.cjs +1 -1
  52. package/dist/segment.cjs +2 -2
  53. package/dist/segment.cjs.map +1 -1
  54. package/dist/segment.js +2 -2
  55. package/dist/slack.cjs +1 -1
  56. package/dist/{tslib.es6-Ck6tgf4J.cjs → tslib.es6-02HJIdSd.cjs} +4 -4
  57. package/dist/{tslib.es6-Ck6tgf4J.cjs.map → tslib.es6-02HJIdSd.cjs.map} +1 -1
  58. package/dist/{tslib.es6-13Ha9x3r.js → tslib.es6-Dvm0j0am.js} +2 -2
  59. package/dist/{tslib.es6-13Ha9x3r.js.map → tslib.es6-Dvm0j0am.js.map} +1 -1
  60. package/dist/webhook.cjs +1 -1
  61. package/package.json +15 -15
  62. package/dist/cjs-BS1fE_MP.js.map +0 -1
  63. package/dist/cjs-BVWTUHeD.cjs.map +0 -1
  64. package/dist/index.node-CVFSZNnN.cjs.map +0 -1
  65. package/dist/index.node-T6N3xCyo.js.map +0 -1
  66. package/dist/posthog-DLBf2UJJ.d.ts.map +0 -1
  67. package/dist/posthog-Duh9pZs7.d.cts.map +0 -1
@@ -3,7 +3,7 @@ import { createReadStream } from "node:fs";
3
3
  import { createInterface } from "node:readline";
4
4
  import { AsyncLocalStorage } from "node:async_hooks";
5
5
 
6
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
6
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
7
7
  function createModulerModifier() {
8
8
  const getModuleFromFileName = createGetModuleFromFilename();
9
9
  return async (frames) => {
@@ -34,7 +34,7 @@ function normalizeWindowsPath(path) {
34
34
  }
35
35
 
36
36
  //#endregion
37
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/featureFlagUtils.mjs
37
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/featureFlagUtils.mjs
38
38
  const normalizeFlagsResponse = (flagsResponse) => {
39
39
  if ("flags" in flagsResponse) {
40
40
  const featureFlags = getFlagValuesFromFlags(flagsResponse.flags);
@@ -93,7 +93,7 @@ const parsePayload = (response) => {
93
93
  };
94
94
 
95
95
  //#endregion
96
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/types.mjs
96
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/types.mjs
97
97
  var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProperty) {
98
98
  PostHogPersistedProperty["AnonymousId"] = "anonymous_id";
99
99
  PostHogPersistedProperty["DistinctId"] = "distinct_id";
@@ -118,6 +118,7 @@ var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProp
118
118
  PostHogPersistedProperty["InstalledAppBuild"] = "installed_app_build";
119
119
  PostHogPersistedProperty["InstalledAppVersion"] = "installed_app_version";
120
120
  PostHogPersistedProperty["SessionReplay"] = "session_replay";
121
+ PostHogPersistedProperty["SessionReplayEventTriggerActivatedSession"] = "session_replay_event_trigger_activated_session";
121
122
  PostHogPersistedProperty["SurveyLastSeenDate"] = "survey_last_seen_date";
122
123
  PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
123
124
  PostHogPersistedProperty["Surveys"] = "surveys";
@@ -128,7 +129,7 @@ var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProp
128
129
  }({});
129
130
 
130
131
  //#endregion
131
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/gzip.mjs
132
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/gzip.mjs
132
133
  function isGzipSupported() {
133
134
  return "CompressionStream" in globalThis && "TextEncoder" in globalThis && "Response" in globalThis && "function" == typeof Response.prototype.blob;
134
135
  }
@@ -191,7 +192,7 @@ async function gzipCompress(input, isDebug = true, options) {
191
192
  }
192
193
 
193
194
  //#endregion
194
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/bot-detection.mjs
195
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/bot-detection.mjs
195
196
  const DEFAULT_BLOCKED_UA_STRS = [
196
197
  "amazonbot",
197
198
  "amazonproductbot",
@@ -281,7 +282,28 @@ const isBlockedUA = function(ua, customBlockedUserAgents = []) {
281
282
  };
282
283
 
283
284
  //#endregion
284
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/type-utils.mjs
285
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/string-utils.mjs
286
+ function safeJsonStringify(value) {
287
+ const ancestors = [];
288
+ return JSON.stringify(value, function(_key, replacementValue) {
289
+ if ("bigint" == typeof replacementValue) return replacementValue.toString();
290
+ if ("function" == typeof replacementValue || "symbol" == typeof replacementValue) return;
291
+ if (replacementValue instanceof Error) return {
292
+ name: replacementValue.name,
293
+ message: replacementValue.message,
294
+ stack: replacementValue.stack
295
+ };
296
+ if (replacementValue && "object" == typeof replacementValue) {
297
+ while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop();
298
+ if (ancestors.includes(replacementValue)) return "[Circular]";
299
+ ancestors.push(replacementValue);
300
+ }
301
+ return replacementValue;
302
+ }) ?? "null";
303
+ }
304
+
305
+ //#endregion
306
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/type-utils.mjs
285
307
  const nativeIsArray = Array.isArray;
286
308
  const ObjProto = Object.prototype;
287
309
  const type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
@@ -316,7 +338,7 @@ function isInstanceOf(candidate, base) {
316
338
  }
317
339
 
318
340
  //#endregion
319
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/number-utils.mjs
341
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/number-utils.mjs
320
342
  function clampToRange(value, min, max, logger, fallbackValue) {
321
343
  if (min > max) {
322
344
  logger.warn("min cannot be greater than max.");
@@ -335,7 +357,7 @@ function clampToRange(value, min, max, logger, fallbackValue) {
335
357
  }
336
358
 
337
359
  //#endregion
338
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
360
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
339
361
  const ONE_DAY_IN_MS = 864e5;
340
362
  var BucketedRateLimiter = class {
341
363
  constructor(options) {
@@ -377,7 +399,7 @@ var BucketedRateLimiter = class {
377
399
  };
378
400
 
379
401
  //#endregion
380
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
402
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/vendor/uuidv7.mjs
381
403
  /*! For license information please see uuidv7.mjs.LICENSE.txt */
382
404
  /**
383
405
  * uuidv7: An experimental implementation of the proposed UUID Version 7
@@ -396,7 +418,7 @@ var UUID = class UUID {
396
418
  }
397
419
  static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
398
420
  if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 0xffffffffffff || randA > 4095 || randBHi > 1073741823 || randBLo > 4294967295) throw new RangeError("invalid field value");
399
- const bytes = new Uint8Array(16);
421
+ const bytes = /* @__PURE__ */ new Uint8Array(16);
400
422
  bytes[0] = unixTsMs / 2 ** 40;
401
423
  bytes[1] = unixTsMs / 2 ** 32;
402
424
  bytes[2] = unixTsMs / 2 ** 24;
@@ -433,7 +455,7 @@ var UUID = class UUID {
433
455
  default: break;
434
456
  }
435
457
  if (hex) {
436
- const inner = new Uint8Array(16);
458
+ const inner = /* @__PURE__ */ new Uint8Array(16);
437
459
  for (let i = 0; i < 16; i += 4) {
438
460
  const n = parseInt(hex.substring(2 * i, 2 * i + 8), 16);
439
461
  inner[i + 0] = n >>> 24;
@@ -544,35 +566,47 @@ const uuidv7 = () => uuidv7obj().toString();
544
566
  const uuidv7obj = () => (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
545
567
 
546
568
  //#endregion
547
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/promise-queue.mjs
569
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/promise-queue.mjs
548
570
  var PromiseQueue = class {
549
571
  add(promise) {
550
572
  const promiseUUID = uuidv7();
551
- this.promiseByIds[promiseUUID] = promise;
573
+ const id = ++this.nextId;
574
+ this.promiseByIds[promiseUUID] = {
575
+ id,
576
+ promise
577
+ };
552
578
  promise.catch(() => {}).finally(() => {
553
579
  delete this.promiseByIds[promiseUUID];
554
580
  });
555
581
  return promise;
556
582
  }
557
583
  async join() {
558
- let promises = Object.values(this.promiseByIds);
584
+ let promises = Object.values(this.promiseByIds).map((item) => item.promise);
559
585
  let length = promises.length;
560
586
  while (length > 0) {
561
587
  await Promise.all(promises);
562
- promises = Object.values(this.promiseByIds);
588
+ promises = Object.values(this.promiseByIds).map((item) => item.promise);
563
589
  length = promises.length;
564
590
  }
565
591
  }
592
+ getPromises(ignoredPromises = [], maxId = this.nextId) {
593
+ const ignoredPromiseSet = new Set(ignoredPromises);
594
+ return Object.values(this.promiseByIds).filter((item) => item.id <= maxId && !ignoredPromiseSet.has(item.promise)).map((item) => item.promise);
595
+ }
596
+ get maxId() {
597
+ return this.nextId;
598
+ }
566
599
  get length() {
567
600
  return Object.keys(this.promiseByIds).length;
568
601
  }
569
602
  constructor() {
570
603
  this.promiseByIds = {};
604
+ this.nextId = 0;
571
605
  }
572
606
  };
573
607
 
574
608
  //#endregion
575
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/logger.mjs
609
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/logger.mjs
576
610
  function createConsole(consoleLike = console) {
577
611
  return {
578
612
  log: consoleLike.log.bind(consoleLike),
@@ -613,7 +647,7 @@ function createLogger(prefix, maybeCall = passThrough) {
613
647
  }
614
648
 
615
649
  //#endregion
616
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
650
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
617
651
  const MOBILE = "Mobile";
618
652
  const IOS = "iOS";
619
653
  const ANDROID = "Android";
@@ -652,18 +686,22 @@ const osMatchers = [
652
686
  if (new RegExp(MOBILE).test(user_agent) && !/IEMobile\b/.test(user_agent)) return ["Windows Mobile", ""];
653
687
  const match = /Windows NT ([0-9.]+)/i.exec(user_agent);
654
688
  if (match && match[1]) {
655
- let osVersion = windowsVersionMap[match[1]] || "";
689
+ const version = match[1];
690
+ let osVersion = windowsVersionMap[version] || "";
656
691
  if (/arm/i.test(user_agent)) osVersion = "RT";
657
692
  return [WINDOWS, osVersion];
658
693
  }
659
694
  return [WINDOWS, ""];
660
695
  }],
661
696
  [/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/, (match) => {
662
- if (match && match[3]) return [IOS, [
663
- match[3],
664
- match[4],
665
- match[5] || "0"
666
- ].join(".")];
697
+ if (match && match[3]) {
698
+ const versionParts = [
699
+ match[3],
700
+ match[4],
701
+ match[5] || "0"
702
+ ];
703
+ return [IOS, versionParts.join(".")];
704
+ }
667
705
  return [IOS, ""];
668
706
  }],
669
707
  [/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i, (match) => {
@@ -672,11 +710,14 @@ const osMatchers = [
672
710
  return ["watchOS", version];
673
711
  }],
674
712
  [/* @__PURE__ */ new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)", "i"), (match) => {
675
- if (match && match[2]) return [ANDROID, [
676
- match[2],
677
- match[3],
678
- match[4] || "0"
679
- ].join(".")];
713
+ if (match && match[2]) {
714
+ const versionParts = [
715
+ match[2],
716
+ match[3],
717
+ match[4] || "0"
718
+ ];
719
+ return [ANDROID, versionParts.join(".")];
720
+ }
680
721
  return [ANDROID, ""];
681
722
  }],
682
723
  [/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i, (match) => {
@@ -694,8 +735,15 @@ const osMatchers = [
694
735
  ];
695
736
 
696
737
  //#endregion
697
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/utils/index.mjs
738
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/utils/index.mjs
698
739
  const STRING_FORMAT = "utf8";
740
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
741
+ function isValidUUID(value) {
742
+ return "string" == typeof value && UUID_REGEX.test(value);
743
+ }
744
+ function getEventUuid(uuid, generateUuid) {
745
+ return isValidUUID(uuid) ? uuid : generateUuid();
746
+ }
699
747
  function removeTrailingSlash(url) {
700
748
  return url?.replace(/\/+$/, "");
701
749
  }
@@ -732,7 +780,7 @@ function allSettled(promises) {
732
780
  }
733
781
 
734
782
  //#endregion
735
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/logs/logs-utils.mjs
783
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/logs/logs-utils.mjs
736
784
  const OTLP_SEVERITY_MAP = {
737
785
  trace: {
738
786
  text: "TRACE",
@@ -762,7 +810,7 @@ const OTLP_SEVERITY_MAP = {
762
810
  const DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
763
811
 
764
812
  //#endregion
765
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/eventemitter.mjs
813
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/eventemitter.mjs
766
814
  var SimpleEventEmitter = class {
767
815
  constructor() {
768
816
  this.events = {};
@@ -782,7 +830,7 @@ var SimpleEventEmitter = class {
782
830
  };
783
831
 
784
832
  //#endregion
785
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
833
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
786
834
  let parsedStackResults;
787
835
  let lastKeysCount;
788
836
  let cachedFilenameChunkIds;
@@ -814,7 +862,7 @@ function getFilenameToChunkIdMap(stackParser) {
814
862
  }
815
863
 
816
864
  //#endregion
817
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
865
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
818
866
  const MAX_CAUSE_RECURSION = 4;
819
867
  var ErrorPropertiesBuilder = class {
820
868
  constructor(coercers, stackParser, modifiers = []) {
@@ -919,7 +967,7 @@ var ErrorPropertiesBuilder = class {
919
967
  };
920
968
 
921
969
  //#endregion
922
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
970
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
923
971
  const UNKNOWN_FUNCTION = "?";
924
972
  function createFrame(platform, filename, func, lineno, colno) {
925
973
  const frame = {
@@ -934,7 +982,7 @@ function createFrame(platform, filename, func, lineno, colno) {
934
982
  }
935
983
 
936
984
  //#endregion
937
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
985
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
938
986
  const extractSafariExtensionDetails = (func, filename) => {
939
987
  const isSafariExtension = -1 !== func.indexOf("safari-extension");
940
988
  const isSafariWebExtension = -1 !== func.indexOf("safari-web-extension");
@@ -942,7 +990,7 @@ const extractSafariExtensionDetails = (func, filename) => {
942
990
  };
943
991
 
944
992
  //#endregion
945
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
993
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
946
994
  const chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
947
995
  const chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
948
996
  const chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
@@ -968,7 +1016,7 @@ const chromeStackLineParser = (line, platform) => {
968
1016
  };
969
1017
 
970
1018
  //#endregion
971
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
1019
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
972
1020
  const geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
973
1021
  const geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
974
1022
  const geckoStackLineParser = (line, platform) => {
@@ -991,7 +1039,7 @@ const geckoStackLineParser = (line, platform) => {
991
1039
  };
992
1040
 
993
1041
  //#endregion
994
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
1042
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
995
1043
  const FILENAME_MATCH = /^\s*[-]{4,}$/;
996
1044
  const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
997
1045
  const nodeStackLineParser = (line, platform) => {
@@ -1056,7 +1104,7 @@ function _parseIntOrUndefined(input) {
1056
1104
  }
1057
1105
 
1058
1106
  //#endregion
1059
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
1107
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
1060
1108
  const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
1061
1109
  const STACKTRACE_FRAME_LIMIT = 50;
1062
1110
  function reverseAndStripFrames(stack) {
@@ -1099,7 +1147,7 @@ function createStackParser(platform, ...parsers) {
1099
1147
  }
1100
1148
 
1101
1149
  //#endregion
1102
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
1150
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
1103
1151
  var ErrorCoercer = class {
1104
1152
  match(err) {
1105
1153
  return isPlainError(err);
@@ -1127,7 +1175,7 @@ var ErrorCoercer = class {
1127
1175
  };
1128
1176
 
1129
1177
  //#endregion
1130
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
1178
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
1131
1179
  const ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
1132
1180
  var StringCoercer = class {
1133
1181
  match(input) {
@@ -1155,7 +1203,7 @@ var StringCoercer = class {
1155
1203
  };
1156
1204
 
1157
1205
  //#endregion
1158
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/types.mjs
1206
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/types.mjs
1159
1207
  const severityLevels = [
1160
1208
  "fatal",
1161
1209
  "error",
@@ -1166,7 +1214,7 @@ const severityLevels = [
1166
1214
  ];
1167
1215
 
1168
1216
  //#endregion
1169
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
1217
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
1170
1218
  function extractExceptionKeysForMessage(err, maxLength = 40) {
1171
1219
  const keys = Object.keys(err);
1172
1220
  keys.sort();
@@ -1182,7 +1230,7 @@ function extractExceptionKeysForMessage(err, maxLength = 40) {
1182
1230
  }
1183
1231
 
1184
1232
  //#endregion
1185
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
1233
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
1186
1234
  var ObjectCoercer = class {
1187
1235
  match(candidate) {
1188
1236
  return "object" == typeof candidate && null !== candidate;
@@ -1232,7 +1280,7 @@ var ObjectCoercer = class {
1232
1280
  };
1233
1281
 
1234
1282
  //#endregion
1235
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
1283
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
1236
1284
  var EventCoercer = class {
1237
1285
  match(err) {
1238
1286
  return isEvent(err);
@@ -1249,7 +1297,7 @@ var EventCoercer = class {
1249
1297
  };
1250
1298
 
1251
1299
  //#endregion
1252
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
1300
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
1253
1301
  var PrimitiveCoercer = class {
1254
1302
  match(candidate) {
1255
1303
  return isPrimitive(candidate);
@@ -1265,7 +1313,7 @@ var PrimitiveCoercer = class {
1265
1313
  };
1266
1314
 
1267
1315
  //#endregion
1268
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/utils.mjs
1316
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/utils.mjs
1269
1317
  var ReduceableCache = class {
1270
1318
  constructor(_maxSize) {
1271
1319
  this._maxSize = _maxSize;
@@ -1290,15 +1338,15 @@ var ReduceableCache = class {
1290
1338
  };
1291
1339
 
1292
1340
  //#endregion
1293
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
1341
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
1294
1342
  const EXCEPTION_STEP_INTERNAL_FIELDS = {
1295
1343
  MESSAGE: "$message",
1296
1344
  TIMESTAMP: "$timestamp"
1297
1345
  };
1298
- const RESERVED_EXCEPTION_STEP_KEYS = new Set([EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE, EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP]);
1346
+ const RESERVED_EXCEPTION_STEP_KEYS = /* @__PURE__ */ new Set([EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE, EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP]);
1299
1347
 
1300
1348
  //#endregion
1301
- //#region ../../node_modules/.pnpm/@posthog+core@1.30.10/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
1349
+ //#region ../../node_modules/.pnpm/@posthog+core@1.39.6/node_modules/@posthog/core/dist/posthog-core-stateless.mjs
1302
1350
  var PostHogFetchHttpError = class extends Error {
1303
1351
  constructor(response, reqByteLength) {
1304
1352
  super("HTTP error while fetching PostHog: status=" + response.status + ", reqByteLength=" + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = "PostHogFetchHttpError";
@@ -1318,6 +1366,9 @@ var PostHogFetchNetworkError = class extends Error {
1318
1366
  super("Network error while fetching PostHog", error instanceof Error ? { cause: error } : {}), this.error = error, this.name = "PostHogFetchNetworkError";
1319
1367
  }
1320
1368
  };
1369
+ const applyCallerFeatureFlagOverrides = (target, callerProperties) => {
1370
+ for (const key of Object.keys(callerProperties)) if (key.startsWith("$feature/") || "$active_feature_flags" === key) target[key] = callerProperties[key];
1371
+ };
1321
1372
  async function logFlushError(err) {
1322
1373
  if (err instanceof PostHogFetchHttpError) {
1323
1374
  let text = "";
@@ -1334,9 +1385,22 @@ function isPostHogFetchError(err) {
1334
1385
  function isPostHogFetchNetworkError(err) {
1335
1386
  return err instanceof PostHogFetchNetworkError;
1336
1387
  }
1388
+ function isRetryableFlagsFetchError(err) {
1389
+ if (err instanceof PostHogFetchHttpError) return 502 === err.status || 504 === err.status;
1390
+ if (!(err instanceof PostHogFetchNetworkError)) return false;
1391
+ const cause = err.error;
1392
+ return "ECONNREFUSED" !== (cause?.code ?? cause?.cause?.code);
1393
+ }
1337
1394
  function isPostHogFetchContentTooLargeError(err) {
1338
1395
  return "object" == typeof err && err instanceof PostHogFetchHttpError && 413 === err.status;
1339
1396
  }
1397
+ function isPostHogFetchRetryableError(err) {
1398
+ if (err instanceof PostHogFetchHttpError) return 408 === err.status || 429 === err.status || err.status >= 500;
1399
+ return isPostHogFetchNetworkError(err);
1400
+ }
1401
+ function isPostHogEventProperties(value) {
1402
+ return null !== value && "object" == typeof value && !Array.isArray(value);
1403
+ }
1340
1404
  var PostHogCoreStateless = class {
1341
1405
  getErrorPropertiesBuilder() {
1342
1406
  if (!this._errorPropertiesBuilder) this._errorPropertiesBuilder = this.createErrorPropertiesBuilder();
@@ -1352,6 +1416,7 @@ var PostHogCoreStateless = class {
1352
1416
  }
1353
1417
  constructor(apiKey, options = {}) {
1354
1418
  this.flushPromise = null;
1419
+ this.flushPromises = /* @__PURE__ */ new Set();
1355
1420
  this.shutdownPromise = null;
1356
1421
  this.promiseQueue = new PromiseQueue();
1357
1422
  this._events = new SimpleEventEmitter();
@@ -1373,10 +1438,11 @@ var PostHogCoreStateless = class {
1373
1438
  this._retryOptions = {
1374
1439
  retryCount: options.fetchRetryCount ?? 3,
1375
1440
  retryDelay: options.fetchRetryDelay ?? 3e3,
1376
- retryCheck: isPostHogFetchError
1441
+ retryCheck: isPostHogFetchRetryableError
1377
1442
  };
1378
1443
  this.requestTimeout = options.requestTimeout ?? 1e4;
1379
1444
  this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3e3;
1445
+ this.featureFlagsRequestMaxRetries = options.featureFlagsRequestMaxRetries ?? 1;
1380
1446
  this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3e3;
1381
1447
  this.disableGeoip = options.disableGeoip ?? true;
1382
1448
  this.disabled = (options.disabled ?? false) || missingApiKey;
@@ -1434,13 +1500,16 @@ var PostHogCoreStateless = class {
1434
1500
  return this.disabled;
1435
1501
  }
1436
1502
  buildPayload(payload) {
1503
+ const userProperties = payload.properties || {};
1504
+ const properties = {
1505
+ ...userProperties,
1506
+ ...this.getCommonEventProperties()
1507
+ };
1508
+ applyCallerFeatureFlagOverrides(properties, userProperties);
1437
1509
  return {
1438
1510
  distinct_id: payload.distinct_id,
1439
1511
  event: payload.event,
1440
- properties: {
1441
- ...payload.properties || {},
1442
- ...this.getCommonEventProperties()
1443
- }
1512
+ properties
1444
1513
  };
1445
1514
  }
1446
1515
  addPendingPromise(promise) {
@@ -1523,6 +1592,19 @@ var PostHogCoreStateless = class {
1523
1592
  this.enqueue("capture", payload, options);
1524
1593
  });
1525
1594
  }
1595
+ async groupIdentifyStatelessImmediate(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
1596
+ const payload = this.buildPayload({
1597
+ distinct_id: distinctId || `$${groupType}_${groupKey}`,
1598
+ event: "$groupidentify",
1599
+ properties: {
1600
+ $group_type: groupType,
1601
+ $group_key: groupKey,
1602
+ $group_set: groupProperties || {},
1603
+ ...eventProperties || {}
1604
+ }
1605
+ });
1606
+ await this.sendImmediate("capture", payload, options);
1607
+ }
1526
1608
  async getRemoteConfig() {
1527
1609
  await this._initPromise;
1528
1610
  let host = this.host;
@@ -1564,7 +1646,10 @@ var PostHogCoreStateless = class {
1564
1646
  body: JSON.stringify(requestData)
1565
1647
  };
1566
1648
  this._logger.info("Flags URL", url);
1567
- return this.fetchWithRetry(url, fetchOptions, { retryCount: 0 }, this.featureFlagsRequestTimeoutMs).then((response) => response.json()).then((response) => ({
1649
+ return this.fetchWithRetry(url, fetchOptions, {
1650
+ retryCount: this.featureFlagsRequestMaxRetries,
1651
+ retryCheck: isRetryableFlagsFetchError
1652
+ }, this.featureFlagsRequestTimeoutMs).then((response) => response.json()).then((response) => ({
1568
1653
  success: true,
1569
1654
  response: normalizeFlagsResponse(response)
1570
1655
  })).catch((error) => {
@@ -1643,8 +1728,7 @@ var PostHogCoreStateless = class {
1643
1728
  }
1644
1729
  async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
1645
1730
  await this._initPromise;
1646
- const extraPayload = {};
1647
- if (disableGeoip ?? this.disableGeoip) extraPayload["geoip_disable"] = true;
1731
+ const extraPayload = { geoip_disable: disableGeoip ?? this.disableGeoip };
1648
1732
  if (flagKeysToEvaluate) extraPayload["flag_keys_to_evaluate"] = flagKeysToEvaluate;
1649
1733
  const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
1650
1734
  if (!result.success) return;
@@ -1722,9 +1806,10 @@ var PostHogCoreStateless = class {
1722
1806
  enqueue(type, _message, options) {
1723
1807
  this.wrap(() => {
1724
1808
  if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
1725
- let message = this.prepareMessage(type, _message, options);
1809
+ let message = this.prepareMessage(_message, options);
1726
1810
  message = this.processBeforeEnqueue(message);
1727
1811
  if (null === message) return;
1812
+ message = this.normalizeMessage(message);
1728
1813
  const queue = this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || [];
1729
1814
  if (queue.length >= this.maxQueueSize) {
1730
1815
  queue.shift();
@@ -1741,16 +1826,17 @@ var PostHogCoreStateless = class {
1741
1826
  if (this.disabled) return void this._logger.warn("The client is disabled");
1742
1827
  if (!this._isInitialized) await this._initPromise;
1743
1828
  if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
1744
- let message = this.prepareMessage(type, _message, options);
1829
+ let message = this.prepareMessage(_message, options);
1745
1830
  message = this.processBeforeEnqueue(message);
1746
1831
  if (null === message) return;
1832
+ message = this.normalizeMessage(message);
1747
1833
  const data = {
1748
1834
  api_key: this.apiKey,
1749
1835
  batch: [message],
1750
1836
  sent_at: currentISOTime()
1751
1837
  };
1752
1838
  if (this.historicalMigration) data.historical_migration = true;
1753
- const payload = JSON.stringify(data);
1839
+ const payload = safeJsonStringify(data);
1754
1840
  const url = `${this.host}/batch/`;
1755
1841
  const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
1756
1842
  const fetchOptions = {
@@ -1768,18 +1854,30 @@ var PostHogCoreStateless = class {
1768
1854
  this._events.emit("error", err);
1769
1855
  }
1770
1856
  }
1771
- prepareMessage(type, _message, options) {
1857
+ normalizeMessage(message) {
1858
+ const { type: _type, library, library_version, ...sanitizedMessage } = message;
1859
+ let properties = isPostHogEventProperties(sanitizedMessage.properties) ? sanitizedMessage.properties : void 0;
1860
+ if (void 0 !== library && properties?.$lib === void 0) properties = {
1861
+ ...properties || {},
1862
+ $lib: library
1863
+ };
1864
+ if (void 0 !== library_version && properties?.$lib_version === void 0) properties = {
1865
+ ...properties || {},
1866
+ $lib_version: library_version
1867
+ };
1868
+ if (properties) sanitizedMessage.properties = properties;
1869
+ sanitizedMessage.uuid = getEventUuid(sanitizedMessage.uuid, uuidv7);
1870
+ return sanitizedMessage;
1871
+ }
1872
+ prepareMessage(_message, options) {
1772
1873
  const message = {
1773
1874
  ..._message,
1774
- type,
1775
- library: this.getLibraryId(),
1776
- library_version: this.getLibraryVersion(),
1777
1875
  timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
1778
- uuid: options?.uuid ? options.uuid : uuidv7()
1876
+ uuid: getEventUuid(options?.uuid, uuidv7)
1779
1877
  };
1780
1878
  if (options?.disableGeoip ?? this.disableGeoip) {
1781
- if (!message.properties) message.properties = {};
1782
- message["properties"]["$geoip_disable"] = true;
1879
+ if (!isPostHogEventProperties(message.properties)) message.properties = {};
1880
+ message.properties["$geoip_disable"] = true;
1783
1881
  }
1784
1882
  if (message.distinctId) {
1785
1883
  message.distinct_id = message.distinctId;
@@ -1798,12 +1896,35 @@ var PostHogCoreStateless = class {
1798
1896
  await logFlushError(err);
1799
1897
  });
1800
1898
  }
1801
- async flush() {
1802
- if (this.disabled) return;
1803
- const nextFlushPromise = allSettled([this.flushPromise]).then(() => this._flush());
1899
+ async waitForPendingPromises(maxPromiseId, ignoredPromises = []) {
1900
+ const ignoredPendingPromises = ignoredPromises.filter((promise) => !!promise);
1901
+ let iteration = 0;
1902
+ while (true) {
1903
+ const promises = this.promiseQueue.getPromises([...ignoredPendingPromises, ...this.flushPromises], maxPromiseId);
1904
+ if (0 === promises.length) return;
1905
+ if (iteration > 0) this._logger.debug(`flush() re-checking ${promises.length} pending promise(s) before flushing`);
1906
+ await Promise.all(promises.map((promise) => promise.catch(() => {})));
1907
+ iteration++;
1908
+ }
1909
+ }
1910
+ flushWithPendingPromises() {
1911
+ return this.flushInternal(true);
1912
+ }
1913
+ flush() {
1914
+ return this.flushInternal(false);
1915
+ }
1916
+ flushInternal(waitForPendingPromises) {
1917
+ if (this.disabled) return Promise.resolve();
1918
+ const previousFlushPromise = this.flushPromise;
1919
+ const maxPromiseId = this.promiseQueue.maxId;
1920
+ const nextFlushPromise = Promise.resolve().then(() => {
1921
+ if (waitForPendingPromises) return this.waitForPendingPromises(maxPromiseId, [previousFlushPromise, nextFlushPromise]);
1922
+ }).then(() => allSettled([previousFlushPromise])).then(() => this._flush());
1804
1923
  this.flushPromise = nextFlushPromise;
1924
+ this.flushPromises.add(nextFlushPromise);
1805
1925
  this.addPendingPromise(nextFlushPromise);
1806
1926
  allSettled([nextFlushPromise]).then(() => {
1927
+ this.flushPromises.delete(nextFlushPromise);
1807
1928
  if (this.flushPromise === nextFlushPromise) this.flushPromise = null;
1808
1929
  });
1809
1930
  return nextFlushPromise;
@@ -1823,7 +1944,7 @@ var PostHogCoreStateless = class {
1823
1944
  const originalQueueLength = queue.length;
1824
1945
  while (queue.length > 0 && sentMessages.length < originalQueueLength) {
1825
1946
  const batchItems = queue.slice(0, this.maxBatchSize);
1826
- const batchMessages = batchItems.map((item) => item.message);
1947
+ const batchMessages = batchItems.map((item) => void 0 === item.message ? item.message : this.normalizeMessage(item.message));
1827
1948
  const persistQueueChange = async () => {
1828
1949
  const newQueue = (this.getPersistedProperty(types_PostHogPersistedProperty.Queue) || []).slice(batchItems.length);
1829
1950
  this.setPersistedProperty(types_PostHogPersistedProperty.Queue, newQueue);
@@ -1836,7 +1957,7 @@ var PostHogCoreStateless = class {
1836
1957
  sent_at: currentISOTime()
1837
1958
  };
1838
1959
  if (this.historicalMigration) data.historical_migration = true;
1839
- const payload = JSON.stringify(data);
1960
+ const payload = safeJsonStringify(data);
1840
1961
  const url = `${this.host}/batch/`;
1841
1962
  const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
1842
1963
  const fetchOptions = {
@@ -1850,7 +1971,7 @@ var PostHogCoreStateless = class {
1850
1971
  };
1851
1972
  const retryOptions = { retryCheck: (err) => {
1852
1973
  if (isPostHogFetchContentTooLargeError(err)) return false;
1853
- return isPostHogFetchError(err);
1974
+ return isPostHogFetchRetryableError(err);
1854
1975
  } };
1855
1976
  try {
1856
1977
  await (await this.fetchWithRetry(url, fetchOptions, retryOptions)).body?.cancel()?.catch(() => {});
@@ -1889,7 +2010,7 @@ var PostHogCoreStateless = class {
1889
2010
  try {
1890
2011
  await this.fetchWithRetry(url, fetchOptions, { retryCheck: (err) => {
1891
2012
  if (isPostHogFetchContentTooLargeError(err)) return false;
1892
- return isPostHogFetchError(err);
2013
+ return isPostHogFetchRetryableError(err);
1893
2014
  } });
1894
2015
  return { kind: "ok" };
1895
2016
  } catch (err) {
@@ -1975,7 +2096,7 @@ var PostHogCoreStateless = class {
1975
2096
  };
1976
2097
 
1977
2098
  //#endregion
1978
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
2099
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
1979
2100
  const LRU_FILE_CONTENTS_CACHE = new ReduceableCache(25);
1980
2101
  const LRU_FILE_CONTENTS_FS_READ_FAILED = new ReduceableCache(20);
1981
2102
  const DEFAULT_LINES_OF_CONTEXT = 7;
@@ -2155,7 +2276,7 @@ function snipLine(line, colno) {
2155
2276
  }
2156
2277
 
2157
2278
  //#endregion
2158
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
2279
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
2159
2280
  function createRelativePathModifier(basePath = process.cwd()) {
2160
2281
  const isWindows = "\\" === sep;
2161
2282
  const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
@@ -2169,11 +2290,11 @@ function createRelativePathModifier(basePath = process.cwd()) {
2169
2290
  }
2170
2291
 
2171
2292
  //#endregion
2172
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/version.mjs
2173
- const version = "5.36.4";
2293
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/version.mjs
2294
+ const version = "5.40.0";
2174
2295
 
2175
2296
  //#endregion
2176
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/types.mjs
2297
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/types.mjs
2177
2298
  const FeatureFlagError = {
2178
2299
  ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
2179
2300
  FLAG_MISSING: "flag_missing",
@@ -2182,7 +2303,7 @@ const FeatureFlagError = {
2182
2303
  };
2183
2304
 
2184
2305
  //#endregion
2185
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
2306
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/feature-flag-evaluations.mjs
2186
2307
  var FeatureFlagEvaluations = class FeatureFlagEvaluations {
2187
2308
  constructor(init) {
2188
2309
  this._host = init.host;
@@ -2300,7 +2421,7 @@ var FeatureFlagEvaluations = class FeatureFlagEvaluations {
2300
2421
  };
2301
2422
 
2302
2423
  //#endregion
2303
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
2424
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs
2304
2425
  async function hashSHA1(text) {
2305
2426
  const subtle = globalThis.crypto?.subtle;
2306
2427
  if (!subtle) throw new Error("SubtleCrypto API not available");
@@ -2309,7 +2430,7 @@ async function hashSHA1(text) {
2309
2430
  }
2310
2431
 
2311
2432
  //#endregion
2312
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
2433
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs
2313
2434
  const SIXTY_SECONDS = 6e4;
2314
2435
  const LONG_SCALE = 0x1000000000000000;
2315
2436
  const NULL_VALUES_ALLOWED_OPERATORS = ["is_not", "is_set"];
@@ -2322,20 +2443,21 @@ var ClientError = class ClientError extends Error {
2322
2443
  Object.setPrototypeOf(this, ClientError.prototype);
2323
2444
  }
2324
2445
  };
2446
+ function setCustomErrorPrototype(error, constructor) {
2447
+ error.name = constructor.name;
2448
+ Error.captureStackTrace(error, constructor);
2449
+ Object.setPrototypeOf(error, constructor.prototype);
2450
+ }
2325
2451
  var InconclusiveMatchError = class InconclusiveMatchError extends Error {
2326
2452
  constructor(message) {
2327
2453
  super(message);
2328
- this.name = this.constructor.name;
2329
- Error.captureStackTrace(this, this.constructor);
2330
- Object.setPrototypeOf(this, InconclusiveMatchError.prototype);
2454
+ setCustomErrorPrototype(this, InconclusiveMatchError);
2331
2455
  }
2332
2456
  };
2333
2457
  var RequiresServerEvaluation = class RequiresServerEvaluation extends Error {
2334
2458
  constructor(message) {
2335
2459
  super(message);
2336
- this.name = this.constructor.name;
2337
- Error.captureStackTrace(this, this.constructor);
2338
- Object.setPrototypeOf(this, RequiresServerEvaluation.prototype);
2460
+ setCustomErrorPrototype(this, RequiresServerEvaluation);
2339
2461
  }
2340
2462
  };
2341
2463
  var FeatureFlagsPoller = class {
@@ -2522,6 +2644,7 @@ var FeatureFlagsPoller = class {
2522
2644
  const flagFilters = flag.filters || {};
2523
2645
  const flagConditions = flagFilters.groups || [];
2524
2646
  const flagAggregation = flagFilters.aggregation_group_type_index;
2647
+ const earlyExitEnabled = flagFilters.early_exit ?? false;
2525
2648
  const { groups, groupProperties } = evaluationContext;
2526
2649
  let isInconclusive = false;
2527
2650
  let result;
@@ -2544,12 +2667,14 @@ var FeatureFlagsPoller = class {
2544
2667
  effectiveBucketingValue = groups[groupName];
2545
2668
  }
2546
2669
  }
2547
- if (await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext)) {
2670
+ const matchResult = await this.isConditionMatch(flag, effectiveBucketingValue, condition, effectiveProperties, evaluationContext);
2671
+ if ("match" === matchResult) {
2548
2672
  const variantOverride = condition.variant;
2549
2673
  const flagVariants = flagFilters.multivariate?.variants || [];
2550
2674
  result = variantOverride && flagVariants.some((variant) => variant.key === variantOverride) ? variantOverride : await this.getMatchingVariant(flag, effectiveBucketingValue) || true;
2551
2675
  break;
2552
2676
  }
2677
+ if (earlyExitEnabled && "out_of_rollout_bound" === matchResult) return false;
2553
2678
  } catch (e) {
2554
2679
  if (e instanceof RequiresServerEvaluation) throw e;
2555
2680
  if (e instanceof InconclusiveMatchError) isInconclusive = true;
@@ -2568,13 +2693,16 @@ var FeatureFlagsPoller = class {
2568
2693
  for (const prop of condition.properties) {
2569
2694
  const propertyType = prop.type;
2570
2695
  let matches = false;
2571
- matches = "cohort" === propertyType ? await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext)) : "flag" === propertyType ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
2572
- if (!matches) return false;
2696
+ if ("cohort" === propertyType) {
2697
+ const inCohort = await matchCohort(prop, properties, this.cohorts, this.debugMode, (depProp) => this.evaluateFlagDependency(depProp, properties, evaluationContext));
2698
+ matches = "not_in" === prop.operator ? !inCohort : inCohort;
2699
+ } else matches = "flag" === propertyType ? await this.evaluateFlagDependency(prop, properties, evaluationContext) : matchProperty(prop, properties, warnFunction);
2700
+ if (!matches) return "no_match";
2573
2701
  }
2574
- if (void 0 == rolloutPercentage) return true;
2702
+ if (void 0 == rolloutPercentage) return "match";
2575
2703
  }
2576
- if (void 0 != rolloutPercentage && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100) return false;
2577
- return true;
2704
+ if (void 0 != rolloutPercentage && await _hash(flag.key, bucketingValue) > rolloutPercentage / 100) return "out_of_rollout_bound";
2705
+ return "match";
2578
2706
  }
2579
2707
  async getMatchingVariant(flag, bucketingValue) {
2580
2708
  const hashValue = await _hash(flag.key, bucketingValue, "variant");
@@ -2681,7 +2809,7 @@ var FeatureFlagsPoller = class {
2681
2809
  return;
2682
2810
  case 401:
2683
2811
  this.beginBackoff();
2684
- throw new ClientError(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
2812
+ throw new ClientError(`Your project key or secret key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
2685
2813
  case 402:
2686
2814
  console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts");
2687
2815
  this.featureFlags = [];
@@ -2691,7 +2819,7 @@ var FeatureFlagsPoller = class {
2691
2819
  return;
2692
2820
  case 403:
2693
2821
  this.beginBackoff();
2694
- throw new ClientError(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);
2822
+ throw new ClientError(`Your secret key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct secret and Project API key pair? More information: https://posthog.com/docs/api/overview`);
2695
2823
  case 429:
2696
2824
  this.beginBackoff();
2697
2825
  throw new ClientError(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);
@@ -3049,7 +3177,7 @@ function relativeDateParseForFeatureFlagMatching(value) {
3049
3177
  }
3050
3178
 
3051
3179
  //#endregion
3052
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
3180
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
3053
3181
  function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
3054
3182
  let calledFatalError = false;
3055
3183
  return Object.assign((error) => {
@@ -3075,7 +3203,7 @@ function addUnhandledRejectionListener(captureFn) {
3075
3203
  }
3076
3204
 
3077
3205
  //#endregion
3078
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
3206
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
3079
3207
  const SHUTDOWN_TIMEOUT = 2e3;
3080
3208
  var ErrorTracking = class ErrorTracking {
3081
3209
  constructor(client, options, _logger) {
@@ -3119,7 +3247,7 @@ var ErrorTracking = class ErrorTracking {
3119
3247
  const eventMessage = await ErrorTracking.buildEventMessage(this.client.getErrorPropertiesBuilder(), exception, hint);
3120
3248
  const exceptionType = eventMessage.properties?.$exception_list[0]?.type ?? "Exception";
3121
3249
  if (this._rateLimiter.consumeRateLimit(exceptionType)) return void this._logger.info("Skipping exception capture because of client rate limiting.", { exception: exceptionType });
3122
- return this.client.capture(eventMessage);
3250
+ return this.client._capturePreparedEvent(eventMessage, false);
3123
3251
  }
3124
3252
  })());
3125
3253
  }
@@ -3137,7 +3265,7 @@ var ErrorTracking = class ErrorTracking {
3137
3265
  };
3138
3266
 
3139
3267
  //#endregion
3140
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/storage-memory.mjs
3268
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/storage-memory.mjs
3141
3269
  var PostHogMemoryStorage = class {
3142
3270
  getProperty(key) {
3143
3271
  return this._memoryStorage[key];
@@ -3151,7 +3279,7 @@ var PostHogMemoryStorage = class {
3151
3279
  };
3152
3280
 
3153
3281
  //#endregion
3154
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/client.mjs
3282
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/client.mjs
3155
3283
  const MINIMUM_POLLING_INTERVAL = 100;
3156
3284
  const THIRTY_SECONDS = 3e4;
3157
3285
  const MAX_CACHE_SIZE = 5e4;
@@ -3173,6 +3301,9 @@ function normalizePersonalApiKey(value) {
3173
3301
  function normalizeHost(value) {
3174
3302
  return ("string" == typeof value ? value.trim() : "") || DEFAULT_NODE_HOST;
3175
3303
  }
3304
+ function normalizeUnsetPersonProperties(value) {
3305
+ return (Array.isArray(value) ? value : [value]).filter((propertyName) => "string" == typeof propertyName && propertyName.trim().length > 0);
3306
+ }
3176
3307
  function buildFlagEventProperties(flagValues) {
3177
3308
  if (!flagValues) return {};
3178
3309
  const additionalProperties = {};
@@ -3187,7 +3318,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3187
3318
  const normalizedOptions = {
3188
3319
  ...options,
3189
3320
  host: normalizeHost(options.host),
3190
- personalApiKey: normalizePersonalApiKey(options.personalApiKey)
3321
+ personalApiKey: normalizePersonalApiKey(options.secretKey ?? options.personalApiKey)
3191
3322
  };
3192
3323
  super(normalizedApiKey, normalizedOptions), this._memoryStorage = new PostHogMemoryStorage();
3193
3324
  this.options = normalizedOptions;
@@ -3224,7 +3355,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3224
3355
  this.scheduleDebouncedFlush();
3225
3356
  }
3226
3357
  async flush() {
3227
- const flushPromise = super.flush();
3358
+ const flushPromise = this.flushWithPendingPromises();
3228
3359
  const waitUntil = this.options.waitUntil;
3229
3360
  if (waitUntil && !this._waitUntilCycle) try {
3230
3361
  waitUntil(flushPromise.catch(() => {}));
@@ -3270,7 +3401,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3270
3401
  async resolveWaitUntilFlush() {
3271
3402
  const resolve = this._consumeWaitUntilCycle();
3272
3403
  try {
3273
- await super.flush();
3404
+ await this.flushWithPendingPromises();
3274
3405
  } catch {} finally {
3275
3406
  resolve?.();
3276
3407
  }
@@ -3305,27 +3436,40 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3305
3436
  super.debug(enabled);
3306
3437
  this.featureFlagsPoller?.debug(enabled);
3307
3438
  }
3308
- capture(props) {
3309
- if ("string" == typeof props) this._logger.warn("Called capture() with a string as the first argument when an object was expected.");
3310
- if ("$exception" === props.event && !props._originatedFromCaptureException) this._logger.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
3311
- this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStateless(distinctId, event, properties, {
3312
- timestamp: options.timestamp,
3313
- disableGeoip: options.disableGeoip,
3314
- uuid: options.uuid
3315
- })).catch((err) => {
3439
+ _warnIfInvalidCapture(props, stringArgumentWarning, exceptionCaptureWarning) {
3440
+ if ("string" == typeof props) this._logger.warn(stringArgumentWarning);
3441
+ if ("$exception" === props.event && !props._originatedFromCaptureException) this._logger.warn(exceptionCaptureWarning);
3442
+ }
3443
+ _sendPreparedEvent(type, props, immediate, prepareOptions) {
3444
+ return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options }) => {
3445
+ const captureOptions = {
3446
+ timestamp: options.timestamp,
3447
+ disableGeoip: options.disableGeoip,
3448
+ uuid: options.uuid
3449
+ };
3450
+ const message = {
3451
+ distinctId,
3452
+ event,
3453
+ properties: {
3454
+ ...properties,
3455
+ ...this.getCommonEventProperties()
3456
+ }
3457
+ };
3458
+ return immediate ? this.sendImmediate(type, message, captureOptions) : this.enqueue(type, message, captureOptions);
3459
+ }).catch((err) => {
3316
3460
  if (err) console.error(err);
3317
3461
  }));
3318
3462
  }
3463
+ _capturePreparedEvent(props, immediate) {
3464
+ return this._sendPreparedEvent("capture", props, immediate);
3465
+ }
3466
+ capture(props) {
3467
+ this._warnIfInvalidCapture(props, "Called capture() with a string as the first argument when an object was expected.", "Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
3468
+ this._capturePreparedEvent(props, false);
3469
+ }
3319
3470
  async captureImmediate(props) {
3320
- if ("string" == typeof props) this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected.");
3321
- if ("$exception" === props.event && !props._originatedFromCaptureException) this._logger.warn("Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
3322
- return this.addPendingPromise(this.prepareEventMessage(props).then(({ distinctId, event, properties, options }) => super.captureStatelessImmediate(distinctId, event, properties, {
3323
- timestamp: options.timestamp,
3324
- disableGeoip: options.disableGeoip,
3325
- uuid: options.uuid
3326
- })).catch((err) => {
3327
- if (err) console.error(err);
3328
- }));
3471
+ this._warnIfInvalidCapture(props, "Called captureImmediate() with a string as the first argument when an object was expected.", "Capturing a `$exception` event via `posthog.captureImmediate('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureExceptionImmediate(error)` instead, which attaches this metadata by default.");
3472
+ return this._capturePreparedEvent(props, true);
3329
3473
  }
3330
3474
  identify({ distinctId, properties = {}, disableGeoip }) {
3331
3475
  const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
@@ -3334,7 +3478,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3334
3478
  $set_once: $set_once || {},
3335
3479
  $anon_distinct_id: $anon_distinct_id ?? void 0
3336
3480
  };
3337
- super.identifyStateless(distinctId, eventProperties, { disableGeoip });
3481
+ this._sendPreparedEvent("identify", {
3482
+ distinctId,
3483
+ event: "$identify",
3484
+ properties: eventProperties,
3485
+ disableGeoip
3486
+ }, false, { includeContextProperties: false });
3338
3487
  }
3339
3488
  async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
3340
3489
  const { $set, $set_once, $anon_distinct_id, ...rest } = properties;
@@ -3343,13 +3492,54 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3343
3492
  $set_once: $set_once || {},
3344
3493
  $anon_distinct_id: $anon_distinct_id ?? void 0
3345
3494
  };
3346
- await super.identifyStatelessImmediate(distinctId, eventProperties, { disableGeoip });
3495
+ await this._sendPreparedEvent("identify", {
3496
+ distinctId,
3497
+ event: "$identify",
3498
+ properties: eventProperties,
3499
+ disableGeoip
3500
+ }, true, { includeContextProperties: false });
3501
+ }
3502
+ setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
3503
+ if (0 === Object.keys(properties).length && 0 === Object.keys(propertiesOnce).length) return;
3504
+ const eventProperties = {};
3505
+ if (Object.keys(properties).length > 0) eventProperties.$set = properties;
3506
+ if (Object.keys(propertiesOnce).length > 0) eventProperties.$set_once = propertiesOnce;
3507
+ this.capture({
3508
+ distinctId,
3509
+ event: "$set",
3510
+ properties: eventProperties
3511
+ });
3512
+ }
3513
+ unsetPersonProperties({ distinctId, properties }) {
3514
+ const propertyNames = normalizeUnsetPersonProperties(properties);
3515
+ if (0 === propertyNames.length) return;
3516
+ this.capture({
3517
+ distinctId,
3518
+ event: "$set",
3519
+ properties: { $unset: propertyNames }
3520
+ });
3347
3521
  }
3348
3522
  alias(data) {
3349
- super.aliasStateless(data.alias, data.distinctId, void 0, { disableGeoip: data.disableGeoip });
3523
+ this._sendPreparedEvent("alias", {
3524
+ distinctId: data.distinctId,
3525
+ event: "$create_alias",
3526
+ properties: {
3527
+ distinct_id: data.distinctId,
3528
+ alias: data.alias
3529
+ },
3530
+ disableGeoip: data.disableGeoip
3531
+ }, false, { includeContextProperties: false });
3350
3532
  }
3351
3533
  async aliasImmediate(data) {
3352
- await super.aliasStatelessImmediate(data.alias, data.distinctId, void 0, { disableGeoip: data.disableGeoip });
3534
+ await this._sendPreparedEvent("alias", {
3535
+ distinctId: data.distinctId,
3536
+ event: "$create_alias",
3537
+ properties: {
3538
+ distinct_id: data.distinctId,
3539
+ alias: data.alias
3540
+ },
3541
+ disableGeoip: data.disableGeoip
3542
+ }, true, { includeContextProperties: false });
3353
3543
  }
3354
3544
  isLocalEvaluationReady() {
3355
3545
  return this.featureFlagsPoller?.isLocalEvaluationReady() ?? false;
@@ -3398,7 +3588,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3398
3588
  const adjustedProperties = this.addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties);
3399
3589
  personProperties = adjustedProperties.allPersonProperties;
3400
3590
  groupProperties = adjustedProperties.allGroupProperties;
3401
- const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties);
3591
+ const evaluationContext = this.createFeatureFlagEvaluationContext(distinctId, groups, this.personPropertiesForLocalEvaluation(distinctId, personProperties), groupProperties);
3402
3592
  if (void 0 == onlyEvaluateLocally) onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
3403
3593
  let result;
3404
3594
  let flagWasLocallyEvaluated = false;
@@ -3431,7 +3621,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3431
3621
  }
3432
3622
  }
3433
3623
  if (!flagWasLocallyEvaluated && !onlyEvaluateLocally) {
3434
- const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, [key]);
3624
+ const flagsResponse = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, [key]);
3435
3625
  if (void 0 === flagsResponse) featureFlagError = FeatureFlagError.UNKNOWN_ERROR;
3436
3626
  else {
3437
3627
  requestId = flagsResponse.requestId;
@@ -3572,7 +3762,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3572
3762
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
3573
3763
  personProperties = adjustedProperties.allPersonProperties;
3574
3764
  groupProperties = adjustedProperties.allGroupProperties;
3575
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
3765
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
3576
3766
  if (void 0 == onlyEvaluateLocally) onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
3577
3767
  const localEvaluationResult = await this.featureFlagsPoller?.getAllFlagsAndPayloads(evaluationContext, flagKeys);
3578
3768
  let featureFlags = {};
@@ -3584,7 +3774,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3584
3774
  fallbackToFlags = localEvaluationResult.fallbackToFlags;
3585
3775
  }
3586
3776
  if (fallbackToFlags && !onlyEvaluateLocally) {
3587
- const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
3777
+ const remoteEvaluationResult = await super.getFeatureFlagsAndPayloadsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
3588
3778
  featureFlags = {
3589
3779
  ...featureFlags,
3590
3780
  ...remoteEvaluationResult.flags || {}
@@ -3630,7 +3820,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3630
3820
  const adjustedProperties = this.addLocalPersonAndGroupProperties(resolvedDistinctId, groups, personProperties, groupProperties);
3631
3821
  personProperties = adjustedProperties.allPersonProperties;
3632
3822
  groupProperties = adjustedProperties.allGroupProperties;
3633
- const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, personProperties, groupProperties);
3823
+ const evaluationContext = this.createFeatureFlagEvaluationContext(resolvedDistinctId, groups, this.personPropertiesForLocalEvaluation(resolvedDistinctId, personProperties), groupProperties);
3634
3824
  if (void 0 == onlyEvaluateLocally) onlyEvaluateLocally = this.options.strictLocalEvaluation ?? false;
3635
3825
  const records = {};
3636
3826
  let requestId;
@@ -3654,7 +3844,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3654
3844
  locallyEvaluatedKeys.add(key);
3655
3845
  }
3656
3846
  if ((localResult ? localResult.fallbackToFlags : true) && !onlyEvaluateLocally) {
3657
- const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, evaluationContext.personProperties, evaluationContext.groupProperties, disableGeoip, flagKeys);
3847
+ const details = await super.getFeatureFlagDetailsStateless(evaluationContext.distinctId, evaluationContext.groups, personProperties, groupProperties, disableGeoip, flagKeys);
3658
3848
  if (details) {
3659
3849
  requestId = details.requestId;
3660
3850
  evaluatedAt = details.evaluatedAt;
@@ -3724,7 +3914,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3724
3914
  if (distinctId in this.distinctIdHasSentFlagCalls && this.distinctIdHasSentFlagCalls[distinctId].has(featureFlagReportedKey)) return;
3725
3915
  if (Object.keys(this.distinctIdHasSentFlagCalls).length >= this.maxCacheSize) this.distinctIdHasSentFlagCalls = {};
3726
3916
  if (this.distinctIdHasSentFlagCalls[distinctId] instanceof Set) this.distinctIdHasSentFlagCalls[distinctId].add(featureFlagReportedKey);
3727
- else this.distinctIdHasSentFlagCalls[distinctId] = new Set([featureFlagReportedKey]);
3917
+ else this.distinctIdHasSentFlagCalls[distinctId] = /* @__PURE__ */ new Set([featureFlagReportedKey]);
3728
3918
  this.capture({
3729
3919
  distinctId,
3730
3920
  event: "$feature_flag_called",
@@ -3743,7 +3933,28 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3743
3933
  return this._featureFlagEvaluationsHost;
3744
3934
  }
3745
3935
  groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
3746
- super.groupIdentifyStateless(groupType, groupKey, properties, { disableGeoip }, distinctId);
3936
+ this._sendPreparedEvent("capture", {
3937
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
3938
+ event: "$groupidentify",
3939
+ properties: {
3940
+ $group_type: groupType,
3941
+ $group_key: groupKey,
3942
+ $group_set: properties || {}
3943
+ },
3944
+ disableGeoip
3945
+ }, false, { includeContextProperties: false });
3946
+ }
3947
+ async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
3948
+ await this._sendPreparedEvent("capture", {
3949
+ distinctId: distinctId || `$${groupType}_${groupKey}`,
3950
+ event: "$groupidentify",
3951
+ properties: {
3952
+ $group_type: groupType,
3953
+ $group_key: groupKey,
3954
+ $group_set: properties || {}
3955
+ },
3956
+ disableGeoip
3957
+ }, true, { includeContextProperties: false });
3747
3958
  }
3748
3959
  async reloadFeatureFlags() {
3749
3960
  await this.featureFlagsPoller?.loadFeatureFlags(true);
@@ -3803,6 +4014,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3803
4014
  try {
3804
4015
  return await super._shutdown(shutdownTimeoutMs);
3805
4016
  } finally {
4017
+ this.distinctIdHasSentFlagCalls = {};
3806
4018
  resolve?.();
3807
4019
  }
3808
4020
  }
@@ -3884,10 +4096,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3884
4096
  return (await super.getFeatureFlagsStateless(distinctId, groups, finalPersonProperties, finalGroupProperties, disableGeoip)).flags;
3885
4097
  }
3886
4098
  addLocalPersonAndGroupProperties(distinctId, groups, personProperties, groupProperties) {
3887
- const allPersonProperties = {
3888
- distinct_id: distinctId,
3889
- ...personProperties || {}
3890
- };
4099
+ const allPersonProperties = { ...personProperties || {} };
3891
4100
  const allGroupProperties = {};
3892
4101
  if (groups) for (const groupName of Object.keys(groups)) allGroupProperties[groupName] = {
3893
4102
  $group_key: groups[groupName],
@@ -3898,6 +4107,12 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3898
4107
  allGroupProperties
3899
4108
  };
3900
4109
  }
4110
+ personPropertiesForLocalEvaluation(distinctId, personProperties) {
4111
+ return {
4112
+ distinct_id: distinctId,
4113
+ ...personProperties || {}
4114
+ };
4115
+ }
3901
4116
  createFeatureFlagEvaluationContext(distinctId, groups, personProperties, groupProperties) {
3902
4117
  return {
3903
4118
  distinctId,
@@ -3910,11 +4125,11 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3910
4125
  captureException(error, distinctId, additionalProperties, uuid, flags) {
3911
4126
  if (!ErrorTracking.isPreviouslyCapturedError(error)) {
3912
4127
  const syntheticException = /* @__PURE__ */ new Error("PostHog syntheticException");
3913
- this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this.capture({
4128
+ this.addPendingPromise(ErrorTracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, { syntheticException }, distinctId, additionalProperties).then((msg) => this._capturePreparedEvent({
3914
4129
  ...msg,
3915
4130
  uuid,
3916
4131
  flags
3917
- })));
4132
+ }, false)));
3918
4133
  }
3919
4134
  }
3920
4135
  async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
@@ -3927,19 +4142,23 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3927
4142
  }
3928
4143
  }
3929
4144
  async prepareEventMessage(props) {
4145
+ return this._prepareEventMessage(props);
4146
+ }
4147
+ async _prepareEventMessage(props, options = {}) {
3930
4148
  const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
3931
4149
  const contextData = this.context?.get();
4150
+ const includeContextProperties = options.includeContextProperties ?? true;
3932
4151
  let mergedDistinctId = distinctId || contextData?.distinctId;
3933
- const mergedProperties = {
4152
+ const mergedProperties = includeContextProperties ? {
3934
4153
  ...this.props,
3935
4154
  ...contextData?.properties || {},
3936
4155
  ...properties || {}
3937
- };
4156
+ } : { ...properties || {} };
3938
4157
  if (!mergedDistinctId) {
3939
4158
  mergedDistinctId = uuidv7();
3940
4159
  mergedProperties.$process_person_profile = false;
3941
4160
  }
3942
- if (contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
4161
+ if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
3943
4162
  const eventMessage = this._runBeforeSend({
3944
4163
  distinctId: mergedDistinctId,
3945
4164
  event,
@@ -3964,10 +4183,11 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
3964
4183
  }
3965
4184
  return {};
3966
4185
  }).catch(() => ({})).then((additionalProperties) => {
4186
+ const resolvedGroups = eventMessage.groups || groups;
3967
4187
  return {
3968
4188
  ...additionalProperties,
3969
4189
  ...eventMessage.properties || {},
3970
- $groups: eventMessage.groups || groups
4190
+ ...void 0 !== resolvedGroups && Object.keys(resolvedGroups).length > 0 ? { $groups: resolvedGroups } : {}
3971
4191
  };
3972
4192
  });
3973
4193
  if ("$pageview" === eventMessage.event && this.options.__preview_capture_bot_pageviews && "string" == typeof eventProperties.$raw_user_agent) {
@@ -4008,7 +4228,7 @@ var PostHogBackendClient = class extends PostHogCoreStateless {
4008
4228
  };
4009
4229
 
4010
4230
  //#endregion
4011
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/context/context.mjs
4231
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/context/context.mjs
4012
4232
  var PostHogContext = class {
4013
4233
  constructor() {
4014
4234
  this.storage = new AsyncLocalStorage();
@@ -4037,7 +4257,7 @@ var PostHogContext = class {
4037
4257
  };
4038
4258
 
4039
4259
  //#endregion
4040
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
4260
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/extensions/sentry-integration.mjs
4041
4261
  const NAME = "posthog-node";
4042
4262
  function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = ["error"], sendExceptionsToPostHog = true } = {}) {
4043
4263
  return (event) => {
@@ -4099,7 +4319,7 @@ var PostHogSentryIntegration = class {
4099
4319
  };
4100
4320
 
4101
4321
  //#endregion
4102
- //#region ../../node_modules/.pnpm/posthog-node@5.36.4_rxjs@7.8.2/node_modules/posthog-node/dist/entrypoints/index.node.mjs
4322
+ //#region ../../node_modules/.pnpm/posthog-node@5.40.0_rxjs@7.8.2/node_modules/posthog-node/dist/entrypoints/index.node.mjs
4103
4323
  var PostHog = class extends PostHogBackendClient {
4104
4324
  getLibraryId() {
4105
4325
  return "posthog-node";
@@ -4124,4 +4344,4 @@ var PostHog = class extends PostHogBackendClient {
4124
4344
 
4125
4345
  //#endregion
4126
4346
  export { PostHog };
4127
- //# sourceMappingURL=index.node-T6N3xCyo.js.map
4347
+ //# sourceMappingURL=index.node-BF2WkODf.js.map