@codebards/ik-embeddable-form 0.0.2730435737-qa → 0.0.2736450101-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
@@ -443,10 +443,10 @@ var IKEmbeddableFormBundle = function(exports) {
443
443
  if (!(Sentry == null ? void 0 : Sentry.captureMessage)) return;
444
444
  Sentry.captureMessage(message, { level, extra: context });
445
445
  }
446
- function setUserContext(userId, email) {
446
+ function setUserContext(userId, email2) {
447
447
  const Sentry = getSentry();
448
448
  if (!(Sentry == null ? void 0 : Sentry.setUser)) return;
449
- Sentry.setUser({ id: userId, email });
449
+ Sentry.setUser({ id: userId, email: email2 });
450
450
  }
451
451
  function addBreadcrumb(message, category, data) {
452
452
  const Sentry = getSentry();
@@ -1950,8 +1950,7 @@ var IKEmbeddableFormBundle = function(exports) {
1950
1950
  Region: formData.region ?? (ctx == null ? void 0 : ctx.region) ?? "",
1951
1951
  step,
1952
1952
  data_click_id: resolveClickId(formData),
1953
- ab_bucket_json: JSON.stringify({ gql_yoe_dropdown_ab: "" }),
1954
- fingerprint_id: getFingerprintId()
1953
+ ab_bucket_json: JSON.stringify({ gql_yoe_dropdown_ab: "" })
1955
1954
  };
1956
1955
  }
1957
1956
  async function postClickstream(url, apiKey, datasetId, tableId, row) {
@@ -2140,9 +2139,9 @@ var IKEmbeddableFormBundle = function(exports) {
2140
2139
  * would otherwise leave the digest permanently unset.
2141
2140
  */
2142
2141
  async ensureEmailDigest() {
2143
- const email = String(this.state.formData.email ?? "").trim();
2144
- if (!email || this.state.formData.emailSha256) return;
2145
- const digest = await sha256Hex(email);
2142
+ const email2 = String(this.state.formData.email ?? "").trim();
2143
+ if (!email2 || this.state.formData.emailSha256) return;
2144
+ const digest = await sha256Hex(email2);
2146
2145
  if (digest) this.mergeFormData({ emailSha256: digest });
2147
2146
  }
2148
2147
  getOpenConfig() {
@@ -2364,13 +2363,13 @@ var IKEmbeddableFormBundle = function(exports) {
2364
2363
  }
2365
2364
  startSlotsPrefetch() {
2366
2365
  if (!this.needsSlotsPrefetch() || this.slotsPrefetchPromise) return;
2367
- this.mergeFormData({ slotsLoading: true }, true);
2366
+ this.mergeFormData({ slotsLoading: true });
2368
2367
  const earlyPrefetch = getSlotsPrefetchPromise();
2369
2368
  const prefetch = earlyPrefetch ? earlyPrefetch.then((result) => {
2370
2369
  this.applySlotFetchResult(result);
2371
2370
  }) : this.loadSlotsIntoFormData();
2372
2371
  this.slotsPrefetchPromise = prefetch.catch((err) => {
2373
- this.mergeFormData({ slotsLoading: false }, true);
2372
+ this.patchFormData({ slotsLoading: false });
2374
2373
  this.analytics.trackError(err, {
2375
2374
  stepId: "prefetch-slots",
2376
2375
  formId: this.config.id
@@ -2400,7 +2399,7 @@ var IKEmbeddableFormBundle = function(exports) {
2400
2399
  patch.inviteeEndTime = firstSlot.inviteeEndTime;
2401
2400
  patch.slotDisplay = formatInviteeDisplay(firstSlot.inviteeStartTime, firstSlot.startTime);
2402
2401
  }
2403
- this.mergeFormData(patch, true);
2402
+ this.patchFormData(patch);
2404
2403
  }
2405
2404
  async ensureSlotsReady(step) {
2406
2405
  if (this.slotsPrefetchPromise) {
@@ -2737,18 +2736,23 @@ var IKEmbeddableFormBundle = function(exports) {
2737
2736
  });
2738
2737
  return data;
2739
2738
  }
2740
- mergeFormData(incoming, notify = false) {
2739
+ mergeFormData(incoming) {
2741
2740
  this.state = {
2742
2741
  ...this.state,
2743
2742
  formData: { ...this.state.formData, ...incoming }
2744
2743
  };
2745
- if (notify) this.notifyListeners();
2744
+ }
2745
+ /**
2746
+ * Like `mergeFormData`, but notifies subscribers so the UI re-renders.
2747
+ * Needed for data that arrives asynchronously while a step is already on screen
2748
+ * (slot prefetch), where `mergeFormData` alone leaves the view stale until the
2749
+ * next unrelated `setState`.
2750
+ */
2751
+ patchFormData(incoming) {
2752
+ this.setState({ formData: { ...this.state.formData, ...incoming } });
2746
2753
  }
2747
2754
  setState(partial) {
2748
2755
  this.state = { ...this.state, ...partial };
2749
- this.notifyListeners();
2750
- }
2751
- notifyListeners() {
2752
2756
  this.listeners.forEach((l2) => l2(this.getState()));
2753
2757
  }
2754
2758
  }
@@ -2863,6 +2867,9 @@ var IKEmbeddableFormBundle = function(exports) {
2863
2867
  function str(value) {
2864
2868
  return value != null ? String(value) : "";
2865
2869
  }
2870
+ function email(value) {
2871
+ return str(value).trim().replace(/\.+$/, "");
2872
+ }
2866
2873
  function bool(value) {
2867
2874
  return value === true || value === "true";
2868
2875
  }
@@ -2881,10 +2888,6 @@ var IKEmbeddableFormBundle = function(exports) {
2881
2888
  lastName: parts.slice(1).join(" ") || (parts[0] ?? "")
2882
2889
  };
2883
2890
  }
2884
- function customerIdFields(context) {
2885
- const customerId = str(context.openConfig.customerId);
2886
- return customerId ? { customer_id: customerId } : {};
2887
- }
2888
2891
  function resolveUtmMedium(context) {
2889
2892
  return resolveWordPressUtmMedium(
2890
2893
  context.visitorId,
@@ -2912,10 +2915,9 @@ var IKEmbeddableFormBundle = function(exports) {
2912
2915
  const { firstName, lastName } = resolveName(formData);
2913
2916
  const webinarType = resolveEffectiveWebinarType(formData, context.webinarType);
2914
2917
  return {
2915
- ...customerIdFields(context),
2916
2918
  "First Name": firstName,
2917
2919
  "Last Name": lastName,
2918
- "Email Address": str(formData.email),
2920
+ "Email Address": email(formData.email),
2919
2921
  ByeCalendlyType: "NoPhoneInTheFirstStep",
2920
2922
  "webinar-type": webinarType,
2921
2923
  "Webinar Lead Type": webinarType,
@@ -2992,10 +2994,9 @@ var IKEmbeddableFormBundle = function(exports) {
2992
2994
  const gaEventId = Date.now();
2993
2995
  const { firstName, lastName } = resolveName(formData);
2994
2996
  return {
2995
- ...customerIdFields(context),
2996
2997
  "First Name": firstName,
2997
2998
  "Last Name": lastName,
2998
- "Email Address": str(formData.email),
2999
+ "Email Address": email(formData.email),
2999
3000
  ...resolveProfileApiFields(formData, context),
3000
3001
  "Interview Start Time": str(formData.interviewTimeline),
3001
3002
  utm_source: resolveUtmSource(context),
@@ -3064,12 +3065,11 @@ var IKEmbeddableFormBundle = function(exports) {
3064
3065
  const linkedIn = str(formData.linkedIn).trim();
3065
3066
  const resumeBase64 = str(formData.resumeFileBase64).trim();
3066
3067
  return {
3067
- ...customerIdFields(context),
3068
3068
  Lead_Created_Time: formatLeadCreatedTime(formData.leadCreatedTime),
3069
3069
  Page_URL: encodeURIComponent(context.pageUrl),
3070
3070
  "First Name": firstName,
3071
3071
  "Last Name": lastName,
3072
- "Email Address": str(formData.email),
3072
+ "Email Address": email(formData.email),
3073
3073
  utm_source: resolveUtmSource(context),
3074
3074
  utm_medium: resolveUtmMedium(context),
3075
3075
  utm_campaign: str(utm.utm_campaign ?? ""),
@@ -3187,10 +3187,6 @@ var IKEmbeddableFormBundle = function(exports) {
3187
3187
  return url.toString();
3188
3188
  }
3189
3189
  buildBody(contract, formData) {
3190
- const body = this.buildRawBody(contract, formData);
3191
- return { ...body, fingerprint_id: getFingerprintId() };
3192
- }
3193
- buildRawBody(contract, formData) {
3194
3190
  if (contract.payloadBuilder) {
3195
3191
  return buildPayload(contract.payloadBuilder, formData);
3196
3192
  }
@@ -3215,13 +3211,7 @@ var IKEmbeddableFormBundle = function(exports) {
3215
3211
  }
3216
3212
  async fetchWithRetry(url, init, retriesLeft, timeoutMs) {
3217
3213
  const controller = new AbortController();
3218
- let timedOut = false;
3219
- const timeoutId = setTimeout(() => {
3220
- timedOut = true;
3221
- controller.abort(
3222
- new DOMException(`Request timed out after ${timeoutMs}ms`, "TimeoutError")
3223
- );
3224
- }, timeoutMs);
3214
+ const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
3225
3215
  try {
3226
3216
  const res = await fetch(url, { ...init, signal: controller.signal });
3227
3217
  clearTimeout(timeoutId);
@@ -3238,21 +3228,13 @@ var IKEmbeddableFormBundle = function(exports) {
3238
3228
  return { data, status: res.status, ok: true };
3239
3229
  } catch (err) {
3240
3230
  clearTimeout(timeoutId);
3241
- const normalizedErr = timedOut ? this.buildTimeoutError(timeoutMs) : err;
3242
- if (retriesLeft > 1 && this.isRetryable(normalizedErr)) {
3231
+ if (retriesLeft > 1 && this.isRetryable(err)) {
3243
3232
  await this.delay(500 * (2 - retriesLeft));
3244
3233
  return this.fetchWithRetry(url, init, retriesLeft - 1, timeoutMs);
3245
3234
  }
3246
- throw normalizedErr;
3235
+ throw err;
3247
3236
  }
3248
3237
  }
3249
- buildTimeoutError(timeoutMs) {
3250
- return {
3251
- code: "TIMEOUT",
3252
- message: "This is taking longer than expected. Please try again.",
3253
- details: { timeoutMs }
3254
- };
3255
- }
3256
3238
  applyResponseMapping(mapping, response) {
3257
3239
  if (!mapping) return {};
3258
3240
  const result = {};
@@ -3268,7 +3250,7 @@ var IKEmbeddableFormBundle = function(exports) {
3268
3250
  if (err instanceof TypeError) return true;
3269
3251
  if (err && typeof err === "object" && "code" in err) {
3270
3252
  const code = err.code;
3271
- return code === "TIMEOUT" || code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
3253
+ return code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
3272
3254
  }
3273
3255
  return false;
3274
3256
  }
@@ -19335,7 +19317,7 @@ var IKEmbeddableFormBundle = function(exports) {
19335
19317
  break;
19336
19318
  case "email":
19337
19319
  rules["pattern"] = {
19338
- value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
19320
+ value: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
19339
19321
  message: rule.message
19340
19322
  };
19341
19323
  break;
@@ -21613,49 +21595,10 @@ var IKEmbeddableFormBundle = function(exports) {
21613
21595
  }
21614
21596
  }
21615
21597
  };
21616
- const emailRegistrationVariant = {
21617
- id: "email-registration",
21618
- overrides: {
21619
- layout: {
21620
- leftPanel: {
21621
- progressGroups: [
21622
- {
21623
- number: 1,
21624
- title: "Webinar Registration",
21625
- stepIds: ["slot-selection"]
21626
- },
21627
- {
21628
- number: 2,
21629
- title: "Profile Details",
21630
- stepIds: ["profile-details", "goals-details"]
21631
- }
21632
- ]
21633
- },
21634
- rightPanel: {
21635
- progressGroups: [
21636
- { stepIds: ["slot-selection"] },
21637
- { stepIds: ["profile-details"] },
21638
- { stepIds: ["goals-details"] },
21639
- { stepIds: ["consultation-prefs"] }
21640
- ]
21641
- }
21642
- },
21643
- steps: {
21644
- // Lead is resolved from customer_id on the backend — skip contact collection.
21645
- "contact-details": { show: false },
21646
- "profile-details": {
21647
- fields: {
21648
- interviewTimeline: { show: false }
21649
- }
21650
- }
21651
- }
21652
- }
21653
- };
21654
21598
  const GQL_WEBINAR_VARIANTS = [
21655
21599
  defaultVariant,
21656
21600
  indiaVariant,
21657
- eventVariant,
21658
- emailRegistrationVariant
21601
+ eventVariant
21659
21602
  ];
21660
21603
  const gqlWebinarConfig = {
21661
21604
  ...gqlWebinarBaseConfig,
@@ -21819,7 +21762,7 @@ ${intlTelStyles}`;
21819
21762
  destroy();
21820
21763
  },
21821
21764
  getVersion() {
21822
- return "1.0.33";
21765
+ return "1.0.36";
21823
21766
  },
21824
21767
  /**
21825
21768
  * Allowlisted snapshot of everything the user has submitted so far.