posthog-js 1.347.2 → 1.349.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/array.full.es5.js +1 -1
  2. package/dist/array.full.js +1 -1
  3. package/dist/array.full.no-external.js +1 -1
  4. package/dist/array.js +1 -1
  5. package/dist/array.no-external.js +1 -1
  6. package/dist/conversations.js +1 -1
  7. package/dist/conversations.js.map +1 -1
  8. package/dist/customizations.full.js +1 -1
  9. package/dist/lazy-recorder.js +1 -1
  10. package/dist/main.js +1 -1
  11. package/dist/main.js.map +1 -1
  12. package/dist/module.d.ts +56 -2
  13. package/dist/module.full.d.ts +56 -2
  14. package/dist/module.full.js +1 -1
  15. package/dist/module.full.js.map +1 -1
  16. package/dist/module.full.no-external.d.ts +56 -2
  17. package/dist/module.full.no-external.js +1 -1
  18. package/dist/module.full.no-external.js.map +1 -1
  19. package/dist/module.js +1 -1
  20. package/dist/module.js.map +1 -1
  21. package/dist/module.no-external.d.ts +56 -2
  22. package/dist/module.no-external.js +1 -1
  23. package/dist/module.no-external.js.map +1 -1
  24. package/dist/posthog-recorder.js +1 -1
  25. package/dist/product-tours-preview.d.ts +14 -0
  26. package/dist/product-tours-preview.js +1 -1
  27. package/dist/product-tours-preview.js.map +1 -1
  28. package/dist/product-tours.js +1 -1
  29. package/dist/product-tours.js.map +1 -1
  30. package/dist/src/extensions/conversations/external/components/ConversationsWidget.d.ts +43 -2
  31. package/dist/src/extensions/conversations/external/components/TicketListItem.d.ts +13 -0
  32. package/dist/src/extensions/conversations/external/components/TicketListView.d.ts +15 -0
  33. package/dist/src/extensions/conversations/external/components/styles.d.ts +184 -0
  34. package/dist/src/extensions/conversations/external/components/utils.d.ts +8 -0
  35. package/dist/src/extensions/conversations/external/index.d.ts +39 -1
  36. package/dist/src/extensions/product-tours/product-tours-utils.d.ts +1 -0
  37. package/dist/src/extensions/product-tours/product-tours.d.ts +3 -0
  38. package/dist/src/posthog-product-tours-types.d.ts +54 -0
  39. package/dist/surveys-preview.d.ts +14 -0
  40. package/lib/package.json +1 -1
  41. package/lib/src/extensions/conversations/external/components/ConversationsWidget.d.ts +43 -2
  42. package/lib/src/extensions/conversations/external/components/ConversationsWidget.js +96 -28
  43. package/lib/src/extensions/conversations/external/components/ConversationsWidget.js.map +1 -1
  44. package/lib/src/extensions/conversations/external/components/TicketListItem.d.ts +13 -0
  45. package/lib/src/extensions/conversations/external/components/TicketListItem.js +47 -0
  46. package/lib/src/extensions/conversations/external/components/TicketListItem.js.map +1 -0
  47. package/lib/src/extensions/conversations/external/components/TicketListView.d.ts +15 -0
  48. package/lib/src/extensions/conversations/external/components/TicketListView.js +75 -0
  49. package/lib/src/extensions/conversations/external/components/TicketListView.js.map +1 -0
  50. package/lib/src/extensions/conversations/external/components/styles.d.ts +184 -0
  51. package/lib/src/extensions/conversations/external/components/styles.js +189 -0
  52. package/lib/src/extensions/conversations/external/components/styles.js.map +1 -1
  53. package/lib/src/extensions/conversations/external/components/utils.d.ts +8 -0
  54. package/lib/src/extensions/conversations/external/components/utils.js +49 -0
  55. package/lib/src/extensions/conversations/external/components/utils.js.map +1 -0
  56. package/lib/src/extensions/conversations/external/index.d.ts +39 -1
  57. package/lib/src/extensions/conversations/external/index.js +253 -31
  58. package/lib/src/extensions/conversations/external/index.js.map +1 -1
  59. package/lib/src/extensions/product-tours/components/ProductTourSurveyStepInner.js +1 -1
  60. package/lib/src/extensions/product-tours/components/ProductTourSurveyStepInner.js.map +1 -1
  61. package/lib/src/extensions/product-tours/product-tours-utils.d.ts +1 -0
  62. package/lib/src/extensions/product-tours/product-tours-utils.js +34 -0
  63. package/lib/src/extensions/product-tours/product-tours-utils.js.map +1 -1
  64. package/lib/src/extensions/product-tours/product-tours.d.ts +3 -0
  65. package/lib/src/extensions/product-tours/product-tours.js +104 -75
  66. package/lib/src/extensions/product-tours/product-tours.js.map +1 -1
  67. package/lib/src/posthog-product-tours-types.d.ts +54 -0
  68. package/lib/src/posthog-product-tours-types.js +43 -1
  69. package/lib/src/posthog-product-tours-types.js.map +1 -1
  70. package/lib/src/utils/product-tour-event-receiver.js +2 -1
  71. package/lib/src/utils/product-tour-event-receiver.js.map +1 -1
  72. package/lib/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +3 -3
  74. package/react/dist/esm/index.js +25 -1
  75. package/react/dist/esm/index.js.map +1 -1
  76. package/react/dist/types/index.d.ts +4 -2
  77. package/react/dist/umd/index.js +25 -0
  78. package/react/dist/umd/index.js.map +1 -1
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.ProductTourManager = void 0;
26
26
  var jsx_runtime_1 = require("preact/jsx-runtime");
