posthog-js 1.66.1 → 1.67.0

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/module.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { SurveyCallback as SurveyCallback$1 } from 'types';
2
+
1
3
  declare enum NodeType {
2
4
  Document = 0,
3
5
  DocumentType = 1,
@@ -432,6 +434,51 @@ interface EarlyAccessFeatureResponse {
432
434
  declare type NetworkRequest = {
433
435
  url: string;
434
436
  };
437
+ interface Survey {
438
+ name: string;
439
+ description: string;
440
+ type: SurveyType;
441
+ linked_flag_key?: string | null;
442
+ targeting_flag_key?: string | null;
443
+ questions: SurveyQuestion[];
444
+ appearance?: SurveyAppearance | null;
445
+ conditions?: {
446
+ url?: string;
447
+ selector?: string;
448
+ } | null;
449
+ start_date?: string | null;
450
+ end_date?: string | null;
451
+ }
452
+ interface SurveyAppearance {
453
+ background_color?: string;
454
+ button_color?: string;
455
+ text_color?: string;
456
+ }
457
+ declare enum SurveyType {
458
+ Popover = "Popover",
459
+ Button = "Button",
460
+ Email = "Email",
461
+ FullScreen = "Fullscreen"
462
+ }
463
+ interface SurveyQuestion {
464
+ type: SurveyQuestionType;
465
+ question: string;
466
+ required?: boolean;
467
+ link?: boolean;
468
+ choices?: string[];
469
+ }
470
+ declare enum SurveyQuestionType {
471
+ Open = "open",
472
+ MultipleChoiceSingle = "multiple_single",
473
+ MultipleChoiceMulti = "multiple_multi",
474
+ NPS = "nps",
475
+ Rating = "rating",
476
+ Link = "link"
477
+ }
478
+ declare type SurveyCallback = (surveys: Survey[]) => void;
479
+ interface SurveyResponse {
480
+ surveys: Survey[];
481
+ }
435
482
 
436
483
  /**
437
484
  * PostHog People Object
@@ -1119,6 +1166,13 @@ declare class ExceptionObserver {
1119
1166
  }): void;
1120
1167
  }
1121
1168
 
1169
+ declare class PostHogSurveys {
1170
+ instance: PostHog;
1171
+ constructor(instance: PostHog);
1172
+ getSurveys(callback: SurveyCallback$1, forceReload?: boolean): void;
1173
+ getActiveMatchingSurveys(callback: SurveyCallback$1, forceReload?: boolean): void;
1174
+ }
1175
+
1122
1176
  /**
1123
1177
  * PostHog Library Object
1124
1178
  * @constructor
@@ -1134,6 +1188,7 @@ declare class PostHog {
1134
1188
  people: PostHogPeople;
1135
1189
  featureFlags: PostHogFeatureFlags;
1136
1190
  feature_flags: PostHogFeatureFlags;
1191
+ surveys: PostHogSurveys;
1137
1192
  toolbar: Toolbar;
1138
1193
  sessionRecording: SessionRecording | undefined;
1139
1194
  webPerformance: WebPerformanceObserver | undefined;
@@ -1331,6 +1386,10 @@ declare class PostHog {
1331
1386
  /** Get the list of early access features. To check enrollment status, use `isFeatureEnabled`. */
1332
1387
  getEarlyAccessFeatures(callback: EarlyAccessFeatureCallback, force_reload?: boolean): void;
1333
1388
  onFeatureFlags(callback: (flags: string[], variants: Record<string, string | boolean>) => void): () => void;
1389
+ /** Get list of all surveys. */
1390
+ getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
1391
+ /** Get surveys that should be enabled for the current user. */
1392
+ getActiveMatchingSurveys(callback: SurveyCallback, forceReload?: boolean): void;
1334
1393
  /**
1335
1394
  * Identify a user with a unique ID instead of a PostHog
1336
1395
  * randomly generated distinct_id. If the method is never called,
@@ -1790,4 +1849,4 @@ declare class PostHog {
1790
1849
 
1791
1850
  declare const posthog: PostHog;
1792
1851
 
1793
- export { AutoCaptureCustomProperty, AutocaptureCompatibleElement, AutocaptureConfig, Breaker, CaptureCallback, CaptureOptions, CaptureResult, Compression, CompressionData, DecideResponse, DomAutocaptureEvents, EarlyAccessFeature, EarlyAccessFeatureCallback, EarlyAccessFeatureResponse, EventHandler, FeatureFlagsCallback, GDPROptions, JSC, JsonType, NetworkRequest, OptInOutCapturingOptions, PersistentStore, PostData, PostHog, PostHogConfig, Properties, Property, QueuedRequestData, RequestCallback, RetryQueueElement, SessionRecordingOptions, SnippetArrayItem, ToolbarParams, ToolbarSource, ToolbarUserIntent, ToolbarVersion, XHROptions, XHRParams, posthog as default, isFeatureEnabledOptions, posthog };
1852
+ export { AutoCaptureCustomProperty, AutocaptureCompatibleElement, AutocaptureConfig, Breaker, CaptureCallback, CaptureOptions, CaptureResult, Compression, CompressionData, DecideResponse, DomAutocaptureEvents, EarlyAccessFeature, EarlyAccessFeatureCallback, EarlyAccessFeatureResponse, EventHandler, FeatureFlagsCallback, GDPROptions, JSC, JsonType, NetworkRequest, OptInOutCapturingOptions, PersistentStore, PostData, PostHog, PostHogConfig, Properties, Property, QueuedRequestData, RequestCallback, RetryQueueElement, SessionRecordingOptions, SnippetArrayItem, Survey, SurveyAppearance, SurveyCallback, SurveyQuestion, SurveyQuestionType, SurveyResponse, SurveyType, ToolbarParams, ToolbarSource, ToolbarUserIntent, ToolbarVersion, XHROptions, XHRParams, posthog as default, isFeatureEnabledOptions, posthog };