posthog-node 4.2.0 → 4.2.2
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/CONTRIBUTING.md +14 -0
- package/lib/index.cjs.js +106 -273
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +23 -18
- package/lib/index.esm.js +106 -273
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +5 -3
- 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;
|
|
@@ -140,7 +143,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
140
143
|
private removeDebugCallback?;
|
|
141
144
|
private disableGeoip;
|
|
142
145
|
private historicalMigration;
|
|
143
|
-
disabled: boolean;
|
|
146
|
+
protected disabled: boolean;
|
|
144
147
|
private defaultOptIn;
|
|
145
148
|
private pendingPromises;
|
|
146
149
|
protected _events: SimpleEventEmitter;
|
|
@@ -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;
|
|
@@ -163,6 +167,7 @@ declare abstract class PostHogCoreStateless {
|
|
|
163
167
|
on(event: string, cb: (...args: any[]) => void): () => void;
|
|
164
168
|
debug(enabled?: boolean): void;
|
|
165
169
|
get isDebug(): boolean;
|
|
170
|
+
get isDisabled(): boolean;
|
|
166
171
|
private buildPayload;
|
|
167
172
|
protected addPendingPromise<T>(promise: Promise<T>): Promise<T>;
|
|
168
173
|
/***
|
|
@@ -230,7 +235,7 @@ interface GroupIdentifyMessage {
|
|
|
230
235
|
distinctId?: string;
|
|
231
236
|
disableGeoip?: boolean;
|
|
232
237
|
}
|
|
233
|
-
|
|
238
|
+
type PostHogNodeV1 = {
|
|
234
239
|
/**
|
|
235
240
|
* @description Capture allows you to capture anything a user does within your system,
|
|
236
241
|
* which you can later use in PostHog to find patterns in usage,
|
|
@@ -352,7 +357,7 @@ declare type PostHogNodeV1 = {
|
|
|
352
357
|
shutdown(shutdownTimeoutMs?: number): void;
|
|
353
358
|
};
|
|
354
359
|
|
|
355
|
-
|
|
360
|
+
type PostHogOptions = PostHogCoreOptions & {
|
|
356
361
|
persistence?: 'memory';
|
|
357
362
|
personalApiKey?: string;
|
|
358
363
|
featureFlagsPollingInterval?: number;
|
|
@@ -430,8 +435,8 @@ declare class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
|
|
|
430
435
|
* @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
436
|
*/
|
|
432
437
|
|
|
433
|
-
|
|
434
|
-
|
|
438
|
+
type _SentryEventProcessor = any;
|
|
439
|
+
type _SentryHub = any;
|
|
435
440
|
interface _SentryIntegration {
|
|
436
441
|
name: string;
|
|
437
442
|
setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
|