@heycater/qualification-funnel 1.13.0 → 1.15.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/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_v12_answer_selected", properties);
10088
+ captureEvent("qf_v13_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_v12_form_submitted", properties);
10106
+ captureEvent("qf_v13_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_v12_completed", properties);
10123
+ captureEvent("qf_v13_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_v12_abandoned", properties);
10142
+ captureEvent("qf_v13_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_v12_started", properties);
10150
+ captureEvent("qf_v13_started", properties);
10151
10151
  }
10152
10152
  function serializeAnswerValue(value) {
10153
10153
  if (value === void 0) return null;
@@ -10171,17 +10171,23 @@ function TrackingProvider({
10171
10171
  children
10172
10172
  }) {
10173
10173
  const { state, answerOf } = useQualification();
10174
- const trackStepCompletion = useCallback(() => {
10174
+ const trackStepCompletion = useCallback((currentValues) => {
10175
10175
  var _a2;
10176
10176
  if (!("qualification" in state)) return;
10177
10177
  const qual = state.qualification;
10178
10178
  if (!("step" in qual)) return;
10179
10179
  const step2 = qual.step;
10180
10180
  const stepIndex = qual.stepIndex;
10181
- const steps2 = ((_a2 = qual.steps) == null ? void 0 : _a2.filter((s3) => !s3.disabled)) || [];
10181
+ ((_a2 = qual.steps) == null ? void 0 : _a2.filter((s3) => !s3.disabled)) || [];
10182
+ const getValue2 = (questionId) => {
10183
+ if (currentValues && questionId in currentValues) {
10184
+ return currentValues[questionId];
10185
+ }
10186
+ return answerOf(questionId);
10187
+ };
10182
10188
  const serviceType = funnelContextRef.current.service_type || answerOf("service_type") || "";
10183
- const sessionKey = `qf_v12_started_${funnelContextRef.current.session_id}_${serviceType}`;
10184
- const trackedStepsKey = `qf_v12_tracked_steps_${funnelContextRef.current.session_id}_${serviceType}`;
10189
+ const sessionKey = `qf_v13_started_${funnelContextRef.current.session_id}_${serviceType}`;
10190
+ const trackedStepsKey = `qf_v13_tracked_steps_${funnelContextRef.current.session_id}_${serviceType}`;
10185
10191
  let isFirstTracking = false;
10186
10192
  if (typeof sessionStorage !== "undefined") {
10187
10193
  const hasStarted = sessionStorage.getItem(sessionKey);
@@ -10200,30 +10206,31 @@ function TrackingProvider({
10200
10206
  trackedSteps = [];
10201
10207
  }
10202
10208
  }
10203
- if (isFirstTracking && stepIndex > 0) {
10204
- for (let i2 = 0; i2 < stepIndex; i2++) {
10205
- const skippedStep = steps2[i2];
10206
- if (!skippedStep || trackedSteps.includes(skippedStep.id)) continue;
10207
- const skippedSchemaStep = SCHEMA_STEPS[skippedStep.id];
10209
+ if (isFirstTracking && stepIndex > 0 && isValidServiceType(serviceType)) {
10210
+ const stepOrder = getStepOrderForServiceType(serviceType);
10211
+ for (let i2 = 0; i2 < stepIndex && i2 < stepOrder.length; i2++) {
10212
+ const skippedStepId = stepOrder[i2];
10213
+ if (trackedSteps.includes(skippedStepId)) continue;
10214
+ const skippedSchemaStep = SCHEMA_STEPS[skippedStepId];
10208
10215
  const skippedQuestions = (skippedSchemaStep == null ? void 0 : skippedSchemaStep.questions) || [];
10209
10216
  skippedQuestions.forEach((question, qIdx) => {
10210
10217
  const value = answerOf(question.id);
10211
10218
  trackAnswerSelected(funnelContextRef.current, {
10212
- step_id: skippedStep.id,
10219
+ step_id: skippedStepId,
10213
10220
  step_index: i2,
10214
10221
  question_id: question.id,
10215
10222
  answer_value: serializeAnswerValue(value),
10216
10223
  is_last_question: qIdx === skippedQuestions.length - 1
10217
10224
  });
10218
10225
  });
10219
- trackedSteps.push(skippedStep.id);
10226
+ trackedSteps.push(skippedStepId);
10220
10227
  }
10221
10228
  }
10222
10229
  if (trackedSteps.includes(step2.id)) return;
10223
10230
  const schemaStep = SCHEMA_STEPS[step2.id];
10224
10231
  const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10225
10232
  questions2.forEach((question, questionIndex) => {
10226
- const currentValue = answerOf(question.id);
10233
+ const currentValue = getValue2(question.id);
10227
10234
  const isLastQuestion = questionIndex === questions2.length - 1;
10228
10235
  if (question.id === "service_type" && isValidServiceType(currentValue)) {
10229
10236
  const stepOrder = getStepOrderForServiceType(currentValue);
@@ -11657,6 +11664,7 @@ const EmbeddedQuestion = ({
11657
11664
  var _a2, _b, _c, _d, _e;
11658
11665
  const { t: t2 } = useTranslation();
11659
11666
  const { state, actions, answerOf } = useQualification();
11667
+ const { trackStepCompletion } = useTracking();
11660
11668
  const getTitleContent = useCallback(
11661
11669
  (title2) => renderTitle ? renderTitle(title2) : title2,
11662
11670
  []
@@ -11679,6 +11687,7 @@ const EmbeddedQuestion = ({
11679
11687
  selected: answerOf("city"),
11680
11688
  onSelect: (city) => {
11681
11689
  actions.answerQuestion("city", city);
11690
+ trackStepCompletion({ city });
11682
11691
  actions.nextStep();
11683
11692
  }
11684
11693
  }
@@ -11761,6 +11770,7 @@ const EmbeddedQuestion = ({
11761
11770
  selected: answerOf("service_type"),
11762
11771
  onSelect: (serviceType2) => {
11763
11772
  actions.answerQuestion("service_type", serviceType2);
11773
+ trackStepCompletion({ service_type: serviceType2 });
11764
11774
  actions.nextStep();
11765
11775
  }
11766
11776
  }
@@ -11802,6 +11812,7 @@ const EmbeddedQuestion = ({
11802
11812
  selected: answerOf("delivery_frequency"),
11803
11813
  onSelect: (frequency) => {
11804
11814
  actions.answerQuestion("delivery_frequency", frequency);
11815
+ trackStepCompletion({ delivery_frequency: frequency });
11805
11816
  actions.nextStep();
11806
11817
  }
11807
11818
  }
@@ -11845,6 +11856,7 @@ const EmbeddedQuestion = ({
11845
11856
  selected: answerOf("budget_range"),
11846
11857
  onSelect: (range2) => {
11847
11858
  actions.answerQuestion("budget_range", range2);
11859
+ trackStepCompletion({ budget_range: range2 });
11848
11860
  actions.nextStep();
11849
11861
  }
11850
11862
  }
@@ -12368,7 +12380,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12368
12380
  var ys = arrObjKeys(obj, inspect2);
12369
12381
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12370
12382
  var protoTag = obj instanceof Object ? "" : "null prototype";
12371
- var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
12383
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12372
12384
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12373
12385
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12374
12386
  if (ys.length === 0) {
@@ -12393,25 +12405,25 @@ function canTrustToString(obj) {
12393
12405
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12394
12406
  }
12395
12407
  function isArray$3(obj) {
12396
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12408
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
12397
12409
  }
12398
12410
  function isDate(obj) {
12399
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12411
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
12400
12412
  }
12401
12413
  function isRegExp$1(obj) {
12402
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12414
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12403
12415
  }
12404
12416
  function isError(obj) {
12405
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12417
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
12406
12418
  }
12407
12419
  function isString(obj) {
12408
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12420
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
12409
12421
  }
12410
12422
  function isNumber(obj) {
12411
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12423
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
12412
12424
  }
12413
12425
  function isBoolean(obj) {
12414
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12426
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12415
12427
  }
12416
12428
  function isSymbol(obj) {
12417
12429
  if (hasShammedSymbols) {
@@ -12447,7 +12459,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12447
12459
  function has$4(obj, key) {
12448
12460
  return hasOwn$1.call(obj, key);
12449
12461
  }
12450
- function toStr$1(obj) {
12462
+ function toStr(obj) {
12451
12463
  return objectToString.call(obj);
12452
12464
  }
12453
12465
  function nameOf(f) {
@@ -12756,7 +12768,7 @@ var syntax = SyntaxError;
12756
12768
  var uri = URIError;
12757
12769
  var abs$1 = Math.abs;
12758
12770
  var floor$1 = Math.floor;
12759
- var max$2 = Math.max;
12771
+ var max$1 = Math.max;
12760
12772
  var min$1 = Math.min;
12761
12773
  var pow$1 = Math.pow;
12762
12774
  var round$2 = Math.round;
@@ -12885,78 +12897,99 @@ function requireObject_getPrototypeOf() {
12885
12897
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12886
12898
  return Object_getPrototypeOf;
12887
12899
  }
12888
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12889
- var toStr = Object.prototype.toString;
12890
- var max$1 = Math.max;
12891
- var funcType = "[object Function]";
12892
- var concatty = function concatty2(a3, b2) {
12893
- var arr = [];
12894
- for (var i2 = 0; i2 < a3.length; i2 += 1) {
12895
- arr[i2] = a3[i2];
12896
- }
12897
- for (var j = 0; j < b2.length; j += 1) {
12898
- arr[j + a3.length] = b2[j];
12899
- }
12900
- return arr;
12901
- };
12902
- var slicy = function slicy2(arrLike, offset2) {
12903
- var arr = [];
12904
- for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12905
- arr[j] = arrLike[i2];
12906
- }
12907
- return arr;
12908
- };
12909
- var joiny = function(arr, joiner) {
12910
- var str = "";
12911
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
12912
- str += arr[i2];
12913
- if (i2 + 1 < arr.length) {
12914
- str += joiner;
12900
+ var implementation;
12901
+ var hasRequiredImplementation;
12902
+ function requireImplementation() {
12903
+ if (hasRequiredImplementation) return implementation;
12904
+ hasRequiredImplementation = 1;
12905
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12906
+ var toStr2 = Object.prototype.toString;
12907
+ var max2 = Math.max;
12908
+ var funcType = "[object Function]";
12909
+ var concatty = function concatty2(a3, b2) {
12910
+ var arr = [];
12911
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12912
+ arr[i2] = a3[i2];
12915
12913
  }
12916
- }
12917
- return str;
12918
- };
12919
- var implementation$1 = function bind(that) {
12920
- var target = this;
12921
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
12922
- throw new TypeError(ERROR_MESSAGE + target);
12923
- }
12924
- var args = slicy(arguments, 1);
12925
- var bound;
12926
- var binder = function() {
12927
- if (this instanceof bound) {
12928
- var result = target.apply(
12929
- this,
12930
- concatty(args, arguments)
12931
- );
12932
- if (Object(result) === result) {
12933
- return result;
12914
+ for (var j = 0; j < b2.length; j += 1) {
12915
+ arr[j + a3.length] = b2[j];
12916
+ }
12917
+ return arr;
12918
+ };
12919
+ var slicy = function slicy2(arrLike, offset2) {
12920
+ var arr = [];
12921
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12922
+ arr[j] = arrLike[i2];
12923
+ }
12924
+ return arr;
12925
+ };
12926
+ var joiny = function(arr, joiner) {
12927
+ var str = "";
12928
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12929
+ str += arr[i2];
12930
+ if (i2 + 1 < arr.length) {
12931
+ str += joiner;
12934
12932
  }
12935
- return this;
12936
12933
  }
12937
- return target.apply(
12938
- that,
12939
- concatty(args, arguments)
12940
- );
12934
+ return str;
12941
12935
  };
12942
- var boundLength = max$1(0, target.length - args.length);
12943
- var boundArgs = [];
12944
- for (var i2 = 0; i2 < boundLength; i2++) {
12945
- boundArgs[i2] = "$" + i2;
12946
- }
12947
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12948
- if (target.prototype) {
12949
- var Empty = function Empty2() {
12936
+ implementation = function bind2(that) {
12937
+ var target = this;
12938
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
12939
+ throw new TypeError(ERROR_MESSAGE + target);
12940
+ }
12941
+ var args = slicy(arguments, 1);
12942
+ var bound;
12943
+ var binder = function() {
12944
+ if (this instanceof bound) {
12945
+ var result = target.apply(
12946
+ this,
12947
+ concatty(args, arguments)
12948
+ );
12949
+ if (Object(result) === result) {
12950
+ return result;
12951
+ }
12952
+ return this;
12953
+ }
12954
+ return target.apply(
12955
+ that,
12956
+ concatty(args, arguments)
12957
+ );
12950
12958
  };
12951
- Empty.prototype = target.prototype;
12952
- bound.prototype = new Empty();
12953
- Empty.prototype = null;
12954
- }
12955
- return bound;
12956
- };
12957
- var implementation = implementation$1;
12958
- var functionBind = Function.prototype.bind || implementation;
12959
- var functionCall = Function.prototype.call;
12959
+ var boundLength = max2(0, target.length - args.length);
12960
+ var boundArgs = [];
12961
+ for (var i2 = 0; i2 < boundLength; i2++) {
12962
+ boundArgs[i2] = "$" + i2;
12963
+ }
12964
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12965
+ if (target.prototype) {
12966
+ var Empty = function Empty2() {
12967
+ };
12968
+ Empty.prototype = target.prototype;
12969
+ bound.prototype = new Empty();
12970
+ Empty.prototype = null;
12971
+ }
12972
+ return bound;
12973
+ };
12974
+ return implementation;
12975
+ }
12976
+ var functionBind;
12977
+ var hasRequiredFunctionBind;
12978
+ function requireFunctionBind() {
12979
+ if (hasRequiredFunctionBind) return functionBind;
12980
+ hasRequiredFunctionBind = 1;
12981
+ var implementation2 = requireImplementation();
12982
+ functionBind = Function.prototype.bind || implementation2;
12983
+ return functionBind;
12984
+ }
12985
+ var functionCall;
12986
+ var hasRequiredFunctionCall;
12987
+ function requireFunctionCall() {
12988
+ if (hasRequiredFunctionCall) return functionCall;
12989
+ hasRequiredFunctionCall = 1;
12990
+ functionCall = Function.prototype.call;
12991
+ return functionCall;
12992
+ }
12960
12993
  var functionApply;
12961
12994
  var hasRequiredFunctionApply;
12962
12995
  function requireFunctionApply() {
@@ -12966,14 +12999,14 @@ function requireFunctionApply() {
12966
12999
  return functionApply;
12967
13000
  }
12968
13001
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12969
- var bind$2 = functionBind;
13002
+ var bind$2 = requireFunctionBind();
12970
13003
  var $apply$1 = requireFunctionApply();
12971
- var $call$2 = functionCall;
13004
+ var $call$2 = requireFunctionCall();
12972
13005
  var $reflectApply = reflectApply;
12973
13006
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
12974
- var bind$1 = functionBind;
13007
+ var bind$1 = requireFunctionBind();
12975
13008
  var $TypeError$4 = type;
12976
- var $call$1 = functionCall;
13009
+ var $call$1 = requireFunctionCall();
12977
13010
  var $actualApply = actualApply;
12978
13011
  var callBindApplyHelpers = function callBindBasic(args) {
12979
13012
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -13039,8 +13072,8 @@ function requireHasown() {
13039
13072
  hasRequiredHasown = 1;
13040
13073
  var call = Function.prototype.call;
13041
13074
  var $hasOwn = Object.prototype.hasOwnProperty;
13042
- var bind3 = functionBind;
13043
- hasown = bind3.call(call, $hasOwn);
13075
+ var bind2 = requireFunctionBind();
13076
+ hasown = bind2.call(call, $hasOwn);
13044
13077
  return hasown;
13045
13078
  }
13046
13079
  var undefined$1;
@@ -13054,7 +13087,7 @@ var $TypeError$3 = type;
13054
13087
  var $URIError = uri;
13055
13088
  var abs = abs$1;
13056
13089
  var floor = floor$1;
13057
- var max = max$2;
13090
+ var max = max$1;
13058
13091
  var min = min$1;
13059
13092
  var pow = pow$1;
13060
13093
  var round$1 = round$2;
@@ -13088,7 +13121,7 @@ var getProto = requireGetProto();
13088
13121
  var $ObjectGPO = requireObject_getPrototypeOf();
13089
13122
  var $ReflectGPO = requireReflect_getPrototypeOf();
13090
13123
  var $apply = requireFunctionApply();
13091
- var $call = functionCall;
13124
+ var $call = requireFunctionCall();
13092
13125
  var needsEval = {};
13093
13126
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
13094
13127
  var INTRINSICS = {
@@ -13259,13 +13292,13 @@ var LEGACY_ALIASES = {
13259
13292
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13260
13293
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13261
13294
  };
13262
- var bind2 = functionBind;
13295
+ var bind = requireFunctionBind();
13263
13296
  var hasOwn = requireHasown();
13264
- var $concat = bind2.call($call, Array.prototype.concat);
13265
- var $spliceApply = bind2.call($apply, Array.prototype.splice);
13266
- var $replace = bind2.call($call, String.prototype.replace);
13267
- var $strSlice = bind2.call($call, String.prototype.slice);
13268
- var $exec = bind2.call($call, RegExp.prototype.exec);
13297
+ var $concat = bind.call($call, Array.prototype.concat);
13298
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
13299
+ var $replace = bind.call($call, String.prototype.replace);
13300
+ var $strSlice = bind.call($call, String.prototype.slice);
13301
+ var $exec = bind.call($call, RegExp.prototype.exec);
13269
13302
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13270
13303
  var reEscapeChar = /\\(\\)?/g;
13271
13304
  var stringToPath = function stringToPath2(string2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",
@@ -35,7 +35,9 @@
35
35
  "type-check": "tsc --noEmit",
36
36
  "test": "vitest",
37
37
  "test:ui": "vitest --ui",
38
- "test:coverage": "vitest --coverage"
38
+ "test:coverage": "vitest --coverage",
39
+ "test:e2e": "playwright test",
40
+ "test:e2e:ui": "playwright test --ui"
39
41
  },
40
42
  "peerDependencies": {
41
43
  "@bugsnag/js": "^7.5.4",
@@ -68,6 +70,7 @@
68
70
  "yup": "^0.32.9"
69
71
  },
70
72
  "devDependencies": {
73
+ "@playwright/test": "^1.58.2",
71
74
  "@svgr/rollup": "^8.1.0",
72
75
  "@testing-library/react": "^12.1.5",
73
76
  "@testing-library/react-hooks": "^8.0.1",