@heycater/qualification-funnel 1.10.0 → 1.12.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 +96 -96
- package/dist/index.cjs.js +106 -106
- package/dist/index.esm.js +61 -9
- package/package.json +1 -1
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("
|
|
10088
|
+
captureEvent("qf_v11_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("
|
|
10106
|
+
captureEvent("qf_v11_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("
|
|
10123
|
+
captureEvent("qf_v11_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("
|
|
10142
|
+
captureEvent("qf_v11_abandoned", properties);
|
|
10143
10143
|
}
|
|
10144
10144
|
function trackStarted(context, initialStepId) {
|
|
10145
10145
|
const properties = {
|
|
@@ -10147,7 +10147,21 @@ function trackStarted(context, initialStepId) {
|
|
|
10147
10147
|
session_id: context.session_id,
|
|
10148
10148
|
initial_step: initialStepId
|
|
10149
10149
|
};
|
|
10150
|
-
captureEvent("
|
|
10150
|
+
captureEvent("qf_v11_started", properties);
|
|
10151
|
+
}
|
|
10152
|
+
function serializeAnswerValue(value) {
|
|
10153
|
+
if (value === void 0) return null;
|
|
10154
|
+
if (value === null) return null;
|
|
10155
|
+
if (value instanceof Date) {
|
|
10156
|
+
return format(value, "yyyy-MM-dd");
|
|
10157
|
+
}
|
|
10158
|
+
if (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) {
|
|
10159
|
+
return null;
|
|
10160
|
+
}
|
|
10161
|
+
if (Array.isArray(value)) {
|
|
10162
|
+
return value;
|
|
10163
|
+
}
|
|
10164
|
+
return value;
|
|
10151
10165
|
}
|
|
10152
10166
|
const TrackingContext = createContext(null);
|
|
10153
10167
|
function TrackingProvider({
|
|
@@ -10158,21 +10172,55 @@ function TrackingProvider({
|
|
|
10158
10172
|
}) {
|
|
10159
10173
|
const { state, answerOf } = useQualification();
|
|
10160
10174
|
const trackStepCompletion = useCallback(() => {
|
|
10175
|
+
var _a2;
|
|
10161
10176
|
if (!("qualification" in state)) return;
|
|
10162
10177
|
const qual = state.qualification;
|
|
10163
10178
|
if (!("step" in qual)) return;
|
|
10164
10179
|
const step2 = qual.step;
|
|
10165
10180
|
const stepIndex = qual.stepIndex;
|
|
10166
|
-
const
|
|
10167
|
-
const
|
|
10168
|
-
const
|
|
10181
|
+
const steps2 = ((_a2 = qual.steps) == null ? void 0 : _a2.filter((s3) => !s3.disabled)) || [];
|
|
10182
|
+
const sessionKey = `qf_v11_started_${funnelContextRef.current.session_id}`;
|
|
10183
|
+
const trackedStepsKey = `qf_v11_tracked_steps_${funnelContextRef.current.session_id}`;
|
|
10184
|
+
let isFirstTracking = false;
|
|
10169
10185
|
if (typeof sessionStorage !== "undefined") {
|
|
10170
10186
|
const hasStarted = sessionStorage.getItem(sessionKey);
|
|
10171
10187
|
if (!hasStarted) {
|
|
10188
|
+
isFirstTracking = true;
|
|
10172
10189
|
sessionStorage.setItem(sessionKey, "true");
|
|
10190
|
+
sessionStorage.setItem(trackedStepsKey, "[]");
|
|
10173
10191
|
trackStarted(funnelContextRef.current, currentStepId);
|
|
10174
10192
|
}
|
|
10175
10193
|
}
|
|
10194
|
+
let trackedSteps = [];
|
|
10195
|
+
if (typeof sessionStorage !== "undefined") {
|
|
10196
|
+
try {
|
|
10197
|
+
trackedSteps = JSON.parse(sessionStorage.getItem(trackedStepsKey) || "[]");
|
|
10198
|
+
} catch {
|
|
10199
|
+
trackedSteps = [];
|
|
10200
|
+
}
|
|
10201
|
+
}
|
|
10202
|
+
if (isFirstTracking && stepIndex > 0) {
|
|
10203
|
+
for (let i2 = 0; i2 < stepIndex; i2++) {
|
|
10204
|
+
const skippedStep = steps2[i2];
|
|
10205
|
+
if (!skippedStep || trackedSteps.includes(skippedStep.id)) continue;
|
|
10206
|
+
const skippedSchemaStep = SCHEMA_STEPS[skippedStep.id];
|
|
10207
|
+
const skippedQuestions = (skippedSchemaStep == null ? void 0 : skippedSchemaStep.questions) || [];
|
|
10208
|
+
skippedQuestions.forEach((question, qIdx) => {
|
|
10209
|
+
const value = answerOf(question.id);
|
|
10210
|
+
trackAnswerSelected(funnelContextRef.current, {
|
|
10211
|
+
step_id: skippedStep.id,
|
|
10212
|
+
step_index: i2,
|
|
10213
|
+
question_id: question.id,
|
|
10214
|
+
answer_value: serializeAnswerValue(value),
|
|
10215
|
+
is_last_question: qIdx === skippedQuestions.length - 1
|
|
10216
|
+
});
|
|
10217
|
+
});
|
|
10218
|
+
trackedSteps.push(skippedStep.id);
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
if (trackedSteps.includes(step2.id)) return;
|
|
10222
|
+
const schemaStep = SCHEMA_STEPS[step2.id];
|
|
10223
|
+
const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
|
|
10176
10224
|
questions2.forEach((question, questionIndex) => {
|
|
10177
10225
|
const currentValue = answerOf(question.id);
|
|
10178
10226
|
const isLastQuestion = questionIndex === questions2.length - 1;
|
|
@@ -10189,10 +10237,14 @@ function TrackingProvider({
|
|
|
10189
10237
|
step_id: step2.id,
|
|
10190
10238
|
step_index: stepIndex,
|
|
10191
10239
|
question_id: question.id,
|
|
10192
|
-
answer_value: currentValue
|
|
10240
|
+
answer_value: serializeAnswerValue(currentValue),
|
|
10193
10241
|
is_last_question: isLastQuestion
|
|
10194
10242
|
});
|
|
10195
10243
|
});
|
|
10244
|
+
trackedSteps.push(step2.id);
|
|
10245
|
+
if (typeof sessionStorage !== "undefined") {
|
|
10246
|
+
sessionStorage.setItem(trackedStepsKey, JSON.stringify(trackedSteps));
|
|
10247
|
+
}
|
|
10196
10248
|
}, [funnelContextRef, currentStepId, state, updateContext, answerOf]);
|
|
10197
10249
|
const trackAnswer = useCallback(
|
|
10198
10250
|
(questionId, value) => {
|