@posthog/browser-common 0.9.4 → 0.9.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/dist/client.d.ts +6 -0
- package/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -10
- package/dist/index.mjs +1 -0
- package/dist/survey-action-matcher.d.ts +27 -0
- package/dist/survey-action-matcher.js +169 -0
- package/dist/survey-action-matcher.mjs +131 -0
- package/dist/survey-constants.d.ts +86 -0
- package/dist/survey-constants.js +144 -0
- package/dist/survey-constants.mjs +76 -0
- package/dist/survey-event-host.d.ts +15 -0
- package/dist/survey-event-host.js +18 -0
- package/dist/survey-event-host.mjs +1 -0
- package/dist/survey-event-receiver-base.d.ts +180 -0
- package/dist/survey-event-receiver-base.js +354 -0
- package/dist/survey-event-receiver-base.mjs +316 -0
- package/dist/survey-event-receiver.d.ts +36 -0
- package/dist/survey-event-receiver.js +133 -0
- package/dist/survey-event-receiver.mjs +95 -0
- package/dist/survey-render-context.d.ts +13 -0
- package/dist/survey-render-context.js +45 -0
- package/dist/survey-render-context.mjs +7 -0
- package/dist/surveys/components/BottomSection.d.ts +12 -0
- package/dist/surveys/components/BottomSection.js +82 -0
- package/dist/surveys/components/BottomSection.mjs +44 -0
- package/dist/surveys/components/ConfirmationMessage.d.ts +10 -0
- package/dist/surveys/components/ConfirmationMessage.js +92 -0
- package/dist/surveys/components/ConfirmationMessage.mjs +54 -0
- package/dist/surveys/components/IntroScreen.d.ts +10 -0
- package/dist/surveys/components/IntroScreen.js +78 -0
- package/dist/surveys/components/IntroScreen.mjs +40 -0
- package/dist/surveys/components/PostHogLogo.d.ts +5 -0
- package/dist/surveys/components/PostHogLogo.js +54 -0
- package/dist/surveys/components/PostHogLogo.mjs +16 -0
- package/dist/surveys/components/QuestionHeader.d.ts +10 -0
- package/dist/surveys/components/QuestionHeader.js +82 -0
- package/dist/surveys/components/QuestionHeader.mjs +41 -0
- package/dist/surveys/components/QuestionTypes.d.ts +31 -0
- package/dist/surveys/components/QuestionTypes.js +519 -0
- package/dist/surveys/components/QuestionTypes.mjs +469 -0
- package/dist/surveys/icons.d.ts +12 -0
- package/dist/surveys/icons.js +212 -0
- package/dist/surveys/icons.mjs +147 -0
- package/dist/surveys/survey-branching.d.ts +12 -0
- package/dist/surveys/survey-branching.js +101 -0
- package/dist/surveys/survey-branching.mjs +60 -0
- package/dist/surveys/survey-styles.d.ts +1 -0
- package/dist/surveys/survey-styles.js +40 -0
- package/dist/surveys/survey-styles.mjs +2 -0
- package/dist/surveys/survey-translations.d.ts +22 -0
- package/dist/surveys/survey-translations.js +68 -0
- package/dist/surveys/survey-translations.mjs +27 -0
- package/dist/surveys/survey-url-prefill.d.ts +36 -0
- package/dist/surveys/survey-url-prefill.js +162 -0
- package/dist/surveys/survey-url-prefill.mjs +118 -0
- package/dist/surveys/surveys-extension-utils.d.ts +133 -0
- package/dist/surveys/surveys-extension-utils.js +739 -0
- package/dist/surveys/surveys-extension-utils.mjs +608 -0
- package/dist/surveys-config.d.ts +60 -0
- package/dist/surveys-config.js +68 -0
- package/dist/surveys-config.mjs +9 -0
- package/dist/surveys-renderer.d.ts +248 -0
- package/dist/surveys-renderer.js +1299 -0
- package/dist/surveys-renderer.mjs +1230 -0
- package/dist/surveys.d.ts +117 -0
- package/dist/surveys.js +566 -0
- package/dist/surveys.mjs +495 -0
- package/dist/types/surveys.d.ts +83 -86
- package/dist/types/surveys.js +1 -127
- package/dist/types/surveys.mjs +1 -76
- package/dist/utils/autocapture-utils.js +8 -9
- package/dist/utils/autocapture-utils.mjs +8 -9
- package/dist/utils/event-utils.js +1 -0
- package/dist/utils/event-utils.mjs +1 -0
- package/dist/utils/matcher-utils.d.ts +1 -1
- package/dist/utils/matcher-utils.js +13 -10
- package/dist/utils/matcher-utils.mjs +10 -7
- package/dist/utils/survey-utils.d.ts +16 -0
- package/dist/utils/survey-utils.js +121 -0
- package/dist/utils/survey-utils.mjs +38 -0
- package/dist/utils/url-targeting-utils.d.ts +3 -1
- package/dist/utils/url-targeting-utils.js +1 -2
- package/dist/utils/url-targeting-utils.mjs +1 -2
- package/dist/utils/uuidv7.js +4 -4
- package/dist/utils/uuidv7.mjs +4 -4
- package/package.json +97 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const SURVEYS = '$surveys';
|
|
31
|
+
const SURVEYS_LOADED_AT = '$surveys_loaded_at';
|
|
32
|
+
const SURVEYS_CACHE_TTL_MS = 300000;
|
|
33
|
+
const SURVEYS_REFRESH_BACKOFF_MS = SURVEYS_CACHE_TTL_MS;
|
|
34
|
+
const LOAD_EXT_NOT_FOUND = 'PostHog loadExternalDependency extension not found.';
|
|
35
|
+
const SURVEYS_ACTIVATED = '$surveys_activated';
|
|
36
|
+
const SURVEYS_ACTIVATED_SESSION = '$surveys_activated_session';
|
|
37
|
+
const SURVEYS_ACTIVATED_TIMESTAMPS = '$surveys_activated_timestamps';
|
|
38
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
39
|
+
LOAD_EXT_NOT_FOUND: LOAD_EXT_NOT_FOUND,
|
|
40
|
+
SURVEYS: SURVEYS,
|
|
41
|
+
SURVEYS_ACTIVATED: SURVEYS_ACTIVATED,
|
|
42
|
+
SURVEYS_ACTIVATED_SESSION: SURVEYS_ACTIVATED_SESSION,
|
|
43
|
+
SURVEYS_ACTIVATED_TIMESTAMPS: SURVEYS_ACTIVATED_TIMESTAMPS,
|
|
44
|
+
SURVEYS_CACHE_TTL_MS: SURVEYS_CACHE_TTL_MS,
|
|
45
|
+
SURVEYS_LOADED_AT: SURVEYS_LOADED_AT,
|
|
46
|
+
SURVEYS_REFRESH_BACKOFF_MS: SURVEYS_REFRESH_BACKOFF_MS
|
|
47
|
+
});
|
|
48
|
+
exports.LOAD_EXT_NOT_FOUND = __webpack_exports__.LOAD_EXT_NOT_FOUND;
|
|
49
|
+
exports.SURVEYS = __webpack_exports__.SURVEYS;
|
|
50
|
+
exports.SURVEYS_ACTIVATED = __webpack_exports__.SURVEYS_ACTIVATED;
|
|
51
|
+
exports.SURVEYS_ACTIVATED_SESSION = __webpack_exports__.SURVEYS_ACTIVATED_SESSION;
|
|
52
|
+
exports.SURVEYS_ACTIVATED_TIMESTAMPS = __webpack_exports__.SURVEYS_ACTIVATED_TIMESTAMPS;
|
|
53
|
+
exports.SURVEYS_CACHE_TTL_MS = __webpack_exports__.SURVEYS_CACHE_TTL_MS;
|
|
54
|
+
exports.SURVEYS_LOADED_AT = __webpack_exports__.SURVEYS_LOADED_AT;
|
|
55
|
+
exports.SURVEYS_REFRESH_BACKOFF_MS = __webpack_exports__.SURVEYS_REFRESH_BACKOFF_MS;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"LOAD_EXT_NOT_FOUND",
|
|
58
|
+
"SURVEYS",
|
|
59
|
+
"SURVEYS_ACTIVATED",
|
|
60
|
+
"SURVEYS_ACTIVATED_SESSION",
|
|
61
|
+
"SURVEYS_ACTIVATED_TIMESTAMPS",
|
|
62
|
+
"SURVEYS_CACHE_TTL_MS",
|
|
63
|
+
"SURVEYS_LOADED_AT",
|
|
64
|
+
"SURVEYS_REFRESH_BACKOFF_MS"
|
|
65
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
|
+
Object.defineProperty(exports, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const SURVEYS = '$surveys';
|
|
2
|
+
const SURVEYS_LOADED_AT = '$surveys_loaded_at';
|
|
3
|
+
const SURVEYS_CACHE_TTL_MS = 300000;
|
|
4
|
+
const SURVEYS_REFRESH_BACKOFF_MS = SURVEYS_CACHE_TTL_MS;
|
|
5
|
+
const LOAD_EXT_NOT_FOUND = 'PostHog loadExternalDependency extension not found.';
|
|
6
|
+
const SURVEYS_ACTIVATED = '$surveys_activated';
|
|
7
|
+
const SURVEYS_ACTIVATED_SESSION = '$surveys_activated_session';
|
|
8
|
+
const SURVEYS_ACTIVATED_TIMESTAMPS = '$surveys_activated_timestamps';
|
|
9
|
+
export { LOAD_EXT_NOT_FOUND, SURVEYS, SURVEYS_ACTIVATED, SURVEYS_ACTIVATED_SESSION, SURVEYS_ACTIVATED_TIMESTAMPS, SURVEYS_CACHE_TTL_MS, SURVEYS_LOADED_AT, SURVEYS_REFRESH_BACKOFF_MS };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { type JSX, type RefObject } from 'preact';
|
|
2
|
+
import type { SurveyRenderContext } from './survey-render-context';
|
|
3
|
+
import type { DisplaySurveyPopoverOptions, Survey, SurveyCallback, SurveyWithTypeAndAppearance } from './types/surveys';
|
|
4
|
+
import type { Properties } from '@posthog/types';
|
|
5
|
+
import { getNextSurveyStep } from './surveys/survey-branching';
|
|
6
|
+
export { getNextSurveyStep };
|
|
7
|
+
/**
|
|
8
|
+
* `previewPageIndex` sentinel for the intro screen — the leading mirror of the confirmation
|
|
9
|
+
* page's `survey.questions.length` sentinel. Also serves as a capability marker for the main
|
|
10
|
+
* app: bundles without this export cannot render the intro screen preview.
|
|
11
|
+
*/
|
|
12
|
+
export declare const INTRO_SCREEN_PREVIEW_INDEX = -1;
|
|
13
|
+
export declare class SurveyManager {
|
|
14
|
+
private _host;
|
|
15
|
+
private _surveyInFocus;
|
|
16
|
+
private _surveyTimeouts;
|
|
17
|
+
private _widgetSelectorListeners;
|
|
18
|
+
private _renderedTabWidgets;
|
|
19
|
+
private _renderedTargets;
|
|
20
|
+
private _prefillHandledSurveys;
|
|
21
|
+
private _automaticDisplayDispose?;
|
|
22
|
+
private _disposed;
|
|
23
|
+
private _currentLanguage;
|
|
24
|
+
private _surveyIsRendered;
|
|
25
|
+
private _languageChangeListener;
|
|
26
|
+
private _unsubscribeFeatureFlags;
|
|
27
|
+
private _surveyPopupProps;
|
|
28
|
+
private _displayOptions;
|
|
29
|
+
private _loggedFeatureFlagsDisabledWarning;
|
|
30
|
+
constructor(posthog: SurveyRenderContext);
|
|
31
|
+
private _onLanguageChange;
|
|
32
|
+
private _applyDisplayOverrides;
|
|
33
|
+
handlePageUnload: () => void;
|
|
34
|
+
private _clearSurveyTimeout;
|
|
35
|
+
/**
|
|
36
|
+
* cancel a "pending" survey, i.e. one that is waiting to be displayed in
|
|
37
|
+
* the _surveyTimeouts queue
|
|
38
|
+
*/
|
|
39
|
+
cancelSurvey(surveyId: string): void;
|
|
40
|
+
startAutomaticDisplay(): void;
|
|
41
|
+
clearInMemoryInProgressSurveyState(): void;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
/**
|
|
44
|
+
* `resumeDelayFromActivation` is internal to the display loop: a survey armed by an
|
|
45
|
+
* event/action trigger resumes its popup delay from when the trigger fired, so navigating
|
|
46
|
+
* mid-delay does not restart the countdown. An explicit `displaySurvey()` call carries its own
|
|
47
|
+
* `ignoreDelay` option instead, so it must always honor the full configured delay.
|
|
48
|
+
*/
|
|
49
|
+
handlePopoverSurvey: (surveyParam: Survey, options?: DisplaySurveyPopoverOptions, { resumeDelayFromActivation }?: {
|
|
50
|
+
resumeDelayFromActivation?: boolean | undefined;
|
|
51
|
+
}) => void;
|
|
52
|
+
private _handleWidget;
|
|
53
|
+
private _detachWidgetSelectorListener;
|
|
54
|
+
private _removeWidgetSelectorListener;
|
|
55
|
+
private _removeTabWidget;
|
|
56
|
+
private _isWidgetSurveyOpen;
|
|
57
|
+
private _manageWidgetSelectorListener;
|
|
58
|
+
/**
|
|
59
|
+
* Sorts surveys by their appearance delay in ascending order. If a survey does not have an appearance delay,
|
|
60
|
+
* it is considered to have a delay of 0.
|
|
61
|
+
* @param surveys
|
|
62
|
+
* @returns The surveys sorted by their appearance delay
|
|
63
|
+
*/
|
|
64
|
+
private _sortSurveysByAppearanceDelay;
|
|
65
|
+
renderPopover: (survey: Survey) => void;
|
|
66
|
+
renderSurvey: (survey: Survey, selector: Element, properties?: Properties) => void;
|
|
67
|
+
private _translateSurveyForRendering;
|
|
68
|
+
private _handleUrlPrefill;
|
|
69
|
+
/**
|
|
70
|
+
* On load, capture a response for prefilled questions only when:
|
|
71
|
+
* 1) the survey is complete, OR
|
|
72
|
+
* 2) partial responses are enabled AND the skipped questions were set to auto-submit.
|
|
73
|
+
*/
|
|
74
|
+
private _autoSubmitPrefilledResponses;
|
|
75
|
+
/**
|
|
76
|
+
* process prefilled responses for non-hosted surveys
|
|
77
|
+
*
|
|
78
|
+
* @returns boolean, true if the survey is completed
|
|
79
|
+
*/
|
|
80
|
+
private _handleInitialResponses;
|
|
81
|
+
private _processPrefillData;
|
|
82
|
+
private _isSurveyFeatureFlagEnabled;
|
|
83
|
+
private _warnIfFeatureFlagsDisabled;
|
|
84
|
+
private _isSurveyConditionMatched;
|
|
85
|
+
private _internalFlagCheckSatisfied;
|
|
86
|
+
checkSurveyEligibility(survey: Survey): {
|
|
87
|
+
eligible: boolean;
|
|
88
|
+
reason?: string | undefined;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* PostHog's capture state, as an eligibility result. This is a prerequisite for any survey the
|
|
92
|
+
* SDK renders itself, not one of the survey's display conditions: without it a person types an
|
|
93
|
+
* answer, sees the confirmation, and `capture()` drops the `survey sent` event. So
|
|
94
|
+
* `displaySurvey`'s `ignoreConditions` must not bypass it. `is_capturing()` is the same gate
|
|
95
|
+
* `capture()` uses, so cookieless `on_reject` stays eligible.
|
|
96
|
+
*
|
|
97
|
+
* Deliberately kept out of `checkSurveyEligibility`: that also backs the public
|
|
98
|
+
* `getActiveMatchingSurveys`, which custom integrations use to discover API surveys they
|
|
99
|
+
* render themselves and record through their own backend (see `markSurveyAsSeen`). PostHog's
|
|
100
|
+
* capture state says nothing about whether such a response can be recorded, so discovery
|
|
101
|
+
* stays capture-independent.
|
|
102
|
+
*/
|
|
103
|
+
checkSurveyCaptureEligibility(): {
|
|
104
|
+
eligible: boolean;
|
|
105
|
+
reason?: string | undefined;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Eligibility for a survey the SDK renders and captures the response for itself: everything
|
|
109
|
+
* `checkSurveyEligibility` checks, plus PostHog's capture state.
|
|
110
|
+
*/
|
|
111
|
+
checkSurveyDisplayEligibility(survey: Survey): {
|
|
112
|
+
eligible: boolean;
|
|
113
|
+
reason?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Renderability = display eligibility (running, type, flags, wait period, already-seen,
|
|
117
|
+
* capturing) plus the survey's event/action activation trigger. Used by the programmatic
|
|
118
|
+
* `canRenderSurvey` / `canRenderSurveyAsync` checks so they match the display loop.
|
|
119
|
+
*
|
|
120
|
+
* The trigger is intentionally kept out of `checkSurveyDisplayEligibility`: that method is
|
|
121
|
+
* also used by the explicit `displaySurvey` path, and the trigger state only lives in memory
|
|
122
|
+
* (a reload clears it, server-side events never set it). Gating eligibility on it would
|
|
123
|
+
* make explicit `displaySurvey('id')` calls silently show nothing.
|
|
124
|
+
*/
|
|
125
|
+
checkSurveyRenderability(survey: Survey): {
|
|
126
|
+
eligible: boolean;
|
|
127
|
+
reason?: string | undefined;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Surveys can be activated by events or actions. This method checks if the survey has events and actions,
|
|
131
|
+
* and if so, it checks if the survey has been activated.
|
|
132
|
+
* @param survey
|
|
133
|
+
*/
|
|
134
|
+
private _hasActionOrEventTriggeredSurvey;
|
|
135
|
+
private _checkFlags;
|
|
136
|
+
/**
|
|
137
|
+
* The full predicate for "should this survey display right now": eligibility (running,
|
|
138
|
+
* type, linked/targeting/internal flags, wait period, already-seen) plus the URL/device/
|
|
139
|
+
* selector conditions, the event/action trigger, and any feature-flag dependencies.
|
|
140
|
+
*
|
|
141
|
+
* Shared by the display loop and re-checked when a popover's delay timer fires, so a
|
|
142
|
+
* survey that became ineligible *during* the delay (e.g. an identify() reloaded flags and
|
|
143
|
+
* the internal targeting flag is now false) is not shown. Note this is purely an AND gate:
|
|
144
|
+
* adding it can only ever suppress a display, never cause an extra one.
|
|
145
|
+
*
|
|
146
|
+
* PostHog's capture state is not part of this: it also backs the public
|
|
147
|
+
* `getActiveMatchingSurveys` discovery result, so the paths where the SDK renders the survey
|
|
148
|
+
* itself apply that gate separately — see `checkSurveyDisplayEligibility`.
|
|
149
|
+
*/
|
|
150
|
+
private _shouldDisplaySurvey;
|
|
151
|
+
getActiveMatchingSurveys: (callback: SurveyCallback, forceReload?: boolean) => void;
|
|
152
|
+
callSurveysAndEvaluateDisplayLogic: (forceReload?: boolean) => void;
|
|
153
|
+
private _addSurveyToFocus;
|
|
154
|
+
private _removeSurveyFromDom;
|
|
155
|
+
private _removeSurveyFromFocus;
|
|
156
|
+
getTestAPI(): {
|
|
157
|
+
addSurveyToFocus: (survey: Pick<Survey, 'id'>) => void;
|
|
158
|
+
removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void;
|
|
159
|
+
surveyInFocus: string | null;
|
|
160
|
+
surveyTimeouts: Map<string, number>;
|
|
161
|
+
handleWidget: (survey: Survey) => void;
|
|
162
|
+
handlePopoverSurvey: (surveyParam: Survey, options?: DisplaySurveyPopoverOptions, { resumeDelayFromActivation }?: {
|
|
163
|
+
resumeDelayFromActivation?: boolean | undefined;
|
|
164
|
+
}) => void;
|
|
165
|
+
manageWidgetSelectorListener: (survey: Survey, selector: string) => void;
|
|
166
|
+
sortSurveysByAppearanceDelay: (surveys: Survey[]) => Survey[];
|
|
167
|
+
checkFlags: (survey: Survey) => boolean;
|
|
168
|
+
isSurveyFeatureFlagEnabled: (flagKey: string | null, flagVariant?: string | undefined) => boolean;
|
|
169
|
+
onLanguageChange: () => void;
|
|
170
|
+
currentLanguage: string | null;
|
|
171
|
+
surveyIsRendered: boolean;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export declare const renderSurveysPreview: ({ survey, parentElement, previewPageIndex, forceDisableHtml, onPreviewSubmit, onPreviewBack, posthog, positionStyles, }: {
|
|
175
|
+
survey: Survey;
|
|
176
|
+
parentElement: HTMLElement;
|
|
177
|
+
previewPageIndex: number;
|
|
178
|
+
forceDisableHtml?: boolean | undefined;
|
|
179
|
+
onPreviewSubmit?: ((res: string | string[] | number | null) => void) | undefined;
|
|
180
|
+
onPreviewBack?: (() => void) | undefined;
|
|
181
|
+
posthog?: SurveyRenderContext | undefined;
|
|
182
|
+
positionStyles?: JSX.CSSProperties | undefined;
|
|
183
|
+
}) => void;
|
|
184
|
+
export declare const renderFeedbackWidgetPreview: ({ survey, root, forceDisableHtml, posthog, }: {
|
|
185
|
+
survey: Survey;
|
|
186
|
+
root: HTMLElement;
|
|
187
|
+
forceDisableHtml?: boolean | undefined;
|
|
188
|
+
posthog?: SurveyRenderContext | undefined;
|
|
189
|
+
}) => void;
|
|
190
|
+
export declare function generateSurveys(posthog: SurveyRenderContext, isSurveysEnabled: boolean | undefined): SurveyManager | undefined;
|
|
191
|
+
type UseHideSurveyOnURLChangeProps = {
|
|
192
|
+
survey: Pick<Survey, 'id' | 'conditions' | 'type' | 'appearance'>;
|
|
193
|
+
removeSurveyFromFocus?: ((survey: SurveyWithTypeAndAppearance) => void) | undefined;
|
|
194
|
+
setSurveyVisible: (visible: boolean) => void;
|
|
195
|
+
isPreviewMode?: boolean | undefined;
|
|
196
|
+
posthog?: SurveyRenderContext | undefined;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* This hook handles URL-based survey visibility after the initial mount.
|
|
200
|
+
* The initial URL check is handled by the `getActiveMatchingSurveys` method in the `PostHogSurveys` class,
|
|
201
|
+
* which ensures the URL matches before displaying a survey for the first time.
|
|
202
|
+
* That is the method that is called every second to see if there's a matching survey.
|
|
203
|
+
*
|
|
204
|
+
* This separation of concerns means:
|
|
205
|
+
* 1. Initial URL matching is done by `getActiveMatchingSurveys` before displaying the survey
|
|
206
|
+
* 2. Subsequent URL changes are handled here to hide the survey as the user navigates
|
|
207
|
+
*/
|
|
208
|
+
export declare function useHideSurveyOnURLChange({ survey, removeSurveyFromFocus, setSurveyVisible, isPreviewMode, posthog, }: UseHideSurveyOnURLChangeProps): void;
|
|
209
|
+
export declare function usePopupVisibility(survey: Survey, posthog: SurveyRenderContext | undefined, millisecondDelay: number, isPreviewMode: boolean, removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void, isPopup: boolean, surveyContainerRef?: RefObject<HTMLDivElement>, skipShownEvent?: boolean, surveyLanguage?: string | null): {
|
|
210
|
+
isPopupVisible: boolean;
|
|
211
|
+
isSurveySent: boolean;
|
|
212
|
+
setIsPopupVisible: import("preact/hooks").Dispatch<import("preact/hooks").StateUpdater<boolean>>;
|
|
213
|
+
hidePopupWithAnimation: () => void;
|
|
214
|
+
};
|
|
215
|
+
interface SurveyPopupProps {
|
|
216
|
+
survey: Survey;
|
|
217
|
+
forceDisableHtml?: boolean | undefined;
|
|
218
|
+
posthog?: SurveyRenderContext | undefined;
|
|
219
|
+
style?: JSX.CSSProperties | undefined;
|
|
220
|
+
previewPageIndex?: number | undefined;
|
|
221
|
+
removeSurveyFromFocus?: ((survey: SurveyWithTypeAndAppearance) => void) | undefined;
|
|
222
|
+
isPopup?: boolean | undefined;
|
|
223
|
+
onPreviewSubmit?: ((res: string | string[] | number | null) => void) | undefined;
|
|
224
|
+
onPreviewBack?: (() => void) | undefined;
|
|
225
|
+
onPopupSurveyDismissed?: (() => void) | undefined;
|
|
226
|
+
onCloseConfirmationMessage?: (() => void) | undefined;
|
|
227
|
+
/** Additional properties to include in all survey events */
|
|
228
|
+
properties?: Properties | undefined;
|
|
229
|
+
/** if true, survey popup will only render if there is a thank-you message */
|
|
230
|
+
isSurveyCompleted?: boolean | undefined;
|
|
231
|
+
/** When true, `survey shown` events will not be emitted automatically */
|
|
232
|
+
skipShownEvent?: boolean | undefined;
|
|
233
|
+
/** The language that was applied to the survey. */
|
|
234
|
+
surveyLanguage?: (string | null) | undefined;
|
|
235
|
+
}
|
|
236
|
+
export declare function SurveyPopup({ survey, forceDisableHtml, posthog, style, previewPageIndex, removeSurveyFromFocus, isPopup, onPreviewSubmit, onPreviewBack, onPopupSurveyDismissed, onCloseConfirmationMessage, properties, isSurveyCompleted, skipShownEvent, surveyLanguage, }: SurveyPopupProps): JSX.Element | null;
|
|
237
|
+
export declare function Questions({ survey, forceDisableHtml, posthog, }: {
|
|
238
|
+
survey: Survey;
|
|
239
|
+
forceDisableHtml: boolean;
|
|
240
|
+
posthog?: SurveyRenderContext | undefined;
|
|
241
|
+
}): JSX.Element | null;
|
|
242
|
+
export declare function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, surveyLanguage, }: {
|
|
243
|
+
survey: Survey;
|
|
244
|
+
forceDisableHtml?: boolean | undefined;
|
|
245
|
+
posthog?: SurveyRenderContext | undefined;
|
|
246
|
+
readOnly?: boolean | undefined;
|
|
247
|
+
surveyLanguage?: (string | null) | undefined;
|
|
248
|
+
}): JSX.Element | null;
|