posthog-node 4.2.0 → 4.2.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 +4 -0
- package/CONTRIBUTING.md +14 -0
- package/lib/index.cjs.js +70 -252
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +21 -17
- package/lib/index.esm.js +70 -252
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +3 -2
- package/lib/posthog-core/src/types.d.ts +16 -13
- package/lib/posthog-node/src/extensions/sentry-integration.d.ts +2 -2
- package/lib/posthog-node/src/feature-flags.d.ts +2 -1
- package/lib/posthog-node/src/fetch.d.ts +1 -1
- package/lib/posthog-node/src/posthog-node.d.ts +1 -1
- package/lib/posthog-node/src/types.d.ts +5 -5
- package/package.json +1 -1
- package/src/feature-flags.ts +14 -14
- package/src/posthog-node.ts +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
type PostHogCoreOptions = {
|
|
3
3
|
/** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
|
|
4
4
|
host?: string;
|
|
5
5
|
/** The number of events to queue before sending to PostHog (flushing) */
|
|
@@ -37,7 +37,7 @@ declare type PostHogCoreOptions = {
|
|
|
37
37
|
featureFlagsRequestTimeoutMs?: number;
|
|
38
38
|
/** For Session Analysis how long before we expire a session (defaults to 30 mins) */
|
|
39
39
|
sessionExpirationTimeSeconds?: number;
|
|
40
|
-
/** Whether to post events to PostHog in JSON or compressed format. Defaults to '
|
|
40
|
+
/** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
|
|
41
41
|
captureMode?: 'json' | 'form';
|
|
42
42
|
disableGeoip?: boolean;
|
|
43
43
|
/** Special flag to indicate ingested data is for a historical migration. */
|
|
@@ -57,9 +57,10 @@ declare enum PostHogPersistedProperty {
|
|
|
57
57
|
PersonProperties = "person_properties",
|
|
58
58
|
GroupProperties = "group_properties",
|
|
59
59
|
InstalledAppBuild = "installed_app_build",
|
|
60
|
-
InstalledAppVersion = "installed_app_version"
|
|
60
|
+
InstalledAppVersion = "installed_app_version",
|
|
61
|
+
SessionReplay = "session_replay"
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
type PostHogFetchOptions = {
|
|
63
64
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
|
|
64
65
|
mode?: 'no-cors';
|
|
65
66
|
credentials?: 'omit';
|
|
@@ -69,22 +70,22 @@ declare type PostHogFetchOptions = {
|
|
|
69
70
|
body?: string;
|
|
70
71
|
signal?: AbortSignal;
|
|
71
72
|
};
|
|
72
|
-
|
|
73
|
+
type PostHogCaptureOptions = {
|
|
73
74
|
/** If provided overrides the auto-generated event ID */
|
|
74
75
|
uuid?: string;
|
|
75
76
|
/** If provided overrides the auto-generated timestamp */
|
|
76
77
|
timestamp?: Date;
|
|
77
78
|
disableGeoip?: boolean;
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
+
type PostHogFetchResponse = {
|
|
80
81
|
status: number;
|
|
81
82
|
text: () => Promise<string>;
|
|
82
83
|
json: () => Promise<any>;
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
type PostHogEventProperties = {
|
|
85
86
|
[key: string]: any;
|
|
86
87
|
};
|
|
87
|
-
|
|
88
|
+
type PostHogDecideResponse = {
|
|
88
89
|
config: {
|
|
89
90
|
enable_collect_everything: boolean;
|
|
90
91
|
};
|
|
@@ -101,13 +102,15 @@ declare type PostHogDecideResponse = {
|
|
|
101
102
|
[key: string]: JsonType;
|
|
102
103
|
};
|
|
103
104
|
errorsWhileComputingFlags: boolean;
|
|
104
|
-
sessionRecording
|
|
105
|
+
sessionRecording?: boolean | {
|
|
106
|
+
[key: string]: JsonType;
|
|
107
|
+
};
|
|
105
108
|
};
|
|
106
|
-
|
|
109
|
+
type PostHogFlagsAndPayloadsResponse = {
|
|
107
110
|
featureFlags: PostHogDecideResponse['featureFlags'];
|
|
108
111
|
featureFlagPayloads: PostHogDecideResponse['featureFlagPayloads'];
|
|
109
112
|
};
|
|
110
|
-
|
|
113
|
+
type JsonType = string | number | boolean | null | {
|
|
111
114
|
[key: string]: JsonType;
|
|
112
115
|
} | Array<JsonType>;
|
|
113
116
|
|
|
@@ -127,8 +130,8 @@ declare class SimpleEventEmitter {
|
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
declare abstract class PostHogCoreStateless {
|
|
130
|
-
|
|
131
|
-
host: string;
|
|
133
|
+
readonly apiKey: string;
|
|
134
|
+
readonly host: string;
|
|
132
135
|
private flushAt;
|
|
133
136
|
private maxBatchSize;
|
|
134
137
|
private maxQueueSize;
|
|
@@ -155,6 +158,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
155
158
|
abstract getPersistedProperty<T>(key: PostHogPersistedProperty): T | undefined;
|
|
156
159
|
abstract setPersistedProperty<T>(key: PostHogPersistedProperty, value: T | null): void;
|
|
157
160
|
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
161
|
+
protected logMsgIfDebug(fn: () => void): void;
|
|
158
162
|
protected wrap(fn: () => void): void;
|
|
159
163
|
protected getCommonEventProperties(): any;
|
|
160
164
|
get optedOut(): boolean;
|
|
@@ -230,7 +234,7 @@ interface GroupIdentifyMessage {
|
|
|
230
234
|
distinctId?: string;
|
|
231
235
|
disableGeoip?: boolean;
|
|
232
236
|
}
|
|
233
|
-
|
|
237
|
+
type PostHogNodeV1 = {
|
|
234
238
|
/**
|
|
235
239
|
* @description Capture allows you to capture anything a user does within your system,
|
|
236
240
|
* which you can later use in PostHog to find patterns in usage,
|
|
@@ -352,7 +356,7 @@ declare type PostHogNodeV1 = {
|
|
|
352
356
|
shutdown(shutdownTimeoutMs?: number): void;
|
|
353
357
|
};
|
|
354
358
|
|
|
355
|
-
|
|
359
|
+
type PostHogOptions = PostHogCoreOptions & {
|
|
356
360
|
persistence?: 'memory';
|
|
357
361
|
personalApiKey?: string;
|
|
358
362
|
featureFlagsPollingInterval?: number;
|
|
@@ -430,8 +434,8 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
430
434
|
* @file Adapted from [posthog-js](https://github.com/PostHog/posthog-js/blob/8157df935a4d0e71d2fefef7127aa85ee51c82d1/src/extensions/sentry-integration.ts) with modifications for the Node SDK.
|
|
431
435
|
*/
|
|
432
436
|
|
|
433
|
-
|
|
434
|
-
|
|
437
|
+
type _SentryEventProcessor = any;
|
|
438
|
+
type _SentryHub = any;
|
|
435
439
|
interface _SentryIntegration {
|
|
436
440
|
name: string;
|
|
437
441
|
setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
|