posthog-js 1.136.8 → 1.138.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.
Files changed (50) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +1 -1
  6. package/dist/es.js.map +1 -1
  7. package/dist/lib/src/constants.d.ts +1 -0
  8. package/dist/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +6 -3
  9. package/dist/lib/src/extensions/surveys/components/QuestionHeader.d.ts +7 -3
  10. package/dist/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -4
  11. package/dist/lib/src/extensions/surveys/surveys-utils.d.ts +13 -0
  12. package/dist/lib/src/extensions/surveys.d.ts +17 -5
  13. package/dist/lib/src/posthog-surveys-types.d.ts +8 -0
  14. package/dist/lib/src/posthog-surveys.d.ts +2 -0
  15. package/dist/lib/src/utils/survey-event-receiver.d.ts +12 -0
  16. package/dist/module.d.ts +21 -1
  17. package/dist/module.js +1 -1
  18. package/dist/module.js.map +1 -1
  19. package/dist/surveys-module-previews.js +1 -1
  20. package/dist/surveys-module-previews.js.map +1 -1
  21. package/dist/surveys.js +1 -1
  22. package/dist/surveys.js.map +1 -1
  23. package/lib/package.json +1 -1
  24. package/lib/src/constants.d.ts +1 -0
  25. package/lib/src/constants.js +1 -0
  26. package/lib/src/constants.js.map +1 -1
  27. package/lib/src/extensions/surveys/components/ConfirmationMessage.d.ts +6 -3
  28. package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx +10 -3
  29. package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx.map +1 -1
  30. package/lib/src/extensions/surveys/components/QuestionHeader.d.ts +7 -3
  31. package/lib/src/extensions/surveys/components/QuestionHeader.jsx +9 -3
  32. package/lib/src/extensions/surveys/components/QuestionHeader.jsx.map +1 -1
  33. package/lib/src/extensions/surveys/components/QuestionTypes.d.ts +8 -4
  34. package/lib/src/extensions/surveys/components/QuestionTypes.jsx +8 -8
  35. package/lib/src/extensions/surveys/components/QuestionTypes.jsx.map +1 -1
  36. package/lib/src/extensions/surveys/surveys-utils.d.ts +13 -0
  37. package/lib/src/extensions/surveys/surveys-utils.jsx +14 -2
  38. package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
  39. package/lib/src/extensions/surveys.d.ts +17 -5
  40. package/lib/src/extensions/surveys.jsx +35 -22
  41. package/lib/src/extensions/surveys.jsx.map +1 -1
  42. package/lib/src/posthog-surveys-types.d.ts +8 -0
  43. package/lib/src/posthog-surveys-types.js.map +1 -1
  44. package/lib/src/posthog-surveys.d.ts +2 -0
  45. package/lib/src/posthog-surveys.js +37 -4
  46. package/lib/src/posthog-surveys.js.map +1 -1
  47. package/lib/src/utils/survey-event-receiver.d.ts +12 -0
  48. package/lib/src/utils/survey-event-receiver.js +75 -0
  49. package/lib/src/utils/survey-event-receiver.js.map +1 -0
  50. package/package.json +1 -1
@@ -18,6 +18,7 @@ export declare const PERSISTENCE_EARLY_ACCESS_FEATURES = "$early_access_features
18
18
  export declare const STORED_PERSON_PROPERTIES_KEY = "$stored_person_properties";
19
19
  export declare const STORED_GROUP_PROPERTIES_KEY = "$stored_group_properties";
20
20
  export declare const SURVEYS = "$surveys";
21
+ export declare const SURVEYS_ACTIVATED = "$surveys_activated";
21
22
  export declare const FLAG_CALL_REPORTED = "$flag_call_reported";
22
23
  export declare const USER_STATE = "$user_state";
23
24
  export declare const CLIENT_SESSION_PROPS = "$client_session_props";