27
27
  var preact_1 = require("preact");
28
+ var posthog_product_tours_types_1 = require("../../posthog-product-tours-types");
28
29
  var posthog_surveys_types_1 = require("../../posthog-surveys-types");
29
30
  var product_tours_utils_1 = require("./product-tours-utils");
30
31
  var ProductTourTooltip_1 = require("./components/ProductTourTooltip");
@@ -39,6 +40,7 @@ var constants_1 = require("./constants");
39
40
  var product_tour_utils_1 = require("../../utils/product-tour-utils");
40
41
  var constants_2 = require("../../constants");
41
42
  var product_tour_event_receiver_1 = require("../../utils/product-tour-event-receiver");
43
+ var event_utils_1 = require("../../utils/event-utils");
42
44
  var logger = (0, logger_1.createLogger)('[Product Tours]');
43
45
  var document = globals_1.document;
44
46
  var window = globals_1.window;
@@ -174,15 +176,16 @@ var ProductTourManager = /** @class */ (function () {
174
176
  }
175
177
  };
176
178
  this.nextStep = function () {
179
+ var _a;
177
180
  if (!_this._activeTour) {
178
181
  return;
179
182
  }
180
183
  var currentStep = _this._activeTour.steps[_this._currentStepIndex];
181
- _this._captureEvent('product tour step completed', {
182
- $product_tour_id: _this._activeTour.id,
183
- $product_tour_step_id: currentStep.id,
184
- $product_tour_step_order: _this._currentStepIndex,
185
- });
184
+ _this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.STEP_COMPLETED, (_a = {},
185
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = _this._activeTour.id,
186
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ID] = currentStep.id,
187
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ORDER] = _this._currentStepIndex,
188
+ _a));
186
189
  if (_this._currentStepIndex < _this._activeTour.steps.length - 1) {
187
190
  _this._setStepIndex(_this._currentStepIndex + 1);
188
191
  _this._renderCurrentStep();
@@ -199,32 +202,33 @@ var ProductTourManager = /** @class */ (function () {
199
202
  _this._renderCurrentStep();
200
203
  };
201
204
  this.dismissTour = function (reason) {
202
- var _a;
205
+ var _a, _b;
203
206
  if (reason === void 0) { reason = 'user_clicked_skip'; }
204
207
  if (!_this._activeTour) {
205
208
  return;
206
209
  }
207
210
  var currentStep = _this._activeTour.steps[_this._currentStepIndex];
208
- _this._captureEvent('product tour dismissed', {
209
- $product_tour_id: _this._activeTour.id,
210
- $product_tour_step_id: currentStep.id,
211
- $product_tour_step_order: _this._currentStepIndex,
212
- $product_tour_dismiss_reason: reason,
213
- });
211
+ _this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.DISMISSED, (_a = {},
212
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = _this._activeTour.id,
213
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ID] = currentStep.id,
214
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ORDER] = _this._currentStepIndex,
215
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_DISMISS_REASON] = reason,
216
+ _a));
214
217
  if (!_this._isPreviewMode) {
215
218
  storage_1.localStore._set("".concat(constants_1.TOUR_DISMISSED_KEY_PREFIX).concat(_this._activeTour.id), true);
216
219
  _this._instance.capture('$set', {
217
- $set: (_a = {}, _a["$product_tour_dismissed/".concat(_this._activeTour.id)] = true, _a),
220
+ $set: (_b = {}, _b["$product_tour_dismissed/".concat(_this._activeTour.id)] = true, _b),
218
221
  });
219
222
  }
