@codebards/ik-embeddable-form 0.0.2736696173-qa → 0.0.2736851469-qa

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/embed.js CHANGED
@@ -2050,7 +2050,8 @@ var IKEmbeddableFormBundle = function(exports) {
2050
2050
  Region: formData.region ?? (ctx == null ? void 0 : ctx.region) ?? "",
2051
2051
  step,
2052
2052
  data_click_id: resolveClickId(formData),
2053
- ab_bucket_json: JSON.stringify({ gql_yoe_dropdown_ab: "" })
2053
+ ab_bucket_json: JSON.stringify({ gql_yoe_dropdown_ab: "" }),
2054
+ fingerprint_id: getFingerprintId()
2054
2055
  };
2055
2056
  }
2056
2057
  async function postClickstream(url, apiKey, datasetId, tableId, row) {
@@ -2463,7 +2464,7 @@ var IKEmbeddableFormBundle = function(exports) {
2463
2464
  }
2464
2465
  startSlotsPrefetch() {
2465
2466
  if (!this.needsSlotsPrefetch() || this.slotsPrefetchPromise) return;
2466
- this.mergeFormData({ slotsLoading: true });
2467
+ this.mergeFormData({ slotsLoading: true }, true);
2467
2468
  const earlyPrefetch = getSlotsPrefetchPromise();
2468
2469
  const prefetch = earlyPrefetch ? earlyPrefetch.then((result) => {
2469
2470
  this.applySlotFetchResult(result);
@@ -2836,11 +2837,12 @@ var IKEmbeddableFormBundle = function(exports) {
2836
2837
  });
2837
2838
  return data;
2838
2839
  }
2839
- mergeFormData(incoming) {
2840
+ mergeFormData(incoming, notify = false) {
2840
2841
  this.state = {
2841
2842
  ...this.state,
2842
2843
  formData: { ...this.state.formData, ...incoming }
2843
2844
  };
2845
+ if (notify) this.notifyListeners();
2844
2846
  }
2845
2847
  /**
2846
2848
  * Like `mergeFormData`, but notifies subscribers so the UI re-renders.
@@ -2853,6 +2855,9 @@ var IKEmbeddableFormBundle = function(exports) {
2853
2855
  }
2854
2856
  setState(partial) {
2855
2857
  this.state = { ...this.state, ...partial };
2858
+ this.notifyListeners();
2859
+ }
2860
+ notifyListeners() {
2856
2861
  this.listeners.forEach((l2) => l2(this.getState()));
2857
2862
  }
2858
2863
  }
@@ -2988,6 +2993,10 @@ var IKEmbeddableFormBundle = function(exports) {
2988
2993
  lastName: parts.slice(1).join(" ") || (parts[0] ?? "")
2989
2994
  };
2990
2995
  }
2996
+ function customerIdFields(context) {
2997
+ const customerId = str(context.openConfig.customerId);
2998
+ return customerId ? { customer_id: customerId } : {};
2999
+ }
2991
3000
  function resolveUtmMedium(context) {
2992
3001
  return resolveWordPressUtmMedium(
2993
3002
  context.visitorId,
@@ -3015,6 +3024,7 @@ var IKEmbeddableFormBundle = function(exports) {
3015
3024
  const { firstName, lastName } = resolveName(formData);
3016
3025
  const webinarType = resolveEffectiveWebinarType(formData, context.webinarType);
3017
3026
  return {
3027
+ ...customerIdFields(context),
3018
3028
  "First Name": firstName,
3019
3029
  "Last Name": lastName,
3020
3030
  "Email Address": email(formData.email),
@@ -3094,6 +3104,7 @@ var IKEmbeddableFormBundle = function(exports) {
3094
3104
  const gaEventId = Date.now();
3095
3105
  const { firstName, lastName } = resolveName(formData);
3096
3106
  return {
3107
+ ...customerIdFields(context),
3097
3108
  "First Name": firstName,
3098
3109
  "Last Name": lastName,
3099
3110
  "Email Address": email(formData.email),
@@ -3165,6 +3176,7 @@ var IKEmbeddableFormBundle = function(exports) {
3165
3176
  const linkedIn = str(formData.linkedIn).trim();
3166
3177
  const resumeBase64 = str(formData.resumeFileBase64).trim();
3167
3178
  return {
3179
+ ...customerIdFields(context),
3168
3180
  Lead_Created_Time: formatLeadCreatedTime(formData.leadCreatedTime),
3169
3181
  Page_URL: encodeURIComponent(context.pageUrl),
3170
3182
  "First Name": firstName,
@@ -3287,6 +3299,10 @@ var IKEmbeddableFormBundle = function(exports) {
3287
3299
  return url.toString();
3288
3300
  }
3289
3301
  buildBody(contract, formData) {
3302
+ const body = this.buildRawBody(contract, formData);
3303
+ return { ...body, fingerprint_id: getFingerprintId() };
3304
+ }
3305
+ buildRawBody(contract, formData) {
3290
3306
  if (contract.payloadBuilder) {
3291
3307
  return buildPayload(contract.payloadBuilder, formData);
3292
3308
  }
@@ -3311,7 +3327,13 @@ var IKEmbeddableFormBundle = function(exports) {
3311
3327
  }
3312
3328
  async fetchWithRetry(url, init, retriesLeft, timeoutMs) {
3313
3329
  const controller = new AbortController();
3314
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
3330
+ let timedOut = false;
3331
+ const timeoutId = setTimeout(() => {
3332
+ timedOut = true;
3333
+ controller.abort(
3334
+ new DOMException(`Request timed out after ${timeoutMs}ms`, "TimeoutError")
3335
+ );
3336
+ }, timeoutMs);
3315
3337
  try {
3316
3338
  const res = await fetch(url, { ...init, signal: controller.signal });
3317
3339
  clearTimeout(timeoutId);
@@ -3328,13 +3350,21 @@ var IKEmbeddableFormBundle = function(exports) {
3328
3350
  return { data, status: res.status, ok: true };
3329
3351
  } catch (err) {
3330
3352
  clearTimeout(timeoutId);
3331
- if (retriesLeft > 1 && this.isRetryable(err)) {
3353
+ const normalizedErr = timedOut ? this.buildTimeoutError(timeoutMs) : err;
3354
+ if (retriesLeft > 1 && this.isRetryable(normalizedErr)) {
3332
3355
  await this.delay(500 * (2 - retriesLeft));
3333
3356
  return this.fetchWithRetry(url, init, retriesLeft - 1, timeoutMs);
3334
3357
  }
3335
- throw err;
3358
+ throw normalizedErr;
3336
3359
  }
3337
3360
  }
3361
+ buildTimeoutError(timeoutMs) {
3362
+ return {
3363
+ code: "TIMEOUT",
3364
+ message: "This is taking longer than expected. Please try again.",
3365
+ details: { timeoutMs }
3366
+ };
3367
+ }
3338
3368
  applyResponseMapping(mapping, response) {
3339
3369
  if (!mapping) return {};
3340
3370
  const result = {};
@@ -3350,7 +3380,7 @@ var IKEmbeddableFormBundle = function(exports) {
3350
3380
  if (err instanceof TypeError) return true;
3351
3381
  if (err && typeof err === "object" && "code" in err) {
3352
3382
  const code = err.code;
3353
- return code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
3383
+ return code === "TIMEOUT" || code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
3354
3384
  }
3355
3385
  return false;
3356
3386
  }
@@ -21695,10 +21725,49 @@ var IKEmbeddableFormBundle = function(exports) {
21695
21725
  }
21696
21726
  }
21697
21727
  };
21728
+ const emailRegistrationVariant = {
21729
+ id: "email-registration",
21730
+ overrides: {
21731
+ layout: {
21732
+ leftPanel: {
21733
+ progressGroups: [
21734
+ {
21735
+ number: 1,
21736
+ title: "Webinar Registration",
21737
+ stepIds: ["slot-selection"]
21738
+ },
21739
+ {
21740
+ number: 2,
21741
+ title: "Profile Details",
21742
+ stepIds: ["profile-details", "goals-details"]
21743
+ }
21744
+ ]
21745
+ },
21746
+ rightPanel: {
21747
+ progressGroups: [
21748
+ { stepIds: ["slot-selection"] },
21749
+ { stepIds: ["profile-details"] },
21750
+ { stepIds: ["goals-details"] },
21751
+ { stepIds: ["consultation-prefs"] }
21752
+ ]
21753
+ }
21754
+ },
21755
+ steps: {
21756
+ // Lead is resolved from customer_id on the backend — skip contact collection.
21757
+ "contact-details": { show: false },
21758
+ "profile-details": {
21759
+ fields: {
21760
+ interviewTimeline: { show: false }
21761
+ }
21762
+ }
21763
+ }
21764
+ }
21765
+ };
21698
21766
  const GQL_WEBINAR_VARIANTS = [
21699
21767
  defaultVariant,
21700
21768
  indiaVariant,
21701
- eventVariant
21769
+ eventVariant,
21770
+ emailRegistrationVariant
21702
21771
  ];
21703
21772
  const gqlWebinarConfig = {
21704
21773
  ...gqlWebinarBaseConfig,