@heycater/qualification-funnel 1.6.0 → 1.7.1

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/index.esm.js CHANGED
@@ -10085,7 +10085,7 @@ function trackAnswerSelected(context, answer) {
10085
10085
  if (context.city) {
10086
10086
  properties.city = context.city;
10087
10087
  }
10088
- captureEvent("qf_v4_answer_selected", properties);
10088
+ captureEvent("qf_v6_answer_selected", properties);
10089
10089
  }
10090
10090
  function trackFormSubmitted(context, metadata) {
10091
10091
  if (!context.session_id) {
@@ -10103,7 +10103,7 @@ function trackFormSubmitted(context, metadata) {
10103
10103
  if (context.city) {
10104
10104
  properties.city = context.city;
10105
10105
  }
10106
- captureEvent("qf_v4_form_submitted", properties);
10106
+ captureEvent("qf_v6_form_submitted", properties);
10107
10107
  }
10108
10108
  function trackCompleted(context) {
10109
10109
  if (!context.session_id) {
@@ -10120,7 +10120,7 @@ function trackCompleted(context) {
10120
10120
  if (context.city) {
10121
10121
  properties.city = context.city;
10122
10122
  }
10123
- captureEvent("qf_v4_completed", properties);
10123
+ captureEvent("qf_v6_completed", properties);
10124
10124
  }
10125
10125
  function trackAbandoned(context, lastStep) {
10126
10126
  if (!context.session_id) {
@@ -10139,7 +10139,7 @@ function trackAbandoned(context, lastStep) {
10139
10139
  if (context.city) {
10140
10140
  properties.city = context.city;
10141
10141
  }
10142
- captureEvent("qf_v4_abandoned", properties);
10142
+ captureEvent("qf_v6_abandoned", properties);
10143
10143
  }
10144
10144
  function trackStarted(context, initialStepId) {
10145
10145
  const properties = {
@@ -10147,7 +10147,7 @@ function trackStarted(context, initialStepId) {
10147
10147
  session_id: context.session_id,
10148
10148
  initial_step: initialStepId
10149
10149
  };
10150
- captureEvent("qf_v4_started", properties);
10150
+ captureEvent("qf_v6_started", properties);
10151
10151
  }
10152
10152
  const TrackingContext = createContext(null);
10153
10153
  function TrackingProvider({
@@ -10168,7 +10168,7 @@ function TrackingProvider({
10168
10168
  const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10169
10169
  const questionIndex = questions2.findIndex((q2) => q2.id === questionId);
10170
10170
  const isLastQuestion = questionIndex === questions2.length - 1;
10171
- const sessionKey = `qf_v4_started_${funnelContextRef.current.session_id}`;
10171
+ const sessionKey = `qf_v6_started_${funnelContextRef.current.session_id}`;
10172
10172
  if (typeof sessionStorage !== "undefined") {
10173
10173
  const hasStarted = sessionStorage.getItem(sessionKey);
10174
10174
  if (!hasStarted) {
@@ -10737,7 +10737,7 @@ function DatePickerEmbedded() {
10737
10737
  month,
10738
10738
  onDayClick: (date22) => {
10739
10739
  actions.answerQuestion("event_date", date22);
10740
- trackAnswer("event_date", date22);
10740
+ trackAnswer("event_date", format(date22, "yyyy-MM-dd"));
10741
10741
  },
10742
10742
  selected: activeDate,
10743
10743
  fromDate: minimumDate,
@@ -26721,27 +26721,40 @@ function RequestForm({ header = null }) {
26721
26721
  if (success) {
26722
26722
  setIsActualUkLead(isUkLead);
26723
26723
  setShowLeadSuccess(true);
26724
+ trackFormSubmitted(funnelContextRef.current, { is_uk_lead: isUkLead });
26724
26725
  trackCompleted(funnelContextRef.current);
26725
26726
  return;
26726
26727
  } else {
26727
- console.error("[HeyCater Funnel] Expected success screen but got success=false. Result:", response);
26728
+ console.error("[HeyCater Funnel] Lead submission failed. Result:", response);
26729
+ handleDisableCTA(false);
26730
+ return;
26728
26731
  }
26729
26732
  }
26730
26733
  let redirectRoute = "";
26731
26734
  if (currentUserAccount) {
26732
26735
  try {
26733
26736
  const opportunity = await submitAsExistingCustomer(values2);
26737
+ if (!opportunity || !opportunity.id) {
26738
+ console.error("[HeyCater Funnel] submitAsExistingCustomer returned invalid opportunity:", opportunity);
26739
+ handleDisableCTA(false);
26740
+ return;
26741
+ }
26734
26742
  redirectRoute = `/account/requests/${opportunity.id}`;
26735
26743
  } catch (err) {
26736
26744
  if (err instanceof Error) {
26737
26745
  BugsnagExport.notify(err);
26738
26746
  }
26747
+ handleDisableCTA(false);
26748
+ return;
26739
26749
  }
26740
26750
  } else {
26741
- const {
26742
- signInToken,
26743
- opportunity
26744
- } = await submitAsNewCustomer(values2);
26751
+ const response = await submitAsNewCustomer(values2);
26752
+ const { signInToken, opportunity } = response || {};
26753
+ if (!opportunity || !opportunity.id) {
26754
+ console.error("[HeyCater Funnel] submitAsNewCustomer returned invalid opportunity:", response);
26755
+ handleDisableCTA(false);
26756
+ return;
26757
+ }
26745
26758
  if (signInToken) {
26746
26759
  redirectRoute = `/${router.locale}/account/requests/${opportunity.id}?one_time_sign_in_token=${signInToken}`;
26747
26760
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",