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.
- package/CHANGELOG.md +8 -0
- package/lib/edge/index.cjs +3919 -0
- package/lib/edge/index.cjs.map +1 -0
- package/lib/edge/index.mjs +3893 -0
- package/lib/edge/index.mjs.map +1 -0
- package/lib/index.d.ts +921 -859
- package/lib/{index.cjs.js → node/index.cjs} +3576 -3595
- package/lib/node/index.cjs.map +1 -0
- package/lib/{index.esm.js → node/index.mjs} +3577 -3593
- package/lib/node/index.mjs.map +1 -0
- package/package.json +31 -4
- package/index.ts +0 -3
- package/lib/index.cjs.js.map +0 -1
- package/lib/index.esm.js.map +0 -1
- package/lib/posthog-core/src/eventemitter.d.ts +0 -8
- package/lib/posthog-core/src/featureFlagUtils.d.ts +0 -34
- package/lib/posthog-core/src/index.d.ts +0 -259
- package/lib/posthog-core/src/lz-string.d.ts +0 -8
- package/lib/posthog-core/src/storage-memory.d.ts +0 -6
- package/lib/posthog-core/src/types.d.ts +0 -422
- package/lib/posthog-core/src/utils.d.ts +0 -20
- package/lib/posthog-core/src/vendor/uuidv7.d.ts +0 -179
- package/lib/posthog-node/index.d.ts +0 -3
- package/lib/posthog-node/src/crypto-helpers.d.ts +0 -3
- package/lib/posthog-node/src/crypto.d.ts +0 -2
- package/lib/posthog-node/src/error-tracking.d.ts +0 -12
- package/lib/posthog-node/src/extensions/error-tracking/autocapture.d.ts +0 -3
- package/lib/posthog-node/src/extensions/error-tracking/context-lines.d.ts +0 -6
- package/lib/posthog-node/src/extensions/error-tracking/error-conversion.d.ts +0 -2
- package/lib/posthog-node/src/extensions/error-tracking/reduceable-cache.d.ts +0 -12
- package/lib/posthog-node/src/extensions/error-tracking/stack-trace.d.ts +0 -15
- package/lib/posthog-node/src/extensions/error-tracking/type-checking.d.ts +0 -7
- package/lib/posthog-node/src/extensions/error-tracking/types.d.ts +0 -57
- package/lib/posthog-node/src/extensions/express.d.ts +0 -17
- package/lib/posthog-node/src/extensions/sentry-integration.d.ts +0 -51
- package/lib/posthog-node/src/feature-flags.d.ts +0 -84
- package/lib/posthog-node/src/fetch.d.ts +0 -11
- package/lib/posthog-node/src/lazy.d.ts +0 -23
- package/lib/posthog-node/src/posthog-node.d.ts +0 -98
- package/lib/posthog-node/src/types.d.ts +0 -229
- package/lib/posthog-node/test/test-utils.d.ts +0 -18
- package/src/crypto-helpers.ts +0 -36
- package/src/crypto.ts +0 -22
- package/src/error-tracking.ts +0 -67
- package/src/extensions/error-tracking/autocapture.ts +0 -65
- package/src/extensions/error-tracking/context-lines.ts +0 -425
- package/src/extensions/error-tracking/error-conversion.ts +0 -262
- package/src/extensions/error-tracking/reduceable-cache.ts +0 -39
- package/src/extensions/error-tracking/stack-trace.ts +0 -269
- package/src/extensions/error-tracking/type-checking.ts +0 -40
- package/src/extensions/error-tracking/types.ts +0 -65
- package/src/extensions/express.ts +0 -37
- package/src/extensions/sentry-integration.ts +0 -196
- package/src/feature-flags.ts +0 -864
- package/src/fetch.ts +0 -39
- package/src/lazy.ts +0 -55
- package/src/posthog-node.ts +0 -668
- package/src/types.ts +0 -257
- package/test/crypto.spec.ts +0 -36
- package/test/extensions/error-conversion.spec.ts +0 -44
- package/test/extensions/sentry-integration.spec.ts +0 -164
- package/test/feature-flags.decide.spec.ts +0 -380
- package/test/feature-flags.spec.ts +0 -4683
- package/test/lazy.spec.ts +0 -71
- package/test/posthog-node.spec.ts +0 -1341
- package/test/test-utils.ts +0 -111
- 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
|
-
}
|