@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,144 @@
|
|
|
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 SurveyEventType = {
|
|
31
|
+
Activation: 'events',
|
|
32
|
+
Cancellation: 'cancelEvents'
|
|
33
|
+
};
|
|
34
|
+
const SurveyWidgetType = {
|
|
35
|
+
Button: 'button',
|
|
36
|
+
Tab: 'tab',
|
|
37
|
+
Selector: 'selector'
|
|
38
|
+
};
|
|
39
|
+
const SurveyPosition = {
|
|
40
|
+
TopLeft: 'top_left',
|
|
41
|
+
TopRight: 'top_right',
|
|
42
|
+
TopCenter: 'top_center',
|
|
43
|
+
MiddleLeft: 'middle_left',
|
|
44
|
+
MiddleRight: 'middle_right',
|
|
45
|
+
MiddleCenter: 'middle_center',
|
|
46
|
+
Left: 'left',
|
|
47
|
+
Center: 'center',
|
|
48
|
+
Right: 'right',
|
|
49
|
+
NextToTrigger: 'next_to_trigger'
|
|
50
|
+
};
|
|
51
|
+
const SurveyTabPosition = {
|
|
52
|
+
Top: 'top',
|
|
53
|
+
Left: 'left',
|
|
54
|
+
Right: 'right',
|
|
55
|
+
Bottom: 'bottom'
|
|
56
|
+
};
|
|
57
|
+
const SurveyType = {
|
|
58
|
+
Popover: 'popover',
|
|
59
|
+
API: 'api',
|
|
60
|
+
Widget: 'widget',
|
|
61
|
+
ExternalSurvey: 'external_survey'
|
|
62
|
+
};
|
|
63
|
+
const SurveyQuestionType = {
|
|
64
|
+
Open: 'open',
|
|
65
|
+
MultipleChoice: 'multiple_choice',
|
|
66
|
+
SingleChoice: 'single_choice',
|
|
67
|
+
Rating: 'rating',
|
|
68
|
+
Link: 'link'
|
|
69
|
+
};
|
|
70
|
+
const SurveyQuestionBranchingType = {
|
|
71
|
+
NextQuestion: 'next_question',
|
|
72
|
+
End: 'end',
|
|
73
|
+
ResponseBased: 'response_based',
|
|
74
|
+
SpecificQuestion: 'specific_question'
|
|
75
|
+
};
|
|
76
|
+
const SurveySchedule = {
|
|
77
|
+
Once: 'once',
|
|
78
|
+
Recurring: 'recurring',
|
|
79
|
+
Always: 'always'
|
|
80
|
+
};
|
|
81
|
+
const SurveyEventName = {
|
|
82
|
+
SHOWN: 'survey shown',
|
|
83
|
+
DISMISSED: 'survey dismissed',
|
|
84
|
+
SENT: 'survey sent',
|
|
85
|
+
ABANDONED: 'survey abandoned'
|
|
86
|
+
};
|
|
87
|
+
const SurveyEventProperties = {
|
|
88
|
+
SURVEY_ID: '$survey_id',
|
|
89
|
+
SURVEY_NAME: '$survey_name',
|
|
90
|
+
SURVEY_RESPONSE: '$survey_response',
|
|
91
|
+
SURVEY_ITERATION: '$survey_iteration',
|
|
92
|
+
SURVEY_ITERATION_START_DATE: '$survey_iteration_start_date',
|
|
93
|
+
SURVEY_PARTIALLY_COMPLETED: '$survey_partially_completed',
|
|
94
|
+
SURVEY_SUBMISSION_ID: '$survey_submission_id',
|
|
95
|
+
SURVEY_QUESTIONS: '$survey_questions',
|
|
96
|
+
SURVEY_COMPLETED: '$survey_completed',
|
|
97
|
+
PRODUCT_TOUR_ID: '$product_tour_id',
|
|
98
|
+
SURVEY_LAST_SEEN_DATE: '$survey_last_seen_date',
|
|
99
|
+
SURVEY_LANGUAGE: '$survey_language'
|
|
100
|
+
};
|
|
101
|
+
const DisplaySurveyType = {
|
|
102
|
+
Popover: 'popover',
|
|
103
|
+
Inline: 'inline'
|
|
104
|
+
};
|
|
105
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
106
|
+
DisplaySurveyType: DisplaySurveyType,
|
|
107
|
+
SurveyEventName: SurveyEventName,
|
|
108
|
+
SurveyEventProperties: SurveyEventProperties,
|
|
109
|
+
SurveyEventType: SurveyEventType,
|
|
110
|
+
SurveyPosition: SurveyPosition,
|
|
111
|
+
SurveyQuestionBranchingType: SurveyQuestionBranchingType,
|
|
112
|
+
SurveyQuestionType: SurveyQuestionType,
|
|
113
|
+
SurveySchedule: SurveySchedule,
|
|
114
|
+
SurveyTabPosition: SurveyTabPosition,
|
|
115
|
+
SurveyType: SurveyType,
|
|
116
|
+
SurveyWidgetType: SurveyWidgetType
|
|
117
|
+
});
|
|
118
|
+
exports.DisplaySurveyType = __webpack_exports__.DisplaySurveyType;
|
|
119
|
+
exports.SurveyEventName = __webpack_exports__.SurveyEventName;
|
|
120
|
+
exports.SurveyEventProperties = __webpack_exports__.SurveyEventProperties;
|
|
121
|
+
exports.SurveyEventType = __webpack_exports__.SurveyEventType;
|
|
122
|
+
exports.SurveyPosition = __webpack_exports__.SurveyPosition;
|
|
123
|
+
exports.SurveyQuestionBranchingType = __webpack_exports__.SurveyQuestionBranchingType;
|
|
124
|
+
exports.SurveyQuestionType = __webpack_exports__.SurveyQuestionType;
|
|
125
|
+
exports.SurveySchedule = __webpack_exports__.SurveySchedule;
|
|
126
|
+
exports.SurveyTabPosition = __webpack_exports__.SurveyTabPosition;
|
|
127
|
+
exports.SurveyType = __webpack_exports__.SurveyType;
|
|
128
|
+
exports.SurveyWidgetType = __webpack_exports__.SurveyWidgetType;
|
|
129
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
130
|
+
"DisplaySurveyType",
|
|
131
|
+
"SurveyEventName",
|
|
132
|
+
"SurveyEventProperties",
|
|
133
|
+
"SurveyEventType",
|
|
134
|
+
"SurveyPosition",
|
|
135
|
+
"SurveyQuestionBranchingType",
|
|
136
|
+
"SurveyQuestionType",
|
|
137
|
+
"SurveySchedule",
|
|
138
|
+
"SurveyTabPosition",
|
|
139
|
+
"SurveyType",
|
|
140
|
+
"SurveyWidgetType"
|
|
141
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
142
|
+
Object.defineProperty(exports, '__esModule', {
|
|
143
|
+
value: true
|
|
144
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const SurveyEventType = {
|
|
2
|
+
Activation: 'events',
|
|
3
|
+
Cancellation: 'cancelEvents'
|
|
4
|
+
};
|
|
5
|
+
const SurveyWidgetType = {
|
|
6
|
+
Button: 'button',
|
|
7
|
+
Tab: 'tab',
|
|
8
|
+
Selector: 'selector'
|
|
9
|
+
};
|
|
10
|
+
const SurveyPosition = {
|
|
11
|
+
TopLeft: 'top_left',
|
|
12
|
+
TopRight: 'top_right',
|
|
13
|
+
TopCenter: 'top_center',
|
|
14
|
+
MiddleLeft: 'middle_left',
|
|
15
|
+
MiddleRight: 'middle_right',
|
|
16
|
+
MiddleCenter: 'middle_center',
|
|
17
|
+
Left: 'left',
|
|
18
|
+
Center: 'center',
|
|
19
|
+
Right: 'right',
|
|
20
|
+
NextToTrigger: 'next_to_trigger'
|
|
21
|
+
};
|
|
22
|
+
const SurveyTabPosition = {
|
|
23
|
+
Top: 'top',
|
|
24
|
+
Left: 'left',
|
|
25
|
+
Right: 'right',
|
|
26
|
+
Bottom: 'bottom'
|
|
27
|
+
};
|
|
28
|
+
const SurveyType = {
|
|
29
|
+
Popover: 'popover',
|
|
30
|
+
API: 'api',
|
|
31
|
+
Widget: 'widget',
|
|
32
|
+
ExternalSurvey: 'external_survey'
|
|
33
|
+
};
|
|
34
|
+
const SurveyQuestionType = {
|
|
35
|
+
Open: 'open',
|
|
36
|
+
MultipleChoice: 'multiple_choice',
|
|
37
|
+
SingleChoice: 'single_choice',
|
|
38
|
+
Rating: 'rating',
|
|
39
|
+
Link: 'link'
|
|
40
|
+
};
|
|
41
|
+
const SurveyQuestionBranchingType = {
|
|
42
|
+
NextQuestion: 'next_question',
|
|
43
|
+
End: 'end',
|
|
44
|
+
ResponseBased: 'response_based',
|
|
45
|
+
SpecificQuestion: 'specific_question'
|
|
46
|
+
};
|
|
47
|
+
const SurveySchedule = {
|
|
48
|
+
Once: 'once',
|
|
49
|
+
Recurring: 'recurring',
|
|
50
|
+
Always: 'always'
|
|
51
|
+
};
|
|
52
|
+
const SurveyEventName = {
|
|
53
|
+
SHOWN: 'survey shown',
|
|
54
|
+
DISMISSED: 'survey dismissed',
|
|
55
|
+
SENT: 'survey sent',
|
|
56
|
+
ABANDONED: 'survey abandoned'
|
|
57
|
+
};
|
|
58
|
+
const SurveyEventProperties = {
|
|
59
|
+
SURVEY_ID: '$survey_id',
|
|
60
|
+
SURVEY_NAME: '$survey_name',
|
|
61
|
+
SURVEY_RESPONSE: '$survey_response',
|
|
62
|
+
SURVEY_ITERATION: '$survey_iteration',
|
|
63
|
+
SURVEY_ITERATION_START_DATE: '$survey_iteration_start_date',
|
|
64
|
+
SURVEY_PARTIALLY_COMPLETED: '$survey_partially_completed',
|
|
65
|
+
SURVEY_SUBMISSION_ID: '$survey_submission_id',
|
|
66
|
+
SURVEY_QUESTIONS: '$survey_questions',
|
|
67
|
+
SURVEY_COMPLETED: '$survey_completed',
|
|
68
|
+
PRODUCT_TOUR_ID: '$product_tour_id',
|
|
69
|
+
SURVEY_LAST_SEEN_DATE: '$survey_last_seen_date',
|
|
70
|
+
SURVEY_LANGUAGE: '$survey_language'
|
|
71
|
+
};
|
|
72
|
+
const DisplaySurveyType = {
|
|
73
|
+
Popover: 'popover',
|
|
74
|
+
Inline: 'inline'
|
|
75
|
+
};
|
|
76
|
+
export { DisplaySurveyType, SurveyEventName, SurveyEventProperties, SurveyEventType, SurveyPosition, SurveyQuestionBranchingType, SurveyQuestionType, SurveySchedule, SurveyTabPosition, SurveyType, SurveyWidgetType };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Properties } from '@posthog/types';
|
|
2
|
+
export interface SurveyCapturedEvent {
|
|
3
|
+
event: string;
|
|
4
|
+
properties: Properties;
|
|
5
|
+
}
|
|
6
|
+
/** Event observation and selector registration used by survey and tour triggers. */
|
|
7
|
+
export interface SurveyActionHost {
|
|
8
|
+
subscribeCapture?: ((listener: (event: string, payload?: SurveyCapturedEvent) => void) => () => void) | undefined;
|
|
9
|
+
setElementSelectors?: ((selectors: Set<string>, owner?: object) => void) | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface SurveyEventHost extends SurveyActionHost {
|
|
12
|
+
subscribeSession?: ((listener: (sessionId: string) => void) => () => void) | undefined;
|
|
13
|
+
getSessionId(): string | undefined;
|
|
14
|
+
getProperty<T = unknown>(key: string): T | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { SurveyActionType, SurveyEventWithFilters } from './types/surveys';
|
|
2
|
+
import { ActionMatcher } from './survey-action-matcher';
|
|
3
|
+
import type { SurveyEventHost, SurveyCapturedEvent as CaptureResult } from './survey-event-host';
|
|
4
|
+
import { createLogger } from './utils/logger';
|
|
5
|
+
/**
|
|
6
|
+
* Interface for items that can be triggered by events/actions.
|
|
7
|
+
* Both Survey and ProductTour implement this interface.
|
|
8
|
+
*/
|
|
9
|
+
export interface EventTriggerable {
|
|
10
|
+
id: string;
|
|
11
|
+
conditions?: {
|
|
12
|
+
events?: {
|
|
13
|
+
repeatedActivation?: boolean;
|
|
14
|
+
values: SurveyEventWithFilters[];
|
|
15
|
+
} | null;
|
|
16
|
+
cancelEvents?: {
|
|
17
|
+
values: SurveyEventWithFilters[];
|
|
18
|
+
} | null;
|
|
19
|
+
actions?: {
|
|
20
|
+
values: SurveyActionType[];
|
|
21
|
+
} | null;
|
|
22
|
+
} | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What a captured lifecycle event (shown / dismissed / sent) does to an already-activated item:
|
|
26
|
+
* - `consume`: it's done — drop it from both the in-memory and persisted sets.
|
|
27
|
+
* - `persist`: it was shown and should survive a reload — move it from memory into persistence.
|
|
28
|
+
* - `ignore`: no transition for this item on this event.
|
|
29
|
+
*/
|
|
30
|
+
export type ActivationOutcome = 'consume' | 'persist' | 'ignore';
|
|
31
|
+
/**
|
|
32
|
+
* Abstract base class for receiving events and matching them to triggerable items.
|
|
33
|
+
* Subclasses implement type-specific behavior for surveys and product tours.
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class EventReceiver<T extends EventTriggerable> {
|
|
36
|
+
private readonly _onActivationChanged?;
|
|
37
|
+
protected _eventToItems: Map<string, string[]>;
|
|
38
|
+
protected _cancelEventToItems: Map<string, string[]>;
|
|
39
|
+
protected readonly _actionToItems: Map<string, string[]>;
|
|
40
|
+
protected _actionMatcher: ActionMatcher | null | undefined;
|
|
41
|
+
protected readonly _host: SurveyEventHost;
|
|
42
|
+
/**
|
|
43
|
+
* Items armed by an event or action but not yet shown live here, in memory only.
|
|
44
|
+
* They are intentionally NOT persisted, so they do not survive a page reload: an
|
|
45
|
+
* event trigger only displays an item in the session the event fired in. Once an
|
|
46
|
+
* item is shown, surviving items are promoted into persistence (see `onEvent`) so
|
|
47
|
+
* a reload re-reads and re-displays them until the user interacts — but that
|
|
48
|
+
* persisted activation is scoped to the triggering session (see
|
|
49
|
+
* `_getPersistedActivatedIds`), so it does not leak into a brand-new session where
|
|
50
|
+
* the trigger never fired.
|
|
51
|
+
*/
|
|
52
|
+
private _pendingActivatedItems;
|
|
53
|
+
private _captureHookUnsubscribe;
|
|
54
|
+
private _sessionIdUnsubscribe;
|
|
55
|
+
constructor(host: SurveyEventHost, _onActivationChanged?: (() => void) | undefined);
|
|
56
|
+
/** Start after subclass dependencies are initialized; hosts may publish synchronously. */
|
|
57
|
+
protected _subscribeSession(): void;
|
|
58
|
+
protected abstract _getActivatedKey(): string;
|
|
59
|
+
/** Persistence key under which the session id of the persisted activation set is stamped. */
|
|
60
|
+
protected abstract _getActivatedSessionKey(): string;
|
|
61
|
+
protected abstract _getShownEventName(): string;
|
|
62
|
+
protected abstract _getItems(callback: (items: T[]) => void): void;
|
|
63
|
+
protected abstract _cancelPendingItem(itemId: string): void;
|
|
64
|
+
protected abstract _getLogger(): ReturnType<typeof createLogger>;
|
|
65
|
+
protected abstract _setActivatedItems(eligibleItems: string[]): void;
|
|
66
|
+
/** Persist the session id the current activation set belongs to. */
|
|
67
|
+
protected abstract _setActivatedSession(sessionId: string): void;
|
|
68
|
+
/** Forget the persisted session stamp. */
|
|
69
|
+
protected abstract _clearActivatedSession(): void;
|
|
70
|
+
/** Check if item is permanently ineligible (e.g. completed/dismissed). Skip adding to activated list. */
|
|
71
|
+
protected abstract _isItemPermanentlyIneligible(itemId?: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Decide what a captured lifecycle `event` does to an already-activated `itemId`. Most items are
|
|
74
|
+
* consumed when shown (so they only reappear when their trigger fires again). Surveys keep
|
|
75
|
+
* non-repeatable ones activated — promoting them to session-scoped persistence on shown — until the
|
|
76
|
+
* user dismisses or answers them, so an event-triggered survey survives a reload within the
|
|
77
|
+
* triggering session (but not a brand-new session) until it's actually interacted with.
|
|
78
|
+
*/
|
|
79
|
+
protected abstract _activationOutcome(event: string, itemId: string, eventPayload?: CaptureResult): ActivationOutcome;
|
|
80
|
+
/**
|
|
81
|
+
* Whether an item armed by a trigger should be persisted immediately (session-scoped)
|
|
82
|
+
* instead of kept in memory until it is shown. Overridden by receivers whose items carry a
|
|
83
|
+
* display delay that must survive a navigation, so the delay can resume from where it left
|
|
84
|
+
* off on the next page. Default: keep in memory, so the arming is page-scoped and an
|
|
85
|
+
* exit-intent-style trigger cannot leak an armed item onto a later page load.
|
|
86
|
+
*/
|
|
87
|
+
protected _shouldPersistArmedActivation(_itemId: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Persistence key under which per-item activation timestamps are read from, or null for
|
|
90
|
+
* receivers that don't track them. Used to resume a display delay across navigations. Writes
|
|
91
|
+
* go through `_writeActivationTimestamps` / `_clearActivationTimestampsStore` so the register
|
|
92
|
+
* sink always resolves to a literal key constant.
|
|
93
|
+
*/
|
|
94
|
+
protected _getActivationTimestampsKey(): string | null;
|
|
95
|
+
/** Persist the activation timestamp map. Overridden by receivers that track timestamps. */
|
|
96
|
+
protected _writeActivationTimestamps(_timestamps: Record<string, number>): void;
|
|
97
|
+
/** Forget the whole activation timestamp map. Overridden by receivers that track timestamps. */
|
|
98
|
+
protected _clearActivationTimestampsStore(): void;
|
|
99
|
+
private _doesEventMatchFilter;
|
|
100
|
+
private _buildEventToItemMap;
|
|
101
|
+
/**
|
|
102
|
+
* build a map of (Event1) => [Item1, Item2, Item3]
|
|
103
|
+
* used for items that should be [activated|cancelled] by Event1
|
|
104
|
+
*/
|
|
105
|
+
private _getMatchingItems;
|
|
106
|
+
register(items: T[]): void;
|
|
107
|
+
replace(items: T[]): void;
|
|
108
|
+
private _register;
|
|
109
|
+
private _setupActionBasedItems;
|
|
110
|
+
private _mergeItemMaps;
|
|
111
|
+
private _setupEventBasedItems;
|
|
112
|
+
onEvent(event: string, eventPayload?: CaptureResult): void;
|
|
113
|
+
onAction(actionName: string): void;
|
|
114
|
+
/**
|
|
115
|
+
* Arm items. Most are held in memory only (not persisted) until they are shown, so their
|
|
116
|
+
* arming is page-scoped. Items that opt in via `_shouldPersistArmedActivation` (those with a
|
|
117
|
+
* display delay) are persisted right away and stamped with the activation time, so the delay
|
|
118
|
+
* survives a navigation and resumes from the elapsed time on the next page.
|
|
119
|
+
*/
|
|
120
|
+
private _activateItems;
|
|
121
|
+
/**
|
|
122
|
+
* Move an in-memory activation into persistence so it survives a page reload within the
|
|
123
|
+
* triggering session. The set is (re)stamped with the current session id; reading it back
|
|
124
|
+
* via `_getPersistedActivatedIds` discards it once the session rolls over. Because we build
|
|
125
|
+
* on top of the session-scoped read, a stale set left over from a previous session is
|
|
126
|
+
* dropped here rather than accumulated.
|
|
127
|
+
*/
|
|
128
|
+
private _persistActivation;
|
|
129
|
+
/** Drop items from both the in-memory and persisted activation sets. */
|
|
130
|
+
private _deactivateItems;
|
|
131
|
+
private _notifyActivationChanged;
|
|
132
|
+
/** The raw persisted activation timestamps as stored, ignoring session scoping. */
|
|
133
|
+
private _getRawActivationTimestamps;
|
|
134
|
+
/**
|
|
135
|
+
* Stamp when an item enters persisted activation, so a resumed display delay can be computed
|
|
136
|
+
* from the elapsed time on a later page load. Repeated triggers do not call this method because
|
|
137
|
+
* `_persistActivation` returns false while the current activation is still live.
|
|
138
|
+
*/
|
|
139
|
+
private _recordActivationTimestamp;
|
|
140
|
+
/** Drop the activation timestamps for the given items. */
|
|
141
|
+
private _clearActivationTimestamps;
|
|
142
|
+
/** Forget all activation timestamps (e.g. on reset or a session rollover). */
|
|
143
|
+
private _clearAllActivationTimestamps;
|
|
144
|
+
/**
|
|
145
|
+
* The time (epoch ms) an item was armed by its trigger, or undefined if none is recorded.
|
|
146
|
+
* Session-scoped: a timestamp is only honored while its activation is still live for the
|
|
147
|
+
* current session, so a stale entry left in persistence cannot resurrect an expired delay.
|
|
148
|
+
*/
|
|
149
|
+
getActivationTimestamp(itemId: string): number | undefined;
|
|
150
|
+
/** The raw persisted set as stored, ignoring session scoping. */
|
|
151
|
+
private _getRawPersistedActivatedIds;
|
|
152
|
+
/**
|
|
153
|
+
* The persisted activations that still belong to the current session. A persisted activation
|
|
154
|
+
* is scoped to the session the item was shown in: an event/action trigger only earns a display
|
|
155
|
+
* in the session it fired in, so once the session rolls over the activation is stale and must
|
|
156
|
+
* not silently re-display the item in a brand-new session where the trigger never fired.
|
|
157
|
+
*/
|
|
158
|
+
private _getPersistedActivatedIds;
|
|
159
|
+
/** Stamp the persisted activation set with the current session id. */
|
|
160
|
+
private _stampActivationSession;
|
|
161
|
+
/** Forget the session stamp once nothing is persisted under it. */
|
|
162
|
+
private _clearActivationSession;
|
|
163
|
+
/**
|
|
164
|
+
* Drop a persisted activation once the session it was stamped under is no longer current.
|
|
165
|
+
* Fired on session rotation (idle timeout, max length, cross-tab adoption) — the cases the
|
|
166
|
+
* read-only session read on the display path cannot observe. Pending timers must also be
|
|
167
|
+
* cancelled so a fresh trigger in the new session starts its full delay from the new timestamp.
|
|
168
|
+
*/
|
|
169
|
+
private _onSessionIdChanged;
|
|
170
|
+
getActivatedIds(): string[];
|
|
171
|
+
/**
|
|
172
|
+
* Clear all activations. Called on `posthog.reset()` so a logout or account switch
|
|
173
|
+
* (without a full page reload) does not leave an event-armed item live for the next
|
|
174
|
+
* user — the in-memory set would otherwise survive `persistence.clear()`.
|
|
175
|
+
*/
|
|
176
|
+
dispose(): void;
|
|
177
|
+
reset(): void;
|
|
178
|
+
getEventToItemsMap(): Map<string, string[]>;
|
|
179
|
+
_getActionMatcher(): ActionMatcher | null | undefined;
|
|
180
|
+
}
|