posthog-node 5.8.8 → 5.9.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/dist/{index.d.ts → client.d.ts} +7 -378
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +480 -0
- package/dist/client.mjs +436 -0
- package/dist/entrypoints/index.edge.d.ts +6 -0
- package/dist/entrypoints/index.edge.d.ts.map +1 -0
- package/dist/entrypoints/index.edge.js +96 -0
- package/dist/entrypoints/index.edge.mjs +19 -0
- package/dist/entrypoints/index.node.d.ts +6 -0
- package/dist/entrypoints/index.node.d.ts.map +1 -0
- package/dist/entrypoints/index.node.js +107 -0
- package/dist/entrypoints/index.node.mjs +24 -0
- package/dist/exports.d.ts +4 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/exports.js +78 -0
- package/dist/exports.mjs +3 -0
- package/dist/extensions/error-tracking/autocapture.d.ts +4 -0
- package/dist/extensions/error-tracking/autocapture.d.ts.map +1 -0
- package/dist/extensions/error-tracking/autocapture.js +68 -0
- package/dist/extensions/error-tracking/autocapture.mjs +31 -0
- package/dist/extensions/error-tracking/index.d.ts +19 -0
- package/dist/extensions/error-tracking/index.d.ts.map +1 -0
- package/dist/extensions/error-tracking/index.js +97 -0
- package/dist/extensions/error-tracking/index.mjs +63 -0
- package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts +5 -0
- package/dist/extensions/error-tracking/modifiers/context-lines.node.d.ts.map +1 -0
- package/dist/extensions/error-tracking/modifiers/context-lines.node.js +227 -0
- package/dist/extensions/error-tracking/modifiers/context-lines.node.mjs +187 -0
- package/dist/extensions/error-tracking/modifiers/module.node.d.ts +3 -0
- package/dist/extensions/error-tracking/modifiers/module.node.d.ts.map +1 -0
- package/dist/extensions/error-tracking/modifiers/module.node.js +64 -0
- package/dist/extensions/error-tracking/modifiers/module.node.mjs +30 -0
- package/dist/extensions/express.d.ts +17 -0
- package/dist/extensions/express.d.ts.map +1 -0
- package/dist/extensions/express.js +61 -0
- package/dist/extensions/express.mjs +17 -0
- package/dist/extensions/feature-flags/crypto-helpers.d.ts +3 -0
- package/dist/extensions/feature-flags/crypto-helpers.d.ts.map +1 -0
- package/dist/extensions/feature-flags/crypto-helpers.js +77 -0
- package/dist/extensions/feature-flags/crypto-helpers.mjs +22 -0
- package/dist/extensions/feature-flags/crypto.d.ts +2 -0
- package/dist/extensions/feature-flags/crypto.d.ts.map +1 -0
- package/dist/extensions/feature-flags/crypto.js +47 -0
- package/dist/extensions/feature-flags/crypto.mjs +13 -0
- package/dist/extensions/feature-flags/feature-flags.d.ts +89 -0
- package/dist/extensions/feature-flags/feature-flags.d.ts.map +1 -0
- package/dist/extensions/feature-flags/feature-flags.js +529 -0
- package/dist/extensions/feature-flags/feature-flags.mjs +483 -0
- package/dist/extensions/feature-flags/lazy.d.ts +24 -0
- package/dist/extensions/feature-flags/lazy.d.ts.map +1 -0
- package/dist/extensions/feature-flags/lazy.js +60 -0
- package/dist/extensions/feature-flags/lazy.mjs +26 -0
- package/dist/extensions/sentry-integration.d.ts +54 -0
- package/dist/extensions/sentry-integration.d.ts.map +1 -0
- package/dist/extensions/sentry-integration.js +113 -0
- package/dist/extensions/sentry-integration.mjs +73 -0
- package/dist/storage-memory.d.ts +7 -0
- package/dist/storage-memory.d.ts.map +1 -0
- package/dist/storage-memory.js +46 -0
- package/dist/storage-memory.mjs +12 -0
- package/dist/types.d.ts +253 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/types.mjs +0 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/dist/utils/logger.mjs +29 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +36 -0
- package/dist/version.mjs +2 -0
- package/package.json +32 -31
- package/src/client.ts +1532 -0
- package/src/entrypoints/index.edge.ts +22 -0
- package/src/entrypoints/index.node.ts +26 -0
- package/src/exports.ts +3 -0
- package/src/extensions/error-tracking/autocapture.ts +67 -0
- package/src/extensions/error-tracking/index.ts +104 -0
- package/src/extensions/error-tracking/modifiers/context-lines.node.ts +404 -0
- package/src/extensions/error-tracking/modifiers/module.node.ts +68 -0
- package/src/extensions/express.ts +40 -0
- package/src/extensions/feature-flags/crypto-helpers.ts +36 -0
- package/src/extensions/feature-flags/crypto.ts +22 -0
- package/src/extensions/feature-flags/feature-flags.ts +1003 -0
- package/src/extensions/feature-flags/lazy.ts +55 -0
- package/src/extensions/sentry-integration.ts +216 -0
- package/src/storage-memory.ts +13 -0
- package/src/types.ts +294 -0
- package/src/utils/logger.ts +39 -0
- package/src/version.ts +1 -0
- package/dist/edge/index.cjs +0 -3150
- package/dist/edge/index.cjs.map +0 -1
- package/dist/edge/index.mjs +0 -3144
- package/dist/edge/index.mjs.map +0 -1
- package/dist/node/index.cjs +0 -3556
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.mjs +0 -3550
- package/dist/node/index.mjs.map +0 -1
|
@@ -1,309 +1,9 @@
|
|
|
1
|
-
import { JsonType,
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
mechanism?: Partial<Mechanism>;
|
|
8
|
-
syntheticException?: Error | null;
|
|
9
|
-
}
|
|
10
|
-
interface Mechanism {
|
|
11
|
-
handled?: boolean;
|
|
12
|
-
type?: string;
|
|
13
|
-
source?: string;
|
|
14
|
-
synthetic?: boolean;
|
|
15
|
-
}
|
|
16
|
-
type StackParser = (stack: string, skipFirstLines?: number) => StackFrame[];
|
|
17
|
-
type StackFrameModifierFn = (frames: StackFrame[]) => Promise<StackFrame[]>;
|
|
18
|
-
interface StackFrame {
|
|
19
|
-
platform: string;
|
|
20
|
-
filename?: string;
|
|
21
|
-
function?: string;
|
|
22
|
-
module?: string;
|
|
23
|
-
lineno?: number;
|
|
24
|
-
colno?: number;
|
|
25
|
-
abs_path?: string;
|
|
26
|
-
context_line?: string;
|
|
27
|
-
pre_context?: string[];
|
|
28
|
-
post_context?: string[];
|
|
29
|
-
in_app?: boolean;
|
|
30
|
-
instruction_addr?: string;
|
|
31
|
-
addr_mode?: string;
|
|
32
|
-
vars?: {
|
|
33
|
-
[key: string]: JsonType;
|
|
34
|
-
};
|
|
35
|
-
chunk_id?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface IdentifyMessage {
|
|
39
|
-
distinctId: string;
|
|
40
|
-
properties?: Record<string | number, any>;
|
|
41
|
-
disableGeoip?: boolean;
|
|
42
|
-
}
|
|
43
|
-
interface SendFeatureFlagsOptions {
|
|
44
|
-
onlyEvaluateLocally?: boolean;
|
|
45
|
-
personProperties?: Record<string, any>;
|
|
46
|
-
groupProperties?: Record<string, Record<string, any>>;
|
|
47
|
-
flagKeys?: string[];
|
|
48
|
-
}
|
|
49
|
-
interface EventMessage extends IdentifyMessage {
|
|
50
|
-
event: string;
|
|
51
|
-
groups?: Record<string, string | number>;
|
|
52
|
-
sendFeatureFlags?: boolean | SendFeatureFlagsOptions;
|
|
53
|
-
timestamp?: Date;
|
|
54
|
-
uuid?: string;
|
|
55
|
-
}
|
|
56
|
-
interface GroupIdentifyMessage {
|
|
57
|
-
groupType: string;
|
|
58
|
-
groupKey: string;
|
|
59
|
-
properties?: Record<string | number, any>;
|
|
60
|
-
distinctId?: string;
|
|
61
|
-
disableGeoip?: boolean;
|
|
62
|
-
}
|
|
63
|
-
type PropertyGroup = {
|
|
64
|
-
type: 'AND' | 'OR';
|
|
65
|
-
values: PropertyGroup[] | FlagProperty[];
|
|
66
|
-
};
|
|
67
|
-
type FlagProperty = {
|
|
68
|
-
key: string;
|
|
69
|
-
type?: string;
|
|
70
|
-
value: FlagPropertyValue;
|
|
71
|
-
operator?: string;
|
|
72
|
-
negation?: boolean;
|
|
73
|
-
dependency_chain?: string[];
|
|
74
|
-
};
|
|
75
|
-
type FlagPropertyValue = string | number | (string | number)[] | boolean;
|
|
76
|
-
type FeatureFlagCondition = {
|
|
77
|
-
properties: FlagProperty[];
|
|
78
|
-
rollout_percentage?: number;
|
|
79
|
-
variant?: string;
|
|
80
|
-
};
|
|
81
|
-
type BeforeSendFn = (event: EventMessage | null) => EventMessage | null;
|
|
82
|
-
type PostHogOptions = PostHogCoreOptions & {
|
|
83
|
-
persistence?: 'memory';
|
|
84
|
-
personalApiKey?: string;
|
|
85
|
-
privacyMode?: boolean;
|
|
86
|
-
enableExceptionAutocapture?: boolean;
|
|
87
|
-
featureFlagsPollingInterval?: number;
|
|
88
|
-
maxCacheSize?: number;
|
|
89
|
-
fetch?: (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
|
|
90
|
-
enableLocalEvaluation?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Allows modification or dropping of events before they're sent to PostHog.
|
|
93
|
-
* If an array is provided, the functions are run in order.
|
|
94
|
-
* If a function returns null, the event will be dropped.
|
|
95
|
-
*/
|
|
96
|
-
before_send?: BeforeSendFn | BeforeSendFn[];
|
|
97
|
-
};
|
|
98
|
-
type PostHogFeatureFlag = {
|
|
99
|
-
id: number;
|
|
100
|
-
name: string;
|
|
101
|
-
key: string;
|
|
102
|
-
filters?: {
|
|
103
|
-
aggregation_group_type_index?: number;
|
|
104
|
-
groups?: FeatureFlagCondition[];
|
|
105
|
-
multivariate?: {
|
|
106
|
-
variants: {
|
|
107
|
-
key: string;
|
|
108
|
-
rollout_percentage: number;
|
|
109
|
-
}[];
|
|
110
|
-
};
|
|
111
|
-
payloads?: Record<string, string>;
|
|
112
|
-
};
|
|
113
|
-
deleted: boolean;
|
|
114
|
-
active: boolean;
|
|
115
|
-
rollout_percentage: null | number;
|
|
116
|
-
ensure_experience_continuity: boolean;
|
|
117
|
-
experiment_set: number[];
|
|
118
|
-
};
|
|
119
|
-
interface IPostHog {
|
|
120
|
-
/**
|
|
121
|
-
* @description Capture allows you to capture anything a user does within your system,
|
|
122
|
-
* which you can later use in PostHog to find patterns in usage,
|
|
123
|
-
* work out which features to improve or where people are giving up.
|
|
124
|
-
* A capture call requires:
|
|
125
|
-
* @param distinctId which uniquely identifies your user
|
|
126
|
-
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
127
|
-
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
128
|
-
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
129
|
-
* @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event.
|
|
130
|
-
*/
|
|
131
|
-
capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void;
|
|
132
|
-
/**
|
|
133
|
-
* @description Capture an event immediately. Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls.
|
|
134
|
-
* @param distinctId which uniquely identifies your user
|
|
135
|
-
* @param event We recommend using [verb] [noun], like movie played or movie updated to easily identify what your events mean later on.
|
|
136
|
-
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
137
|
-
* @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
|
|
138
|
-
* @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event.
|
|
139
|
-
*/
|
|
140
|
-
captureImmediate({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
|
|
143
|
-
* and even do things like segment users by these properties.
|
|
144
|
-
* An identify call requires:
|
|
145
|
-
* @param distinctId which uniquely identifies your user
|
|
146
|
-
* @param properties with a dict with any key: value pairs
|
|
147
|
-
*/
|
|
148
|
-
identify({ distinctId, properties }: IdentifyMessage): void;
|
|
149
|
-
/**
|
|
150
|
-
* @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog.
|
|
151
|
-
* Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls.
|
|
152
|
-
* @param distinctId which uniquely identifies your user
|
|
153
|
-
* @param properties with a dict with any key: value pairs
|
|
154
|
-
*/
|
|
155
|
-
identifyImmediate({ distinctId, properties }: IdentifyMessage): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
|
|
158
|
-
* This will allow you to answer questions like "Which marketing channels leads to users churning after a month?"
|
|
159
|
-
* or "What do users do on our website before signing up?"
|
|
160
|
-
* In a purely back-end implementation, this means whenever an anonymous user does something, you'll want to send a session ID with the capture call.
|
|
161
|
-
* Then, when that users signs up, you want to do an alias call with the session ID and the newly created user ID.
|
|
162
|
-
* The same concept applies for when a user logs in. If you're using PostHog in the front-end and back-end,
|
|
163
|
-
* doing the identify call in the frontend will be enough.:
|
|
164
|
-
* @param distinctId the current unique id
|
|
165
|
-
* @param alias the unique ID of the user before
|
|
166
|
-
*/
|
|
167
|
-
alias(data: {
|
|
168
|
-
distinctId: string;
|
|
169
|
-
alias: string;
|
|
170
|
-
}): void;
|
|
171
|
-
/**
|
|
172
|
-
* @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
|
|
173
|
-
* Useful for edge environments where the usual queue-based sending is not preferable. Do not mix immediate and non-immediate calls.
|
|
174
|
-
* @param distinctId the current unique id
|
|
175
|
-
* @param alias the unique ID of the user before
|
|
176
|
-
*/
|
|
177
|
-
aliasImmediate(data: {
|
|
178
|
-
distinctId: string;
|
|
179
|
-
alias: string;
|
|
180
|
-
}): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* @description PostHog feature flags (https://posthog.com/docs/features/feature-flags)
|
|
183
|
-
* allow you to safely deploy and roll back new features. Once you've created a feature flag in PostHog,
|
|
184
|
-
* you can use this method to check if the flag is on for a given user, allowing you to create logic to turn
|
|
185
|
-
* features on and off for different user groups or individual users.
|
|
186
|
-
* @param key the unique key of your feature flag
|
|
187
|
-
* @param distinctId the current unique id
|
|
188
|
-
* @param options: dict with optional parameters below
|
|
189
|
-
* @param groups optional - what groups are currently active (group analytics). Required if the flag depends on groups.
|
|
190
|
-
* @param personProperties optional - what person properties are known. Used to compute flags locally, if personalApiKey is present.
|
|
191
|
-
* @param groupProperties optional - what group properties are known. Used to compute flags locally, if personalApiKey is present.
|
|
192
|
-
* @param onlyEvaluateLocally optional - whether to only evaluate the flag locally. Defaults to false.
|
|
193
|
-
* @param sendFeatureFlagEvents optional - whether to send feature flag events. Used for Experiments. Defaults to true.
|
|
194
|
-
*
|
|
195
|
-
* @returns true if the flag is on, false if the flag is off, undefined if there was an error.
|
|
196
|
-
*/
|
|
197
|
-
isFeatureEnabled(key: string, distinctId: string, options?: {
|
|
198
|
-
groups?: Record<string, string>;
|
|
199
|
-
personProperties?: Record<string, string>;
|
|
200
|
-
groupProperties?: Record<string, Record<string, string>>;
|
|
201
|
-
onlyEvaluateLocally?: boolean;
|
|
202
|
-
sendFeatureFlagEvents?: boolean;
|
|
203
|
-
}): Promise<boolean | undefined>;
|
|
204
|
-
/**
|
|
205
|
-
* @description PostHog feature flags (https://posthog.com/docs/features/feature-flags)
|
|
206
|
-
* allow you to safely deploy and roll back new features. Once you've created a feature flag in PostHog,
|
|
207
|
-
* you can use this method to check if the flag is on for a given user, allowing you to create logic to turn
|
|
208
|
-
* features on and off for different user groups or individual users.
|
|
209
|
-
* @param key the unique key of your feature flag
|
|
210
|
-
* @param distinctId the current unique id
|
|
211
|
-
* @param options: dict with optional parameters below
|
|
212
|
-
* @param groups optional - what groups are currently active (group analytics). Required if the flag depends on groups.
|
|
213
|
-
* @param personProperties optional - what person properties are known. Used to compute flags locally, if personalApiKey is present.
|
|
214
|
-
* @param groupProperties optional - what group properties are known. Used to compute flags locally, if personalApiKey is present.
|
|
215
|
-
* @param onlyEvaluateLocally optional - whether to only evaluate the flag locally. Defaults to false.
|
|
216
|
-
* @param sendFeatureFlagEvents optional - whether to send feature flag events. Used for Experiments. Defaults to true.
|
|
217
|
-
*
|
|
218
|
-
* @returns true or string(for multivariates) if the flag is on, false if the flag is off, undefined if there was an error.
|
|
219
|
-
*/
|
|
220
|
-
getFeatureFlag(key: string, distinctId: string, options?: {
|
|
221
|
-
groups?: Record<string, string>;
|
|
222
|
-
personProperties?: Record<string, string>;
|
|
223
|
-
groupProperties?: Record<string, Record<string, string>>;
|
|
224
|
-
onlyEvaluateLocally?: boolean;
|
|
225
|
-
sendFeatureFlagEvents?: boolean;
|
|
226
|
-
}): Promise<FeatureFlagValue | undefined>;
|
|
227
|
-
/**
|
|
228
|
-
* @description Retrieves payload associated with the specified flag and matched value that is passed in.
|
|
229
|
-
*
|
|
230
|
-
* IMPORTANT: The `matchValue` parameter should be the value you previously obtained from `getFeatureFlag()`.
|
|
231
|
-
* If matchValue isn't passed (or is undefined), this method will automatically call `getFeatureFlag()`
|
|
232
|
-
* internally to fetch the flag value, which could result in a network call to the PostHog server if this flag can
|
|
233
|
-
* not be evaluated locally. This means that omitting `matchValue` will potentially:
|
|
234
|
-
* - Bypass local evaluation
|
|
235
|
-
* - Count as an additional flag evaluation against your quota
|
|
236
|
-
* - Impact performance due to the extra network request
|
|
237
|
-
*
|
|
238
|
-
* Example usage:
|
|
239
|
-
* ```js
|
|
240
|
-
* const flagValue = await client.getFeatureFlag('my-flag', distinctId);
|
|
241
|
-
* const payload = await client.getFeatureFlagPayload('my-flag', distinctId, flagValue);
|
|
242
|
-
* ```
|
|
243
|
-
*
|
|
244
|
-
* @param key the unique key of your feature flag
|
|
245
|
-
* @param distinctId the current unique id
|
|
246
|
-
* @param matchValue The flag value previously obtained from calling `getFeatureFlag()`. Can be a string or boolean.
|
|
247
|
-
* To avoid extra network calls, pass this parameter when you can.
|
|
248
|
-
* @param options: dict with optional parameters below
|
|
249
|
-
* @param onlyEvaluateLocally optional - whether to only evaluate the flag locally. Defaults to false.
|
|
250
|
-
*
|
|
251
|
-
* @returns payload of a json type object
|
|
252
|
-
*/
|
|
253
|
-
getFeatureFlagPayload(key: string, distinctId: string, matchValue?: FeatureFlagValue, options?: {
|
|
254
|
-
onlyEvaluateLocally?: boolean;
|
|
255
|
-
}): Promise<JsonType | undefined>;
|
|
256
|
-
/**
|
|
257
|
-
* @description Sets a groups properties, which allows asking questions like "Who are the most active companies"
|
|
258
|
-
* using my product in PostHog.
|
|
259
|
-
*
|
|
260
|
-
* @param groupType Type of group (ex: 'company'). Limited to 5 per project
|
|
261
|
-
* @param groupKey Unique identifier for that type of group (ex: 'id:5')
|
|
262
|
-
* @param properties OPTIONAL | which can be a object with any information you'd like to add
|
|
263
|
-
*/
|
|
264
|
-
groupIdentify({ groupType, groupKey, properties }: GroupIdentifyMessage): void;
|
|
265
|
-
/**
|
|
266
|
-
* @description Force an immediate reload of the polled feature flags. Please note that they are
|
|
267
|
-
* already polled automatically at a regular interval.
|
|
268
|
-
*/
|
|
269
|
-
reloadFeatureFlags(): Promise<void>;
|
|
270
|
-
/**
|
|
271
|
-
* @description Flushes the events still in the queue and clears the feature flags poller to allow for
|
|
272
|
-
* a clean shutdown.
|
|
273
|
-
*
|
|
274
|
-
* @param shutdownTimeoutMs The shutdown timeout, in milliseconds. Defaults to 30000 (30s).
|
|
275
|
-
*/
|
|
276
|
-
shutdown(shutdownTimeoutMs?: number): void;
|
|
277
|
-
/**
|
|
278
|
-
* @description Waits for local evaluation to be ready, with an optional timeout.
|
|
279
|
-
* @param timeoutMs - Maximum time to wait in milliseconds. Defaults to 30 seconds.
|
|
280
|
-
* @returns A promise that resolves to true if local evaluation is ready, false if the timeout was reached.
|
|
281
|
-
*/
|
|
282
|
-
waitForLocalEvaluationReady(timeoutMs?: number): Promise<boolean>;
|
|
283
|
-
/**
|
|
284
|
-
* @description Returns true if local evaluation is ready, false if it's not.
|
|
285
|
-
* @returns true if local evaluation is ready, false if it's not.
|
|
286
|
-
*/
|
|
287
|
-
isLocalEvaluationReady(): boolean;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
declare class ErrorTracking {
|
|
291
|
-
private client;
|
|
292
|
-
private _exceptionAutocaptureEnabled;
|
|
293
|
-
private _rateLimiter;
|
|
294
|
-
private _logger;
|
|
295
|
-
static stackParser: StackParser;
|
|
296
|
-
static frameModifiers: StackFrameModifierFn[];
|
|
297
|
-
constructor(client: PostHogBackendClient, options: PostHogOptions, _logger: Logger);
|
|
298
|
-
static buildEventMessage(error: unknown, hint: EventHint, distinctId?: string, additionalProperties?: Record<string | number, any>): Promise<EventMessage>;
|
|
299
|
-
private startAutocaptureIfEnabled;
|
|
300
|
-
private onException;
|
|
301
|
-
private onFatalError;
|
|
302
|
-
isEnabled(): boolean;
|
|
303
|
-
shutdown(): void;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
declare abstract class PostHogBackendClient extends PostHogCoreStateless implements IPostHog {
|
|
1
|
+
import { JsonType, PostHogCoreStateless, PostHogFetchOptions, PostHogFetchResponse, PostHogFlagsAndPayloadsResponse, PostHogPersistedProperty, PostHogCaptureOptions } from '@posthog/core';
|
|
2
|
+
import { EventMessage, GroupIdentifyMessage, IdentifyMessage, IPostHog, PostHogOptions } from './types';
|
|
3
|
+
import { FeatureFlagValue } from '@posthog/core';
|
|
4
|
+
import ErrorTracking from './extensions/error-tracking';
|
|
5
|
+
import { PostHogEventProperties } from '@posthog/core';
|
|
6
|
+
export declare abstract class PostHogBackendClient extends PostHogCoreStateless implements IPostHog {
|
|
307
7
|
private _memoryStorage;
|
|
308
8
|
private featureFlagsPoller?;
|
|
309
9
|
protected errorTracking: ErrorTracking;
|
|
@@ -1088,75 +788,4 @@ declare abstract class PostHogBackendClient extends PostHogCoreStateless impleme
|
|
|
1088
788
|
}>;
|
|
1089
789
|
private _runBeforeSend;
|
|
1090
790
|
}
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
* @file Adapted from [posthog-js](https://github.com/PostHog/posthog-js/blob/8157df935a4d0e71d2fefef7127aa85ee51c82d1/src/extensions/sentry-integration.ts) with modifications for the Node SDK.
|
|
1094
|
-
*/
|
|
1095
|
-
/**
|
|
1096
|
-
* Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog.
|
|
1097
|
-
*
|
|
1098
|
-
* ### Usage
|
|
1099
|
-
*
|
|
1100
|
-
* Sentry.init({
|
|
1101
|
-
* dsn: 'https://example',
|
|
1102
|
-
* integrations: [
|
|
1103
|
-
* new PostHogSentryIntegration(posthog)
|
|
1104
|
-
* ]
|
|
1105
|
-
* })
|
|
1106
|
-
*
|
|
1107
|
-
* Sentry.setTag(PostHogSentryIntegration.POSTHOG_ID_TAG, 'some distinct id');
|
|
1108
|
-
*
|
|
1109
|
-
* @param {Object} [posthog] The posthog object
|
|
1110
|
-
* @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry
|
|
1111
|
-
* @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
|
|
1112
|
-
* @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
|
|
1113
|
-
* @param {SeverityLevel[] | '*'} [severityAllowList] Optional: send events matching the provided levels. Use '*' to send all events (default: ['error'])
|
|
1114
|
-
* @param {boolean} [sendExceptionsToPostHog] Optional: capture exceptions as events in PostHog (default: true)
|
|
1115
|
-
*/
|
|
1116
|
-
|
|
1117
|
-
type _SentryEvent = any;
|
|
1118
|
-
type _SentryEventProcessor = any;
|
|
1119
|
-
type _SentryHub = any;
|
|
1120
|
-
interface _SentryIntegration {
|
|
1121
|
-
name: string;
|
|
1122
|
-
processEvent(event: _SentryEvent): _SentryEvent;
|
|
1123
|
-
}
|
|
1124
|
-
interface _SentryIntegrationClass {
|
|
1125
|
-
name: string;
|
|
1126
|
-
setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
|
|
1127
|
-
}
|
|
1128
|
-
type SentryIntegrationOptions = {
|
|
1129
|
-
organization?: string;
|
|
1130
|
-
projectId?: number;
|
|
1131
|
-
prefix?: string;
|
|
1132
|
-
severityAllowList?: SeverityLevel[] | '*';
|
|
1133
|
-
sendExceptionsToPostHog?: boolean;
|
|
1134
|
-
};
|
|
1135
|
-
declare function createEventProcessor(_posthog: PostHogBackendClient, { organization, projectId, prefix, severityAllowList, sendExceptionsToPostHog, }?: SentryIntegrationOptions): (event: _SentryEvent) => _SentryEvent;
|
|
1136
|
-
declare function sentryIntegration(_posthog: PostHogBackendClient, options?: SentryIntegrationOptions): _SentryIntegration;
|
|
1137
|
-
declare class PostHogSentryIntegration implements _SentryIntegrationClass {
|
|
1138
|
-
readonly name = "posthog-node";
|
|
1139
|
-
static readonly POSTHOG_ID_TAG = "posthog_distinct_id";
|
|
1140
|
-
setupOnce: (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub) => void;
|
|
1141
|
-
constructor(_posthog: PostHogBackendClient, organization?: string, prefix?: string, severityAllowList?: SeverityLevel[] | '*', sendExceptionsToPostHog?: boolean);
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
type ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;
|
|
1145
|
-
type ExpressErrorMiddleware = (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
|
|
1146
|
-
interface MiddlewareError extends Error {
|
|
1147
|
-
status?: number | string;
|
|
1148
|
-
statusCode?: number | string;
|
|
1149
|
-
status_code?: number | string;
|
|
1150
|
-
output?: {
|
|
1151
|
-
statusCode?: number | string;
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
declare function setupExpressErrorHandler(_posthog: PostHogBackendClient, app: {
|
|
1155
|
-
use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown;
|
|
1156
|
-
}): void;
|
|
1157
|
-
|
|
1158
|
-
declare class PostHog extends PostHogBackendClient {
|
|
1159
|
-
getLibraryId(): string;
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
export { type BeforeSendFn, type EventMessage, type FeatureFlagCondition, type FlagProperty, type FlagPropertyValue, type GroupIdentifyMessage, type IPostHog, type IdentifyMessage, PostHog, type PostHogFeatureFlag, type PostHogOptions, PostHogSentryIntegration, type PropertyGroup, type SendFeatureFlagsOptions, type SentryIntegrationOptions, createEventProcessor, sentryIntegration, setupExpressErrorHandler };
|
|
791
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EACR,oBAAoB,EAEpB,mBAAmB,EACnB,oBAAoB,EACpB,+BAA+B,EAC/B,wBAAwB,EAExB,qBAAqB,EAEtB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,cAAc,EAEf,MAAM,SAAS,CAAA;AAChB,OAAO,EAAqB,gBAAgB,EAAuB,MAAM,eAAe,CAAA;AAExF,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAkB,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAWtE,8BAAsB,oBAAqB,SAAQ,oBAAqB,YAAW,QAAQ;IACzF,OAAO,CAAC,cAAc,CAA6B;IAEnD,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,SAAS,CAAC,aAAa,EAAE,aAAa,CAAA;IACtC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAQ;IACtB,SAAgB,OAAO,EAAE,cAAc,CAAA;IAEvC,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB;IA8CxD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,oBAAoB,CAAC,GAAG,EAAE,wBAAwB,GAAG,GAAG,GAAG,SAAS;IAIpE;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