@claudeye/linux-arm64 1.0.4-beta.9 → 1.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 (187) hide show
  1. package/assets/standalone/.next/BUILD_ID +1 -1
  2. package/assets/standalone/.next/build-manifest.json +2 -2
  3. package/assets/standalone/.next/prerender-manifest.json +3 -3
  4. package/assets/standalone/.next/required-server-files.json +0 -3
  5. package/assets/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/assets/standalone/.next/server/app/_global-error.html +2 -2
  7. package/assets/standalone/.next/server/app/_global-error.rsc +7 -7
  8. package/assets/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  9. package/assets/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  10. package/assets/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
  11. package/assets/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  12. package/assets/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/assets/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  14. package/assets/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/assets/standalone/.next/server/app/_not-found.html +2 -2
  16. package/assets/standalone/.next/server/app/_not-found.rsc +14 -14
  17. package/assets/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  18. package/assets/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  19. package/assets/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +9 -9
  20. package/assets/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  21. package/assets/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  22. package/assets/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/assets/standalone/.next/server/app/api/completed-history/route.js +1 -1
  24. package/assets/standalone/.next/server/app/api/queue-item/route.js +2 -2
  25. package/assets/standalone/.next/server/app/api/queue-status/route.js +1 -1
  26. package/assets/standalone/.next/server/app/dashboard/[viewName]/page/server-reference-manifest.json +4 -4
  27. package/assets/standalone/.next/server/app/dashboard/[viewName]/page_client-reference-manifest.js +1 -1
  28. package/assets/standalone/.next/server/app/dashboard/page/server-reference-manifest.json +4 -4
  29. package/assets/standalone/.next/server/app/dashboard/page_client-reference-manifest.js +1 -1
  30. package/assets/standalone/.next/server/app/login/page/server-reference-manifest.json +2 -2
  31. package/assets/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
  32. package/assets/standalone/.next/server/app/login.html +2 -2
  33. package/assets/standalone/.next/server/app/login.rsc +15 -15
  34. package/assets/standalone/.next/server/app/login.segments/_full.segment.rsc +15 -15
  35. package/assets/standalone/.next/server/app/login.segments/_head.segment.rsc +4 -4
  36. package/assets/standalone/.next/server/app/login.segments/_index.segment.rsc +9 -9
  37. package/assets/standalone/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  38. package/assets/standalone/.next/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
  39. package/assets/standalone/.next/server/app/login.segments/login.segment.rsc +3 -3
  40. package/assets/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  41. package/assets/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  42. package/assets/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  43. package/assets/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  44. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  45. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +8 -8
  46. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +1 -1
  47. package/assets/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  48. package/assets/standalone/.next/server/app/queue/page/server-reference-manifest.json +3 -3
  49. package/assets/standalone/.next/server/app/queue/page.js +2 -2
  50. package/assets/standalone/.next/server/app/queue/page_client-reference-manifest.js +1 -1
  51. package/assets/standalone/.next/server/chunks/{[externals]_next_dist_db0236a7._.js → [externals]__06cd15c5._.js} +2 -2
  52. package/assets/standalone/.next/server/chunks/[externals]__10373a08._.js +3 -0
  53. package/assets/standalone/.next/server/chunks/[externals]__d78bcb54._.js +3 -0
  54. package/assets/standalone/.next/server/chunks/[root-of-the-server]__067f11b8._.js +3 -0
  55. package/assets/standalone/.next/server/chunks/[root-of-the-server]__22ffcb4e._.js +3 -0
  56. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__3232b9b5._.js → [root-of-the-server]__292809cf._.js} +1 -1
  57. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__bf0c3d33._.js → [root-of-the-server]__3c3ad1da._.js} +4 -4
  58. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__6d076258._.js → [root-of-the-server]__43c4e0bc._.js} +1 -1
  59. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__6fc9da2e._.js → [root-of-the-server]__7c44135a._.js} +1 -1
  60. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__ffb39c82._.js → [root-of-the-server]__939bf5b3._.js} +2 -2
  61. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__fe48bb1c._.js → [root-of-the-server]__bd194a73._.js} +2 -2
  62. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__b2f1c82c._.js → [root-of-the-server]__ca12b24d._.js} +2 -2
  63. package/assets/standalone/.next/server/chunks/[root-of-the-server]__d7355d04._.js +1 -1
  64. package/assets/standalone/.next/server/chunks/{[root-of-the-server]__255e6fbc._.js → [root-of-the-server]__dcb3f873._.js} +1 -1
  65. package/assets/standalone/.next/server/chunks/[root-of-the-server]__e3e9ab09._.js +4 -0
  66. package/assets/standalone/.next/server/chunks/[root-of-the-server]__f26a70d1._.js +3 -0
  67. package/assets/standalone/.next/server/chunks/_3f3c09bf._.js +1 -1
  68. package/assets/standalone/.next/server/chunks/_5336fde9._.js +3 -0
  69. package/assets/standalone/.next/server/chunks/_7e07bbd9._.js +1 -1
  70. package/assets/standalone/.next/server/chunks/_8f856fad._.js +1 -1
  71. package/assets/standalone/.next/server/chunks/{_717db053._.js → _b7316450._.js} +1 -1
  72. package/assets/standalone/.next/server/chunks/_b8adaa37._.js +2 -2
  73. package/assets/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_7a66d362.js +1 -1
  74. package/assets/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_05ab10df._.js +3 -0
  75. package/assets/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_20debb74._.js +3 -0
  76. package/assets/standalone/.next/server/chunks/package_json_4b1b4d6f._.js +1 -1
  77. package/assets/standalone/.next/server/chunks/ssr/[externals]__10373a08._.js +3 -0
  78. package/assets/standalone/.next/server/chunks/ssr/{[root-of-the-server]__16a44ef3._.js → [root-of-the-server]__acea31a9._.js} +3 -3
  79. package/assets/standalone/.next/server/chunks/ssr/{[root-of-the-server]__10ac3567._.js → [root-of-the-server]__c3591792._.js} +3 -3
  80. package/assets/standalone/.next/server/chunks/ssr/_14858238._.js +1 -1
  81. package/assets/standalone/.next/server/chunks/ssr/_19a3e694._.js +2 -2
  82. package/assets/standalone/.next/server/chunks/ssr/_1d335924._.js +1 -1
  83. package/assets/standalone/.next/server/chunks/ssr/_3dacef09._.js +1 -1
  84. package/assets/standalone/.next/server/chunks/ssr/_617143fc._.js +2 -2
  85. package/assets/standalone/.next/server/chunks/ssr/_76ab933f._.js +1 -1
  86. package/assets/standalone/.next/server/chunks/ssr/_7ae321cd._.js +2 -2
  87. package/assets/standalone/.next/server/chunks/ssr/_87e025a1._.js +1 -1
  88. package/assets/standalone/.next/server/chunks/ssr/_986c0cdb._.js +2 -2
  89. package/assets/standalone/.next/server/chunks/ssr/_c9400c33._.js +2 -2
  90. package/assets/standalone/.next/server/chunks/ssr/_d7159840._.js +1 -1
  91. package/assets/standalone/.next/server/chunks/ssr/_fa9c2bed._.js +2 -2
  92. package/assets/standalone/.next/server/chunks/ssr/app_actions_compute-dashboard_ts_fc151dbb._.js +1 -1
  93. package/assets/standalone/.next/server/chunks/ssr/app_login_page_tsx_ccc0019b._.js +1 -1
  94. package/assets/standalone/.next/server/chunks/ssr/app_queue_queue-client_tsx_45f040f7._.js +1 -1
  95. package/assets/standalone/.next/server/chunks/ssr/node_modules_next_dist_274ac3eb._.js +1 -1
  96. package/assets/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_8222e100._.js +3 -0
  97. package/assets/standalone/.next/server/instrumentation.js +1 -1
  98. package/assets/standalone/.next/server/middleware.js +2 -2
  99. package/assets/standalone/.next/server/pages/404.html +2 -2
  100. package/assets/standalone/.next/server/pages/500.html +2 -2
  101. package/assets/standalone/.next/server/server-reference-manifest.js +1 -1
  102. package/assets/standalone/.next/server/server-reference-manifest.json +15 -15
  103. package/assets/standalone/.next/static/chunks/{723f2367261046f4.js → 11f25fc2615691ff.js} +1 -1
  104. package/assets/standalone/.next/static/chunks/{98ef6309c816722d.css → 14b2a22c2d5f76c5.css} +1 -1
  105. package/assets/standalone/.next/static/chunks/{d2be314c3ece3fbe.js → 2b423cf30d3964a3.js} +1 -1
  106. package/assets/standalone/.next/static/chunks/{97c295191089a1c2.js → 5920eabcfc97a878.js} +1 -1
  107. package/assets/standalone/.next/static/chunks/{dbec35204e8940b4.js → 6f48312d9fefe6e7.js} +1 -1
  108. package/assets/standalone/.next/static/chunks/8da8518dc46b9734.js +1 -0
  109. package/assets/standalone/.next/static/chunks/91129b8c2a80b1b2.js +4 -0
  110. package/assets/standalone/.next/static/chunks/{fd8c1fc19ac30592.js → 96e6f5987bb7f381.js} +3 -3
  111. package/assets/standalone/.next/static/chunks/{27fc246b001f7ba2.js → ef5e745c131e6572.js} +1 -1
  112. package/assets/standalone/instrumentation.node.ts +54 -0
  113. package/assets/standalone/package.json +3 -2
  114. package/assets/standalone/server.js +1 -1
  115. package/bin/claudeye +0 -0
  116. package/package.json +1 -1
  117. package/assets/standalone/.next/server/chunks/[externals]_posthog-node_4a68be38._.js +0 -3
  118. package/assets/standalone/.next/server/chunks/[root-of-the-server]__19c9c5af._.js +0 -4
  119. package/assets/standalone/.next/server/chunks/[root-of-the-server]__365c750b._.js +0 -3
  120. package/assets/standalone/.next/server/chunks/[root-of-the-server]__4ea757c2._.js +0 -3
  121. package/assets/standalone/.next/server/chunks/[root-of-the-server]__c84cf1dc._.js +0 -3
  122. package/assets/standalone/.next/server/chunks/ssr/[externals]_posthog-node_4a68be38._.js +0 -3
  123. package/assets/standalone/.next/static/chunks/13ab76b2fb94bd45.js +0 -1
  124. package/assets/standalone/.next/static/chunks/3346a6085951648c.js +0 -4
  125. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs +0 -34
  126. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs +0 -31
  127. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs +0 -27
  128. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs +0 -18
  129. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs +0 -17
  130. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/index.mjs +0 -8
  131. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs +0 -51
  132. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs +0 -15
  133. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs +0 -25
  134. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs +0 -29
  135. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs +0 -18
  136. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs +0 -112
  137. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/index.mjs +0 -4
  138. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs +0 -14
  139. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs +0 -27
  140. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs +0 -24
  141. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs +0 -47
  142. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs +0 -65
  143. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs +0 -12
  144. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs +0 -13
  145. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs +0 -7
  146. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/types.mjs +0 -9
  147. package/assets/standalone/node_modules/@posthog/core/dist/error-tracking/utils.mjs +0 -23
  148. package/assets/standalone/node_modules/@posthog/core/dist/eventemitter.mjs +0 -18
  149. package/assets/standalone/node_modules/@posthog/core/dist/featureFlagUtils.mjs +0 -113
  150. package/assets/standalone/node_modules/@posthog/core/dist/gzip.mjs +0 -18
  151. package/assets/standalone/node_modules/@posthog/core/dist/index.mjs +0 -9
  152. package/assets/standalone/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +0 -676
  153. package/assets/standalone/node_modules/@posthog/core/dist/posthog-core.mjs +0 -761
  154. package/assets/standalone/node_modules/@posthog/core/dist/surveys/validation.mjs +0 -33
  155. package/assets/standalone/node_modules/@posthog/core/dist/types.mjs +0 -137
  156. package/assets/standalone/node_modules/@posthog/core/dist/utils/bot-detection.mjs +0 -88
  157. package/assets/standalone/node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs +0 -41
  158. package/assets/standalone/node_modules/@posthog/core/dist/utils/index.mjs +0 -59
  159. package/assets/standalone/node_modules/@posthog/core/dist/utils/logger.mjs +0 -38
  160. package/assets/standalone/node_modules/@posthog/core/dist/utils/number-utils.mjs +0 -41
  161. package/assets/standalone/node_modules/@posthog/core/dist/utils/promise-queue.mjs +0 -27
  162. package/assets/standalone/node_modules/@posthog/core/dist/utils/string-utils.mjs +0 -31
  163. package/assets/standalone/node_modules/@posthog/core/dist/utils/type-utils.mjs +0 -82
  164. package/assets/standalone/node_modules/@posthog/core/dist/utils/user-agent-utils.mjs +0 -338
  165. package/assets/standalone/node_modules/@posthog/core/dist/vendor/uuidv7.mjs +0 -170
  166. package/assets/standalone/node_modules/@posthog/core/package.json +0 -69
  167. package/assets/standalone/node_modules/posthog-node/dist/client.mjs +0 -718
  168. package/assets/standalone/node_modules/posthog-node/dist/entrypoints/index.node.mjs +0 -26
  169. package/assets/standalone/node_modules/posthog-node/dist/exports.mjs +0 -5
  170. package/assets/standalone/node_modules/posthog-node/dist/extensions/context/context.mjs +0 -28
  171. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs +0 -31
  172. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/index.mjs +0 -69
  173. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.js +0 -227
  174. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs +0 -187
  175. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.js +0 -64
  176. package/assets/standalone/node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs +0 -30
  177. package/assets/standalone/node_modules/posthog-node/dist/extensions/express.mjs +0 -32
  178. package/assets/standalone/node_modules/posthog-node/dist/extensions/feature-flags/crypto.mjs +0 -8
  179. package/assets/standalone/node_modules/posthog-node/dist/extensions/feature-flags/feature-flags.mjs +0 -772
  180. package/assets/standalone/node_modules/posthog-node/dist/extensions/sentry-integration.mjs +0 -72
  181. package/assets/standalone/node_modules/posthog-node/dist/storage-memory.mjs +0 -12
  182. package/assets/standalone/node_modules/posthog-node/dist/types.mjs +0 -7
  183. package/assets/standalone/node_modules/posthog-node/dist/version.mjs +0 -2
  184. package/assets/standalone/node_modules/posthog-node/package.json +0 -105
  185. /package/assets/standalone/.next/static/{J4fam3sTS7cM1hFzhpIJy → ooDwT_B4qzYMdxRb-wV62}/_buildManifest.js +0 -0
  186. /package/assets/standalone/.next/static/{J4fam3sTS7cM1hFzhpIJy → ooDwT_B4qzYMdxRb-wV62}/_clientMiddlewareManifest.json +0 -0
  187. /package/assets/standalone/.next/static/{J4fam3sTS7cM1hFzhpIJy → ooDwT_B4qzYMdxRb-wV62}/_ssgManifest.js +0 -0