@@ -1,8 +1,11 @@
1
- import { SurveyAppearance } from '../../../posthog-surveys-types';
2
- export declare function ConfirmationMessage({ header, description, appearance, onClose, styleOverrides, }: {
1
+ import { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types';
2
+ import { h } from 'preact';
3
+ export declare function ConfirmationMessage({ header, description, contentType, forceDisableHtml, appearance, onClose, styleOverrides, }: {
3
4
  header: string;
4
5
  description: string;
6
+ forceDisableHtml: boolean;
7
+ contentType?: SurveyQuestionDescriptionContentType;
5
8
  appearance: SurveyAppearance;
6
9
  onClose: () => void;
7
10
  styleOverrides?: React.CSSProperties;
8
- }): JSX.Element;
11
+ }): h.JSX.Element;
@@ -1,8 +1,12 @@
1
- export declare function QuestionHeader({ question, description, backgroundColor, }: {
1
+ import { SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types';
2
+ import { h } from 'preact';
3
+ export declare function QuestionHeader({ question, description, descriptionContentType, backgroundColor, forceDisableHtml, }: {
2
4
  question: string;
3
5
  description?: string | null;
6
+ descriptionContentType?: SurveyQuestionDescriptionContentType;
7
+ forceDisableHtml: boolean;
4
8
  backgroundColor?: string;
5
- }): JSX.Element;
9
+ }): h.JSX.Element;
6
10
  export declare function Cancel({ onClick }: {
7
11
  onClick: () => void;
8
- }): JSX.Element;
12
+ }): h.JSX.Element;
@@ -1,16 +1,19 @@
1
1
  import { BasicSurveyQuestion, SurveyAppearance, LinkSurveyQuestion, RatingSurveyQuestion, MultipleSurveyQuestion } from '../../../posthog-surveys-types';
