posthog-node 4.16.0 → 4.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/edge/index.cjs +3919 -0
  3. package/lib/edge/index.cjs.map +1 -0
  4. package/lib/edge/index.mjs +3893 -0
  5. package/lib/edge/index.mjs.map +1 -0
  6. package/lib/index.d.ts +921 -859
  7. package/lib/{index.cjs.js → node/index.cjs} +3576 -3595
  8. package/lib/node/index.cjs.map +1 -0
  9. package/lib/{index.esm.js → node/index.mjs} +3577 -3593
  10. package/lib/node/index.mjs.map +1 -0
  11. package/package.json +31 -4
  12. package/index.ts +0 -3
  13. package/lib/index.cjs.js.map +0 -1
  14. package/lib/index.esm.js.map +0 -1
  15. package/lib/posthog-core/src/eventemitter.d.ts +0 -8
  16. package/lib/posthog-core/src/featureFlagUtils.d.ts +0 -34
  17. package/lib/posthog-core/src/index.d.ts +0 -259
  18. package/lib/posthog-core/src/lz-string.d.ts +0 -8
  19. package/lib/posthog-core/src/storage-memory.d.ts +0 -6
  20. package/lib/posthog-core/src/types.d.ts +0 -422
  21. package/lib/posthog-core/src/utils.d.ts +0 -20
  22. package/lib/posthog-core/src/vendor/uuidv7.d.ts +0 -179
  23. package/lib/posthog-node/index.d.ts +0 -3
  24. package/lib/posthog-node/src/crypto-helpers.d.ts +0 -3
  25. package/lib/posthog-node/src/crypto.d.ts +0 -2
  26. package/lib/posthog-node/src/error-tracking.d.ts +0 -12
  27. package/lib/posthog-node/src/extensions/error-tracking/autocapture.d.ts +0 -3
  28. package/lib/posthog-node/src/extensions/error-tracking/context-lines.d.ts +0 -6
  29. package/lib/posthog-node/src/extensions/error-tracking/error-conversion.d.ts +0 -2
  30. package/lib/posthog-node/src/extensions/error-tracking/reduceable-cache.d.ts +0 -12
  31. package/lib/posthog-node/src/extensions/error-tracking/stack-trace.d.ts +0 -15
  32. package/lib/posthog-node/src/extensions/error-tracking/type-checking.d.ts +0 -7
  33. package/lib/posthog-node/src/extensions/error-tracking/types.d.ts +0 -57
  34. package/lib/posthog-node/src/extensions/express.d.ts +0 -17
  35. package/lib/posthog-node/src/extensions/sentry-integration.d.ts +0 -51
  36. package/lib/posthog-node/src/feature-flags.d.ts +0 -84
  37. package/lib/posthog-node/src/fetch.d.ts +0 -11
  38. package/lib/posthog-node/src/lazy.d.ts +0 -23
  39. package/lib/posthog-node/src/posthog-node.d.ts +0 -98
  40. package/lib/posthog-node/src/types.d.ts +0 -229
  41. package/lib/posthog-node/test/test-utils.d.ts +0 -18
  42. package/src/crypto-helpers.ts +0 -36
  43. package/src/crypto.ts +0 -22
  44. package/src/error-tracking.ts +0 -67
  45. package/src/extensions/error-tracking/autocapture.ts +0 -65
  46. package/src/extensions/error-tracking/context-lines.ts +0 -425
  47. package/src/extensions/error-tracking/error-conversion.ts +0 -262
  48. package/src/extensions/error-tracking/reduceable-cache.ts +0 -39
  49. package/src/extensions/error-tracking/stack-trace.ts +0 -269
  50. package/src/extensions/error-tracking/type-checking.ts +0 -40
  51. package/src/extensions/error-tracking/types.ts +0 -65
  52. package/src/extensions/express.ts +0 -37
  53. package/src/extensions/sentry-integration.ts +0 -196
  54. package/src/feature-flags.ts +0 -864
  55. package/src/fetch.ts +0 -39
  56. package/src/lazy.ts +0 -55
  57. package/src/posthog-node.ts +0 -668
  58. package/src/types.ts +0 -257
  59. package/test/crypto.spec.ts +0 -36
  60. package/test/extensions/error-conversion.spec.ts +0 -44
  61. package/test/extensions/sentry-integration.spec.ts +0 -164
  62. package/test/feature-flags.decide.spec.ts +0 -380
  63. package/test/feature-flags.spec.ts +0 -4683
  64. package/test/lazy.spec.ts +0 -71
  65. package/test/posthog-node.spec.ts +0 -1341
  66. package/test/test-utils.ts +0 -111
  67. package/tsconfig.json +0 -7
package/src/fetch.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * Fetch wrapper
3
- *
4
- * We want to polyfill fetch when not available with axios but use it when it is.
5
- * NOTE: The current version of Axios has an issue when in non-node environments like Clouflare Workers.
6
- * This is currently solved by using the global fetch if available instead.
7
- * See https://github.com/PostHog/posthog-js-lite/issues/127 for more info
8
- */
9
-
10
- import { FetchLike, PostHogFetchOptions, PostHogFetchResponse } from 'posthog-core/src'
11
- import { getFetch } from 'posthog-core/src/utils'
12
-
13
- let _fetch: FetchLike | undefined = getFetch()
14
-
15
- if (!_fetch) {
16
- // eslint-disable-next-line @typescript-eslint/no-var-requires
17
- const axios = require('axios')
18
-
19
- _fetch = async (url: string, options: PostHogFetchOptions): Promise<PostHogFetchResponse> => {
20
- const res = await axios.request({
21
- url,
22
- headers: options.headers,
23
- method: options.method.toLowerCase(),
24
- data: options.body,
25
- signal: options.signal,
26
- // fetch only throws on network errors, not on HTTP errors
27
- validateStatus: () => true,
28
- })
29
-
30
- return {
31
- status: res.status,
32
- text: async () => res.data,
33
- json: async () => res.data,
34
- }
35
- }
36
- }
37
-
38
- // NOTE: We have to export this as default, even though we prefer named exports as we are relying on detecting "fetch" in the global scope
39
- export default _fetch as FetchLike
package/src/lazy.ts DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * A lazy value that is only computed when needed. Inspired by C#'s Lazy<T> class.
3
- */
4
- export class Lazy<T> {
5
- private value: T | undefined
6
- private factory: () => Promise<T>
7
- private initializationPromise: Promise<T> | undefined
8
-
9
- constructor(factory: () => Promise<T>) {
10
- this.factory = factory
11
- }
12
-
13
- /**
14
- * Gets the value, initializing it if necessary.
15
- * Multiple concurrent calls will share the same initialization promise.
16
- */
17
- async getValue(): Promise<T> {
18
- if (this.value !== undefined) {
19
- return this.value
20
- }
21
-
22
- if (this.initializationPromise === undefined) {
23
- this.initializationPromise = (async () => {
24
- try {
25
- const result = await this.factory()
26
- this.value = result
27
- return result
28
- } finally {
29
- // Clear the promise so we can retry if needed
30
- this.initializationPromise = undefined
31
- }
32
- })()
33
- }
34
-
35
- return this.initializationPromise
36
- }
37
-
38
- /**
39
- * Returns true if the value has been initialized.
40
- */
41
- isInitialized(): boolean {
42
- return this.value !== undefined
43
- }
44
-
45
- /**
46
- * Returns a promise that resolves when the value is initialized.
47
- * If already initialized, resolves immediately.
48
- */
49
- async waitForInitialization(): Promise<void> {
50
- if (this.isInitialized()) {
51
- return
52
- }
53
- await this.getValue()
54
- }
55
- }