@@ -1,676 +0,0 @@
1
- import { SimpleEventEmitter } from "./eventemitter.mjs";
2
- import { getFeatureFlagValue, normalizeFlagsResponse } from "./featureFlagUtils.mjs";
3
- import { gzipCompress, isGzipSupported } from "./gzip.mjs";
4
- import { PostHogPersistedProperty } from "./types.mjs";
5
- import { PromiseQueue, STRING_FORMAT, allSettled, assert, createLogger, currentISOTime, removeTrailingSlash, retriable, safeSetTimeout } from "./utils/index.mjs";
6
- import { uuidv7 } from "./vendor/uuidv7.mjs";
7
- class PostHogFetchHttpError extends Error {
8
- constructor(response, reqByteLength){
9
- super('HTTP error while fetching PostHog: status=' + response.status + ', reqByteLength=' + reqByteLength), this.response = response, this.reqByteLength = reqByteLength, this.name = 'PostHogFetchHttpError';
10
- }
11
- get status() {
12
- return this.response.status;
13
- }
14
- get text() {
15
- return this.response.text();
16
- }
17
- get json() {
18
- return this.response.json();
19
- }
20
- }
21
- class PostHogFetchNetworkError extends Error {
22
- constructor(error){
23
- super('Network error while fetching PostHog', error instanceof Error ? {
24
- cause: error
25
- } : {}), this.error = error, this.name = 'PostHogFetchNetworkError';
26
- }
27
- }
28
- const maybeAdd = (key, value)=>void 0 !== value ? {
29
- [key]: value
30
- } : {};
31
- async function logFlushError(err) {
32
- if (err instanceof PostHogFetchHttpError) {
33
- let text = '';
34
- try {
35
- text = await err.text;
36
- } catch {}
37
- console.error(`Error while flushing PostHog: message=${err.message}, response body=${text}`, err);
38
- } else console.error('Error while flushing PostHog', err);
39
- return Promise.resolve();
40
- }
41
- function isPostHogFetchError(err) {
42
- return 'object' == typeof err && (err instanceof PostHogFetchHttpError || err instanceof PostHogFetchNetworkError);
43
- }
44
- function isPostHogFetchContentTooLargeError(err) {
45
- return 'object' == typeof err && err instanceof PostHogFetchHttpError && 413 === err.status;
46
- }
47
- var posthog_core_stateless_QuotaLimitedFeature = /*#__PURE__*/ function(QuotaLimitedFeature) {
48
- QuotaLimitedFeature["FeatureFlags"] = "feature_flags";
49
- QuotaLimitedFeature["Recordings"] = "recordings";
50
- return QuotaLimitedFeature;
51
- }({});
52
- class PostHogCoreStateless {
53
- constructor(apiKey, options = {}){
54
- this.flushPromise = null;
55
- this.shutdownPromise = null;
56
- this.promiseQueue = new PromiseQueue();
57
- this._events = new SimpleEventEmitter();
58
- this._isInitialized = false;
59
- assert(apiKey, "You must pass your PostHog project's api key.");
60
- this.apiKey = apiKey;
61
- this.host = removeTrailingSlash(options.host || 'https://us.i.posthog.com');
62
- this.flushAt = options.flushAt ? Math.max(options.flushAt, 1) : 20;
63
- this.maxBatchSize = Math.max(this.flushAt, options.maxBatchSize ?? 100);
64
- this.maxQueueSize = Math.max(this.flushAt, options.maxQueueSize ?? 1000);
65
- this.flushInterval = options.flushInterval ?? 10000;
66
- this.preloadFeatureFlags = options.preloadFeatureFlags ?? true;
67
- this.defaultOptIn = options.defaultOptIn ?? true;
68
- this.disableSurveys = options.disableSurveys ?? false;
69
- this._retryOptions = {
70
- retryCount: options.fetchRetryCount ?? 3,
71
- retryDelay: options.fetchRetryDelay ?? 3000,
72
- retryCheck: isPostHogFetchError
73
- };
74
- this.requestTimeout = options.requestTimeout ?? 10000;
75
- this.featureFlagsRequestTimeoutMs = options.featureFlagsRequestTimeoutMs ?? 3000;
76
- this.remoteConfigRequestTimeoutMs = options.remoteConfigRequestTimeoutMs ?? 3000;
77
- this.disableGeoip = options.disableGeoip ?? true;
78
- this.disabled = options.disabled ?? false;
79
- this.historicalMigration = options?.historicalMigration ?? false;
80
- this._initPromise = Promise.resolve();
81
- this._isInitialized = true;
82
- this._logger = createLogger('[PostHog]', this.logMsgIfDebug.bind(this));
83
- this.evaluationContexts = options?.evaluationContexts ?? options?.evaluationEnvironments;
84
- if (options?.evaluationEnvironments && !options?.evaluationContexts) this._logger.warn('evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version.');
85
- this.disableCompression = !isGzipSupported() || (options?.disableCompression ?? false);
86
- }
87
- logMsgIfDebug(fn) {
88
- if (this.isDebug) fn();
89
- }
90
- wrap(fn) {
91
- if (this.disabled) return void this._logger.warn('The client is disabled');
92
- if (this._isInitialized) return fn();
93
- this._initPromise.then(()=>fn());
94
- }
95
- getCommonEventProperties() {
96
- return {
97
- $lib: this.getLibraryId(),
98
- $lib_version: this.getLibraryVersion()
99
- };
100
- }
101
- get optedOut() {
102
- return this.getPersistedProperty(PostHogPersistedProperty.OptedOut) ?? !this.defaultOptIn;
103
- }
104
- async optIn() {
105
- this.wrap(()=>{
106
- this.setPersistedProperty(PostHogPersistedProperty.OptedOut, false);
107
- });
108
- }
109
- async optOut() {
110
- this.wrap(()=>{
111
- this.setPersistedProperty(PostHogPersistedProperty.OptedOut, true);
112
- });
113
- }
114
- on(event, cb) {
115
- return this._events.on(event, cb);
116
- }
117
- debug(enabled = true) {
118
- this.removeDebugCallback?.();
119
- if (enabled) {
120
- const removeDebugCallback = this.on('*', (event, payload)=>this._logger.info(event, payload));
121
- this.removeDebugCallback = ()=>{
122
- removeDebugCallback();
123
- this.removeDebugCallback = void 0;
124
- };
125
- }
126
- }
127
- get isDebug() {
128
- return !!this.removeDebugCallback;
129
- }
130
- get isDisabled() {
131
- return this.disabled;
132
- }
133
- buildPayload(payload) {
134
- return {
135
- distinct_id: payload.distinct_id,
136
- event: payload.event,
137
- properties: {
138
- ...payload.properties || {},
139
- ...this.getCommonEventProperties()
140
- }
141
- };
142
- }
143
- addPendingPromise(promise) {
144
- return this.promiseQueue.add(promise);
145
- }
146
- identifyStateless(distinctId, properties, options) {
147
- this.wrap(()=>{
148
- const payload = {
149
- ...this.buildPayload({
150
- distinct_id: distinctId,
151
- event: '$identify',
152
- properties
153
- })
154
- };
155
- this.enqueue('identify', payload, options);
156
- });
157
- }
158
- async identifyStatelessImmediate(distinctId, properties, options) {
159
- const payload = {
160
- ...this.buildPayload({
161
- distinct_id: distinctId,
162
- event: '$identify',
163
- properties
164
- })
165
- };
166
- await this.sendImmediate('identify', payload, options);
167
- }
168
- captureStateless(distinctId, event, properties, options) {
169
- this.wrap(()=>{
170
- const payload = this.buildPayload({
171
- distinct_id: distinctId,
172
- event,
173
- properties
174
- });
175
- this.enqueue('capture', payload, options);
176
- });
177
- }
178
- async captureStatelessImmediate(distinctId, event, properties, options) {
179
- const payload = this.buildPayload({
180
- distinct_id: distinctId,
181
- event,
182
- properties
183
- });
184
- await this.sendImmediate('capture', payload, options);
185
- }
186
- aliasStateless(alias, distinctId, properties, options) {
187
- this.wrap(()=>{
188
- const payload = this.buildPayload({
189
- event: '$create_alias',
190
- distinct_id: distinctId,
191
- properties: {
192
- ...properties || {},
193
- distinct_id: distinctId,
194
- alias
195
- }
196
- });
197
- this.enqueue('alias', payload, options);
198
- });
199
- }
200
- async aliasStatelessImmediate(alias, distinctId, properties, options) {
201
- const payload = this.buildPayload({
202
- event: '$create_alias',
203
- distinct_id: distinctId,
204
- properties: {
205
- ...properties || {},
206
- distinct_id: distinctId,
207
- alias
208
- }
209
- });
210
- await this.sendImmediate('alias', payload, options);
211
- }
212
- groupIdentifyStateless(groupType, groupKey, groupProperties, options, distinctId, eventProperties) {
213
- this.wrap(()=>{
214
- const payload = this.buildPayload({
215
- distinct_id: distinctId || `$${groupType}_${groupKey}`,
216
- event: '$groupidentify',
217
- properties: {
218
- $group_type: groupType,
219
- $group_key: groupKey,
220
- $group_set: groupProperties || {},
221
- ...eventProperties || {}
222
- }
223
- });
224
- this.enqueue('capture', payload, options);
225
- });
226
- }
227
- async getRemoteConfig() {
228
- await this._initPromise;
229
- let host = this.host;
230
- if ('https://us.i.posthog.com' === host) host = 'https://us-assets.i.posthog.com';
231
- else if ('https://eu.i.posthog.com' === host) host = 'https://eu-assets.i.posthog.com';
232
- const url = `${host}/array/${this.apiKey}/config`;
233
- const fetchOptions = {
234
- method: 'GET',
235
- headers: {
236
- ...this.getCustomHeaders(),
237
- 'Content-Type': 'application/json'
238
- }
239
- };
240
- return this.fetchWithRetry(url, fetchOptions, {
241
- retryCount: 0
242
- }, this.remoteConfigRequestTimeoutMs).then((response)=>response.json()).catch((error)=>{
243
- this._logger.error('Remote config could not be loaded', error);
244
- this._events.emit('error', error);
245
- });
246
- }
247
- async getFlags(distinctId, groups = {}, personProperties = {}, groupProperties = {}, extraPayload = {}, fetchConfig = true) {
248
- await this._initPromise;
249
- const configParam = fetchConfig ? '&config=true' : '';
250
- const url = `${this.host}/flags/?v=2${configParam}`;
251
- const requestData = {
252
- token: this.apiKey,
253
- distinct_id: distinctId,
254
- groups,
255
- person_properties: personProperties,
256
- group_properties: groupProperties,
257
- ...extraPayload
258
- };
259
- if (this.evaluationContexts && this.evaluationContexts.length > 0) requestData.evaluation_contexts = this.evaluationContexts;
260
- const fetchOptions = {
261
- method: 'POST',
262
- headers: {
263
- ...this.getCustomHeaders(),
264
- 'Content-Type': 'application/json'
265
- },
266
- body: JSON.stringify(requestData)
267
- };
268
- this._logger.info('Flags URL', url);
269
- return this.fetchWithRetry(url, fetchOptions, {
270
- retryCount: 0
271
- }, this.featureFlagsRequestTimeoutMs).then((response)=>response.json()).then((response)=>({
272
- success: true,
273
- response: normalizeFlagsResponse(response)
274
- })).catch((error)=>{
275
- this._events.emit('error', error);
276
- return {
277
- success: false,
278
- error: this.categorizeRequestError(error)
279
- };
280
- });
281
- }
282
- categorizeRequestError(error) {
283
- if (error instanceof PostHogFetchHttpError) return {
284
- type: 'api_error',
285
- statusCode: error.status
286
- };
287
- if (error instanceof PostHogFetchNetworkError) {
288
- const cause = error.error;
289
- if (cause instanceof Error && ('AbortError' === cause.name || 'TimeoutError' === cause.name)) return {
290
- type: 'timeout'
291
- };
292
- return {
293
- type: 'connection_error'
294
- };
295
- }
296
- return {
297
- type: 'unknown_error'
298
- };
299
- }
300
- async getFeatureFlagStateless(key, distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip) {
301
- await this._initPromise;
302
- const flagDetailResponse = await this.getFeatureFlagDetailStateless(key, distinctId, groups, personProperties, groupProperties, disableGeoip);
303
- if (void 0 === flagDetailResponse) return {
304
- response: void 0,
305
- requestId: void 0
306
- };
307
- let response = getFeatureFlagValue(flagDetailResponse.response);
308
- if (void 0 === response) response = false;
309
- return {
310
- response,
311
- requestId: flagDetailResponse.requestId
312
- };
313
- }
314
- async getFeatureFlagDetailStateless(key, distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip) {
315
- await this._initPromise;
316
- const flagsResponse = await this.getFeatureFlagDetailsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, [
317
- key
318
- ]);
319
- if (void 0 === flagsResponse) return;
320
- const featureFlags = flagsResponse.flags;
321
- const flagDetail = featureFlags[key];
322
- return {
323
- response: flagDetail,
324
- requestId: flagsResponse.requestId,
325
- evaluatedAt: flagsResponse.evaluatedAt
326
- };
327
- }
328
- async getFeatureFlagPayloadStateless(key, distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip) {
329
- await this._initPromise;
330
- const payloads = await this.getFeatureFlagPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, [
331
- key
332
- ]);
333
- if (!payloads) return;
334
- const response = payloads[key];
335
- if (void 0 === response) return null;
336
- return response;
337
- }
338
- async getFeatureFlagPayloadsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
339
- await this._initPromise;
340
- const payloads = (await this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, flagKeysToEvaluate)).payloads;
341
- return payloads;
342
- }
343
- async getFeatureFlagsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
344
- await this._initPromise;
345
- return await this.getFeatureFlagsAndPayloadsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, flagKeysToEvaluate);
346
- }
347
- async getFeatureFlagsAndPayloadsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
348
- await this._initPromise;
349
- const featureFlagDetails = await this.getFeatureFlagDetailsStateless(distinctId, groups, personProperties, groupProperties, disableGeoip, flagKeysToEvaluate);
350
- if (!featureFlagDetails) return {
351
- flags: void 0,
352
- payloads: void 0,
353
- requestId: void 0
354
- };
355
- return {
356
- flags: featureFlagDetails.featureFlags,
357
- payloads: featureFlagDetails.featureFlagPayloads,
358
- requestId: featureFlagDetails.requestId
359
- };
360
- }
361
- async getFeatureFlagDetailsStateless(distinctId, groups = {}, personProperties = {}, groupProperties = {}, disableGeoip, flagKeysToEvaluate) {
362
- await this._initPromise;
363
- const extraPayload = {};
364
- if (disableGeoip ?? this.disableGeoip) extraPayload['geoip_disable'] = true;
365
- if (flagKeysToEvaluate) extraPayload['flag_keys_to_evaluate'] = flagKeysToEvaluate;
366
- const result = await this.getFlags(distinctId, groups, personProperties, groupProperties, extraPayload);
367
- if (!result.success) return;
368
- const flagsResponse = result.response;
369
- if (flagsResponse.errorsWhileComputingFlags) console.error('[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices');
370
- if (flagsResponse.quotaLimited?.includes("feature_flags")) {
371
- console.warn('[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts');
372
- return {
373
- flags: {},
374
- featureFlags: {},
375
- featureFlagPayloads: {},
376
- requestId: flagsResponse?.requestId,
377
- quotaLimited: flagsResponse.quotaLimited
378
- };
379
- }
380
- return flagsResponse;
381
- }
382
- async getSurveysStateless() {
383
- await this._initPromise;
384
- if (true === this.disableSurveys) {
385
- this._logger.info('Loading surveys is disabled.');
386
- return [];
387
- }
388
- const url = `${this.host}/api/surveys/?token=${this.apiKey}`;
389
- const fetchOptions = {
390
- method: 'GET',
391
- headers: {
392
- ...this.getCustomHeaders(),
393
- 'Content-Type': 'application/json'
394
- }
395
- };
396
- const response = await this.fetchWithRetry(url, fetchOptions).then((response)=>{
397
- if (200 !== response.status || !response.json) {
398
- const msg = `Surveys API could not be loaded: ${response.status}`;
399
- const error = new Error(msg);
400
- this._logger.error(error);
401
- this._events.emit('error', new Error(msg));
402
- return;
403
- }
404
- return response.json();
405
- }).catch((error)=>{
406
- this._logger.error('Surveys API could not be loaded', error);
407
- this._events.emit('error', error);
408
- });
409
- const newSurveys = response?.surveys;
410
- if (newSurveys) this._logger.info('Surveys fetched from API: ', JSON.stringify(newSurveys));
411
- return newSurveys ?? [];
412
- }
413
- get props() {
414
- if (!this._props) this._props = this.getPersistedProperty(PostHogPersistedProperty.Props);
415
- return this._props || {};
416
- }
417
- set props(val) {
418
- this._props = val;
419
- }
420
- async register(properties) {
421
- this.wrap(()=>{
422
- this.props = {
423
- ...this.props,
424
- ...properties
425
- };
426
- this.setPersistedProperty(PostHogPersistedProperty.Props, this.props);
427
- });
428
- }
429
- async unregister(property) {
430
- this.wrap(()=>{
431
- delete this.props[property];
432
- this.setPersistedProperty(PostHogPersistedProperty.Props, this.props);
433
- });
434
- }
435
- processBeforeEnqueue(message) {
436
- return message;
437
- }
438
- async flushStorage() {}
439
- enqueue(type, _message, options) {
440
- this.wrap(()=>{
441
- if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
442
- let message = this.prepareMessage(type, _message, options);
443
- message = this.processBeforeEnqueue(message);
444
- if (null === message) return;
445
- const queue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
446
- if (queue.length >= this.maxQueueSize) {
447
- queue.shift();
448
- this._logger.info('Queue is full, the oldest event is dropped.');
449
- }
450
- queue.push({
451
- message
452
- });
453
- this.setPersistedProperty(PostHogPersistedProperty.Queue, queue);
454
- this._events.emit(type, message);
455
- if (queue.length >= this.flushAt) this.flushBackground();
456
- if (this.flushInterval && !this._flushTimer) this._flushTimer = safeSetTimeout(()=>this.flushBackground(), this.flushInterval);
457
- });
458
- }
459
- async sendImmediate(type, _message, options) {
460
- if (this.disabled) return void this._logger.warn('The client is disabled');
461
- if (!this._isInitialized) await this._initPromise;
462
- if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
463
- let message = this.prepareMessage(type, _message, options);
464
- message = this.processBeforeEnqueue(message);
465
- if (null === message) return;
466
- const data = {
467
- api_key: this.apiKey,
468
- batch: [
469
- message
470
- ],
471
- sent_at: currentISOTime()
472
- };
473
- if (this.historicalMigration) data.historical_migration = true;
474
- const payload = JSON.stringify(data);
475
- const url = `${this.host}/batch/`;
476
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
477
- const fetchOptions = {
478
- method: 'POST',
479
- headers: {
480
- ...this.getCustomHeaders(),
481
- 'Content-Type': 'application/json',
482
- ...null !== gzippedPayload && {
483
- 'Content-Encoding': 'gzip'
484
- }
485
- },
486
- body: gzippedPayload || payload
487
- };
488
- try {
489
- await this.fetchWithRetry(url, fetchOptions);
490
- } catch (err) {
491
- this._events.emit('error', err);
492
- }
493
- }
494
- prepareMessage(type, _message, options) {
495
- const message = {
496
- ..._message,
497
- type: type,
498
- library: this.getLibraryId(),
499
- library_version: this.getLibraryVersion(),
500
- timestamp: options?.timestamp ? options?.timestamp : currentISOTime(),
501
- uuid: options?.uuid ? options.uuid : uuidv7()
502
- };
503
- const addGeoipDisableProperty = options?.disableGeoip ?? this.disableGeoip;
504
- if (addGeoipDisableProperty) {
505
- if (!message.properties) message.properties = {};
506
- message['properties']['$geoip_disable'] = true;
507
- }
508
- if (message.distinctId) {
509
- message.distinct_id = message.distinctId;
510
- delete message.distinctId;
511
- }
512
- return message;
513
- }
514
- clearFlushTimer() {
515
- if (this._flushTimer) {
516
- clearTimeout(this._flushTimer);
517
- this._flushTimer = void 0;
518
- }
519
- }
520
- flushBackground() {
521
- this.flush().catch(async (err)=>{
522
- await logFlushError(err);
523
- });
524
- }
525
- async flush() {
526
- const nextFlushPromise = allSettled([
527
- this.flushPromise
528
- ]).then(()=>this._flush());
529
- this.flushPromise = nextFlushPromise;
530
- this.addPendingPromise(nextFlushPromise);
531
- allSettled([
532
- nextFlushPromise
533
- ]).then(()=>{
534
- if (this.flushPromise === nextFlushPromise) this.flushPromise = null;
535
- });
536
- return nextFlushPromise;
537
- }
538
- getCustomHeaders() {
539
- const customUserAgent = this.getCustomUserAgent();
540
- const headers = {};
541
- if (customUserAgent && '' !== customUserAgent) headers['User-Agent'] = customUserAgent;
542
- return headers;
543
- }
544
- async _flush() {
545
- this.clearFlushTimer();
546
- await this._initPromise;
547
- let queue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
548
- if (!queue.length) return;
549
- const sentMessages = [];
550
- const originalQueueLength = queue.length;
551
- while(queue.length > 0 && sentMessages.length < originalQueueLength){
552
- const batchItems = queue.slice(0, this.maxBatchSize);
553
- const batchMessages = batchItems.map((item)=>item.message);
554
- const persistQueueChange = async ()=>{
555
- const refreshedQueue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
556
- const newQueue = refreshedQueue.slice(batchItems.length);
557
- this.setPersistedProperty(PostHogPersistedProperty.Queue, newQueue);
558
- queue = newQueue;
559
- await this.flushStorage();
560
- };
561
- const data = {
562
- api_key: this.apiKey,
563
- batch: batchMessages,
564
- sent_at: currentISOTime()
565
- };
566
- if (this.historicalMigration) data.historical_migration = true;
567
- const payload = JSON.stringify(data);
568
- const url = `${this.host}/batch/`;
569
- const gzippedPayload = this.disableCompression ? null : await gzipCompress(payload, this.isDebug);
570
- const fetchOptions = {
571
- method: 'POST',
572
- headers: {
573
- ...this.getCustomHeaders(),
574
- 'Content-Type': 'application/json',
575
- ...null !== gzippedPayload && {
576
- 'Content-Encoding': 'gzip'
577
- }
578
- },
579
- body: gzippedPayload || payload
580
- };
581
- const retryOptions = {
582
- retryCheck: (err)=>{
583
- if (isPostHogFetchContentTooLargeError(err)) return false;
584
- return isPostHogFetchError(err);
585
- }
586
- };
587
- try {
588
- await this.fetchWithRetry(url, fetchOptions, retryOptions);
589
- } catch (err) {
590
- if (isPostHogFetchContentTooLargeError(err) && batchMessages.length > 1) {
591
- this.maxBatchSize = Math.max(1, Math.floor(batchMessages.length / 2));
592
- this._logger.warn(`Received 413 when sending batch of size ${batchMessages.length}, reducing batch size to ${this.maxBatchSize}`);
593
- continue;
594
- }
595
- if (!(err instanceof PostHogFetchNetworkError)) await persistQueueChange();
596
- this._events.emit('error', err);
597
- throw err;
598
- }
599
- await persistQueueChange();
600
- sentMessages.push(...batchMessages);
601
- }
602
- this._events.emit('flush', sentMessages);
603
- }
604
- async fetchWithRetry(url, options, retryOptions, requestTimeout) {
605
- AbortSignal.timeout ??= function(ms) {
606
- const ctrl = new AbortController();
607
- setTimeout(()=>ctrl.abort(), ms);
608
- return ctrl.signal;
609
- };
610
- const body = options.body ? options.body : '';
611
- let reqByteLength = -1;
612
- try {
613
- reqByteLength = body instanceof Blob ? body.size : Buffer.byteLength(body, STRING_FORMAT);
614
- } catch {
615
- if (body instanceof Blob) reqByteLength = body.size;
616
- else {
617
- const encoded = new TextEncoder().encode(body);
618
- reqByteLength = encoded.length;
619
- }
620
- }
621
- return await retriable(async ()=>{
622
- let res = null;
623
- try {
624
- res = await this.fetch(url, {
625
- signal: AbortSignal.timeout(requestTimeout ?? this.requestTimeout),
626
- ...options
627
- });
628
- } catch (e) {
629
- throw new PostHogFetchNetworkError(e);
630
- }
631
- const isNoCors = 'no-cors' === options.mode;
632
- if (!isNoCors && (res.status < 200 || res.status >= 400)) throw new PostHogFetchHttpError(res, reqByteLength);
633
- return res;
634
- }, {
635
- ...this._retryOptions,
636
- ...retryOptions
637
- });
638
- }
639
- async _shutdown(shutdownTimeoutMs = 30000) {
640
- await this._initPromise;
641
- let hasTimedOut = false;
642
- this.clearFlushTimer();
643
- const doShutdown = async ()=>{
644
- try {
645
- await this.promiseQueue.join();
646
- while(true){
647
- const queue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
648
- if (0 === queue.length) break;
649
- await this.flush();
650
- if (hasTimedOut) break;
651
- }
652
- } catch (e) {
653
- if (!isPostHogFetchError(e)) throw e;
654
- await logFlushError(e);
655
- }
656
- };
657
- return Promise.race([
658
- new Promise((_, reject)=>{
659
- safeSetTimeout(()=>{
660
- this._logger.error('Timed out while shutting down PostHog');
661
- hasTimedOut = true;
662
- reject('Timeout while shutting down PostHog. Some events may not have been sent.');
663
- }, shutdownTimeoutMs);
664
- }),
665
- doShutdown()
666
- ]);
667
- }
668
- async shutdown(shutdownTimeoutMs = 30000) {
669
- if (this.shutdownPromise) this._logger.warn('shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup');
670
- else this.shutdownPromise = this._shutdown(shutdownTimeoutMs).finally(()=>{
671
- this.shutdownPromise = null;
672
- });
673
- return this.shutdownPromise;
674
- }
675
- }
676
- export { PostHogCoreStateless, posthog_core_stateless_QuotaLimitedFeature as QuotaLimitedFeature, logFlushError, maybeAdd };