220
223
  window.dispatchEvent(new CustomEvent('PHProductTourDismissed', { detail: { tourId: _this._activeTour.id, reason: reason } }));
221
224
  _this._cleanup();
222
225
  };
223
226
  this._handleButtonClick = function (button) {
227
+ var _a, _b, _c;
224
228
  if (_this._activeTour) {
225
229
  var currentStep = _this._activeTour.steps[_this._currentStepIndex];
226
230
  if (currentStep) {
227
- _this._captureEvent('product tour button clicked', __assign(__assign({ $product_tour_id: _this._activeTour.id, $product_tour_name: _this._activeTour.name, $product_tour_iteration: _this._activeTour.current_iteration || 1, $product_tour_step_id: currentStep.id, $product_tour_step_order: _this._currentStepIndex, $product_tour_button_text: button.text, $product_tour_button_action: button.action }, (button.link && { $product_tour_button_link: button.link })), (button.tourId && { $product_tour_button_tour_id: button.tourId })));
231
+ _this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.BUTTON_CLICKED, __assign(__assign((_a = {}, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = _this._activeTour.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_NAME] = _this._activeTour.name, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ITERATION] = _this._activeTour.current_iteration || 1, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ID] = currentStep.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ORDER] = _this._currentStepIndex, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_BUTTON_TEXT] = button.text, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_BUTTON_ACTION] = button.action, _a), (button.link && (_b = {}, _b[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_BUTTON_LINK] = button.link, _b))), (button.tourId && (_c = {}, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_BUTTON_TOUR_ID] = button.tourId, _c))));
228
232
  }
229
233
  }
