posthog-node 4.11.5 → 4.11.6

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/lib/index.d.ts CHANGED
@@ -2,212 +2,6 @@
2
2
  import { SeverityLevel } from 'posthog-node/src/extensions/error-tracking/types';
3
3
  import * as http from 'node:http';
4
4
 
5
- type SurveyAppearance = {
6
- // keep in sync with frontend/src/types.ts -> SurveyAppearance
7
- backgroundColor?: string
8
- submitButtonColor?: string
9
- // deprecate submit button text eventually
10
- submitButtonText?: string
11
- submitButtonTextColor?: string
12
- ratingButtonColor?: string
13
- ratingButtonActiveColor?: string
14
- autoDisappear?: boolean
15
- displayThankYouMessage?: boolean
16
- thankYouMessageHeader?: string
17
- thankYouMessageDescription?: string
18
- thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType
19
- thankYouMessageCloseButtonText?: string
20
- borderColor?: string
21
- position?: SurveyPosition
22
- placeholder?: string
23
- shuffleQuestions?: boolean
24
- surveyPopupDelaySeconds?: number
25
- // widget options
26
- widgetType?: SurveyWidgetType
27
- widgetSelector?: string
28
- widgetLabel?: string
29
- widgetColor?: string
30
- }
31
-
32
- enum SurveyPosition {
33
- Left = 'left',
34
- Right = 'right',
35
- Center = 'center',
36
- }
37
-
38
- enum SurveyWidgetType {
39
- Button = 'button',
40
- Tab = 'tab',
41
- Selector = 'selector',
42
- }
43
-
44
- enum SurveyType {
45
- Popover = 'popover',
46
- API = 'api',
47
- Widget = 'widget',
48
- }
49
-
50
- type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion
51
-
52
- enum SurveyQuestionDescriptionContentType {
53
- Html = 'html',
54
- Text = 'text',
55
- }
56
-
57
- type SurveyQuestionBase = {
58
- question: string
59
- id?: string // TODO: use this for the question id
60
- description?: string
61
- descriptionContentType?: SurveyQuestionDescriptionContentType
62
- optional?: boolean
63
- buttonText?: string
64
- originalQuestionIndex: number
65
- branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching
66
- }
67
-
68
- interface BasicSurveyQuestion extends SurveyQuestionBase {
69
- type: SurveyQuestionType.Open
70
- }
71
-
72
- interface LinkSurveyQuestion extends SurveyQuestionBase {
73
- type: SurveyQuestionType.Link
74
- link?: string
75
- }
76
-
77
- interface RatingSurveyQuestion extends SurveyQuestionBase {
78
- type: SurveyQuestionType.Rating
79
- display: SurveyRatingDisplay
80
- scale: 3 | 5 | 7 | 10
81
- lowerBoundLabel: string
82
- upperBoundLabel: string
83
- }
84
-
85
- enum SurveyRatingDisplay {
86
- Number = 'number',
87
- Emoji = 'emoji',
88
- }
89
-
90
- interface MultipleSurveyQuestion extends SurveyQuestionBase {
91
- type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice
92
- choices: string[]
93
- hasOpenChoice?: boolean
94
- shuffleOptions?: boolean
95
- }
96
-
97
- enum SurveyQuestionType {
98
- Open = 'open',
99
- MultipleChoice = 'multiple_choice',
100
- SingleChoice = 'single_choice',
101
- Rating = 'rating',
102
- Link = 'link',
103
- }
104
-
105
- enum SurveyQuestionBranchingType {
106
- NextQuestion = 'next_question',
107
- End = 'end',
108
- ResponseBased = 'response_based',
109
- SpecificQuestion = 'specific_question',
110
- }
111
-
112
- type NextQuestionBranching = {
113
- type: SurveyQuestionBranchingType.NextQuestion
114
- }
115
-
116
- type EndBranching = {
117
- type: SurveyQuestionBranchingType.End
118
- }
119
-
120
- type ResponseBasedBranching = {
121
- type: SurveyQuestionBranchingType.ResponseBased
122
- responseValues: Record<string, any>
123
- }
124
-
125
- type SpecificQuestionBranching = {
126
- type: SurveyQuestionBranchingType.SpecificQuestion
127
- index: number
128
- }
129
-
130
- type SurveyResponse = {
131
- surveys: Survey[]
132
- }
133
-
134
- enum SurveyMatchType {
135
- Regex = 'regex',
136
- NotRegex = 'not_regex',
137
- Exact = 'exact',
138
- IsNot = 'is_not',
139
- Icontains = 'icontains',
140
- NotIcontains = 'not_icontains',
141
- }
142
-
143
- type Survey = {
144
- // Sync this with the backend's SurveyAPISerializer!
145
- id: string
146
- name: string
147
- description?: string
148
- type: SurveyType
149
- feature_flag_keys?:
150
- | {
151
- key: string
152
- value?: string
153
- }[]
154
- linked_flag_key?: string
155
- targeting_flag_key?: string
156
- internal_targeting_flag_key?: string
157
- questions: SurveyQuestion[]
158
- appearance?: SurveyAppearance
159
- conditions?: {
160
- url?: string
161
- selector?: string
162
- seenSurveyWaitPeriodInDays?: number
163
- urlMatchType?: SurveyMatchType
164
- events?: {
165
- repeatedActivation?: boolean
166
- values?: {
167
- name: string
168
- }[]
169
- }
170
- actions?: {
171
- values: SurveyActionType[]
172
- }
173
- deviceTypes?: string[]
174
- deviceTypesMatchType?: SurveyMatchType
175
- }
176
- start_date?: string
177
- end_date?: string
178
- current_iteration?: number
179
- current_iteration_start_date?: string
180
- }
181
-
182
- type SurveyActionType = {
183
- id: number
184
- name?: string
185
- steps?: ActionStepType[]
186
- }
187
-
188
- /** Sync with plugin-server/src/types.ts */
189
- enum ActionStepStringMatching {
190
- Contains = 'contains',
191
- Exact = 'exact',
192
- Regex = 'regex',
193
- }
194
-
195
- type ActionStepType = {
196
- event?: string
197
- selector?: string
198
- /** @deprecated Only `selector` should be used now. */
199
- tag_name?: string
200
- text?: string
201
- /** @default StringMatching.Exact */
202
- text_matching?: ActionStepStringMatching
203
- href?: string
204
- /** @default ActionStepStringMatching.Exact */
205
- href_matching?: ActionStepStringMatching
206
- url?: string
207
- /** @default StringMatching.Contains */
208
- url_matching?: ActionStepStringMatching
209
- }
210
-
211
5
  type PostHogCoreOptions = {
212
6
  /** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
213
7
  host?: string;
@@ -317,7 +111,7 @@ type PostHogFetchResponse = {
317
111
  type PostHogEventProperties = {
318
112
  [key: string]: any;
319
113
  };
320
- interface PostHogRemoteConfig {
114
+ type PostHogRemoteConfig = {
321
115
  sessionRecording?: boolean | {
322
116
  [key: string]: JsonType;
323
117
  };
@@ -329,9 +123,9 @@ interface PostHogRemoteConfig {
329
123
  * Indicates if the team has any flags enabled (if not we don't need to load them)
330
124
  */
331
125
  hasFeatureFlags?: boolean;
332
- }
126
+ };
333
127
  type FeatureFlagValue = string | boolean;
