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.
@@ -17824,6 +17824,20 @@ function rollbar(type, msg) {
17824
17824
  }
17825
17825
  }
17826
17826
  }
17827
+ function analyticsEvent(event, body) {
17828
+ try {
17829
+ dbg(body);
17830
+ window._analytics.track(event, body, {
17831
+ plugins: {
17832
+ "google-tag-manager": false
17833
+ }
17834
+ });
17835
+ } catch (err) {
17836
+ var msg = "failed to fire event: " + err.toString();
17837
+ console.warn(msg);
17838
+ rollbar("warning", msg);
17839
+ }
17840
+ }
17827
17841
  function cookie(name, value, ttl, path, samesite, secure, domain) {
17828
17842
  name = name.replace(/\s/g, "_");
17829
17843
  var isSet2 = arguments.length > 1;
@@ -17970,27 +17984,36 @@ var fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
17970
17984
  console.warn(msg);
17971
17985
  rollbar("warning", msg);
17972
17986
  }
17973
- if (typeof window._analytics !== "undefined") {
17974
- try {
17975
- var form_id = formNode.attrs.formId || window.location.hostname + "-" + formNode.id;
17976
- var body = {
17977
- "form_source": "formkit",
17978
- "form_id": form_id,
17979
- "step_count": stepHistory2.value.length,
17980
- "step_name": stepHistory2.value[stepHistory2.value.length - 1],
17981
- "step_values": step_values
17982
- };
17983
- dbg(body);
17984
- window._analytics.track("form-step", body, {
17985
- plugins: {
17986
- "google-tag-manager": false
17987
- }
17988
- });
17989
- } catch (err) {
17990
- var _msg = "failed to fire step event: " + err.toString();
17991
- console.warn(_msg);
17992
- rollbar("warning", _msg);
17993
- }
17987
+ try {
17988
+ var form_id = formNode.attrs.formId || window.location.hostname + "-" + formNode.id;
17989
+ var body = {
17990
+ "form_source": "formkit",
17991
+ "form_id": form_id,
17992
+ "step_count": stepHistory2.value.length,
17993
+ "step_name": stepHistory2.value[stepHistory2.value.length - 1],
17994
+ "step_values": step_values
17995
+ };
17996
+ analyticsEvent("form-step", body);
17997
+ } catch (err) {
17998
+ var _msg = "failed to fire step event: " + err.toString();
17999
+ console.warn(_msg);
18000
+ rollbar("warning", _msg);
18001
+ }
18002
+ };
18003
+ var experimentCallback = (form2, variant, fromCache) => {
18004
+ try {
18005
+ var body = {
18006
+ "experiment": form2.experiment.name,
18007
+ "branch": variant.name,
18008
+ "schema": variant.schema,
18009
+ "no_cache": form2.noCache,
18010
+ "from_cache": fromCache
18011
+ };
18012
+ analyticsEvent("form-experiment", body);
18013
+ } catch (err) {
18014
+ var msg = "failed to fire experiment callback: " + err.toString();
18015
+ console.warn(msg);
18016
+ rollbar("warning", msg);
17994
18017
  }
17995
18018
  };
17996
18019
  var handleRedirect = (formData, node2) => {
@@ -22370,7 +22393,11 @@ var init = () => {
22370
22393
  var res = chooseVariant(form2.experiment);
22371
22394
  schema = res.variant.schema;
22372
22395
  if (form2.experimentCallback) {
22373
- experimentCallback(form2, res.variant, res.fromCache);
22396
+ if (form2.experimentCallback === true) {
22397
+ experimentCallback(form2, res.variant, res.fromCache);
22398
+ } else {
22399
+ form2.experimentCallback(form2, res.variant, res.fromCache);
22400
+ }
22374
22401
  }
22375
22402
  }
22376
22403
  var schemaObj = schema;