230
234
  switch (button.action) {
@@ -273,6 +277,18 @@ var ProductTourManager = /** @class */ (function () {
273
277
  finally { if (e_1) throw e_1.error; }
274
278
  }
275
279
  };
280
+ ProductTourManager.prototype._getCurrentStep = function () {
281
+ var _a;
282
+ if (!this._activeTour) {
283
+ return null;
284
+ }
285
+ var rawStep = this._activeTour.steps[this._currentStepIndex];
286
+ if (!rawStep) {
287
+ return null;
288
+ }
289
+ var language = (_a = this._instance.config.override_display_language) !== null && _a !== void 0 ? _a : (0, event_utils_1.getBrowserLanguage)();
290
+ return (0, product_tours_utils_1.resolveStepTranslation)(rawStep, language !== null && language !== void 0 ? language : null);
291
+ };
276
292
  ProductTourManager.prototype._setStepIndex = function (index) {
277
293
  this._currentStepIndex = index;
278
294
  this._saveSessionState();
@@ -484,24 +500,24 @@ var ProductTourManager = /** @class */ (function () {
484
500
  return true;
485
501
  };
486
502
  ProductTourManager.prototype.showTour = function (tour, options) {
487
- var _a;
488
- var _b;
489
- var renderReason = (_b = options === null || options === void 0 ? void 0 : options.reason) !== null && _b !== void 0 ? _b : 'auto';
503
+ var _a, _b;
504
+ var _c;
505
+ var renderReason = (_c = options === null || options === void 0 ? void 0 : options.reason) !== null && _c !== void 0 ? _c : 'auto';
490
506
  this.cancelPendingTour(tour.id);
491
507
  this._activeTour = tour;
492
508
  this._setStepIndex(0);
493
509
  var rendered = this._renderCurrentStep();
494
510
  if (rendered) {
495
- this._captureEvent('product tour shown', {
496
- $product_tour_id: tour.id,
497
- $product_tour_name: tour.name,
498
- $product_tour_iteration: tour.current_iteration || 1,
499
- $product_tour_render_reason: renderReason,
500
- });
511
+ this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.SHOWN, (_a = {},
512
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = tour.id,
513
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_NAME] = tour.name,
514
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ITERATION] = tour.current_iteration || 1,
515
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_RENDER_REASON] = renderReason,
516
+ _a));
501
517
  if (!this._isPreviewMode) {
502
518
  storage_1.localStore._set("".concat(constants_1.TOUR_SHOWN_KEY_PREFIX).concat(tour.id), true);
503
519
  this._instance.capture('$set', {
504
- $set: (_a = {}, _a["$product_tour_shown/".concat(tour.id)] = true, _a),
520
+ $set: (_b = {}, _b["$product_tour_shown/".concat(tour.id)] = true, _b),
505
521
  });
506
522
  }
507
523
  }
@@ -533,33 +549,34 @@ var ProductTourManager = /** @class */ (function () {
533
549
  this._renderCurrentStep();
534
550
  };
535
551
  ProductTourManager.prototype._completeTour = function () {
536
- var _a;
552
+ var _a, _b;
537
553
  if (!this._activeTour) {
538
554
  return;
539
555
  }
540
- this._captureEvent('product tour completed', {
541
- $product_tour_id: this._activeTour.id,
542
- $product_tour_steps_count: this._activeTour.steps.length,
543
- });
556
+ this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.COMPLETED, (_a = {},
557
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = this._activeTour.id,
558
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEPS_COUNT] = this._activeTour.steps.length,
559
+ _a));
544
560
  if (!this._isPreviewMode) {
545
561
  storage_1.localStore._set("".concat(constants_1.TOUR_COMPLETED_KEY_PREFIX).concat(this._activeTour.id), true);
546
562
  this._instance.capture('$set', {
547
- $set: (_a = {},
548
- _a["$product_tour_completed/".concat(this._activeTour.id)] = true,
549
- _a),
563
+ $set: (_b = {},
564
+ _b["$product_tour_completed/".concat(this._activeTour.id)] = true,
565
+ _b),
550
566
  });
551
567
  }
552
568
  window.dispatchEvent(new CustomEvent('PHProductTourCompleted', { detail: { tourId: this._activeTour.id } }));
553
569
  this._cleanup();
554
570
  };