334
- interface PostHogDecideResponse extends Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> {
128
+ type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
335
129
  featureFlags: {
336
130
  [key: string]: FeatureFlagValue;
337
131
  };
@@ -347,7 +141,7 @@ interface PostHogDecideResponse extends Omit<PostHogRemoteConfig, 'surveys' | 'h
347
141
  };
348
142
  quotaLimited?: string[];
349
143
  requestId?: string;
350
- }
144
+ };
351
145
  /**
352
146
  * Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
353
147
  *
@@ -404,6 +198,183 @@ type EvaluationReason = {
404
198
  code: string | undefined;
405
199
  condition_index: number | undefined;
406
200
  description: string | undefined;
201
+ };
202
+ type SurveyAppearance = {
203
+ backgroundColor?: string;
204
+ submitButtonColor?: string;
205
+ submitButtonText?: string;
206
+ submitButtonTextColor?: string;
207
+ ratingButtonColor?: string;
208
+ ratingButtonActiveColor?: string;
209
+ autoDisappear?: boolean;
210
+ displayThankYouMessage?: boolean;
211
+ thankYouMessageHeader?: string;
212
+ thankYouMessageDescription?: string;
213
+ thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
214
+ thankYouMessageCloseButtonText?: string;
215
+ borderColor?: string;
216
+ position?: SurveyPosition;
217
+ placeholder?: string;
218
+ shuffleQuestions?: boolean;
219
+ surveyPopupDelaySeconds?: number;
220
+ widgetType?: SurveyWidgetType;
221
+ widgetSelector?: string;
222
+ widgetLabel?: string;
223
+ widgetColor?: string;
224
+ };
225
+ declare enum SurveyPosition {
226
+ Left = "left",
227
+ Right = "right",
228
+ Center = "center"
229
+ }
230
+ declare enum SurveyWidgetType {
231
+ Button = "button",
232
+ Tab = "tab",
233
+ Selector = "selector"
234
+ }
235
+ declare enum SurveyType {
236
+ Popover = "popover",
237
+ API = "api",
238
+ Widget = "widget"
239
+ }
240
+ type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
241
+ declare enum SurveyQuestionDescriptionContentType {
242
+ Html = "html",
243
+ Text = "text"
244
+ }
245
+ type SurveyQuestionBase = {
246
+ question: string;
247
+ id?: string;
248
+ description?: string;
249
+ descriptionContentType?: SurveyQuestionDescriptionContentType;
250
+ optional?: boolean;
251
+ buttonText?: string;
252
+ originalQuestionIndex: number;
253
+ branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
254
+ };
255
+ type BasicSurveyQuestion = SurveyQuestionBase & {
256
+ type: SurveyQuestionType.Open;
257
+ };
258
+ type LinkSurveyQuestion = SurveyQuestionBase & {
259
+ type: SurveyQuestionType.Link;
260
+ link?: string;
261
+ };
262
+ type RatingSurveyQuestion = SurveyQuestionBase & {
263
+ type: SurveyQuestionType.Rating;
264
+ display: SurveyRatingDisplay;
265
+ scale: 3 | 5 | 7 | 10;
266
+ lowerBoundLabel: string;
267
+ upperBoundLabel: string;
268
+ };
269
+ declare enum SurveyRatingDisplay {
270
+ Number = "number",
271
+ Emoji = "emoji"
272
+ }
273
+ type MultipleSurveyQuestion = SurveyQuestionBase & {
274
+ type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
275
+ choices: string[];
276
+ hasOpenChoice?: boolean;
277
+ shuffleOptions?: boolean;
278
+ };
279
+ declare enum SurveyQuestionType {
280
+ Open = "open",
281
+ MultipleChoice = "multiple_choice",
282
+ SingleChoice = "single_choice",
283
+ Rating = "rating",
284
+ Link = "link"
285
+ }
286
+ declare enum SurveyQuestionBranchingType {
287
+ NextQuestion = "next_question",
288
+ End = "end",
289
+ ResponseBased = "response_based",
290
+ SpecificQuestion = "specific_question"
291
+ }
292
+ type NextQuestionBranching = {
293
+ type: SurveyQuestionBranchingType.NextQuestion;
294
+ };
295
+ type EndBranching = {
296
+ type: SurveyQuestionBranchingType.End;
297
+ };
298
+ type ResponseBasedBranching = {
299
+ type: SurveyQuestionBranchingType.ResponseBased;
300
+ responseValues: Record<string, any>;
301
+ };
302
+ type SpecificQuestionBranching = {
303
+ type: SurveyQuestionBranchingType.SpecificQuestion;
304
+ index: number;
305
+ };
306
+ type SurveyResponse = {
307
+ surveys: Survey[];
308
+ };
309
+ declare enum SurveyMatchType {
310
+ Regex = "regex",
311
+ NotRegex = "not_regex",
312
+ Exact = "exact",
313
+ IsNot = "is_not",
314
+ Icontains = "icontains",
315
+ NotIcontains = "not_icontains"
316
+ }
317
+ type Survey = {
318
+ id: string;
319
+ name: string;
320
+ description?: string;
321
+ type: SurveyType;
322
+ feature_flag_keys?: {
323
+ key: string;
324
+ value?: string;
325
+ }[];
326
+ linked_flag_key?: string;
327
+ targeting_flag_key?: string;
328
+ internal_targeting_flag_key?: string;
329
+ questions: SurveyQuestion[];
330
+ appearance?: SurveyAppearance;
331
+ conditions?: {
332
+ url?: string;
333
+ selector?: string;
334
+ seenSurveyWaitPeriodInDays?: number;
335
+ urlMatchType?: SurveyMatchType;
336
+ events?: {
337
+ repeatedActivation?: boolean;
338
+ values?: {
339
+ name: string;
340
+ }[];
341
+ };
342
+ actions?: {
343
+ values: SurveyActionType[];
344
+ };
345
+ deviceTypes?: string[];
346
+ deviceTypesMatchType?: SurveyMatchType;
347
+ };
348
+ start_date?: string;
349
+ end_date?: string;
350
+ current_iteration?: number;
351
+ current_iteration_start_date?: string;
352
+ };
353
+ type SurveyActionType = {
354
+ id: number;
355
+ name?: string;
356
+ steps?: ActionStepType[];
357
+ };
358
+ /** Sync with plugin-server/src/types.ts */
359
+ declare enum ActionStepStringMatching {
360
+ Contains = "contains",
361
+ Exact = "exact",
362
+ Regex = "regex"
363
+ }
364
+ type ActionStepType = {
365
+ event?: string;
366
+ selector?: string;
367
+ /** @deprecated Only `selector` should be used now. */
368
+ tag_name?: string;
369
+ text?: string;
370
+ /** @default StringMatching.Exact */
371
+ text_matching?: ActionStepStringMatching;
372
+ href?: string;
373
+ /** @default ActionStepStringMatching.Exact */
374
+ href_matching?: ActionStepStringMatching;
375
+ url?: string;
376
+ /** @default StringMatching.Contains */
377
+ url_matching?: ActionStepStringMatching;
407
378
  };
