@heycater/qualification-funnel 1.14.0 → 1.16.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
@@ -10052,8 +10052,19 @@ const Adornment = styled.div`
10052
10052
  top: 50%;
10053
10053
  transform: translateY(-50%);
10054
10054
  `;
10055
+ const sessionSequence = /* @__PURE__ */ new Map();
10056
+ function getNextSequence(sessionId) {
10057
+ const current = sessionSequence.get(sessionId) || 0;
10058
+ const next = current + 1;
10059
+ sessionSequence.set(sessionId, next);
10060
+ return next;
10061
+ }
10055
10062
  function captureEvent(eventName, properties) {
10056
10063
  if (typeof window === "undefined") return;
10064
+ const sessionId = properties.session_id;
10065
+ if (sessionId) {
10066
+ properties.event_sequence = getNextSequence(sessionId);
10067
+ }
10057
10068
  if (window.posthog) {
10058
10069
  try {
10059
10070
  window.posthog.capture(eventName, properties);
@@ -10171,7 +10182,7 @@ function TrackingProvider({
10171
10182
  children
10172
10183
  }) {
10173
10184
  const { state, answerOf } = useQualification();
10174
- const trackStepCompletion = useCallback(() => {
10185
+ const trackStepCompletion = useCallback((currentValues) => {
10175
10186
  var _a2;
10176
10187
  if (!("qualification" in state)) return;
10177
10188
  const qual = state.qualification;
@@ -10179,6 +10190,12 @@ function TrackingProvider({
10179
10190
  const step2 = qual.step;
10180
10191
  const stepIndex = qual.stepIndex;
10181
10192
  ((_a2 = qual.steps) == null ? void 0 : _a2.filter((s3) => !s3.disabled)) || [];
10193
+ const getValue2 = (questionId) => {
10194
+ if (currentValues && questionId in currentValues) {
10195
+ return currentValues[questionId];
10196
+ }
10197
+ return answerOf(questionId);
10198
+ };
10182
10199
  const serviceType = funnelContextRef.current.service_type || answerOf("service_type") || "";
10183
10200
  const sessionKey = `qf_v13_started_${funnelContextRef.current.session_id}_${serviceType}`;
10184
10201
  const trackedStepsKey = `qf_v13_tracked_steps_${funnelContextRef.current.session_id}_${serviceType}`;
@@ -10224,7 +10241,7 @@ function TrackingProvider({
10224
10241
  const schemaStep = SCHEMA_STEPS[step2.id];
10225
10242
  const questions2 = (schemaStep == null ? void 0 : schemaStep.questions) || [];
10226
10243
  questions2.forEach((question, questionIndex) => {
10227
- const currentValue = answerOf(question.id);
10244
+ const currentValue = getValue2(question.id);
10228
10245
  const isLastQuestion = questionIndex === questions2.length - 1;
10229
10246
  if (question.id === "service_type" && isValidServiceType(currentValue)) {
10230
10247
  const stepOrder = getStepOrderForServiceType(currentValue);
@@ -11681,7 +11698,7 @@ const EmbeddedQuestion = ({
11681
11698
  selected: answerOf("city"),
11682
11699
  onSelect: (city) => {
11683
11700
  actions.answerQuestion("city", city);
11684
- trackStepCompletion();
11701
+ trackStepCompletion({ city });
11685
11702
  actions.nextStep();
11686
11703
  }
11687
11704
  }
@@ -11764,7 +11781,7 @@ const EmbeddedQuestion = ({
11764
11781
  selected: answerOf("service_type"),
11765
11782
  onSelect: (serviceType2) => {
11766
11783
  actions.answerQuestion("service_type", serviceType2);
11767
- trackStepCompletion();
11784
+ trackStepCompletion({ service_type: serviceType2 });
11768
11785
  actions.nextStep();
11769
11786
  }
11770
11787
  }
@@ -11806,7 +11823,7 @@ const EmbeddedQuestion = ({
11806
11823
  selected: answerOf("delivery_frequency"),
11807
11824
  onSelect: (frequency) => {
11808
11825
  actions.answerQuestion("delivery_frequency", frequency);
11809
- trackStepCompletion();
11826
+ trackStepCompletion({ delivery_frequency: frequency });
11810
11827
  actions.nextStep();
11811
11828
  }
11812
11829
  }
@@ -11850,7 +11867,7 @@ const EmbeddedQuestion = ({
11850
11867
  selected: answerOf("budget_range"),
11851
11868
  onSelect: (range2) => {
11852
11869
  actions.answerQuestion("budget_range", range2);
11853
- trackStepCompletion();
11870
+ trackStepCompletion({ budget_range: range2 });
11854
11871
  actions.nextStep();
11855
11872
  }
11856
11873
  }
@@ -12374,7 +12391,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12374
12391
  var ys = arrObjKeys(obj, inspect2);
12375
12392
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12376
12393
  var protoTag = obj instanceof Object ? "" : "null prototype";
12377
- var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
12394
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12378
12395
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12379
12396
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12380
12397
  if (ys.length === 0) {
@@ -12399,25 +12416,25 @@ function canTrustToString(obj) {
12399
12416
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12400
12417
  }
12401
12418
  function isArray$3(obj) {
12402
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12419
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
12403
12420
  }
12404
12421
  function isDate(obj) {
12405
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12422
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
12406
12423
  }
12407
12424
  function isRegExp$1(obj) {
12408
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12425
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12409
12426
  }
12410
12427
  function isError(obj) {
12411
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12428
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
12412
12429
  }
12413
12430
  function isString(obj) {
12414
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12431
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
12415
12432
  }
12416
12433
  function isNumber(obj) {
12417
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12434
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
12418
12435
  }
12419
12436
  function isBoolean(obj) {
12420
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12437
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12421
12438
  }
12422
12439
  function isSymbol(obj) {
12423
12440
  if (hasShammedSymbols) {
@@ -12453,7 +12470,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12453
12470
  function has$4(obj, key) {
12454
12471
  return hasOwn$1.call(obj, key);
12455
12472
  }
12456
- function toStr$1(obj) {
12473
+ function toStr(obj) {
12457
12474
  return objectToString.call(obj);
12458
12475
  }
12459
12476
  function nameOf(f) {
@@ -12762,7 +12779,7 @@ var syntax = SyntaxError;
12762
12779
  var uri = URIError;
12763
12780
  var abs$1 = Math.abs;
12764
12781
  var floor$1 = Math.floor;
12765
- var max$2 = Math.max;
12782
+ var max$1 = Math.max;
12766
12783
  var min$1 = Math.min;
12767
12784
  var pow$1 = Math.pow;
12768
12785
  var round$2 = Math.round;
@@ -12891,78 +12908,99 @@ function requireObject_getPrototypeOf() {
12891
12908
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12892
12909
  return Object_getPrototypeOf;
12893
12910
  }
12894
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12895
- var toStr = Object.prototype.toString;
12896
- var max$1 = Math.max;
12897
- var funcType = "[object Function]";
12898
- var concatty = function concatty2(a3, b2) {
12899
- var arr = [];
12900
- for (var i2 = 0; i2 < a3.length; i2 += 1) {
12901
- arr[i2] = a3[i2];
12902
- }
12903
- for (var j = 0; j < b2.length; j += 1) {
12904
- arr[j + a3.length] = b2[j];
12905
- }
12906
- return arr;
12907
- };
12908
- var slicy = function slicy2(arrLike, offset2) {
12909
- var arr = [];
12910
- for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12911
- arr[j] = arrLike[i2];
12912
- }
12913
- return arr;
12914
- };
12915
- var joiny = function(arr, joiner) {
12916
- var str = "";
12917
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
12918
- str += arr[i2];
12919
- if (i2 + 1 < arr.length) {
12920
- str += joiner;
12911
+ var implementation;
12912
+ var hasRequiredImplementation;
12913
+ function requireImplementation() {
12914
+ if (hasRequiredImplementation) return implementation;
12915
+ hasRequiredImplementation = 1;
12916
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12917
+ var toStr2 = Object.prototype.toString;
12918
+ var max2 = Math.max;
12919
+ var funcType = "[object Function]";
12920
+ var concatty = function concatty2(a3, b2) {
12921
+ var arr = [];
12922
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12923
+ arr[i2] = a3[i2];
12921
12924
  }
12922
- }
12923
- return str;
12924
- };
12925
- var implementation$1 = function bind(that) {
12926
- var target = this;
12927
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
12928
- throw new TypeError(ERROR_MESSAGE + target);
12929
- }
12930
- var args = slicy(arguments, 1);
12931
- var bound;
12932
- var binder = function() {
12933
- if (this instanceof bound) {
12934
- var result = target.apply(
12935
- this,
12936
- concatty(args, arguments)
12937
- );
12938
- if (Object(result) === result) {
12939
- return result;
12925
+ for (var j = 0; j < b2.length; j += 1) {
12926
+ arr[j + a3.length] = b2[j];
12927
+ }
12928
+ return arr;
12929
+ };
12930
+ var slicy = function slicy2(arrLike, offset2) {
12931
+ var arr = [];
12932
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12933
+ arr[j] = arrLike[i2];
12934
+ }
12935
+ return arr;
12936
+ };
12937
+ var joiny = function(arr, joiner) {
12938
+ var str = "";
12939
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12940
+ str += arr[i2];
12941
+ if (i2 + 1 < arr.length) {
12942
+ str += joiner;
12940
12943
  }
12941
- return this;
12942
12944
  }
12943
- return target.apply(
12944
- that,
12945
- concatty(args, arguments)
12946
- );
12945
+ return str;
12947
12946
  };
12948
- var boundLength = max$1(0, target.length - args.length);
12949
- var boundArgs = [];
12950
- for (var i2 = 0; i2 < boundLength; i2++) {
12951
- boundArgs[i2] = "$" + i2;
12952
- }
12953
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12954
- if (target.prototype) {
12955
- var Empty = function Empty2() {
12947
+ implementation = function bind2(that) {
12948
+ var target = this;
12949
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
12950
+ throw new TypeError(ERROR_MESSAGE + target);
12951
+ }
12952
+ var args = slicy(arguments, 1);
12953
+ var bound;
12954
+ var binder = function() {
12955
+ if (this instanceof bound) {
12956
+ var result = target.apply(
12957
+ this,
12958
+ concatty(args, arguments)
12959
+ );
12960
+ if (Object(result) === result) {
12961
+ return result;
12962
+ }
12963
+ return this;
12964
+ }
12965
+ return target.apply(
12966
+ that,
12967
+ concatty(args, arguments)
12968
+ );
12956
12969
  };
12957
- Empty.prototype = target.prototype;
12958
- bound.prototype = new Empty();
12959
- Empty.prototype = null;
12960
- }
12961
- return bound;
12962
- };
12963
- var implementation = implementation$1;
12964
- var functionBind = Function.prototype.bind || implementation;
12965
- var functionCall = Function.prototype.call;
12970
+ var boundLength = max2(0, target.length - args.length);
12971
+ var boundArgs = [];
12972
+ for (var i2 = 0; i2 < boundLength; i2++) {
12973
+ boundArgs[i2] = "$" + i2;
12974
+ }
12975
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12976
+ if (target.prototype) {
12977
+ var Empty = function Empty2() {
12978
+ };
12979
+ Empty.prototype = target.prototype;
12980
+ bound.prototype = new Empty();
12981
+ Empty.prototype = null;
12982
+ }
12983
+ return bound;
12984
+ };
12985
+ return implementation;
12986
+ }
12987
+ var functionBind;
12988
+ var hasRequiredFunctionBind;
12989
+ function requireFunctionBind() {
12990
+ if (hasRequiredFunctionBind) return functionBind;
12991
+ hasRequiredFunctionBind = 1;
12992
+ var implementation2 = requireImplementation();
12993
+ functionBind = Function.prototype.bind || implementation2;
12994
+ return functionBind;
12995
+ }
12996
+ var functionCall;
12997
+ var hasRequiredFunctionCall;
12998
+ function requireFunctionCall() {
12999
+ if (hasRequiredFunctionCall) return functionCall;
13000
+ hasRequiredFunctionCall = 1;
13001
+ functionCall = Function.prototype.call;
13002
+ return functionCall;
13003
+ }
12966
13004
  var functionApply;
12967
13005
  var hasRequiredFunctionApply;
12968
13006
  function requireFunctionApply() {
@@ -12972,14 +13010,14 @@ function requireFunctionApply() {
12972
13010
  return functionApply;
12973
13011
  }
12974
13012
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12975
- var bind$2 = functionBind;
13013
+ var bind$2 = requireFunctionBind();
12976
13014
  var $apply$1 = requireFunctionApply();
12977
- var $call$2 = functionCall;
13015
+ var $call$2 = requireFunctionCall();
12978
13016
  var $reflectApply = reflectApply;
12979
13017
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
12980
- var bind$1 = functionBind;
13018
+ var bind$1 = requireFunctionBind();
12981
13019
  var $TypeError$4 = type;
12982
- var $call$1 = functionCall;
13020
+ var $call$1 = requireFunctionCall();
12983
13021
  var $actualApply = actualApply;
12984
13022
  var callBindApplyHelpers = function callBindBasic(args) {
12985
13023
  if (args.length < 1 || typeof args[0] !== "function") {
@@ -13045,8 +13083,8 @@ function requireHasown() {
13045
13083
  hasRequiredHasown = 1;
13046
13084
  var call = Function.prototype.call;
13047
13085
  var $hasOwn = Object.prototype.hasOwnProperty;
13048
- var bind3 = functionBind;
13049
- hasown = bind3.call(call, $hasOwn);
13086
+ var bind2 = requireFunctionBind();
13087
+ hasown = bind2.call(call, $hasOwn);
13050
13088
  return hasown;
13051
13089
  }
13052
13090
  var undefined$1;
@@ -13060,7 +13098,7 @@ var $TypeError$3 = type;
13060
13098
  var $URIError = uri;
13061
13099
  var abs = abs$1;
13062
13100
  var floor = floor$1;
13063
- var max = max$2;
13101
+ var max = max$1;
13064
13102
  var min = min$1;
13065
13103
  var pow = pow$1;
13066
13104
  var round$1 = round$2;
@@ -13094,7 +13132,7 @@ var getProto = requireGetProto();
13094
13132
  var $ObjectGPO = requireObject_getPrototypeOf();
13095
13133
  var $ReflectGPO = requireReflect_getPrototypeOf();
13096
13134
  var $apply = requireFunctionApply();
13097
- var $call = functionCall;
13135
+ var $call = requireFunctionCall();
13098
13136
  var needsEval = {};
13099
13137
  var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
13100
13138
  var INTRINSICS = {
@@ -13265,13 +13303,13 @@ var LEGACY_ALIASES = {
13265
13303
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13266
13304
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13267
13305
  };
13268
- var bind2 = functionBind;
13306
+ var bind = requireFunctionBind();
13269
13307
  var hasOwn = requireHasown();
13270
- var $concat = bind2.call($call, Array.prototype.concat);
13271
- var $spliceApply = bind2.call($apply, Array.prototype.splice);
13272
- var $replace = bind2.call($call, String.prototype.replace);
13273
- var $strSlice = bind2.call($call, String.prototype.slice);
13274
- var $exec = bind2.call($call, RegExp.prototype.exec);
13308
+ var $concat = bind.call($call, Array.prototype.concat);
13309
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
13310
+ var $replace = bind.call($call, String.prototype.replace);
13311
+ var $strSlice = bind.call($call, String.prototype.slice);
13312
+ var $exec = bind.call($call, RegExp.prototype.exec);
13275
13313
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13276
13314
  var reEscapeChar = /\\(\\)?/g;
13277
13315
  var stringToPath = function stringToPath2(string2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.14.0",
3
+ "version": "1.16.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",