555
571
  ProductTourManager.prototype._renderCurrentStep = function (retryCount) {
572
+ var _a, _b, _c;
556
573
  var _this = this;
557
- var _a;
574
+ var _d;
558
575
  if (retryCount === void 0) { retryCount = 0; }
559
576
  if (!this._activeTour) {
560
577
  return false;
561
578
  }
562
- var step = this._activeTour.steps[this._currentStepIndex];
579
+ var step = this._getCurrentStep();
563
580
  if (!step) {
564
581
  logger.warn("Step ".concat(this._currentStepIndex, " not found in tour ").concat(this._activeTour.id));
565
582
  this._cleanup();
@@ -567,12 +584,7 @@ var ProductTourManager = /** @class */ (function () {
567
584
  }
568
585
  // Banner step - render full-width banner
569
586
  if (step.type === 'banner') {
570
- this._captureEvent('product tour step shown', {
571
- $product_tour_id: this._activeTour.id,
572
- $product_tour_step_id: step.id,
573
- $product_tour_step_order: this._currentStepIndex,
574
- $product_tour_step_type: 'banner',
575
- });
587
+ this._captureStepShown();
576
588
  this._isResuming = false;
577
589
  this._renderBanner();
578
590
  return true;
@@ -588,21 +600,16 @@ var ProductTourManager = /** @class */ (function () {
588
600
  }
589
601
  // Screen-positioned step (no element targeting) - render without a target element
590
602
  if (!(0, product_tours_utils_1.hasElementTarget)(step)) {
591
- this._captureEvent('product tour step shown', {
592
- $product_tour_id: this._activeTour.id,
593
- $product_tour_step_id: step.id,
594
- $product_tour_step_order: this._currentStepIndex,
595
- $product_tour_step_type: step.type,
596
- });
603
+ this._captureStepShown();
597
604
  this._isResuming = false;
598
605
  this._renderTooltipWithPreact(null);
599
606
  return true;
600
607
  }
601
608
  var result = (0, product_tours_utils_1.findStepElement)(step);
602
- var inferenceProps = {
603
- $use_manual_selector: (_a = step.useManualSelector) !== null && _a !== void 0 ? _a : false,
604
- $inference_data_present: !!step.inferenceData,
605
- };
609
+ var inferenceProps = (_a = {},
610
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.USE_MANUAL_SELECTOR] = (_d = step.useManualSelector) !== null && _d !== void 0 ? _d : false,
611
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.INFERENCE_DATA_PRESENT] = !!step.inferenceData,
612
+ _a);
606
613
  var previousStep = this._currentStepIndex > 0 ? this._activeTour.steps[this._currentStepIndex - 1] : null;
607
614
  var shouldWaitForElement = (previousStep === null || previousStep === void 0 ? void 0 : previousStep.progressionTrigger) === 'click' || this._isResuming;
608
615
  // 2s total timeout
@@ -618,7 +625,7 @@ var ProductTourManager = /** @class */ (function () {
618
625
  return false;
619
626
  }
620
627
  var waitDurationMs = retryCount * retryTimeout;
621
- this._captureEvent('product tour step selector failed', __assign({ $product_tour_id: this._activeTour.id, $product_tour_step_id: step.id, $product_tour_step_order: this._currentStepIndex, $product_tour_step_selector: step.selector, $product_tour_error: result.error, $product_tour_matches_count: result.matchCount, $product_tour_failure_phase: 'runtime', $product_tour_waited_for_element: shouldWaitForElement, $product_tour_wait_duration_ms: waitDurationMs }, inferenceProps));
628
+ this._captureStepSelectorFailed(result, __assign((_b = {}, _b[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_WAITED_FOR_ELEMENT] = shouldWaitForElement, _b[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_WAIT_DURATION_MS] = waitDurationMs, _b), inferenceProps));
622
629
  if (this._currentStepIndex === 0 && !this._isResuming) {
623
630
  logger.warn("Tour \"".concat(this._activeTour.name, "\" failed to show: element for first step not found (").concat(result.error, ")"));
624
631
  return false;
@@ -629,7 +636,7 @@ var ProductTourManager = /** @class */ (function () {
629
636
  return false;
630
637
  }
631
638
  if (result.error === 'multiple_matches') {
632
- this._captureEvent('product tour step selector failed', __assign({ $product_tour_id: this._activeTour.id, $product_tour_step_id: step.id, $product_tour_step_order: this._currentStepIndex, $product_tour_step_selector: step.selector, $product_tour_error: result.error, $product_tour_matches_count: result.matchCount, $product_tour_failure_phase: 'runtime' }, inferenceProps));
639
+ this._captureStepSelectorFailed(result, inferenceProps);
633
640
  // Continue with first match for multiple_matches case
634
641
  }
635
642
  if (!result.element) {
@@ -637,7 +644,7 @@ var ProductTourManager = /** @class */ (function () {
637
644
  }
638
645
  var element = result.element;
639
646
  var metadata = (0, product_tours_utils_1.getElementMetadata)(element);
640
- this._captureEvent('product tour step shown', __assign({ $product_tour_id: this._activeTour.id, $product_tour_step_id: step.id, $product_tour_step_order: this._currentStepIndex, $product_tour_step_selector: step.selector, $product_tour_step_selector_found: true, $product_tour_step_element_tag: metadata.tag, $product_tour_step_element_id: metadata.id, $product_tour_step_element_classes: metadata.classes, $product_tour_step_element_text: metadata.text }, inferenceProps));
647
+ this._captureStepShown(__assign((_c = {}, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_SELECTOR] = step.selector, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_SELECTOR_FOUND] = true, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ELEMENT_TAG] = metadata.tag, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ELEMENT_ID] = metadata.id, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ELEMENT_CLASSES] = metadata.classes, _c[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ELEMENT_TEXT] = metadata.text, _c), inferenceProps));
641
648
  this._isResuming = false;
642
649
  this._renderTooltipWithPreact(element);
643
650
  return true;
@@ -646,23 +653,30 @@ var ProductTourManager = /** @class */ (function () {
646
653
  if (!this._activeTour) {
647
654
  return;
648
655
  }
649
- var step = this._activeTour.steps[this._currentStepIndex];
656
+ var step = this._getCurrentStep();
657
+ if (!step) {
658
+ return;
659
+ }
650
660
  var shadow = retrieveTourShadow(this._activeTour).shadow;
651
661
  (0, preact_1.render)((0, jsx_runtime_1.jsx)(ProductTourTooltip_1.ProductTourTooltip, { tour: this._activeTour, step: step, stepIndex: this._currentStepIndex, totalSteps: this._activeTour.steps.length, targetElement: element, onNext: this.nextStep, onPrevious: this.previousStep, onDismiss: onDismissOverride || this.dismissTour, onSurveySubmit: onSurveySubmit, onButtonClick: this._handleButtonClick }), shadow);
652
662
  };
653
663
  ProductTourManager.prototype._renderBanner = function () {
654
- var _this = this;
655
664
  var _a;
665
+ var _this = this;
666
+ var _b;
656
667
  if (!this._activeTour) {
657
668
  return;
658
669
  }
659
- var step = this._activeTour.steps[this._currentStepIndex];
670
+ var step = this._getCurrentStep();
671
+ if (!step) {
672
+ return;
673
+ }
660
674
  var result = retrieveBannerShadow(this._activeTour, step.bannerConfig);
661
675
  if (!result) {
662
- this._captureEvent('product tour banner container selector failed', {
663
- $product_tour_id: this._activeTour.id,
664
- $product_tour_banner_selector: (_a = step === null || step === void 0 ? void 0 : step.bannerConfig) === null || _a === void 0 ? void 0 : _a.selector,
665
- });
676
+ this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.BANNER_CONTAINER_SELECTOR_FAILED, (_a = {},
677
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = this._activeTour.id,
678
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_BANNER_SELECTOR] = (_b = step === null || step === void 0 ? void 0 : step.bannerConfig) === null || _b === void 0 ? void 0 : _b.selector,
679
+ _a));
666
680
  this.dismissTour('container_unavailable');
667
681
  return;
668
682
  }
@@ -678,29 +692,28 @@ var ProductTourManager = /** @class */ (function () {
678
692
  (0, preact_1.render)((0, jsx_runtime_1.jsx)(ProductTourBanner_1.ProductTourBanner, { step: step, onDismiss: function () { return _this.dismissTour('user_clicked_skip'); }, onTriggerTour: handleTriggerTour, displayFrequency: this._activeTour.display_frequency }), shadow);
679
693
  };
680
694
  ProductTourManager.prototype._renderSurveyStep = function () {
681
- var _a;
695
+ var _a, _b;
682
696
  var _this = this;
683
- var _b, _c, _d;
697
+ var _c, _d, _e;
684
698
  if (!this._activeTour) {
685
699
  return;
686
700
  }
687
701
  var tourId = this._activeTour.id;
688
- var step = this._activeTour.steps[this._currentStepIndex];
702
+ var step = this._getCurrentStep();
703
+ if (!step) {
704
+ return;
705
+ }
689
706
  var surveyId = step.linkedSurveyId;
690
707
  var questionId = step.linkedSurveyQuestionId;
691
- var questionText = ((_b = step.survey) === null || _b === void 0 ? void 0 : _b.questionText) || '';
692
- this._captureEvent('product tour step shown', {
693
- $product_tour_id: this._activeTour.id,
694
- $product_tour_step_id: step.id,
695
- $product_tour_step_order: this._currentStepIndex,
696
- $product_tour_step_type: 'survey',
697
- $product_tour_linked_survey_id: surveyId,
698
- });
699
- this._captureEvent(posthog_surveys_types_1.SurveyEventName.SHOWN, (_a = {},
700
- _a[posthog_surveys_types_1.SurveyEventProperties.SURVEY_ID] = surveyId,
701
- _a[posthog_surveys_types_1.SurveyEventProperties.PRODUCT_TOUR_ID] = tourId,
702
- _a.sessionRecordingUrl = (_d = (_c = this._instance).get_session_replay_url) === null || _d === void 0 ? void 0 : _d.call(_c),
708
+ var questionText = ((_c = step.survey) === null || _c === void 0 ? void 0 : _c.questionText) || '';
709
+ this._captureStepShown((_a = {},
710
+ _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_LINKED_SURVEY_ID] = surveyId,
703
711
  _a));
712
+ this._captureEvent(posthog_surveys_types_1.SurveyEventName.SHOWN, (_b = {},
713
+ _b[posthog_surveys_types_1.SurveyEventProperties.SURVEY_ID] = surveyId,
714
+ _b[posthog_surveys_types_1.SurveyEventProperties.PRODUCT_TOUR_ID] = tourId,
715
+ _b.sessionRecordingUrl = (_e = (_d = this._instance).get_session_replay_url) === null || _e === void 0 ? void 0 : _e.call(_d),
716
+ _b));
704
717
  var handleSubmit = function (response) {
705
718
  var _a, _b;
706
719
  var _c, _d;
@@ -836,6 +849,22 @@ var ProductTourManager = /** @class */ (function () {
836
849
  }
837
850
  this._instance.capture(eventName, properties);
838
851
  };
852
+ ProductTourManager.prototype._captureStepShown = function (extraProps) {
853
+ var _a;
854
+ if (!this._activeTour) {
855
+ return;
856
+ }
857
+ var step = this._activeTour.steps[this._currentStepIndex];
858
+ this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.STEP_SHOWN, __assign((_a = {}, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = this._activeTour.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ID] = step.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ORDER] = this._currentStepIndex, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_TYPE] = step.type, _a), extraProps));
859
+ };
860
+ ProductTourManager.prototype._captureStepSelectorFailed = function (result, extraProps) {
861
+ var _a;
862
+ if (!this._activeTour) {
863
+ return;
864
+ }
865
+ var step = this._activeTour.steps[this._currentStepIndex];
866
+ this._captureEvent(posthog_product_tours_types_1.ProductTourEventName.STEP_SELECTOR_FAILED, __assign((_a = {}, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ID] = this._activeTour.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ID] = step.id, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_ORDER] = this._currentStepIndex, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_STEP_SELECTOR] = step.selector, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_ERROR] = result.error, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_MATCHES_COUNT] = result.matchCount, _a[posthog_product_tours_types_1.ProductTourEventProperties.TOUR_FAILURE_PHASE] = 'runtime', _a), extraProps));
867
+ };
839
868
  // Public API methods delegated from PostHogProductTours
840
869
  ProductTourManager.prototype.getActiveProductTours = function (callback) {
841
870
  var _this = this;