408
379
 
409
380
  interface RetriableOptions {
package/lib/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { posix, dirname, sep } from 'node:path';
2
2
 
3
- var version = "4.11.5";
3
+ var version = "4.11.6";
4
4
 
5
5
  var PostHogPersistedProperty;
6
6
  (function (PostHogPersistedProperty) {
@@ -28,7 +28,66 @@ var PostHogPersistedProperty;
28
28
  PostHogPersistedProperty["SurveysSeen"] = "surveys_seen";
29
29
  PostHogPersistedProperty["Surveys"] = "surveys";
30
30
  PostHogPersistedProperty["RemoteConfig"] = "remote_config";
31
- })(PostHogPersistedProperty || (PostHogPersistedProperty = {}));
31
+ })(PostHogPersistedProperty || (PostHogPersistedProperty = {}));
32
+ var SurveyPosition;
33
+ (function (SurveyPosition) {
34
+ SurveyPosition["Left"] = "left";
35
+ SurveyPosition["Right"] = "right";
36
+ SurveyPosition["Center"] = "center";
37
+ })(SurveyPosition || (SurveyPosition = {}));
38
+ var SurveyWidgetType;
39
+ (function (SurveyWidgetType) {
40
+ SurveyWidgetType["Button"] = "button";
41
+ SurveyWidgetType["Tab"] = "tab";
42
+ SurveyWidgetType["Selector"] = "selector";
43
+ })(SurveyWidgetType || (SurveyWidgetType = {}));
44
+ var SurveyType;
45
+ (function (SurveyType) {
46
+ SurveyType["Popover"] = "popover";
47
+ SurveyType["API"] = "api";
48
+ SurveyType["Widget"] = "widget";
49
+ })(SurveyType || (SurveyType = {}));
50
+ var SurveyQuestionDescriptionContentType;
51
+ (function (SurveyQuestionDescriptionContentType) {
52
+ SurveyQuestionDescriptionContentType["Html"] = "html";
53
+ SurveyQuestionDescriptionContentType["Text"] = "text";
54
+ })(SurveyQuestionDescriptionContentType || (SurveyQuestionDescriptionContentType = {}));
55
+ var SurveyRatingDisplay;
56
+ (function (SurveyRatingDisplay) {
57
+ SurveyRatingDisplay["Number"] = "number";
58
+ SurveyRatingDisplay["Emoji"] = "emoji";
59
+ })(SurveyRatingDisplay || (SurveyRatingDisplay = {}));
60
+ var SurveyQuestionType;
61
+ (function (SurveyQuestionType) {
62
+ SurveyQuestionType["Open"] = "open";
63
+ SurveyQuestionType["MultipleChoice"] = "multiple_choice";
64
+ SurveyQuestionType["SingleChoice"] = "single_choice";
65
+ SurveyQuestionType["Rating"] = "rating";
66
+ SurveyQuestionType["Link"] = "link";
67
+ })(SurveyQuestionType || (SurveyQuestionType = {}));
68
+ var SurveyQuestionBranchingType;
69
+ (function (SurveyQuestionBranchingType) {
70
+ SurveyQuestionBranchingType["NextQuestion"] = "next_question";
71
+ SurveyQuestionBranchingType["End"] = "end";
72
+ SurveyQuestionBranchingType["ResponseBased"] = "response_based";
73
+ SurveyQuestionBranchingType["SpecificQuestion"] = "specific_question";
74
+ })(SurveyQuestionBranchingType || (SurveyQuestionBranchingType = {}));
75
+ var SurveyMatchType;
76
+ (function (SurveyMatchType) {
77
+ SurveyMatchType["Regex"] = "regex";
78
+ SurveyMatchType["NotRegex"] = "not_regex";
79
+ SurveyMatchType["Exact"] = "exact";
80
+ SurveyMatchType["IsNot"] = "is_not";
81
+ SurveyMatchType["Icontains"] = "icontains";
82
+ SurveyMatchType["NotIcontains"] = "not_icontains";
83
+ })(SurveyMatchType || (SurveyMatchType = {}));
84
+ /** Sync with plugin-server/src/types.ts */
85
+ var ActionStepStringMatching;
86
+ (function (ActionStepStringMatching) {
87
+ ActionStepStringMatching["Contains"] = "contains";
88
+ ActionStepStringMatching["Exact"] = "exact";
89
+ ActionStepStringMatching["Regex"] = "regex";
90
+ })(ActionStepStringMatching || (ActionStepStringMatching = {}));
32
91
 
33
92
  const normalizeDecideResponse = (decideResponse) => {
34
93
  if ('flags' in decideResponse) {