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