bhl-forms 0.0.66 → 0.0.67

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.
@@ -11038,6 +11038,20 @@ function rollbar(type, msg) {
11038
11038
  }
11039
11039
  }
11040
11040
  }
11041
+ function analyticsEvent(event, body) {
11042
+ try {
11043
+ dbg(body);
11044
+ window._analytics.track(event, body, {
11045
+ plugins: {
11046
+ "google-tag-manager": false
11047
+ }
11048
+ });
11049
+ } catch (err) {
11050
+ const msg = "failed to fire event: " + err.toString();
11051
+ console.warn(msg);
11052
+ rollbar("warning", msg);
11053
+ }
11054
+ }
11041
11055
  function cookie(name, value, ttl, path, samesite, secure, domain) {
11042
11056
  name = name.replace(/\s/g, "_");
11043
11057
  var isSet2 = arguments.length > 1;
@@ -11177,27 +11191,36 @@ const fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
11177
11191
  console.warn(msg);
11178
11192
  rollbar("warning", msg);
11179
11193
  }
11180
- if (typeof window._analytics !== "undefined") {
11181
- try {
11182
- const form_id = formNode.attrs.formId || window.location.hostname + "-" + formNode.id;
11183
- var body = {
11184
- "form_source": "formkit",
11185
- "form_id": form_id,
11186
- "step_count": stepHistory2.value.length,
11187
- "step_name": stepHistory2.value[stepHistory2.value.length - 1],
11188
- "step_values": step_values
11189
- };
11190
- dbg(body);
11191
- window._analytics.track("form-step", body, {
11192
- plugins: {
11193
- "google-tag-manager": false
11194
- }
11195
- });
11196
- } catch (err) {
11197
- const msg = "failed to fire step event: " + err.toString();
11198
- console.warn(msg);
11199
- rollbar("warning", msg);
11200
- }
11194
+ try {
11195
+ const form_id = formNode.attrs.formId || window.location.hostname + "-" + formNode.id;
11196
+ var body = {
11197
+ "form_source": "formkit",
11198
+ "form_id": form_id,
11199
+ "step_count": stepHistory2.value.length,
11200
+ "step_name": stepHistory2.value[stepHistory2.value.length - 1],
11201
+ "step_values": step_values
11202
+ };
11203
+ analyticsEvent("form-step", body);
11204
+ } catch (err) {
11205
+ const msg = "failed to fire step event: " + err.toString();
11206
+ console.warn(msg);
11207
+ rollbar("warning", msg);
11208
+ }
11209
+ };
11210
+ const experimentCallback = (form2, variant, fromCache) => {
11211
+ try {
11212
+ var body = {
11213
+ "experiment": form2.experiment.name,
11214
+ "branch": variant.name,
11215
+ "schema": variant.schema,
11216
+ "no_cache": form2.noCache,
11217
+ "from_cache": fromCache
11218
+ };
11219
+ analyticsEvent("form-experiment", body);
11220
+ } catch (err) {
11221
+ const msg = "failed to fire experiment callback: " + err.toString();
11222
+ console.warn(msg);
11223
+ rollbar("warning", msg);
11201
11224
  }
11202
11225
  };
11203
11226
  const handleRedirect = (formData, node) => {
@@ -15600,7 +15623,11 @@ const init = () => {
15600
15623
  const res = chooseVariant(form2.experiment);
15601
15624
  schema = res.variant.schema;
15602
15625
  if (form2.experimentCallback) {
15603
- experimentCallback(form2, res.variant, res.fromCache);
15626
+ if (form2.experimentCallback === true) {
15627
+ experimentCallback(form2, res.variant, res.fromCache);
15628
+ } else {
15629
+ form2.experimentCallback(form2, res.variant, res.fromCache);
15630
+ }
15604
15631
  }
15605
15632
  }
15606
15633
  let schemaObj = schema;