bhl-forms 0.0.66 → 0.0.69

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.
@@ -5897,6 +5897,9 @@ const dataDefaults = {
5897
5897
  if (!node || !key || !node.attrs.inputMap) {
5898
5898
  return true;
5899
5899
  }
5900
+ if (!(key in node.attrs.inputMap)) {
5901
+ return false;
5902
+ }
5900
5903
  if (node.attrs.inputMap[key].indexOf(inputName) < 0) {
5901
5904
  return false;
5902
5905
  }
@@ -11038,6 +11041,22 @@ function rollbar(type, msg) {
11038
11041
  }
11039
11042
  }
11040
11043
  }
11044
+ function analyticsEvent(event, body) {
11045
+ try {
11046
+ dbg(body);
11047
+ window._analytics.track(event, body, {
11048
+ plugins: {
11049
+ "google-tag-manager": false
11050
+ }
11051
+ });
11052
+ return true;
11053
+ } catch (err) {
11054
+ const msg = "failed to fire event: " + err.toString();
11055
+ console.warn(msg);
11056
+ rollbar("warning", msg);
11057
+ }
11058
+ return false;
11059
+ }
11041
11060
  function cookie(name, value, ttl, path, samesite, secure, domain) {
11042
11061
  name = name.replace(/\s/g, "_");
11043
11062
  var isSet2 = arguments.length > 1;
@@ -11177,27 +11196,38 @@ const fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
11177
11196
  console.warn(msg);
11178
11197
  rollbar("warning", msg);
11179
11198
  }
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
- }
11199
+ try {
11200
+ const form_id = formNode.attrs.formId || window.location.hostname + "-" + formNode.id;
11201
+ var body = {
11202
+ "form_source": "formkit",
11203
+ "form_id": form_id,
11204
+ "step_count": stepHistory2.value.length,
11205
+ "step_name": stepHistory2.value[stepHistory2.value.length - 1],
11206
+ "step_values": step_values
11207
+ };
11208
+ analyticsEvent("form-step", body);
11209
+ } catch (err) {
11210
+ const msg = "failed to fire step event: " + err.toString();
11211
+ console.warn(msg);
11212
+ rollbar("warning", msg);
11213
+ }
11214
+ };
11215
+ const experimentCallback = (form2, variant, fromCache) => {
11216
+ dbg("default experimentCallback", form2, variant, fromCache);
11217
+ try {
11218
+ var body = {
11219
+ "experiment": form2.experiment.name,
11220
+ "branch": variant.name,
11221
+ "schema": variant.schema,
11222
+ "no_cache": form2.noCache,
11223
+ "from_cache": fromCache
11224
+ };
11225
+ const res = analyticsEvent("form-experiment", body);
11226
+ dbg("experimentCallback event", res);
11227
+ } catch (err) {
11228
+ const msg = "failed to fire experiment callback: " + err.toString();
11229
+ console.warn(msg);
11230
+ rollbar("warning", msg);
11201
11231
  }
11202
11232
  };
11203
11233
  const handleRedirect = (formData, node) => {
@@ -15600,7 +15630,12 @@ const init = () => {
15600
15630
  const res = chooseVariant(form2.experiment);
15601
15631
  schema = res.variant.schema;
15602
15632
  if (form2.experimentCallback) {
15603
- experimentCallback(form2, res.variant, res.fromCache);
15633
+ dbg("form.experimentCallback", form2.experimentCallback);
15634
+ if (form2.experimentCallback === true) {
15635
+ experimentCallback(form2, res.variant, res.fromCache);
15636
+ } else {
15637
+ form2.experimentCallback(form2, res.variant, res.fromCache);
15638
+ }
15604
15639
  }
15605
15640
  }
15606
15641
  let schemaObj = schema;