@heycater/qualification-funnel 1.17.0 → 1.19.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.
- package/dist/heycater-funnel.iife.js +56 -56
- package/dist/index.cjs.js +3 -3
- package/dist/index.esm.js +63 -19
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -4272,6 +4272,11 @@ const useIsGb = () => {
|
|
|
4272
4272
|
return getIsGb(query);
|
|
4273
4273
|
};
|
|
4274
4274
|
const getIsGb = (query) => {
|
|
4275
|
+
if (typeof window !== "undefined") {
|
|
4276
|
+
if (window.location.pathname.toLowerCase().includes("london")) {
|
|
4277
|
+
return true;
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4275
4280
|
if (query == null ? void 0 : query.slug) {
|
|
4276
4281
|
return query.slug === "catering-london";
|
|
4277
4282
|
}
|
|
@@ -4984,6 +4989,7 @@ const CITY_VALUES = [
|
|
|
4984
4989
|
"duesseldorf",
|
|
4985
4990
|
"koeln",
|
|
4986
4991
|
"stuttgart",
|
|
4992
|
+
"london",
|
|
4987
4993
|
"other"
|
|
4988
4994
|
];
|
|
4989
4995
|
const CITY_QUESTION_ITEMS = [
|
|
@@ -5029,6 +5035,22 @@ const CITY_QUESTION_ITEMS = [
|
|
|
5029
5035
|
value: "stuttgart",
|
|
5030
5036
|
imageComponent: Stuttgart
|
|
5031
5037
|
},
|
|
5038
|
+
{
|
|
5039
|
+
labelEn: "London",
|
|
5040
|
+
labelDe: "London",
|
|
5041
|
+
value: "london",
|
|
5042
|
+
imageComponent: () => /* @__PURE__ */ jsx(
|
|
5043
|
+
Box,
|
|
5044
|
+
{
|
|
5045
|
+
height: "80px",
|
|
5046
|
+
width: "80px",
|
|
5047
|
+
display: "flex",
|
|
5048
|
+
alignItems: "center",
|
|
5049
|
+
justifyContent: "center",
|
|
5050
|
+
children: /* @__PURE__ */ jsx(Other, { width: "24px" })
|
|
5051
|
+
}
|
|
5052
|
+
)
|
|
5053
|
+
},
|
|
5032
5054
|
{
|
|
5033
5055
|
value: "other",
|
|
5034
5056
|
labelEn: "Other City",
|
|
@@ -5050,13 +5072,23 @@ const cityQuestion = Object.freeze(
|
|
|
5050
5072
|
createSelectorQuestion({
|
|
5051
5073
|
id: "city",
|
|
5052
5074
|
getValidator: ({ selectedCaterer }) => {
|
|
5053
|
-
const
|
|
5075
|
+
const isGb = getIsGb();
|
|
5076
|
+
if (isGb) {
|
|
5077
|
+
return yup.mixed().oneOf(["london"]).required();
|
|
5078
|
+
}
|
|
5079
|
+
const supportedCityValues = getSupportedCityValues(selectedCaterer).filter(
|
|
5080
|
+
(city) => city !== "london"
|
|
5081
|
+
);
|
|
5054
5082
|
return yup.mixed().oneOf(supportedCityValues).required();
|
|
5055
5083
|
},
|
|
5056
5084
|
getItems: ({ selectedCaterer }) => {
|
|
5085
|
+
const isGb = getIsGb();
|
|
5086
|
+
if (isGb) {
|
|
5087
|
+
return CITY_QUESTION_ITEMS.filter(({ value }) => value === "london");
|
|
5088
|
+
}
|
|
5057
5089
|
const supportedCityValues = getSupportedCityValues(selectedCaterer);
|
|
5058
5090
|
return CITY_QUESTION_ITEMS.filter(
|
|
5059
|
-
({ value }) => supportedCityValues.includes(value)
|
|
5091
|
+
({ value }) => supportedCityValues.includes(value) && value !== "london"
|
|
5060
5092
|
);
|
|
5061
5093
|
}
|
|
5062
5094
|
})
|
|
@@ -10096,7 +10128,7 @@ function trackAnswerSelected(context, answer) {
|
|
|
10096
10128
|
if (context.city) {
|
|
10097
10129
|
properties.city = context.city;
|
|
10098
10130
|
}
|
|
10099
|
-
captureEvent("
|
|
10131
|
+
captureEvent("qf_v14_answer_selected", properties);
|
|
10100
10132
|
}
|
|
10101
10133
|
function trackFormSubmitted(context, metadata) {
|
|
10102
10134
|
if (!context.session_id) {
|
|
@@ -10114,7 +10146,7 @@ function trackFormSubmitted(context, metadata) {
|
|
|
10114
10146
|
if (context.city) {
|
|
10115
10147
|
properties.city = context.city;
|
|
10116
10148
|
}
|
|
10117
|
-
captureEvent("
|
|
10149
|
+
captureEvent("qf_v14_form_submitted", properties);
|
|
10118
10150
|
}
|
|
10119
10151
|
function trackCompleted(context) {
|
|
10120
10152
|
if (!context.session_id) {
|
|
@@ -10131,7 +10163,7 @@ function trackCompleted(context) {
|
|
|
10131
10163
|
if (context.city) {
|
|
10132
10164
|
properties.city = context.city;
|
|
10133
10165
|
}
|
|
10134
|
-
captureEvent("
|
|
10166
|
+
captureEvent("qf_v14_completed", properties);
|
|
10135
10167
|
}
|
|
10136
10168
|
function trackAbandoned(context, lastStep) {
|
|
10137
10169
|
if (!context.session_id) {
|
|
@@ -10150,7 +10182,7 @@ function trackAbandoned(context, lastStep) {
|
|
|
10150
10182
|
if (context.city) {
|
|
10151
10183
|
properties.city = context.city;
|
|
10152
10184
|
}
|
|
10153
|
-
captureEvent("
|
|
10185
|
+
captureEvent("qf_v14_abandoned", properties);
|
|
10154
10186
|
}
|
|
10155
10187
|
function trackStarted(context, initialStepId) {
|
|
10156
10188
|
const properties = {
|
|
@@ -10158,7 +10190,7 @@ function trackStarted(context, initialStepId) {
|
|
|
10158
10190
|
session_id: context.session_id,
|
|
10159
10191
|
initial_step: initialStepId
|
|
10160
10192
|
};
|
|
10161
|
-
captureEvent("
|
|
10193
|
+
captureEvent("qf_v14_started", properties);
|
|
10162
10194
|
}
|
|
10163
10195
|
function serializeAnswerValue(value) {
|
|
10164
10196
|
if (value === void 0) return null;
|
|
@@ -10197,8 +10229,8 @@ function TrackingProvider({
|
|
|
10197
10229
|
return answerOf(questionId);
|
|
10198
10230
|
};
|
|
10199
10231
|
const serviceType = funnelContextRef.current.service_type || answerOf("service_type") || "";
|
|
10200
|
-
const sessionKey = `
|
|
10201
|
-
const trackedStepsKey = `
|
|
10232
|
+
const sessionKey = `qf_v14_started_${funnelContextRef.current.session_id}_${serviceType}`;
|
|
10233
|
+
const trackedStepsKey = `qf_v14_tracked_steps_${funnelContextRef.current.session_id}_${serviceType}`;
|
|
10202
10234
|
let isFirstTracking = false;
|
|
10203
10235
|
if (typeof sessionStorage !== "undefined") {
|
|
10204
10236
|
const hasStarted = sessionStorage.getItem(sessionKey);
|
|
@@ -10217,24 +10249,36 @@ function TrackingProvider({
|
|
|
10217
10249
|
trackedSteps = [];
|
|
10218
10250
|
}
|
|
10219
10251
|
}
|
|
10220
|
-
if (isFirstTracking &&
|
|
10252
|
+
if (isFirstTracking && isValidServiceType(serviceType)) {
|
|
10221
10253
|
const stepOrder = getStepOrderForServiceType(serviceType);
|
|
10222
|
-
|
|
10223
|
-
|
|
10224
|
-
|
|
10225
|
-
|
|
10226
|
-
const
|
|
10227
|
-
|
|
10254
|
+
const allSteps = qual.steps || [];
|
|
10255
|
+
for (let i2 = 0; i2 < stepOrder.length; i2++) {
|
|
10256
|
+
const stepId = stepOrder[i2];
|
|
10257
|
+
if (trackedSteps.includes(stepId)) continue;
|
|
10258
|
+
const stepState = allSteps.find((s3) => s3.id === stepId);
|
|
10259
|
+
const isDisabled = (stepState == null ? void 0 : stepState.disabled) === true;
|
|
10260
|
+
const isBeforeCurrentStep = i2 < stepIndex;
|
|
10261
|
+
const isCurrentStep = stepId === step2.id;
|
|
10262
|
+
if (isCurrentStep) continue;
|
|
10263
|
+
const shouldTrack = isBeforeCurrentStep || isDisabled;
|
|
10264
|
+
if (!shouldTrack) continue;
|
|
10265
|
+
const schemaStep2 = SCHEMA_STEPS[stepId];
|
|
10266
|
+
const questions22 = (schemaStep2 == null ? void 0 : schemaStep2.questions) || [];
|
|
10267
|
+
if (isDisabled) {
|
|
10268
|
+
const hasAnswer = questions22.some((q2) => answerOf(q2.id) !== void 0);
|
|
10269
|
+
if (!hasAnswer) continue;
|
|
10270
|
+
}
|
|
10271
|
+
questions22.forEach((question, qIdx) => {
|
|
10228
10272
|
const value = answerOf(question.id);
|
|
10229
10273
|
trackAnswerSelected(funnelContextRef.current, {
|
|
10230
|
-
step_id:
|
|
10274
|
+
step_id: stepId,
|
|
10231
10275
|
step_index: i2,
|
|
10232
10276
|
question_id: question.id,
|
|
10233
10277
|
answer_value: serializeAnswerValue(value),
|
|
10234
|
-
is_last_question: qIdx ===
|
|
10278
|
+
is_last_question: qIdx === questions22.length - 1
|
|
10235
10279
|
});
|
|
10236
10280
|
});
|
|
10237
|
-
trackedSteps.push(
|
|
10281
|
+
trackedSteps.push(stepId);
|
|
10238
10282
|
}
|
|
10239
10283
|
}
|
|
10240
10284
|
if (trackedSteps.includes(step2.id)) return;
|