@posthog/browser-common 0.9.5 → 0.9.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/dist/client.d.ts +6 -0
- package/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/feature-flags.d.ts +1 -0
- package/dist/feature-flags.js +5 -0
- package/dist/feature-flags.mjs +5 -0
- 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/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 +96 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Survey } from './types/surveys';
|
|
2
|
+
import type { Client } from './client';
|
|
3
|
+
import type { SurveyCapturedEvent as CaptureResult } from './survey-event-host';
|
|
4
|
+
import { type ActivationOutcome, EventReceiver } from './survey-event-receiver-base';
|
|
5
|
+
import { createLogger } from './utils/logger';
|
|
6
|
+
export interface SurveyTriggerHost {
|
|
7
|
+
getSurveys(callback: (surveys: Survey[]) => void): void;
|
|
8
|
+
cancelPendingSurvey(id: string): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class SurveyEventReceiver extends EventReceiver<Survey> {
|
|
11
|
+
private readonly _client;
|
|
12
|
+
private readonly _surveys;
|
|
13
|
+
constructor(_client: Client, _surveys: SurveyTriggerHost, onActivationChanged?: () => void);
|
|
14
|
+
protected _getActivatedKey(): string;
|
|
15
|
+
protected _getActivatedSessionKey(): string;
|
|
16
|
+
protected _getActivationTimestampsKey(): string;
|
|
17
|
+
protected _writeActivationTimestamps(timestamps: Record<string, number>): void;
|
|
18
|
+
protected _clearActivationTimestampsStore(): void;
|
|
19
|
+
/**
|
|
20
|
+
* A survey with a popup delay must survive navigation so the delay resumes from the recorded
|
|
21
|
+
* activation time on the next page instead of restarting from zero. Surveys without a delay
|
|
22
|
+
* keep the in-memory arming, so an exit-intent trigger does not surface them on a later page.
|
|
23
|
+
*/
|
|
24
|
+
protected _shouldPersistArmedActivation(itemId: string): boolean;
|
|
25
|
+
protected _getShownEventName(): string;
|
|
26
|
+
protected _getItems(callback: (items: Survey[]) => void): void;
|
|
27
|
+
protected _cancelPendingItem(itemId: string): void;
|
|
28
|
+
protected _getLogger(): ReturnType<typeof createLogger>;
|
|
29
|
+
protected _setActivatedItems(eligibleItems: string[]): void;
|
|
30
|
+
protected _setActivatedSession(sessionId: string): void;
|
|
31
|
+
protected _clearActivatedSession(): void;
|
|
32
|
+
protected _isItemPermanentlyIneligible(): boolean;
|
|
33
|
+
protected _activationOutcome(event: string, itemId: string, eventPayload?: CaptureResult): ActivationOutcome;
|
|
34
|
+
getSurveys(): string[];
|
|
35
|
+
getEventToSurveys(): Map<string, string[]>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
SurveyEventReceiver: ()=>SurveyEventReceiver
|
|
32
|
+
});
|
|
33
|
+
const surveys_namespaceObject = require("@posthog/core/surveys");
|
|
34
|
+
const core_namespaceObject = require("@posthog/core");
|
|
35
|
+
const external_surveys_config_js_namespaceObject = require("./surveys-config.js");
|
|
36
|
+
const external_survey_constants_js_namespaceObject = require("./survey-constants.js");
|
|
37
|
+
const survey_utils_js_namespaceObject = require("./utils/survey-utils.js");
|
|
38
|
+
const external_survey_event_receiver_base_js_namespaceObject = require("./survey-event-receiver-base.js");
|
|
39
|
+
class SurveyEventReceiver extends external_survey_event_receiver_base_js_namespaceObject.EventReceiver {
|
|
40
|
+
constructor(_client, _surveys, onActivationChanged){
|
|
41
|
+
super({
|
|
42
|
+
subscribeCapture: (listener)=>{
|
|
43
|
+
const subscription = _client.onEvent((event)=>listener(event.event, event));
|
|
44
|
+
return ()=>subscription.dispose();
|
|
45
|
+
},
|
|
46
|
+
subscribeSession: (listener)=>{
|
|
47
|
+
const subscription = _client.onSession(listener);
|
|
48
|
+
return ()=>subscription.dispose();
|
|
49
|
+
},
|
|
50
|
+
getSessionId: ()=>_client.session?.sessionId,
|
|
51
|
+
getProperty: (key)=>_client.kv.get(key),
|
|
52
|
+
setElementSelectors: (selectors, owner)=>_client.getExtension('autocapture')?.setElementSelectors(selectors, owner)
|
|
53
|
+
}, onActivationChanged), this._client = _client, this._surveys = _surveys;
|
|
54
|
+
this._subscribeSession();
|
|
55
|
+
}
|
|
56
|
+
_getActivatedKey() {
|
|
57
|
+
return external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED;
|
|
58
|
+
}
|
|
59
|
+
_getActivatedSessionKey() {
|
|
60
|
+
return external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_SESSION;
|
|
61
|
+
}
|
|
62
|
+
_getActivationTimestampsKey() {
|
|
63
|
+
return external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_TIMESTAMPS;
|
|
64
|
+
}
|
|
65
|
+
_writeActivationTimestamps(timestamps) {
|
|
66
|
+
this._client.kv.set({
|
|
67
|
+
[external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_TIMESTAMPS]: timestamps
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
_clearActivationTimestampsStore() {
|
|
71
|
+
this._client.kv.remove(external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_TIMESTAMPS);
|
|
72
|
+
}
|
|
73
|
+
_shouldPersistArmedActivation(itemId) {
|
|
74
|
+
let survey;
|
|
75
|
+
this._getItems((surveys)=>{
|
|
76
|
+
survey = surveys.find((s)=>s.id === itemId);
|
|
77
|
+
});
|
|
78
|
+
const delaySeconds = survey?.appearance?.surveyPopupDelaySeconds;
|
|
79
|
+
return (0, core_namespaceObject.isNumber)(delaySeconds) && delaySeconds > 0;
|
|
80
|
+
}
|
|
81
|
+
_getShownEventName() {
|
|
82
|
+
return external_survey_constants_js_namespaceObject.SurveyEventName.SHOWN;
|
|
83
|
+
}
|
|
84
|
+
_getItems(callback) {
|
|
85
|
+
this._surveys.getSurveys(callback);
|
|
86
|
+
}
|
|
87
|
+
_cancelPendingItem(itemId) {
|
|
88
|
+
this._surveys.cancelPendingSurvey(itemId);
|
|
89
|
+
}
|
|
90
|
+
_getLogger() {
|
|
91
|
+
return survey_utils_js_namespaceObject.SURVEY_LOGGER;
|
|
92
|
+
}
|
|
93
|
+
_setActivatedItems(eligibleItems) {
|
|
94
|
+
this._client.kv.set({
|
|
95
|
+
[external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED]: eligibleItems
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
_setActivatedSession(sessionId) {
|
|
99
|
+
this._client.kv.set({
|
|
100
|
+
[external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_SESSION]: sessionId
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
_clearActivatedSession() {
|
|
104
|
+
this._client.kv.remove(external_surveys_config_js_namespaceObject.SURVEYS_ACTIVATED_SESSION);
|
|
105
|
+
}
|
|
106
|
+
_isItemPermanentlyIneligible() {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
_activationOutcome(event, itemId, eventPayload) {
|
|
110
|
+
if (event === external_survey_constants_js_namespaceObject.SurveyEventName.SENT && eventPayload?.properties?.$survey_completed === false) return 'ignore';
|
|
111
|
+
let survey;
|
|
112
|
+
this._getItems((surveys)=>{
|
|
113
|
+
survey = surveys.find((s)=>s.id === itemId);
|
|
114
|
+
});
|
|
115
|
+
const consumedOnShown = !survey || (0, surveys_namespaceObject.canSurveyActivateRepeatedly)(survey);
|
|
116
|
+
if (consumedOnShown) return event === external_survey_constants_js_namespaceObject.SurveyEventName.SHOWN ? 'consume' : 'ignore';
|
|
117
|
+
if (event === external_survey_constants_js_namespaceObject.SurveyEventName.SHOWN) return 'persist';
|
|
118
|
+
return event === external_survey_constants_js_namespaceObject.SurveyEventName.DISMISSED || event === external_survey_constants_js_namespaceObject.SurveyEventName.SENT ? 'consume' : 'ignore';
|
|
119
|
+
}
|
|
120
|
+
getSurveys() {
|
|
121
|
+
return this.getActivatedIds();
|
|
122
|
+
}
|
|
123
|
+
getEventToSurveys() {
|
|
124
|
+
return this.getEventToItemsMap();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.SurveyEventReceiver = __webpack_exports__.SurveyEventReceiver;
|
|
128
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
129
|
+
"SurveyEventReceiver"
|
|
130
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
131
|
+
Object.defineProperty(exports, '__esModule', {
|
|
132
|
+
value: true
|
|
133
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { canSurveyActivateRepeatedly } from "@posthog/core/surveys";
|
|
2
|
+
import { isNumber } from "@posthog/core";
|
|
3
|
+
import { SURVEYS_ACTIVATED, SURVEYS_ACTIVATED_SESSION, SURVEYS_ACTIVATED_TIMESTAMPS } from "./surveys-config.mjs";
|
|
4
|
+
import { SurveyEventName } from "./survey-constants.mjs";
|
|
5
|
+
import { SURVEY_LOGGER } from "./utils/survey-utils.mjs";
|
|
6
|
+
import { EventReceiver } from "./survey-event-receiver-base.mjs";
|
|
7
|
+
class SurveyEventReceiver extends EventReceiver {
|
|
8
|
+
constructor(_client, _surveys, onActivationChanged){
|
|
9
|
+
super({
|
|
10
|
+
subscribeCapture: (listener)=>{
|
|
11
|
+
const subscription = _client.onEvent((event)=>listener(event.event, event));
|
|
12
|
+
return ()=>subscription.dispose();
|
|
13
|
+
},
|
|
14
|
+
subscribeSession: (listener)=>{
|
|
15
|
+
const subscription = _client.onSession(listener);
|
|
16
|
+
return ()=>subscription.dispose();
|
|
17
|
+
},
|
|
18
|
+
getSessionId: ()=>_client.session?.sessionId,
|
|
19
|
+
getProperty: (key)=>_client.kv.get(key),
|
|
20
|
+
setElementSelectors: (selectors, owner)=>_client.getExtension('autocapture')?.setElementSelectors(selectors, owner)
|
|
21
|
+
}, onActivationChanged), this._client = _client, this._surveys = _surveys;
|
|
22
|
+
this._subscribeSession();
|
|
23
|
+
}
|
|
24
|
+
_getActivatedKey() {
|
|
25
|
+
return SURVEYS_ACTIVATED;
|
|
26
|
+
}
|
|
27
|
+
_getActivatedSessionKey() {
|
|
28
|
+
return SURVEYS_ACTIVATED_SESSION;
|
|
29
|
+
}
|
|
30
|
+
_getActivationTimestampsKey() {
|
|
31
|
+
return SURVEYS_ACTIVATED_TIMESTAMPS;
|
|
32
|
+
}
|
|
33
|
+
_writeActivationTimestamps(timestamps) {
|
|
34
|
+
this._client.kv.set({
|
|
35
|
+
[SURVEYS_ACTIVATED_TIMESTAMPS]: timestamps
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
_clearActivationTimestampsStore() {
|
|
39
|
+
this._client.kv.remove(SURVEYS_ACTIVATED_TIMESTAMPS);
|
|
40
|
+
}
|
|
41
|
+
_shouldPersistArmedActivation(itemId) {
|
|
42
|
+
let survey;
|
|
43
|
+
this._getItems((surveys)=>{
|
|
44
|
+
survey = surveys.find((s)=>s.id === itemId);
|
|
45
|
+
});
|
|
46
|
+
const delaySeconds = survey?.appearance?.surveyPopupDelaySeconds;
|
|
47
|
+
return isNumber(delaySeconds) && delaySeconds > 0;
|
|
48
|
+
}
|
|
49
|
+
_getShownEventName() {
|
|
50
|
+
return SurveyEventName.SHOWN;
|
|
51
|
+
}
|
|
52
|
+
_getItems(callback) {
|
|
53
|
+
this._surveys.getSurveys(callback);
|
|
54
|
+
}
|
|
55
|
+
_cancelPendingItem(itemId) {
|
|
56
|
+
this._surveys.cancelPendingSurvey(itemId);
|
|
57
|
+
}
|
|
58
|
+
_getLogger() {
|
|
59
|
+
return SURVEY_LOGGER;
|
|
60
|
+
}
|
|
61
|
+
_setActivatedItems(eligibleItems) {
|
|
62
|
+
this._client.kv.set({
|
|
63
|
+
[SURVEYS_ACTIVATED]: eligibleItems
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
_setActivatedSession(sessionId) {
|
|
67
|
+
this._client.kv.set({
|
|
68
|
+
[SURVEYS_ACTIVATED_SESSION]: sessionId
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
_clearActivatedSession() {
|
|
72
|
+
this._client.kv.remove(SURVEYS_ACTIVATED_SESSION);
|
|
73
|
+
}
|
|
74
|
+
_isItemPermanentlyIneligible() {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
_activationOutcome(event, itemId, eventPayload) {
|
|
78
|
+
if (event === SurveyEventName.SENT && eventPayload?.properties?.$survey_completed === false) return 'ignore';
|
|
79
|
+
let survey;
|
|
80
|
+
this._getItems((surveys)=>{
|
|
81
|
+
survey = surveys.find((s)=>s.id === itemId);
|
|
82
|
+
});
|
|
83
|
+
const consumedOnShown = !survey || canSurveyActivateRepeatedly(survey);
|
|
84
|
+
if (consumedOnShown) return event === SurveyEventName.SHOWN ? 'consume' : 'ignore';
|
|
85
|
+
if (event === SurveyEventName.SHOWN) return 'persist';
|
|
86
|
+
return event === SurveyEventName.DISMISSED || event === SurveyEventName.SENT ? 'consume' : 'ignore';
|
|
87
|
+
}
|
|
88
|
+
getSurveys() {
|
|
89
|
+
return this.getActivatedIds();
|
|
90
|
+
}
|
|
91
|
+
getEventToSurveys() {
|
|
92
|
+
return this.getEventToItemsMap();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export { SurveyEventReceiver };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Client } from './client';
|
|
2
|
+
import type { SurveysConfig, SurveysEventReceiver } from './surveys-config';
|
|
3
|
+
import type { SurveyCallback } from './types/surveys';
|
|
4
|
+
/** Shared renderer dependencies. The surveys extension remains the lifecycle owner. */
|
|
5
|
+
export interface SurveyRenderContext {
|
|
6
|
+
readonly client?: Client | undefined;
|
|
7
|
+
readonly config: Readonly<SurveysConfig>;
|
|
8
|
+
readonly surveys?: {
|
|
9
|
+
readonly _surveyEventReceiver: SurveysEventReceiver | null | undefined;
|
|
10
|
+
getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function getSurveyReplayUrl({ client, config }: SurveyRenderContext): string | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
function getSurveyReplayUrl({ client, config }) {
|
|
31
|
+
if (!client || !config.uiHost) return;
|
|
32
|
+
const sessionId = client.session?.sessionId;
|
|
33
|
+
if (!sessionId) return;
|
|
34
|
+
return `${config.uiHost}/project/${client.projectToken}/replay/${sessionId}`;
|
|
35
|
+
}
|
|
36
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
getSurveyReplayUrl: ()=>getSurveyReplayUrl
|
|
38
|
+
});
|
|
39
|
+
exports.getSurveyReplayUrl = __webpack_exports__.getSurveyReplayUrl;
|
|
40
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
41
|
+
"getSurveyReplayUrl"
|
|
42
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function getSurveyReplayUrl({ client, config }) {
|
|
2
|
+
if (!client || !config.uiHost) return;
|
|
3
|
+
const sessionId = client.session?.sessionId;
|
|
4
|
+
if (!sessionId) return;
|
|
5
|
+
return `${config.uiHost}/project/${client.projectToken}/replay/${sessionId}`;
|
|
6
|
+
}
|
|
7
|
+
export { getSurveyReplayUrl };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SurveyAppearance } from '../../types/surveys';
|
|
2
|
+
export declare function BottomSection({ text, submitDisabled, appearance, onSubmit, link, onPreviewSubmit, skipSubmitButton, canGoBack, onBack, }: {
|
|
3
|
+
text: string;
|
|
4
|
+
submitDisabled: boolean;
|
|
5
|
+
appearance: SurveyAppearance;
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
link?: (string | null) | undefined;
|
|
8
|
+
onPreviewSubmit?: (() => void) | undefined;
|
|
9
|
+
skipSubmitButton?: boolean | undefined;
|
|
10
|
+
canGoBack?: boolean | undefined;
|
|
11
|
+
onBack?: (() => void) | undefined;
|
|
12
|
+
}): import("preact").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
BottomSection: ()=>BottomSection
|
|
32
|
+
});
|
|
33
|
+
const jsx_runtime_namespaceObject = require("preact/jsx-runtime");
|
|
34
|
+
const hooks_namespaceObject = require("preact/hooks");
|
|
35
|
+
const external_surveys_extension_utils_js_namespaceObject = require("../surveys-extension-utils.js");
|
|
36
|
+
const external_PostHogLogo_js_namespaceObject = require("./PostHogLogo.js");
|
|
37
|
+
function BottomSection({ text, submitDisabled, appearance, onSubmit, link, onPreviewSubmit, skipSubmitButton, canGoBack, onBack }) {
|
|
38
|
+
const { isPreviewMode } = (0, hooks_namespaceObject.useContext)(external_surveys_extension_utils_js_namespaceObject.SurveyContext);
|
|
39
|
+
const showBackButton = !!canGoBack && !!onBack;
|
|
40
|
+
const submitButton = !skipSubmitButton && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
41
|
+
className: "form-submit",
|
|
42
|
+
disabled: submitDisabled,
|
|
43
|
+
"aria-label": "Submit survey",
|
|
44
|
+
type: "button",
|
|
45
|
+
onClick: ()=>{
|
|
46
|
+
if (link) window?.open(link);
|
|
47
|
+
if (isPreviewMode) onPreviewSubmit?.();
|
|
48
|
+
else onSubmit();
|
|
49
|
+
},
|
|
50
|
+
children: text
|
|
51
|
+
});
|
|
52
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
53
|
+
className: "bottom-section",
|
|
54
|
+
children: [
|
|
55
|
+
showBackButton ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
56
|
+
className: "form-buttons form-buttons-with-back",
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
59
|
+
className: "form-back",
|
|
60
|
+
type: "button",
|
|
61
|
+
"aria-label": "Go to previous question",
|
|
62
|
+
onClick: onBack,
|
|
63
|
+
children: appearance.backButtonText || 'Back'
|
|
64
|
+
}),
|
|
65
|
+
submitButton
|
|
66
|
+
]
|
|
67
|
+
}) : submitButton,
|
|
68
|
+
!appearance.whiteLabel && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PostHogLogo_js_namespaceObject.PostHogLogo, {
|
|
69
|
+
urlParams: {
|
|
70
|
+
utm_source: 'survey-footer'
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.BottomSection = __webpack_exports__.BottomSection;
|
|
77
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
78
|
+
"BottomSection"
|
|
79
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
80
|
+
Object.defineProperty(exports, '__esModule', {
|
|
81
|
+
value: true
|
|
82
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useContext } from "preact/hooks";
|
|
3
|
+
import { SurveyContext } from "../surveys-extension-utils.mjs";
|
|
4
|
+
import { PostHogLogo } from "./PostHogLogo.mjs";
|
|
5
|
+
function BottomSection({ text, submitDisabled, appearance, onSubmit, link, onPreviewSubmit, skipSubmitButton, canGoBack, onBack }) {
|
|
6
|
+
const { isPreviewMode } = useContext(SurveyContext);
|
|
7
|
+
const showBackButton = !!canGoBack && !!onBack;
|
|
8
|
+
const submitButton = !skipSubmitButton && /*#__PURE__*/ jsx("button", {
|
|
9
|
+
className: "form-submit",
|
|
10
|
+
disabled: submitDisabled,
|
|
11
|
+
"aria-label": "Submit survey",
|
|
12
|
+
type: "button",
|
|
13
|
+
onClick: ()=>{
|
|
14
|
+
if (link) window?.open(link);
|
|
15
|
+
if (isPreviewMode) onPreviewSubmit?.();
|
|
16
|
+
else onSubmit();
|
|
17
|
+
},
|
|
18
|
+
children: text
|
|
19
|
+
});
|
|
20
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
21
|
+
className: "bottom-section",
|
|
22
|
+
children: [
|
|
23
|
+
showBackButton ? /*#__PURE__*/ jsxs("div", {
|
|
24
|
+
className: "form-buttons form-buttons-with-back",
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ jsx("button", {
|
|
27
|
+
className: "form-back",
|
|
28
|
+
type: "button",
|
|
29
|
+
"aria-label": "Go to previous question",
|
|
30
|
+
onClick: onBack,
|
|
31
|
+
children: appearance.backButtonText || 'Back'
|
|
32
|
+
}),
|
|
33
|
+
submitButton
|
|
34
|
+
]
|
|
35
|
+
}) : submitButton,
|
|
36
|
+
!appearance.whiteLabel && /*#__PURE__*/ jsx(PostHogLogo, {
|
|
37
|
+
urlParams: {
|
|
38
|
+
utm_source: 'survey-footer'
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { BottomSection };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../types/surveys';
|
|
3
|
+
export declare function ConfirmationMessage({ header, description, contentType, forceDisableHtml, appearance, onClose, }: {
|
|
4
|
+
header: string;
|
|
5
|
+
description: string;
|
|
6
|
+
forceDisableHtml: boolean;
|
|
7
|
+
contentType?: SurveyQuestionDescriptionContentType | undefined;
|
|
8
|
+
appearance: SurveyAppearance;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}): h.JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
ConfirmationMessage: ()=>ConfirmationMessage
|
|
32
|
+
});
|
|
33
|
+
const jsx_runtime_namespaceObject = require("preact/jsx-runtime");
|
|
34
|
+
const external_preact_namespaceObject = require("preact");
|
|
35
|
+
const external_surveys_extension_utils_js_namespaceObject = require("../surveys-extension-utils.js");
|
|
36
|
+
const external_BottomSection_js_namespaceObject = require("./BottomSection.js");
|
|
37
|
+
const external_QuestionHeader_js_namespaceObject = require("./QuestionHeader.js");
|
|
38
|
+
const hooks_namespaceObject = require("preact/hooks");
|
|
39
|
+
const general_utils_js_namespaceObject = require("../../utils/general-utils.js");
|
|
40
|
+
function ConfirmationMessage({ header, description, contentType, forceDisableHtml, appearance, onClose }) {
|
|
41
|
+
const { isPopup } = (0, hooks_namespaceObject.useContext)(external_surveys_extension_utils_js_namespaceObject.SurveyContext);
|
|
42
|
+
(0, hooks_namespaceObject.useEffect)(()=>{
|
|
43
|
+
const handleKeyDown = (event)=>{
|
|
44
|
+
if ('Enter' === event.key || 'Escape' === event.key) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
onClose();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
(0, general_utils_js_namespaceObject.addEventListener)(window, 'keydown', handleKeyDown);
|
|
50
|
+
return ()=>{
|
|
51
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
52
|
+
};
|
|
53
|
+
}, [
|
|
54
|
+
onClose
|
|
55
|
+
]);
|
|
56
|
+
const renderCancelButton = isPopup && true !== appearance.hideCancelButton;
|
|
57
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
58
|
+
className: "thank-you-message",
|
|
59
|
+
role: "status",
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
"aria-atomic": "true",
|
|
62
|
+
children: [
|
|
63
|
+
renderCancelButton && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_QuestionHeader_js_namespaceObject.Cancel, {
|
|
64
|
+
onClick: ()=>onClose()
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h3", {
|
|
67
|
+
className: "thank-you-message-header",
|
|
68
|
+
children: header
|
|
69
|
+
}),
|
|
70
|
+
description && (0, external_surveys_extension_utils_js_namespaceObject.renderChildrenAsTextOrHtml)({
|
|
71
|
+
component: (0, external_preact_namespaceObject.h)('p', {
|
|
72
|
+
className: 'thank-you-message-body'
|
|
73
|
+
}),
|
|
74
|
+
children: description,
|
|
75
|
+
renderAsHtml: !forceDisableHtml && 'text' !== contentType
|
|
76
|
+
}),
|
|
77
|
+
isPopup && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_BottomSection_js_namespaceObject.BottomSection, {
|
|
78
|
+
text: appearance.thankYouMessageCloseButtonText || 'Close',
|
|
79
|
+
submitDisabled: false,
|
|
80
|
+
appearance: appearance,
|
|
81
|
+
onSubmit: ()=>onClose()
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.ConfirmationMessage = __webpack_exports__.ConfirmationMessage;
|
|
87
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"ConfirmationMessage"
|
|
89
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
90
|
+
Object.defineProperty(exports, '__esModule', {
|
|
91
|
+
value: true
|
|
92
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { h } from "preact";
|
|
3
|
+
import { SurveyContext, renderChildrenAsTextOrHtml } from "../surveys-extension-utils.mjs";
|
|
4
|
+
import { BottomSection } from "./BottomSection.mjs";
|
|
5
|
+
import { Cancel } from "./QuestionHeader.mjs";
|
|
6
|
+
import { useContext, useEffect } from "preact/hooks";
|
|
7
|
+
import { addEventListener } from "../../utils/general-utils.mjs";
|
|
8
|
+
function ConfirmationMessage({ header, description, contentType, forceDisableHtml, appearance, onClose }) {
|
|
9
|
+
const { isPopup } = useContext(SurveyContext);
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
const handleKeyDown = (event)=>{
|
|
12
|
+
if ('Enter' === event.key || 'Escape' === event.key) {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
onClose();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
addEventListener(window, 'keydown', handleKeyDown);
|
|
18
|
+
return ()=>{
|
|
19
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
onClose
|
|
23
|
+
]);
|
|
24
|
+
const renderCancelButton = isPopup && true !== appearance.hideCancelButton;
|
|
25
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
26
|
+
className: "thank-you-message",
|
|
27
|
+
role: "status",
|
|
28
|
+
tabIndex: 0,
|
|
29
|
+
"aria-atomic": "true",
|
|
30
|
+
children: [
|
|
31
|
+
renderCancelButton && /*#__PURE__*/ jsx(Cancel, {
|
|
32
|
+
onClick: ()=>onClose()
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ jsx("h3", {
|
|
35
|
+
className: "thank-you-message-header",
|
|
36
|
+
children: header
|
|
37
|
+
}),
|
|
38
|
+
description && renderChildrenAsTextOrHtml({
|
|
39
|
+
component: h('p', {
|
|
40
|
+
className: 'thank-you-message-body'
|
|
41
|
+
}),
|
|
42
|
+
children: description,
|
|
43
|
+
renderAsHtml: !forceDisableHtml && 'text' !== contentType
|
|
44
|
+
}),
|
|
45
|
+
isPopup && /*#__PURE__*/ jsx(BottomSection, {
|
|
46
|
+
text: appearance.thankYouMessageCloseButtonText || 'Close',
|
|
47
|
+
submitDisabled: false,
|
|
48
|
+
appearance: appearance,
|
|
49
|
+
onSubmit: ()=>onClose()
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
export { ConfirmationMessage };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { h } from 'preact';
|
|
2
|
+
import type { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../types/surveys';
|
|
3
|
+
export declare function IntroScreen({ header, description, contentType, forceDisableHtml, appearance, onStart, }: {
|
|
4
|
+
header: string;
|
|
5
|
+
description: string;
|
|
6
|
+
forceDisableHtml: boolean;
|
|
7
|
+
contentType?: SurveyQuestionDescriptionContentType | undefined;
|
|
8
|
+
appearance: SurveyAppearance;
|
|
9
|
+
onStart: () => void;
|
|
10
|
+
}): h.JSX.Element;
|