posthog-node 4.11.5 → 4.11.7
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 +10 -0
- package/lib/index.cjs.js +66 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +181 -210
- package/lib/index.esm.js +64 -5
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +1 -2
- package/lib/posthog-core/src/types.d.ts +201 -5
- package/lib/posthog-node/src/extensions/error-tracking/context-lines.d.ts +2 -2
- package/package.json +1 -1
- package/src/extensions/error-tracking/context-lines.ts +4 -4
- package/src/extensions/error-tracking/stack-trace.ts +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PostHogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType, PostHogRemoteConfig, FeatureFlagValue, PostHogFeatureFlagDetails, FeatureFlagDetail } from './types';
|
|
1
|
+
import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PostHogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType, PostHogRemoteConfig, FeatureFlagValue, PostHogFeatureFlagDetails, FeatureFlagDetail, SurveyResponse } from './types';
|
|
2
2
|
import { RetriableOptions } from './utils';
|
|
3
3
|
import { LZString } from './lz-string';
|
|
4
4
|
import { SimpleEventEmitter } from './eventemitter';
|
|
5
|
-
import { SurveyResponse } from './surveys-types';
|
|
6
5
|
export * as utils from './utils';
|
|
7
6
|
export declare abstract class PostHogCoreStateless {
|
|
8
7
|
readonly apiKey: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Survey } from './surveys-types';
|
|
2
1
|
export type PostHogCoreOptions = {
|
|
3
2
|
/** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
|
|
4
3
|
host?: string;
|
|
@@ -122,7 +121,7 @@ export type PostHogAutocaptureElement = {
|
|
|
122
121
|
} & {
|
|
123
122
|
[key: string]: any;
|
|
124
123
|
};
|
|
125
|
-
export
|
|
124
|
+
export type PostHogRemoteConfig = {
|
|
126
125
|
sessionRecording?: boolean | {
|
|
127
126
|
[key: string]: JsonType;
|
|
128
127
|
};
|
|
@@ -134,9 +133,9 @@ export interface PostHogRemoteConfig {
|
|
|
134
133
|
* Indicates if the team has any flags enabled (if not we don't need to load them)
|
|
135
134
|
*/
|
|
136
135
|
hasFeatureFlags?: boolean;
|
|
137
|
-
}
|
|
136
|
+
};
|
|
138
137
|
export type FeatureFlagValue = string | boolean;
|
|
139
|
-
export
|
|
138
|
+
export type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
|
|
140
139
|
featureFlags: {
|
|
141
140
|
[key: string]: FeatureFlagValue;
|
|
142
141
|
};
|
|
@@ -152,7 +151,7 @@ export interface PostHogDecideResponse extends Omit<PostHogRemoteConfig, 'survey
|
|
|
152
151
|
};
|
|
153
152
|
quotaLimited?: string[];
|
|
154
153
|
requestId?: string;
|
|
155
|
-
}
|
|
154
|
+
};
|
|
156
155
|
export type PostHogFeatureFlagsResponse = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
|
|
157
156
|
/**
|
|
158
157
|
* Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
|
|
@@ -224,3 +223,200 @@ export type EvaluationReason = {
|
|
|
224
223
|
condition_index: number | undefined;
|
|
225
224
|
description: string | undefined;
|
|
226
225
|
};
|
|
226
|
+
export type SurveyAppearance = {
|
|
227
|
+
backgroundColor?: string;
|
|
228
|
+
submitButtonColor?: string;
|
|
229
|
+
submitButtonText?: string;
|
|
230
|
+
submitButtonTextColor?: string;
|
|
231
|
+
ratingButtonColor?: string;
|
|
232
|
+
ratingButtonActiveColor?: string;
|
|
233
|
+
autoDisappear?: boolean;
|
|
234
|
+
displayThankYouMessage?: boolean;
|
|
235
|
+
thankYouMessageHeader?: string;
|
|
236
|
+
thankYouMessageDescription?: string;
|
|
237
|
+
thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
238
|
+
thankYouMessageCloseButtonText?: string;
|
|
239
|
+
borderColor?: string;
|
|
240
|
+
position?: SurveyPosition;
|
|
241
|
+
placeholder?: string;
|
|
242
|
+
shuffleQuestions?: boolean;
|
|
243
|
+
surveyPopupDelaySeconds?: number;
|
|
244
|
+
widgetType?: SurveyWidgetType;
|
|
245
|
+
widgetSelector?: string;
|
|
246
|
+
widgetLabel?: string;
|
|
247
|
+
widgetColor?: string;
|
|
248
|
+
};
|
|
249
|
+
export declare enum SurveyPosition {
|
|
250
|
+
Left = "left",
|
|
251
|
+
Right = "right",
|
|
252
|
+
Center = "center"
|
|
253
|
+
}
|
|
254
|
+
export declare enum SurveyWidgetType {
|
|
255
|
+
Button = "button",
|
|
256
|
+
Tab = "tab",
|
|
257
|
+
Selector = "selector"
|
|
258
|
+
}
|
|
259
|
+
export declare enum SurveyType {
|
|
260
|
+
Popover = "popover",
|
|
261
|
+
API = "api",
|
|
262
|
+
Widget = "widget"
|
|
263
|
+
}
|
|
264
|
+
export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
|
|
265
|
+
export declare enum SurveyQuestionDescriptionContentType {
|
|
266
|
+
Html = "html",
|
|
267
|
+
Text = "text"
|
|
268
|
+
}
|
|
269
|
+
type SurveyQuestionBase = {
|
|
270
|
+
question: string;
|
|
271
|
+
id?: string;
|
|
272
|
+
description?: string;
|
|
273
|
+
descriptionContentType?: SurveyQuestionDescriptionContentType;
|
|
274
|
+
optional?: boolean;
|
|
275
|
+
buttonText?: string;
|
|
276
|
+
originalQuestionIndex: number;
|
|
277
|
+
branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
|
|
278
|
+
};
|
|
279
|
+
export type BasicSurveyQuestion = SurveyQuestionBase & {
|
|
280
|
+
type: SurveyQuestionType.Open;
|
|
281
|
+
};
|
|
282
|
+
export type LinkSurveyQuestion = SurveyQuestionBase & {
|
|
283
|
+
type: SurveyQuestionType.Link;
|
|
284
|
+
link?: string;
|
|
285
|
+
};
|
|
286
|
+
export type RatingSurveyQuestion = SurveyQuestionBase & {
|
|
287
|
+
type: SurveyQuestionType.Rating;
|
|
288
|
+
display: SurveyRatingDisplay;
|
|
289
|
+
scale: 3 | 5 | 7 | 10;
|
|
290
|
+
lowerBoundLabel: string;
|
|
291
|
+
upperBoundLabel: string;
|
|
292
|
+
};
|
|
293
|
+
export declare enum SurveyRatingDisplay {
|
|
294
|
+
Number = "number",
|
|
295
|
+
Emoji = "emoji"
|
|
296
|
+
}
|
|
297
|
+
export type MultipleSurveyQuestion = SurveyQuestionBase & {
|
|
298
|
+
type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
|
|
299
|
+
choices: string[];
|
|
300
|
+
hasOpenChoice?: boolean;
|
|
301
|
+
shuffleOptions?: boolean;
|
|
302
|
+
};
|
|
303
|
+
export declare enum SurveyQuestionType {
|
|
304
|
+
Open = "open",
|
|
305
|
+
MultipleChoice = "multiple_choice",
|
|
306
|
+
SingleChoice = "single_choice",
|
|
307
|
+
Rating = "rating",
|
|
308
|
+
Link = "link"
|
|
309
|
+
}
|
|
310
|
+
export declare enum SurveyQuestionBranchingType {
|
|
311
|
+
NextQuestion = "next_question",
|
|
312
|
+
End = "end",
|
|
313
|
+
ResponseBased = "response_based",
|
|
314
|
+
SpecificQuestion = "specific_question"
|
|
315
|
+
}
|
|
316
|
+
export type NextQuestionBranching = {
|
|
317
|
+
type: SurveyQuestionBranchingType.NextQuestion;
|
|
318
|
+
};
|
|
319
|
+
export type EndBranching = {
|
|
320
|
+
type: SurveyQuestionBranchingType.End;
|
|
321
|
+
};
|
|
322
|
+
export type ResponseBasedBranching = {
|
|
323
|
+
type: SurveyQuestionBranchingType.ResponseBased;
|
|
324
|
+
responseValues: Record<string, any>;
|
|
325
|
+
};
|
|
326
|
+
export type SpecificQuestionBranching = {
|
|
327
|
+
type: SurveyQuestionBranchingType.SpecificQuestion;
|
|
328
|
+
index: number;
|
|
329
|
+
};
|
|
330
|
+
export type SurveyResponse = {
|
|
331
|
+
surveys: Survey[];
|
|
332
|
+
};
|
|
333
|
+
export type SurveyCallback = (surveys: Survey[]) => void;
|
|
334
|
+
export declare enum SurveyMatchType {
|
|
335
|
+
Regex = "regex",
|
|
336
|
+
NotRegex = "not_regex",
|
|
337
|
+
Exact = "exact",
|
|
338
|
+
IsNot = "is_not",
|
|
339
|
+
Icontains = "icontains",
|
|
340
|
+
NotIcontains = "not_icontains"
|
|
341
|
+
}
|
|
342
|
+
export type SurveyElement = {
|
|
343
|
+
text?: string;
|
|
344
|
+
$el_text?: string;
|
|
345
|
+
tag_name?: string;
|
|
346
|
+
href?: string;
|
|
347
|
+
attr_id?: string;
|
|
348
|
+
attr_class?: string[];
|
|
349
|
+
nth_child?: number;
|
|
350
|
+
nth_of_type?: number;
|
|
351
|
+
attributes?: Record<string, any>;
|
|
352
|
+
event_id?: number;
|
|
353
|
+
order?: number;
|
|
354
|
+
group_id?: number;
|
|
355
|
+
};
|
|
356
|
+
export type SurveyRenderReason = {
|
|
357
|
+
visible: boolean;
|
|
358
|
+
disabledReason?: string;
|
|
359
|
+
};
|
|
360
|
+
export type Survey = {
|
|
361
|
+
id: string;
|
|
362
|
+
name: string;
|
|
363
|
+
description?: string;
|
|
364
|
+
type: SurveyType;
|
|
365
|
+
feature_flag_keys?: {
|
|
366
|
+
key: string;
|
|
367
|
+
value?: string;
|
|
368
|
+
}[];
|
|
369
|
+
linked_flag_key?: string;
|
|
370
|
+
targeting_flag_key?: string;
|
|
371
|
+
internal_targeting_flag_key?: string;
|
|
372
|
+
questions: SurveyQuestion[];
|
|
373
|
+
appearance?: SurveyAppearance;
|
|
374
|
+
conditions?: {
|
|
375
|
+
url?: string;
|
|
376
|
+
selector?: string;
|
|
377
|
+
seenSurveyWaitPeriodInDays?: number;
|
|
378
|
+
urlMatchType?: SurveyMatchType;
|
|
379
|
+
events?: {
|
|
380
|
+
repeatedActivation?: boolean;
|
|
381
|
+
values?: {
|
|
382
|
+
name: string;
|
|
383
|
+
}[];
|
|
384
|
+
};
|
|
385
|
+
actions?: {
|
|
386
|
+
values: SurveyActionType[];
|
|
387
|
+
};
|
|
388
|
+
deviceTypes?: string[];
|
|
389
|
+
deviceTypesMatchType?: SurveyMatchType;
|
|
390
|
+
};
|
|
391
|
+
start_date?: string;
|
|
392
|
+
end_date?: string;
|
|
393
|
+
current_iteration?: number;
|
|
394
|
+
current_iteration_start_date?: string;
|
|
395
|
+
};
|
|
396
|
+
export type SurveyActionType = {
|
|
397
|
+
id: number;
|
|
398
|
+
name?: string;
|
|
399
|
+
steps?: ActionStepType[];
|
|
400
|
+
};
|
|
401
|
+
/** Sync with plugin-server/src/types.ts */
|
|
402
|
+
export declare enum ActionStepStringMatching {
|
|
403
|
+
Contains = "contains",
|
|
404
|
+
Exact = "exact",
|
|
405
|
+
Regex = "regex"
|
|
406
|
+
}
|
|
407
|
+
export type ActionStepType = {
|
|
408
|
+
event?: string;
|
|
409
|
+
selector?: string;
|
|
410
|
+
/** @deprecated Only `selector` should be used now. */
|
|
411
|
+
tag_name?: string;
|
|
412
|
+
text?: string;
|
|
413
|
+
/** @default StringMatching.Exact */
|
|
414
|
+
text_matching?: ActionStepStringMatching;
|
|
415
|
+
href?: string;
|
|
416
|
+
/** @default ActionStepStringMatching.Exact */
|
|
417
|
+
href_matching?: ActionStepStringMatching;
|
|
418
|
+
url?: string;
|
|
419
|
+
/** @default StringMatching.Contains */
|
|
420
|
+
url_matching?: ActionStepStringMatching;
|
|
421
|
+
};
|
|
422
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StackFrame } from './types';
|
|
2
|
-
export declare function getNodeFs(): Promise<typeof import('
|
|
3
|
-
export declare function getNodeReadline(): Promise<typeof import('
|
|
2
|
+
export declare function getNodeFs(): Promise<typeof import('fs') | undefined>;
|
|
3
|
+
export declare function getNodeReadline(): Promise<typeof import('readline') | undefined>;
|
|
4
4
|
export declare const MAX_CONTEXTLINES_COLNO: number;
|
|
5
5
|
export declare const MAX_CONTEXTLINES_LINENO: number;
|
|
6
6
|
export declare function addSourceContext(frames: StackFrame[]): Promise<StackFrame[]>;
|
package/package.json
CHANGED
|
@@ -7,25 +7,25 @@ import { Lazy } from 'posthog-node/src/lazy'
|
|
|
7
7
|
|
|
8
8
|
const nodeFs = new Lazy(async () => {
|
|
9
9
|
try {
|
|
10
|
-
return await import('
|
|
10
|
+
return await import('fs')
|
|
11
11
|
} catch {
|
|
12
12
|
return undefined
|
|
13
13
|
}
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
export async function getNodeFs(): Promise<typeof import('
|
|
16
|
+
export async function getNodeFs(): Promise<typeof import('fs') | undefined> {
|
|
17
17
|
return await nodeFs.getValue()
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const nodeReadline = new Lazy(async () => {
|
|
21
21
|
try {
|
|
22
|
-
return await import('
|
|
22
|
+
return await import('readline')
|
|
23
23
|
} catch {
|
|
24
24
|
return undefined
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
export async function getNodeReadline(): Promise<typeof import('
|
|
28
|
+
export async function getNodeReadline(): Promise<typeof import('readline') | undefined> {
|
|
29
29
|
return await nodeReadline.getValue()
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Portions of this file are derived from getsentry/sentry-javascript by Software, Inc. dba Sentry
|
|
2
2
|
// Licensed under the MIT License
|
|
3
3
|
|
|
4
|
-
import { posix, sep, dirname } from '
|
|
4
|
+
import { posix, sep, dirname } from 'path'
|
|
5
5
|
import { StackFrame, StackLineParser, StackLineParserFn, StackParser } from './types'
|
|
6
6
|
|
|
7
7
|
type GetModuleFn = (filename: string | undefined) => string | undefined
|