2
- export declare function OpenTextQuestion({ question, appearance, onSubmit, }: {
2
+ export declare function OpenTextQuestion({ question, forceDisableHtml, appearance, onSubmit, }: {
3
3
  question: BasicSurveyQuestion;
4
+ forceDisableHtml: boolean;
4
5
  appearance: SurveyAppearance;
5
6
  onSubmit: (text: string) => void;
6
7
  }): JSX.Element;
7
- export declare function LinkQuestion({ question, appearance, onSubmit, }: {
8
+ export declare function LinkQuestion({ question, forceDisableHtml, appearance, onSubmit, }: {
8
9
  question: LinkSurveyQuestion;
10
+ forceDisableHtml: boolean;
9
11
  appearance: SurveyAppearance;
10
12
  onSubmit: (clicked: string) => void;
11
13
  }): JSX.Element;
12
- export declare function RatingQuestion({ question, displayQuestionIndex, appearance, onSubmit, }: {
14
+ export declare function RatingQuestion({ question, forceDisableHtml, displayQuestionIndex, appearance, onSubmit, }: {
13
15
  question: RatingSurveyQuestion;
16
+ forceDisableHtml: boolean;
14
17
  displayQuestionIndex: number;
15
18
  appearance: SurveyAppearance;
16
19
  onSubmit: (rating: number | null) => void;
@@ -22,8 +25,9 @@ export declare function RatingButton({ num, active, displayQuestionIndex, appear
22
25
  appearance: any;
23
26
  setActiveNumber: (num: number) => void;
24
27
  }): JSX.Element;
25
- export declare function MultipleChoiceQuestion({ question, displayQuestionIndex, appearance, onSubmit, }: {
28
+ export declare function MultipleChoiceQuestion({ question, forceDisableHtml, displayQuestionIndex, appearance, onSubmit, }: {
26
29
  question: MultipleSurveyQuestion;
30
+ forceDisableHtml: boolean;
27
31
  displayQuestionIndex: number;
28
32
  appearance: SurveyAppearance;
29
33
  onSubmit: (choices: string | string[] | null) => void;
@@ -1,5 +1,6 @@
1
1
  import { PostHog } from '../../posthog-core';
2
2
  import { Survey, SurveyAppearance, MultipleSurveyQuestion, SurveyQuestion } from '../../posthog-surveys-types';
3
+ import { VNode } from 'preact';
3
4
  export declare const style: (appearance: SurveyAppearance | null) => string;
4
5
  export declare function getContrastingTextColor(color?: string): "black" | "white";
5
6
  export declare function getTextColor(el: HTMLElement): "black" | "white";
@@ -15,3 +16,15 @@ export declare const SurveyContext: import("preact").Context<{
15
16
  previewPageIndex: number | undefined;
16
17
  handleCloseSurveyPopup: () => void;
17
18
  }>;
19
+ interface RenderProps {
20
+ component: VNode<{
21
+ className: string;
22
+ }>;
23
+ children: string;
24
+ renderAsHtml?: boolean;
25
+ style?: React.CSSProperties;
26
+ }
27
+ export declare const renderChildrenAsTextOrHtml: ({ component, children, renderAsHtml, style }: RenderProps) => VNode<{
28
+ className: string;
29
+ }>;
30
+ export {};
@@ -1,22 +1,34 @@
1
1
  import { PostHog } from '../posthog-core';
2
2
  import { Survey } from '../posthog-surveys-types';
3
3
  export declare const callSurveys: (posthog: PostHog, forceReload?: boolean) => void;
4
- export declare const renderSurveysPreview: (survey: Survey, parentElement: HTMLElement, previewPageIndex: number) => void;
5
- export declare const renderFeedbackWidgetPreview: (survey: Survey, root: HTMLElement) => void;
4
+ export declare const renderSurveysPreview: ({ survey, parentElement, previewPageIndex, forceDisableHtml, }: {
5
+ survey: Survey;
6
+ parentElement: HTMLElement;
7
+ previewPageIndex: number;
8
+ forceDisableHtml?: boolean | undefined;
9
+ }) => void;
10
+ export declare const renderFeedbackWidgetPreview: ({ survey, root, forceDisableHtml, }: {
11
+ survey: Survey;
12
+ root: HTMLElement;
13
+ forceDisableHtml?: boolean | undefined;
14
+ }) => void;
6
15
  export declare function generateSurveys(posthog: PostHog): void;
7
- export declare function SurveyPopup({ survey, posthog, style, previewPageIndex, }: {
16
+ export declare function SurveyPopup({ survey, forceDisableHtml, posthog, style, previewPageIndex, }: {
8
17
  survey: Survey;
18
+ forceDisableHtml?: boolean;
9
19
  posthog?: PostHog;
10
20
  style?: React.CSSProperties;
11
21
  previewPageIndex?: number | undefined;
12
22
  }): JSX.Element;
13
- export declare function Questions({ survey, posthog, styleOverrides, }: {
23
+ export declare function Questions({ survey, forceDisableHtml, posthog, styleOverrides, }: {
14
24
  survey: Survey;
25
+ forceDisableHtml: boolean;
15
26
  posthog?: PostHog;
16
27
  styleOverrides?: React.CSSProperties;
17
28
  }): JSX.Element;
18
- export declare function FeedbackWidget({ survey, posthog, readOnly, }: {
29
+ export declare function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, }: {
19
30
  survey: Survey;
31
+ forceDisableHtml?: boolean;
20
32
  posthog?: PostHog;
21
33
  readOnly?: boolean;
22
34
  }): JSX.Element;
@@ -17,6 +17,7 @@ export interface SurveyAppearance {
17
17
  displayThankYouMessage?: boolean;
18
18
  thankYouMessageHeader?: string;
19
19
  thankYouMessageDescription?: string;
20
+ thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
20
21
  borderColor?: string;
21
22
  position?: 'left' | 'right' | 'center';
22
23
  placeholder?: string;
@@ -34,9 +35,11 @@ export declare enum SurveyType {
34
35
  Widget = "widget"
35
36
  }
36
37
  export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
38
+ export type SurveyQuestionDescriptionContentType = 'html' | 'text';
37
39
  interface SurveyQuestionBase {
38
40
  question: string;
39
41
  description?: string | null;
42
+ descriptionContentType?: SurveyQuestionDescriptionContentType;
40
43
  optional?: boolean;
41
44
  buttonText?: string;
42
45
  originalQuestionIndex: number;
@@ -88,6 +91,11 @@ export interface Survey {
88
91
  selector?: string;
89
92
  seenSurveyWaitPeriodInDays?: number;
90
93
  urlMatchType?: SurveyUrlMatchType;
94
+ events: {
95
+ values: {
96
+ name: string;
97
+ }[];
98
+ } | null;
91
99
  } | null;
92
100
  start_date: string | null;
93
101
  end_date: string | null;
@@ -1,10 +1,12 @@
1
1
  import { PostHog } from './posthog-core';
2
2
  import { SurveyCallback, SurveyUrlMatchType } from './posthog-surveys-types';
3
+ import { SurveyEventReceiver } from './utils/survey-event-receiver';
3
4
  import { DecideResponse } from './types';
4
5
  export declare const surveyUrlValidationMap: Record<SurveyUrlMatchType, (conditionsUrl: string) => boolean>;
5
6
  export declare class PostHogSurveys {
6
7
  instance: PostHog;
7
8
  private _decideServerResponse?;
9
+ _surveyEventReceiver: SurveyEventReceiver | null;
8
10
  constructor(instance: PostHog);
9
11
  afterDecideResponse(response: DecideResponse): void;
10
12
  loadIfEnabled(): void;
@@ -0,0 +1,12 @@
1
+ import { Survey } from '../posthog-surveys-types';
2
+ import { PostHogPersistence } from '../posthog-persistence';
3
+ export declare class SurveyEventReceiver {
4
+ private readonly eventRegistry;
5
+ private readonly persistence?;
6
+ constructor(persistence?: PostHogPersistence);
7
+ register(surveys: Survey[]): void;
8
+ on(event: string): void;
9
+ getSurveys(): string[];
10
+ getEventRegistry(): Map<string, string[]>;
11
+ private _saveSurveysToStorage;
12
+ }
package/dist/module.d.ts CHANGED
@@ -1162,6 +1162,7 @@ interface SurveyAppearance {
1162
1162
  displayThankYouMessage?: boolean;
1163
1163
  thankYouMessageHeader?: string;
1164
1164
  thankYouMessageDescription?: string;
1165
+ thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
1165
1166
  borderColor?: string;
1166
1167
  position?: 'left' | 'right' | 'center';
1167
1168
  placeholder?: string;
@@ -1179,9 +1180,11 @@ declare enum SurveyType {
1179
1180
  Widget = "widget"
1180
1181
  }
1181
1182
  type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
1183
+ type SurveyQuestionDescriptionContentType = 'html' | 'text';
1182
1184
  interface SurveyQuestionBase {
1183
1185
  question: string;
1184
1186
  description?: string | null;
1187
+ descriptionContentType?: SurveyQuestionDescriptionContentType;
1185
1188
  optional?: boolean;
1186
1189
  buttonText?: string;
1187
1190
  originalQuestionIndex: number;
@@ -1233,14 +1236,31 @@ interface Survey {
1233
1236
  selector?: string;
1234
1237
  seenSurveyWaitPeriodInDays?: number;
1235
1238
  urlMatchType?: SurveyUrlMatchType;
1239
+ events: {
1240
+ values: {
1241
+ name: string;
1242
+ }[];
1243
+ } | null;
1236
1244
  } | null;
1237
1245
  start_date: string | null;
1238
1246
  end_date: string | null;
1239
1247
  }
1240
1248
 
1249
+ declare class SurveyEventReceiver {
1250
+ private readonly eventRegistry;
1251
+ private readonly persistence?;
1252
+ constructor(persistence?: PostHogPersistence);
1253
+ register(surveys: Survey[]): void;
1254
+ on(event: string): void;
1255
+ getSurveys(): string[];
1256
+ getEventRegistry(): Map<string, string[]>;
1257
+ private _saveSurveysToStorage;
1258
+ }
1259
+
1241
1260
  declare class PostHogSurveys {
1242
1261
  instance: PostHog;
1243
1262
  private _decideServerResponse?;
1263
+ _surveyEventReceiver: SurveyEventReceiver | null;
1244
1264
  constructor(instance: PostHog);
1245
1265
  afterDecideResponse(response: DecideResponse): void;
1246
1266
  loadIfEnabled(): void;
@@ -2072,4 +2092,4 @@ declare class PostHog {
2072
2092
 
2073
2093
  declare const posthog: PostHog;
2074
2094
 
2075
- export { type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type Headers, type InitiatorType, type IsFeatureEnabledOptions, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SnippetArrayItem, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyQuestion, SurveyQuestionType, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog };
2095
+ export { type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type Headers, type InitiatorType, type IsFeatureEnabledOptions, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SnippetArrayItem, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyQuestion, type SurveyQuestionDescriptionContentType, SurveyQuestionType, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog };