@posthog/browser-common 0.9.5 → 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.
Files changed (86) hide show
  1. package/dist/client.d.ts +6 -0
  2. package/dist/config.js +1 -1
  3. package/dist/config.mjs +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +58 -10
  6. package/dist/index.mjs +1 -0
  7. package/dist/survey-action-matcher.d.ts +27 -0
  8. package/dist/survey-action-matcher.js +169 -0
  9. package/dist/survey-action-matcher.mjs +131 -0
  10. package/dist/survey-constants.d.ts +86 -0
  11. package/dist/survey-constants.js +144 -0
  12. package/dist/survey-constants.mjs +76 -0
  13. package/dist/survey-event-host.d.ts +15 -0
  14. package/dist/survey-event-host.js +18 -0
  15. package/dist/survey-event-host.mjs +1 -0
  16. package/dist/survey-event-receiver-base.d.ts +180 -0
  17. package/dist/survey-event-receiver-base.js +354 -0
  18. package/dist/survey-event-receiver-base.mjs +316 -0
  19. package/dist/survey-event-receiver.d.ts +36 -0
  20. package/dist/survey-event-receiver.js +133 -0
  21. package/dist/survey-event-receiver.mjs +95 -0
  22. package/dist/survey-render-context.d.ts +13 -0
  23. package/dist/survey-render-context.js +45 -0
  24. package/dist/survey-render-context.mjs +7 -0
  25. package/dist/surveys/components/BottomSection.d.ts +12 -0
  26. package/dist/surveys/components/BottomSection.js +82 -0
  27. package/dist/surveys/components/BottomSection.mjs +44 -0
  28. package/dist/surveys/components/ConfirmationMessage.d.ts +10 -0
  29. package/dist/surveys/components/ConfirmationMessage.js +92 -0
  30. package/dist/surveys/components/ConfirmationMessage.mjs +54 -0
  31. package/dist/surveys/components/IntroScreen.d.ts +10 -0
  32. package/dist/surveys/components/IntroScreen.js +78 -0
  33. package/dist/surveys/components/IntroScreen.mjs +40 -0
  34. package/dist/surveys/components/PostHogLogo.d.ts +5 -0
  35. package/dist/surveys/components/PostHogLogo.js +54 -0
  36. package/dist/surveys/components/PostHogLogo.mjs +16 -0
  37. package/dist/surveys/components/QuestionHeader.d.ts +10 -0
  38. package/dist/surveys/components/QuestionHeader.js +82 -0
  39. package/dist/surveys/components/QuestionHeader.mjs +41 -0
  40. package/dist/surveys/components/QuestionTypes.d.ts +31 -0
  41. package/dist/surveys/components/QuestionTypes.js +519 -0
  42. package/dist/surveys/components/QuestionTypes.mjs +469 -0
  43. package/dist/surveys/icons.d.ts +12 -0
  44. package/dist/surveys/icons.js +212 -0
  45. package/dist/surveys/icons.mjs +147 -0
  46. package/dist/surveys/survey-branching.d.ts +12 -0
  47. package/dist/surveys/survey-branching.js +101 -0
  48. package/dist/surveys/survey-branching.mjs +60 -0
  49. package/dist/surveys/survey-styles.d.ts +1 -0
  50. package/dist/surveys/survey-styles.js +40 -0
  51. package/dist/surveys/survey-styles.mjs +2 -0
  52. package/dist/surveys/survey-translations.d.ts +22 -0
  53. package/dist/surveys/survey-translations.js +68 -0
  54. package/dist/surveys/survey-translations.mjs +27 -0
  55. package/dist/surveys/survey-url-prefill.d.ts +36 -0
  56. package/dist/surveys/survey-url-prefill.js +162 -0
  57. package/dist/surveys/survey-url-prefill.mjs +118 -0
  58. package/dist/surveys/surveys-extension-utils.d.ts +133 -0
  59. package/dist/surveys/surveys-extension-utils.js +739 -0
  60. package/dist/surveys/surveys-extension-utils.mjs +608 -0
  61. package/dist/surveys-config.d.ts +60 -0
  62. package/dist/surveys-config.js +68 -0
  63. package/dist/surveys-config.mjs +9 -0
  64. package/dist/surveys-renderer.d.ts +248 -0
  65. package/dist/surveys-renderer.js +1299 -0
  66. package/dist/surveys-renderer.mjs +1230 -0
  67. package/dist/surveys.d.ts +117 -0
  68. package/dist/surveys.js +566 -0
  69. package/dist/surveys.mjs +495 -0
  70. package/dist/types/surveys.d.ts +83 -86
  71. package/dist/types/surveys.js +1 -127
  72. package/dist/types/surveys.mjs +1 -76
  73. package/dist/utils/autocapture-utils.js +8 -9
  74. package/dist/utils/autocapture-utils.mjs +8 -9
  75. package/dist/utils/matcher-utils.d.ts +1 -1
  76. package/dist/utils/matcher-utils.js +13 -10
  77. package/dist/utils/matcher-utils.mjs +10 -7
  78. package/dist/utils/survey-utils.d.ts +16 -0
  79. package/dist/utils/survey-utils.js +121 -0
  80. package/dist/utils/survey-utils.mjs +38 -0
  81. package/dist/utils/url-targeting-utils.d.ts +3 -1
  82. package/dist/utils/url-targeting-utils.js +1 -2
  83. package/dist/utils/url-targeting-utils.mjs +1 -2
  84. package/dist/utils/uuidv7.js +4 -4
  85. package/dist/utils/uuidv7.mjs +4 -4
  86. package/package.json +96 -2
@@ -1,20 +1,5 @@
1
1
  "use strict";
2
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
3
  (()=>{
19
4
  __webpack_require__.r = (exports1)=>{
20
5
  if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
@@ -27,118 +12,7 @@ var __webpack_require__ = {};
27
12
  })();
28
13
  var __webpack_exports__ = {};
29
14
  __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];
15
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
142
16
  Object.defineProperty(exports, '__esModule', {
143
17
  value: true
144
18
  });
@@ -1,76 +1 @@
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 };
1
+ export { };
@@ -55,7 +55,6 @@ __webpack_require__.d(__webpack_exports__, {
55
55
  const external_general_utils_js_namespaceObject = require("./general-utils.js");
56
56
  const core_namespaceObject = require("@posthog/core");
57
57
  const external_logger_js_namespaceObject = require("./logger.js");
58
- const external_globals_js_namespaceObject = require("./globals.js");
59
58
  const external_url_targeting_utils_js_namespaceObject = require("./url-targeting-utils.js");
60
59
  const external_element_utils_js_namespaceObject = require("./element-utils.js");
61
60
  const MAX_DOM_ANCESTOR_DEPTH = 1000;
@@ -195,7 +194,7 @@ function clickedControlText(el, targetElementList) {
195
194
  for (const candidate of targetElementList)if (isInteractiveElement(candidate)) return controlLabelText(candidate);
196
195
  for (const candidate of targetElementList){
197
196
  try {
198
- if (external_globals_js_namespaceObject.window?.getComputedStyle(candidate).getPropertyValue('cursor') !== 'pointer') break;
197
+ if (window?.getComputedStyle(candidate).getPropertyValue('cursor') !== 'pointer') break;
199
198
  } catch {
200
199
  break;
201
200
  }
@@ -228,7 +227,7 @@ const DEFAULT_DEAD_CLICK_IGNORE_LIST = [
228
227
  '.ph-no-capture'
229
228
  ];
230
229
  function shouldCaptureDeadClick(el, _config) {
231
- if (!external_globals_js_namespaceObject.window || cannotCheckForAutocapture(el)) return false;
230
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
232
231
  const selectorIgnoreList = (0, core_namespaceObject.isBoolean)(_config) ? DEFAULT_DEAD_CLICK_IGNORE_LIST : _config?.css_selector_ignorelist ?? DEFAULT_DEAD_CLICK_IGNORE_LIST;
233
232
  const { targetElementList } = getElementAndParentsForElement(el, false);
234
233
  return !checkIfElementsMatchCSSSelector(targetElementList, selectorIgnoreList);
@@ -259,7 +258,7 @@ function isTextSelectionTarget(el) {
259
258
  return isContentEditableTarget(el);
260
259
  }
261
260
  function shouldCaptureRageclick(el, _config) {
262
- if (!external_globals_js_namespaceObject.window || cannotCheckForAutocapture(el)) return false;
261
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
263
262
  let selectorIgnoreList;
264
263
  let contentIgnorelist;
265
264
  let ignoreTextSelection;
@@ -280,7 +279,7 @@ function shouldCaptureRageclick(el, _config) {
280
279
  }
281
280
  const cannotCheckForAutocapture = (el)=>!el || (0, external_element_utils_js_namespaceObject.isTag)(el, 'html') || !(0, external_element_utils_js_namespaceObject.isElementNode)(el);
282
281
  const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
283
- if (!external_globals_js_namespaceObject.window || cannotCheckForAutocapture(el)) return {
282
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return {
284
283
  parentIsUsefulElement: false,
285
284
  targetElementList: []
286
285
  };
@@ -299,7 +298,7 @@ const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
299
298
  if (!parentNode) break;
300
299
  if (captureOnAnyElement || autocaptureCompatibleElements.indexOf(parentNode.tagName.toLowerCase()) > -1) parentIsUsefulElement = true;
301
300
  else try {
302
- const compStyles = external_globals_js_namespaceObject.window.getComputedStyle(parentNode);
301
+ const compStyles = window.getComputedStyle(parentNode);
303
302
  if (compStyles && 'pointer' === compStyles.getPropertyValue('cursor')) parentIsUsefulElement = true;
304
303
  } catch {}
305
304
  targetElementList.push(parentNode);
@@ -311,12 +310,12 @@ const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
311
310
  };
312
311
  };
313
312
  function shouldSkipDeadClick(el) {
314
- if (!external_globals_js_namespaceObject.window || cannotCheckForAutocapture(el)) return false;
313
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
315
314
  const { targetElementList } = getElementAndParentsForElement(el, false);
316
315
  return targetElementList.some((node)=>(0, external_element_utils_js_namespaceObject.isTag)(node, 'a'));
317
316
  }
318
317
  function shouldCaptureDomEvent(el, event, autocaptureConfig, captureOnAnyElement, allowedEventTypes, instance) {
319
- if (!external_globals_js_namespaceObject.window || cannotCheckForAutocapture(el)) return false;
318
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
320
319
  if (autocaptureConfig?.url_allowlist) {
321
320
  if (!checkForURLMatches(autocaptureConfig.url_allowlist, instance)) return false;
322
321
  }
@@ -333,7 +332,7 @@ function shouldCaptureDomEvent(el, event, autocaptureConfig, captureOnAnyElement
333
332
  const selectorIgnoreList = autocaptureConfig?.css_selector_ignorelist ?? DEFAULT_AUTOCAPTURE_IGNORE_LIST;
334
333
  if (checkIfElementsMatchCSSSelector(targetElementList, selectorIgnoreList)) return false;
335
334
  try {
336
- const compStyles = external_globals_js_namespaceObject.window.getComputedStyle(el);
335
+ const compStyles = window.getComputedStyle(el);
337
336
  if (compStyles && 'pointer' === compStyles.getPropertyValue('cursor') && 'click' === event.type) return true;
338
337
  } catch {}
339
338
  const tag = el.tagName.toLowerCase();
@@ -1,7 +1,6 @@
1
1
  import { each, entries } from "./general-utils.mjs";
2
2
  import { includes, isArray, isBoolean, isNullish, isString, isUndefined, trim } from "@posthog/core";
3
3
  import { logger } from "./logger.mjs";
4
- import { window as external_globals_mjs_window } from "./globals.mjs";
5
4
  import { getTargetingUrl } from "./url-targeting-utils.mjs";
6
5
  import { isElementNode, isShadowRoot, isTag, isTextNode } from "./element-utils.mjs";
7
6
  const MAX_DOM_ANCESTOR_DEPTH = 1000;
@@ -141,7 +140,7 @@ function clickedControlText(el, targetElementList) {
141
140
  for (const candidate of targetElementList)if (isInteractiveElement(candidate)) return controlLabelText(candidate);
142
141
  for (const candidate of targetElementList){
143
142
  try {
144
- if (external_globals_mjs_window?.getComputedStyle(candidate).getPropertyValue('cursor') !== 'pointer') break;
143
+ if (window?.getComputedStyle(candidate).getPropertyValue('cursor') !== 'pointer') break;
145
144
  } catch {
146
145
  break;
147
146
  }
@@ -174,7 +173,7 @@ const DEFAULT_DEAD_CLICK_IGNORE_LIST = [
174
173
  '.ph-no-capture'
175
174
  ];
176
175
  function shouldCaptureDeadClick(el, _config) {
177
- if (!external_globals_mjs_window || cannotCheckForAutocapture(el)) return false;
176
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
178
177
  const selectorIgnoreList = isBoolean(_config) ? DEFAULT_DEAD_CLICK_IGNORE_LIST : _config?.css_selector_ignorelist ?? DEFAULT_DEAD_CLICK_IGNORE_LIST;
179
178
  const { targetElementList } = getElementAndParentsForElement(el, false);
180
179
  return !checkIfElementsMatchCSSSelector(targetElementList, selectorIgnoreList);
@@ -205,7 +204,7 @@ function isTextSelectionTarget(el) {
205
204
  return isContentEditableTarget(el);
206
205
  }
207
206
  function shouldCaptureRageclick(el, _config) {
208
- if (!external_globals_mjs_window || cannotCheckForAutocapture(el)) return false;
207
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
209
208
  let selectorIgnoreList;
210
209
  let contentIgnorelist;
211
210
  let ignoreTextSelection;
@@ -226,7 +225,7 @@ function shouldCaptureRageclick(el, _config) {
226
225
  }
227
226
  const cannotCheckForAutocapture = (el)=>!el || isTag(el, 'html') || !isElementNode(el);
228
227
  const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
229
- if (!external_globals_mjs_window || cannotCheckForAutocapture(el)) return {
228
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return {
230
229
  parentIsUsefulElement: false,
231
230
  targetElementList: []
232
231
  };
@@ -245,7 +244,7 @@ const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
245
244
  if (!parentNode) break;
246
245
  if (captureOnAnyElement || autocaptureCompatibleElements.indexOf(parentNode.tagName.toLowerCase()) > -1) parentIsUsefulElement = true;
247
246
  else try {
248
- const compStyles = external_globals_mjs_window.getComputedStyle(parentNode);
247
+ const compStyles = window.getComputedStyle(parentNode);
249
248
  if (compStyles && 'pointer' === compStyles.getPropertyValue('cursor')) parentIsUsefulElement = true;
250
249
  } catch {}
251
250
  targetElementList.push(parentNode);
@@ -257,12 +256,12 @@ const getElementAndParentsForElement = (el, captureOnAnyElement)=>{
257
256
  };
258
257
  };
259
258
  function shouldSkipDeadClick(el) {
260
- if (!external_globals_mjs_window || cannotCheckForAutocapture(el)) return false;
259
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
261
260
  const { targetElementList } = getElementAndParentsForElement(el, false);
262
261
  return targetElementList.some((node)=>isTag(node, 'a'));
263
262
  }
264
263
  function shouldCaptureDomEvent(el, event, autocaptureConfig, captureOnAnyElement, allowedEventTypes, instance) {
265
- if (!external_globals_mjs_window || cannotCheckForAutocapture(el)) return false;
264
+ if ("u" < typeof window || cannotCheckForAutocapture(el)) return false;
266
265
  if (autocaptureConfig?.url_allowlist) {
267
266
  if (!checkForURLMatches(autocaptureConfig.url_allowlist, instance)) return false;
268
267
  }
@@ -279,7 +278,7 @@ function shouldCaptureDomEvent(el, event, autocaptureConfig, captureOnAnyElement
279
278
  const selectorIgnoreList = autocaptureConfig?.css_selector_ignorelist ?? DEFAULT_AUTOCAPTURE_IGNORE_LIST;
280
279
  if (checkIfElementsMatchCSSSelector(targetElementList, selectorIgnoreList)) return false;
281
280
  try {
282
- const compStyles = external_globals_mjs_window.getComputedStyle(el);
281
+ const compStyles = window.getComputedStyle(el);
283
282
  if (compStyles && 'pointer' === compStyles.getPropertyValue('cursor') && 'click' === event.type) return true;
284
283
  } catch {}
285
284
  const tag = el.tagName.toLowerCase();
@@ -1,3 +1,3 @@
1
- import { type PropertyMatchType } from './property-utils';
1
+ import type { PropertyMatchType } from '@posthog/core';
2
2
  export declare function doesDeviceTypeMatch(deviceTypes?: string[], matchType?: PropertyMatchType): boolean;
3
3
  export declare function hasPeriodPassed(periodDays?: number, lastSeenDate?: string | Date | null): boolean;
@@ -32,19 +32,22 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  hasPeriodPassed: ()=>hasPeriodPassed
33
33
  });
34
34
  const core_namespaceObject = require("@posthog/core");
35
- const external_globals_js_namespaceObject = require("./globals.js");
36
- const external_property_utils_js_namespaceObject = require("./property-utils.js");
35
+ const surveys_namespaceObject = require("@posthog/core/surveys");
37
36
  function doesDeviceTypeMatch(deviceTypes, matchType) {
38
37
  if (!deviceTypes || 0 === deviceTypes.length) return true;
39
- if (!external_globals_js_namespaceObject.userAgent) return false;
40
- const deviceType = (0, core_namespaceObject.detectDeviceType)(external_globals_js_namespaceObject.userAgent, {
41
- userAgentDataPlatform: external_globals_js_namespaceObject.navigator?.userAgentData?.platform,
42
- maxTouchPoints: external_globals_js_namespaceObject.navigator?.maxTouchPoints,
43
- screenWidth: external_globals_js_namespaceObject.window?.screen?.width,
44
- screenHeight: external_globals_js_namespaceObject.window?.screen?.height,
45
- devicePixelRatio: external_globals_js_namespaceObject.window?.devicePixelRatio
38
+ const win = "u" > typeof window ? window : void 0;
39
+ const global = "u" > typeof globalThis ? globalThis : win;
40
+ const navigator = global?.navigator;
41
+ const userAgent = navigator?.userAgent;
42
+ if (!userAgent) return false;
43
+ const deviceType = (0, core_namespaceObject.detectDeviceType)(userAgent, {
44
+ userAgentDataPlatform: navigator?.userAgentData?.platform,
45
+ maxTouchPoints: navigator?.maxTouchPoints,
46
+ screenWidth: win?.screen?.width,
47
+ screenHeight: win?.screen?.height,
48
+ devicePixelRatio: win?.devicePixelRatio
46
49
  });
47
- return external_property_utils_js_namespaceObject.propertyComparisons[matchType ?? 'icontains'](deviceTypes, [
50
+ return surveys_namespaceObject.propertyComparisons[matchType ?? 'icontains'](deviceTypes, [
48
51
  deviceType
49
52
  ]);
50
53
  }
@@ -1,15 +1,18 @@
1
1
  import { detectDeviceType } from "@posthog/core";
2
- import { navigator as external_globals_mjs_navigator, userAgent, window as external_globals_mjs_window } from "./globals.mjs";
3
- import { propertyComparisons } from "./property-utils.mjs";
2
+ import { propertyComparisons } from "@posthog/core/surveys";
4
3
  function doesDeviceTypeMatch(deviceTypes, matchType) {
5
4
  if (!deviceTypes || 0 === deviceTypes.length) return true;
5
+ const win = "u" > typeof window ? window : void 0;
6
+ const global = "u" > typeof globalThis ? globalThis : win;
7
+ const navigator = global?.navigator;
8
+ const userAgent = navigator?.userAgent;
6
9
  if (!userAgent) return false;
7
10
  const deviceType = detectDeviceType(userAgent, {
8
- userAgentDataPlatform: external_globals_mjs_navigator?.userAgentData?.platform,
9
- maxTouchPoints: external_globals_mjs_navigator?.maxTouchPoints,
10
- screenWidth: external_globals_mjs_window?.screen?.width,
11
- screenHeight: external_globals_mjs_window?.screen?.height,
12
- devicePixelRatio: external_globals_mjs_window?.devicePixelRatio
11
+ userAgentDataPlatform: navigator?.userAgentData?.platform,
12
+ maxTouchPoints: navigator?.maxTouchPoints,
13
+ screenWidth: win?.screen?.width,
14
+ screenHeight: win?.screen?.height,
15
+ devicePixelRatio: win?.devicePixelRatio
13
16
  });
14
17
  return propertyComparisons[matchType ?? 'icontains'](deviceTypes, [
15
18
  deviceType
@@ -0,0 +1,16 @@
1
+ import type { DisplaySurveyOptions, Survey } from '../types/surveys';
2
+ import { SurveyType } from '../survey-constants';
3
+ export { doesSurveyActivateByEvent, getSurveyInteractionProperty, isSurveyIterationBased } from '@posthog/core/surveys';
4
+ export declare const SURVEY_LOGGER: import("./logger").PosthogJsLogger;
5
+ export declare const SURVEY_CAPTURING_DISABLED = "PostHog is not capturing, so a survey response cannot be recorded";
6
+ export declare function isSurveyRunning(survey: Survey): boolean;
7
+ export declare function doesSurveyActivateByAction(survey: Pick<Survey, 'conditions'>): boolean;
8
+ export declare const SURVEY_SEEN_PREFIX = "seenSurvey_";
9
+ export declare const SURVEY_IN_PROGRESS_PREFIX = "inProgressSurvey_";
10
+ export declare const SURVEY_ABANDONED_PREFIX = "abandonedSurvey_";
11
+ export declare const getSurveyStorageKey: (prefix: string, survey: Pick<Survey, 'id' | 'current_iteration'>) => string;
12
+ export declare const getSurveySeenKey: (survey: Pick<Survey, 'id' | 'current_iteration'>) => string;
13
+ export declare const getSurveyAbandonedKey: (survey: Pick<Survey, 'id' | 'current_iteration'>) => string;
14
+ export declare const setSurveySeenOnLocalStorage: (survey: Pick<Survey, 'id' | 'current_iteration'>) => void;
15
+ export declare const IN_APP_SURVEY_TYPES: SurveyType[];
16
+ export declare const DEFAULT_DISPLAY_SURVEY_OPTIONS: DisplaySurveyOptions;
@@ -0,0 +1,121 @@
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
+ DEFAULT_DISPLAY_SURVEY_OPTIONS: ()=>DEFAULT_DISPLAY_SURVEY_OPTIONS,
32
+ IN_APP_SURVEY_TYPES: ()=>IN_APP_SURVEY_TYPES,
33
+ SURVEY_ABANDONED_PREFIX: ()=>SURVEY_ABANDONED_PREFIX,
34
+ SURVEY_CAPTURING_DISABLED: ()=>SURVEY_CAPTURING_DISABLED,
35
+ SURVEY_IN_PROGRESS_PREFIX: ()=>SURVEY_IN_PROGRESS_PREFIX,
36
+ SURVEY_LOGGER: ()=>SURVEY_LOGGER,
37
+ SURVEY_SEEN_PREFIX: ()=>SURVEY_SEEN_PREFIX,
38
+ doesSurveyActivateByAction: ()=>doesSurveyActivateByAction,
39
+ doesSurveyActivateByEvent: ()=>surveys_namespaceObject.doesSurveyActivateByEvent,
40
+ getSurveyAbandonedKey: ()=>getSurveyAbandonedKey,
41
+ getSurveyInteractionProperty: ()=>surveys_namespaceObject.getSurveyInteractionProperty,
42
+ getSurveySeenKey: ()=>getSurveySeenKey,
43
+ getSurveyStorageKey: ()=>getSurveyStorageKey,
44
+ isSurveyIterationBased: ()=>surveys_namespaceObject.isSurveyIterationBased,
45
+ isSurveyRunning: ()=>isSurveyRunning,
46
+ setSurveySeenOnLocalStorage: ()=>setSurveySeenOnLocalStorage
47
+ });
48
+ const surveys_namespaceObject = require("@posthog/core/surveys");
49
+ const external_survey_constants_js_namespaceObject = require("../survey-constants.js");
50
+ const external_logger_js_namespaceObject = require("./logger.js");
51
+ const SURVEY_LOGGER = (0, external_logger_js_namespaceObject.createLogger)('[Surveys]');
52
+ const SURVEY_CAPTURING_DISABLED = 'PostHog is not capturing, so a survey response cannot be recorded';
53
+ function isSurveyRunning(survey) {
54
+ return !!(survey.start_date && !survey.end_date);
55
+ }
56
+ function doesSurveyActivateByAction(survey) {
57
+ return !!survey.conditions?.actions?.values?.length;
58
+ }
59
+ const SURVEY_SEEN_PREFIX = 'seenSurvey_';
60
+ const SURVEY_IN_PROGRESS_PREFIX = 'inProgressSurvey_';
61
+ const SURVEY_ABANDONED_PREFIX = 'abandonedSurvey_';
62
+ const getSurveyStorageKey = (prefix, survey)=>`${prefix}${(0, surveys_namespaceObject.getSurveyIterationKey)(survey)}`;
63
+ const getSurveySeenKey = (survey)=>getSurveyStorageKey(SURVEY_SEEN_PREFIX, survey);
64
+ const getSurveyAbandonedKey = (survey)=>getSurveyStorageKey(SURVEY_ABANDONED_PREFIX, survey);
65
+ const setSurveySeenOnLocalStorage = (survey)=>{
66
+ try {
67
+ const surveySeenKey = getSurveySeenKey(survey);
68
+ const isSurveySeen = localStorage.getItem(surveySeenKey);
69
+ if (isSurveySeen) return;
70
+ localStorage.setItem(surveySeenKey, 'true');
71
+ } catch (error) {
72
+ SURVEY_LOGGER.error('Failed to persist survey seen state', error);
73
+ }
74
+ };
75
+ const IN_APP_SURVEY_TYPES = [
76
+ external_survey_constants_js_namespaceObject.SurveyType.Popover,
77
+ external_survey_constants_js_namespaceObject.SurveyType.Widget,
78
+ external_survey_constants_js_namespaceObject.SurveyType.API
79
+ ];
80
+ const DEFAULT_DISPLAY_SURVEY_OPTIONS = {
81
+ ignoreConditions: false,
82
+ ignoreDelay: false,
83
+ displayType: external_survey_constants_js_namespaceObject.DisplaySurveyType.Popover
84
+ };
85
+ exports.DEFAULT_DISPLAY_SURVEY_OPTIONS = __webpack_exports__.DEFAULT_DISPLAY_SURVEY_OPTIONS;
86
+ exports.IN_APP_SURVEY_TYPES = __webpack_exports__.IN_APP_SURVEY_TYPES;
87
+ exports.SURVEY_ABANDONED_PREFIX = __webpack_exports__.SURVEY_ABANDONED_PREFIX;
88
+ exports.SURVEY_CAPTURING_DISABLED = __webpack_exports__.SURVEY_CAPTURING_DISABLED;
89
+ exports.SURVEY_IN_PROGRESS_PREFIX = __webpack_exports__.SURVEY_IN_PROGRESS_PREFIX;
90
+ exports.SURVEY_LOGGER = __webpack_exports__.SURVEY_LOGGER;
91
+ exports.SURVEY_SEEN_PREFIX = __webpack_exports__.SURVEY_SEEN_PREFIX;
92
+ exports.doesSurveyActivateByAction = __webpack_exports__.doesSurveyActivateByAction;
93
+ exports.doesSurveyActivateByEvent = __webpack_exports__.doesSurveyActivateByEvent;
94
+ exports.getSurveyAbandonedKey = __webpack_exports__.getSurveyAbandonedKey;
95
+ exports.getSurveyInteractionProperty = __webpack_exports__.getSurveyInteractionProperty;
96
+ exports.getSurveySeenKey = __webpack_exports__.getSurveySeenKey;
97
+ exports.getSurveyStorageKey = __webpack_exports__.getSurveyStorageKey;
98
+ exports.isSurveyIterationBased = __webpack_exports__.isSurveyIterationBased;
99
+ exports.isSurveyRunning = __webpack_exports__.isSurveyRunning;
100
+ exports.setSurveySeenOnLocalStorage = __webpack_exports__.setSurveySeenOnLocalStorage;
101
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
102
+ "DEFAULT_DISPLAY_SURVEY_OPTIONS",
103
+ "IN_APP_SURVEY_TYPES",
104
+ "SURVEY_ABANDONED_PREFIX",
105
+ "SURVEY_CAPTURING_DISABLED",
106
+ "SURVEY_IN_PROGRESS_PREFIX",
107
+ "SURVEY_LOGGER",
108
+ "SURVEY_SEEN_PREFIX",
109
+ "doesSurveyActivateByAction",
110
+ "doesSurveyActivateByEvent",
111
+ "getSurveyAbandonedKey",
112
+ "getSurveyInteractionProperty",
113
+ "getSurveySeenKey",
114
+ "getSurveyStorageKey",
115
+ "isSurveyIterationBased",
116
+ "isSurveyRunning",
117
+ "setSurveySeenOnLocalStorage"
118
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
119
+ Object.defineProperty(exports, '__esModule', {
120
+ value: true
121
+ });
@@ -0,0 +1,38 @@
1
+ import { doesSurveyActivateByEvent, getSurveyInteractionProperty, getSurveyIterationKey, isSurveyIterationBased } from "@posthog/core/surveys";
2
+ import { DisplaySurveyType, SurveyType } from "../survey-constants.mjs";
3
+ import { createLogger } from "./logger.mjs";
4
+ const SURVEY_LOGGER = createLogger('[Surveys]');
5
+ const SURVEY_CAPTURING_DISABLED = 'PostHog is not capturing, so a survey response cannot be recorded';
6
+ function isSurveyRunning(survey) {
7
+ return !!(survey.start_date && !survey.end_date);
8
+ }
9
+ function doesSurveyActivateByAction(survey) {
10
+ return !!survey.conditions?.actions?.values?.length;
11
+ }
12
+ const SURVEY_SEEN_PREFIX = 'seenSurvey_';
13
+ const SURVEY_IN_PROGRESS_PREFIX = 'inProgressSurvey_';
14
+ const SURVEY_ABANDONED_PREFIX = 'abandonedSurvey_';
15
+ const getSurveyStorageKey = (prefix, survey)=>`${prefix}${getSurveyIterationKey(survey)}`;
16
+ const getSurveySeenKey = (survey)=>getSurveyStorageKey(SURVEY_SEEN_PREFIX, survey);
17
+ const getSurveyAbandonedKey = (survey)=>getSurveyStorageKey(SURVEY_ABANDONED_PREFIX, survey);
18
+ const setSurveySeenOnLocalStorage = (survey)=>{
19
+ try {
20
+ const surveySeenKey = getSurveySeenKey(survey);
21
+ const isSurveySeen = localStorage.getItem(surveySeenKey);
22
+ if (isSurveySeen) return;
23
+ localStorage.setItem(surveySeenKey, 'true');
24
+ } catch (error) {
25
+ SURVEY_LOGGER.error('Failed to persist survey seen state', error);
26
+ }
27
+ };
28
+ const IN_APP_SURVEY_TYPES = [
29
+ SurveyType.Popover,
30
+ SurveyType.Widget,
31
+ SurveyType.API
32
+ ];
33
+ const DEFAULT_DISPLAY_SURVEY_OPTIONS = {
34
+ ignoreConditions: false,
35
+ ignoreDelay: false,
36
+ displayType: DisplaySurveyType.Popover
37
+ };
38
+ export { DEFAULT_DISPLAY_SURVEY_OPTIONS, IN_APP_SURVEY_TYPES, SURVEY_ABANDONED_PREFIX, SURVEY_CAPTURING_DISABLED, SURVEY_IN_PROGRESS_PREFIX, SURVEY_LOGGER, SURVEY_SEEN_PREFIX, doesSurveyActivateByAction, doesSurveyActivateByEvent, getSurveyAbandonedKey, getSurveyInteractionProperty, getSurveySeenKey, getSurveyStorageKey, isSurveyIterationBased, isSurveyRunning, setSurveySeenOnLocalStorage };
@@ -1,6 +1,8 @@
1
1
  import type { PostHogConfig } from '@posthog/types';
2
2
  export type UrlTargetingInstance = {
3
- config: Pick<PostHogConfig, 'get_current_url'>;
3
+ config: {
4
+ get_current_url?: PostHogConfig['get_current_url'];
5
+ };
4
6
  };
5
7
  /**
6
8
  * Applies the `get_current_url` config hook to an already-resolved URL. Returns `defaultUrl`
@@ -32,7 +32,6 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  getTargetingUrl: ()=>getTargetingUrl
33
33
  });
34
34
  const core_namespaceObject = require("@posthog/core");
35
- const external_globals_js_namespaceObject = require("./globals.js");
36
35
  const external_logger_js_namespaceObject = require("./logger.js");
37
36
  function applyUrlTargetingOverride(instance, defaultUrl) {
38
37
  const override = instance?.config?.get_current_url;
@@ -46,7 +45,7 @@ function applyUrlTargetingOverride(instance, defaultUrl) {
46
45
  }
47
46
  }
48
47
  function getTargetingUrl(instance) {
49
- const defaultUrl = external_globals_js_namespaceObject.window?.location?.href;
48
+ const defaultUrl = "u" > typeof window ? window.location?.href : void 0;
50
49
  return (0, core_namespaceObject.isUndefined)(defaultUrl) ? void 0 : applyUrlTargetingOverride(instance, defaultUrl);
51
50
  }
52
51
  exports.applyUrlTargetingOverride = __webpack_exports__.applyUrlTargetingOverride;
@@ -1,5 +1,4 @@
1
1
  import { isFunction, isString, isUndefined } from "@posthog/core";
2
- import { window as external_globals_mjs_window } from "./globals.mjs";
3
2
  import { logger } from "./logger.mjs";
4
3
  function applyUrlTargetingOverride(instance, defaultUrl) {
5
4
  const override = instance?.config?.get_current_url;
@@ -13,7 +12,7 @@ function applyUrlTargetingOverride(instance, defaultUrl) {
13
12
  }
14
13
  }
15
14
  function getTargetingUrl(instance) {
16
- const defaultUrl = external_globals_mjs_window?.location?.href;
15
+ const defaultUrl = "u" > typeof window ? window.location?.href : void 0;
17
16
  return isUndefined(defaultUrl) ? void 0 : applyUrlTargetingOverride(instance, defaultUrl);
18
17
  }
19
18
  export { applyUrlTargetingOverride, getTargetingUrl };