@heycater/qualification-funnel 1.4.3 → 1.4.6

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
@@ -11028,12 +11028,20 @@ function getContextualProperties(state) {
11028
11028
  }
11029
11029
  return props;
11030
11030
  }
11031
- function trackFunnelEvent(action2, properties) {
11032
- const eventName = `funnel_${action2}`;
11031
+ function capturePostHogEvent(eventName, properties, retryCount = 0) {
11033
11032
  if (typeof window === "undefined") return;
11034
- if (window.posthog) {
11033
+ if (window.posthog && window.posthog.__loaded) {
11034
+ window.posthog.capture(eventName, properties);
11035
+ } else if (window.posthog && retryCount < 3) {
11036
+ setTimeout(() => capturePostHogEvent(eventName, properties, retryCount + 1), 100);
11037
+ } else if (window.posthog) {
11035
11038
  window.posthog.capture(eventName, properties);
11036
11039
  }
11040
+ }
11041
+ function trackFunnelEvent(action2, properties) {
11042
+ const eventName = `qualification_funnel_${action2}`;
11043
+ if (typeof window === "undefined") return;
11044
+ capturePostHogEvent(eventName, properties);
11037
11045
  if (window.dataLayer) {
11038
11046
  window.dataLayer.push({
11039
11047
  event: eventName,
@@ -11057,10 +11065,12 @@ function trackStepViewed(mode, stepId, stepIndex, totalSteps, contextProps) {
11057
11065
  ...contextProps
11058
11066
  });
11059
11067
  }
11060
- function trackAnswerSelected(mode, stepId, questionId, value, contextProps) {
11068
+ function trackAnswerSelected(mode, stepId, stepIndex, totalSteps, questionId, value, contextProps) {
11061
11069
  trackFunnelEvent("answer_selected", {
11062
11070
  funnel_mode: mode,
11063
11071
  step_id: stepId,
11072
+ step_index: stepIndex,
11073
+ total_steps: totalSteps,
11064
11074
  question_id: questionId,
11065
11075
  answer_value: value,
11066
11076
  ...contextProps
@@ -11093,11 +11103,21 @@ function TrackingProvider({
11093
11103
  currentStepId,
11094
11104
  children
11095
11105
  }) {
11106
+ const { state } = useQualification();
11096
11107
  const trackAnswer = useCallback(
11097
11108
  (questionId, value) => {
11098
- trackAnswerSelected(mode, currentStepId, questionId, value);
11109
+ if (!currentStepId) return;
11110
+ if (!("qualification" in state)) return;
11111
+ const stepIndex = state.qualification.stepIndex;
11112
+ const totalSteps = state.qualification.steps.filter((s3) => !s3.disabled).length;
11113
+ const contextProps = {
11114
+ ...getContextualProperties(state),
11115
+ ...questionId === "service_type" && { service_type: value },
11116
+ ...questionId === "city" && { city: value }
11117
+ };
11118
+ trackAnswerSelected(mode, currentStepId, stepIndex, totalSteps, questionId, value, contextProps);
11099
11119
  },
11100
- [mode, currentStepId]
11120
+ [currentStepId, mode, state]
11101
11121
  );
11102
11122
  return /* @__PURE__ */ jsx(TrackingContext.Provider, { value: { mode, currentStepId, trackAnswer }, children });
11103
11123
  }
@@ -12201,7 +12221,7 @@ var objectInspect = function inspect_(obj, options, depth, seen) {
12201
12221
  var ys = arrObjKeys(obj, inspect2);
12202
12222
  var isPlainObject2 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
12203
12223
  var protoTag = obj instanceof Object ? "" : "null prototype";
12204
- var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr$1(obj), 8, -1) : protoTag ? "Object" : "";
12224
+ var stringTag2 = !isPlainObject2 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
12205
12225
  var constructorTag = isPlainObject2 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
12206
12226
  var tag = constructorTag + (stringTag2 || protoTag ? "[" + $join.call($concat$1.call([], stringTag2 || [], protoTag || []), ": ") + "] " : "");
12207
12227
  if (ys.length === 0) {
@@ -12226,25 +12246,25 @@ function canTrustToString(obj) {
12226
12246
  return !toStringTag || !(typeof obj === "object" && (toStringTag in obj || typeof obj[toStringTag] !== "undefined"));
12227
12247
  }
12228
12248
  function isArray$3(obj) {
12229
- return toStr$1(obj) === "[object Array]" && canTrustToString(obj);
12249
+ return toStr(obj) === "[object Array]" && canTrustToString(obj);
12230
12250
  }
12231
12251
  function isDate(obj) {
12232
- return toStr$1(obj) === "[object Date]" && canTrustToString(obj);
12252
+ return toStr(obj) === "[object Date]" && canTrustToString(obj);
12233
12253
  }
12234
12254
  function isRegExp$1(obj) {
12235
- return toStr$1(obj) === "[object RegExp]" && canTrustToString(obj);
12255
+ return toStr(obj) === "[object RegExp]" && canTrustToString(obj);
12236
12256
  }
12237
12257
  function isError(obj) {
12238
- return toStr$1(obj) === "[object Error]" && canTrustToString(obj);
12258
+ return toStr(obj) === "[object Error]" && canTrustToString(obj);
12239
12259
  }
12240
12260
  function isString(obj) {
12241
- return toStr$1(obj) === "[object String]" && canTrustToString(obj);
12261
+ return toStr(obj) === "[object String]" && canTrustToString(obj);
12242
12262
  }
12243
12263
  function isNumber(obj) {
12244
- return toStr$1(obj) === "[object Number]" && canTrustToString(obj);
12264
+ return toStr(obj) === "[object Number]" && canTrustToString(obj);
12245
12265
  }
12246
12266
  function isBoolean(obj) {
12247
- return toStr$1(obj) === "[object Boolean]" && canTrustToString(obj);
12267
+ return toStr(obj) === "[object Boolean]" && canTrustToString(obj);
12248
12268
  }
12249
12269
  function isSymbol(obj) {
12250
12270
  if (hasShammedSymbols) {
@@ -12280,7 +12300,7 @@ var hasOwn$1 = Object.prototype.hasOwnProperty || function(key) {
12280
12300
  function has$4(obj, key) {
12281
12301
  return hasOwn$1.call(obj, key);
12282
12302
  }
12283
- function toStr$1(obj) {
12303
+ function toStr(obj) {
12284
12304
  return objectToString.call(obj);
12285
12305
  }
12286
12306
  function nameOf(f) {
@@ -12589,7 +12609,7 @@ var syntax = SyntaxError;
12589
12609
  var uri = URIError;
12590
12610
  var abs$1 = Math.abs;
12591
12611
  var floor$1 = Math.floor;
12592
- var max$2 = Math.max;
12612
+ var max$1 = Math.max;
12593
12613
  var min$1 = Math.min;
12594
12614
  var pow$1 = Math.pow;
12595
12615
  var round$2 = Math.round;
@@ -12718,77 +12738,91 @@ function requireObject_getPrototypeOf() {
12718
12738
  Object_getPrototypeOf = $Object2.getPrototypeOf || null;
12719
12739
  return Object_getPrototypeOf;
12720
12740
  }
12721
- var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12722
- var toStr = Object.prototype.toString;
12723
- var max$1 = Math.max;
12724
- var funcType = "[object Function]";
12725
- var concatty = function concatty2(a3, b2) {
12726
- var arr = [];
12727
- for (var i2 = 0; i2 < a3.length; i2 += 1) {
12728
- arr[i2] = a3[i2];
12729
- }
12730
- for (var j = 0; j < b2.length; j += 1) {
12731
- arr[j + a3.length] = b2[j];
12732
- }
12733
- return arr;
12734
- };
12735
- var slicy = function slicy2(arrLike, offset2) {
12736
- var arr = [];
12737
- for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12738
- arr[j] = arrLike[i2];
12739
- }
12740
- return arr;
12741
- };
12742
- var joiny = function(arr, joiner) {
12743
- var str = "";
12744
- for (var i2 = 0; i2 < arr.length; i2 += 1) {
12745
- str += arr[i2];
12746
- if (i2 + 1 < arr.length) {
12747
- str += joiner;
12741
+ var implementation;
12742
+ var hasRequiredImplementation;
12743
+ function requireImplementation() {
12744
+ if (hasRequiredImplementation) return implementation;
12745
+ hasRequiredImplementation = 1;
12746
+ var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
12747
+ var toStr2 = Object.prototype.toString;
12748
+ var max2 = Math.max;
12749
+ var funcType = "[object Function]";
12750
+ var concatty = function concatty2(a3, b2) {
12751
+ var arr = [];
12752
+ for (var i2 = 0; i2 < a3.length; i2 += 1) {
12753
+ arr[i2] = a3[i2];
12748
12754
  }
12749
- }
12750
- return str;
12751
- };
12752
- var implementation$1 = function bind(that) {
12753
- var target = this;
12754
- if (typeof target !== "function" || toStr.apply(target) !== funcType) {
12755
- throw new TypeError(ERROR_MESSAGE + target);
12756
- }
12757
- var args = slicy(arguments, 1);
12758
- var bound;
12759
- var binder = function() {
12760
- if (this instanceof bound) {
12761
- var result = target.apply(
12762
- this,
12763
- concatty(args, arguments)
12764
- );
12765
- if (Object(result) === result) {
12766
- return result;
12755
+ for (var j = 0; j < b2.length; j += 1) {
12756
+ arr[j + a3.length] = b2[j];
12757
+ }
12758
+ return arr;
12759
+ };
12760
+ var slicy = function slicy2(arrLike, offset2) {
12761
+ var arr = [];
12762
+ for (var i2 = offset2, j = 0; i2 < arrLike.length; i2 += 1, j += 1) {
12763
+ arr[j] = arrLike[i2];
12764
+ }
12765
+ return arr;
12766
+ };
12767
+ var joiny = function(arr, joiner) {
12768
+ var str = "";
12769
+ for (var i2 = 0; i2 < arr.length; i2 += 1) {
12770
+ str += arr[i2];
12771
+ if (i2 + 1 < arr.length) {
12772
+ str += joiner;
12767
12773
  }
12768
- return this;
12769
12774
  }
12770
- return target.apply(
12771
- that,
12772
- concatty(args, arguments)
12773
- );
12775
+ return str;
12774
12776
  };
12775
- var boundLength = max$1(0, target.length - args.length);
12776
- var boundArgs = [];
12777
- for (var i2 = 0; i2 < boundLength; i2++) {
12778
- boundArgs[i2] = "$" + i2;
12779
- }
12780
- bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12781
- if (target.prototype) {
12782
- var Empty = function Empty2() {
12777
+ implementation = function bind2(that) {
12778
+ var target = this;
12779
+ if (typeof target !== "function" || toStr2.apply(target) !== funcType) {
12780
+ throw new TypeError(ERROR_MESSAGE + target);
12781
+ }
12782
+ var args = slicy(arguments, 1);
12783
+ var bound;
12784
+ var binder = function() {
12785
+ if (this instanceof bound) {
12786
+ var result = target.apply(
12787
+ this,
12788
+ concatty(args, arguments)
12789
+ );
12790
+ if (Object(result) === result) {
12791
+ return result;
12792
+ }
12793
+ return this;
12794
+ }
12795
+ return target.apply(
12796
+ that,
12797
+ concatty(args, arguments)
12798
+ );
12783
12799
  };
12784
- Empty.prototype = target.prototype;
12785
- bound.prototype = new Empty();
12786
- Empty.prototype = null;
12787
- }
12788
- return bound;
12789
- };
12790
- var implementation = implementation$1;
12791
- var functionBind = Function.prototype.bind || implementation;
12800
+ var boundLength = max2(0, target.length - args.length);
12801
+ var boundArgs = [];
12802
+ for (var i2 = 0; i2 < boundLength; i2++) {
12803
+ boundArgs[i2] = "$" + i2;
12804
+ }
12805
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
12806
+ if (target.prototype) {
12807
+ var Empty = function Empty2() {
12808
+ };
12809
+ Empty.prototype = target.prototype;
12810
+ bound.prototype = new Empty();
12811
+ Empty.prototype = null;
12812
+ }
12813
+ return bound;
12814
+ };
12815
+ return implementation;
12816
+ }
12817
+ var functionBind;
12818
+ var hasRequiredFunctionBind;
12819
+ function requireFunctionBind() {
12820
+ if (hasRequiredFunctionBind) return functionBind;
12821
+ hasRequiredFunctionBind = 1;
12822
+ var implementation2 = requireImplementation();
12823
+ functionBind = Function.prototype.bind || implementation2;
12824
+ return functionBind;
12825
+ }
12792
12826
  var functionCall = Function.prototype.call;
12793
12827
  var functionApply;
12794
12828
  var hasRequiredFunctionApply;
@@ -12799,12 +12833,12 @@ function requireFunctionApply() {
12799
12833
  return functionApply;
12800
12834
  }
12801
12835
  var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
12802
- var bind$2 = functionBind;
12836
+ var bind$2 = requireFunctionBind();
12803
12837
  var $apply$1 = requireFunctionApply();
12804
12838
  var $call$2 = functionCall;
12805
12839
  var $reflectApply = reflectApply;
12806
12840
  var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
12807
- var bind$1 = functionBind;
12841
+ var bind$1 = requireFunctionBind();
12808
12842
  var $TypeError$4 = type;
12809
12843
  var $call$1 = functionCall;
12810
12844
  var $actualApply = actualApply;
@@ -12872,8 +12906,8 @@ function requireHasown() {
12872
12906
  hasRequiredHasown = 1;
12873
12907
  var call = Function.prototype.call;
12874
12908
  var $hasOwn = Object.prototype.hasOwnProperty;
12875
- var bind3 = functionBind;
12876
- hasown = bind3.call(call, $hasOwn);
12909
+ var bind2 = requireFunctionBind();
12910
+ hasown = bind2.call(call, $hasOwn);
12877
12911
  return hasown;
12878
12912
  }
12879
12913
  var undefined$1;
@@ -12887,7 +12921,7 @@ var $TypeError$3 = type;
12887
12921
  var $URIError = uri;
12888
12922
  var abs = abs$1;
12889
12923
  var floor = floor$1;
12890
- var max = max$2;
12924
+ var max = max$1;
12891
12925
  var min = min$1;
12892
12926
  var pow = pow$1;
12893
12927
  var round$1 = round$2;
@@ -13092,13 +13126,13 @@ var LEGACY_ALIASES = {
13092
13126
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
13093
13127
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
13094
13128
  };
13095
- var bind2 = functionBind;
13129
+ var bind = requireFunctionBind();
13096
13130
  var hasOwn = requireHasown();
13097
- var $concat = bind2.call($call, Array.prototype.concat);
13098
- var $spliceApply = bind2.call($apply, Array.prototype.splice);
13099
- var $replace = bind2.call($call, String.prototype.replace);
13100
- var $strSlice = bind2.call($call, String.prototype.slice);
13101
- var $exec = bind2.call($call, RegExp.prototype.exec);
13131
+ var $concat = bind.call($call, Array.prototype.concat);
13132
+ var $spliceApply = bind.call($apply, Array.prototype.splice);
13133
+ var $replace = bind.call($call, String.prototype.replace);
13134
+ var $strSlice = bind.call($call, String.prototype.slice);
13135
+ var $exec = bind.call($call, RegExp.prototype.exec);
13102
13136
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
13103
13137
  var reEscapeChar = /\\(\\)?/g;
13104
13138
  var stringToPath = function stringToPath2(string2) {
@@ -29818,7 +29852,7 @@ const EmbeddedFunnel = React__default.forwardRef(
29818
29852
  var _a3, _b2;
29819
29853
  const sessionId = "qualification" in state ? (_b2 = (_a3 = state.qualification) == null ? void 0 : _a3.sessionInfo) == null ? void 0 : _b2.sessionId : null;
29820
29854
  if (!sessionId) return;
29821
- const trackingKey = `funnel_started_${sessionId}`;
29855
+ const trackingKey = `qualification_funnel_started_${sessionId}`;
29822
29856
  let alreadyTracked = false;
29823
29857
  try {
29824
29858
  alreadyTracked = sessionStorage.getItem(trackingKey) === "true";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycater/qualification-funnel",
3
- "version": "1.4.3",
3
+ "version": "1.4.6",
4
4
  "type": "module",
5
5
  "description": "Heycater embedded qualification funnel widget",
6
6
  "main": "dist/index.cjs.js",
@@ -35,8 +35,6 @@
35
35
  "type-check": "tsc --noEmit"
36
36
  },
37
37
  "peerDependencies": {
38
- "react": "^17.0.2 || ^18.0.0",
39
- "react-dom": "^17.0.2 || ^18.0.0",
40
38
  "@bugsnag/js": "^7.5.4",
41
39
  "@bugsnag/plugin-react": "^7.5.4",
42
40
  "@material-ui/core": "^4.12.0",
@@ -44,7 +42,9 @@
44
42
  "@material-ui/system": "^4.12.2",
45
43
  "formik": "^2.2.9",
46
44
  "i18next": "^19.8.4",
45
+ "react": "^17.0.2 || ^18.0.0",
47
46
  "react-day-picker": "^8.8.0",
47
+ "react-dom": "^17.0.2 || ^18.0.0",
48
48
  "react-i18next": "^11.8.3",
49
49
  "react-intersection-observer": "^8.34.0",
50
50
  "styled-components": "^5.1.1",