@codebards/ik-embeddable-form 0.0.2702285982-qa → 0.0.2713998803-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
@@ -454,7 +454,8 @@ var IKEmbeddableFormBundle = function(exports) {
454
454
  countryName: geoData.country,
455
455
  timezone: geoData.timezone,
456
456
  region: geoData.region,
457
- city: geoData.city
457
+ city: geoData.city,
458
+ ip: geoData.ip ?? ""
458
459
  };
459
460
  }
460
461
  }
@@ -482,13 +483,15 @@ var IKEmbeddableFormBundle = function(exports) {
482
483
  countryName: COUNTRIES_BY_CODE[code] ?? code,
483
484
  timezone,
484
485
  region: data.region,
485
- city: data.city
486
+ city: data.city,
487
+ ip: data.ip ?? ""
486
488
  };
487
489
  } catch {
488
490
  return {
489
491
  countryCode: "US",
490
492
  countryName: "United States",
491
- timezone: resolveBrowserTimezone()
493
+ timezone: resolveBrowserTimezone(),
494
+ ip: ""
492
495
  };
493
496
  }
494
497
  }
@@ -1208,6 +1211,34 @@ var IKEmbeddableFormBundle = function(exports) {
1208
1211
  if (window.innerWidth < 1024) return "Tablet";
1209
1212
  return "Desktop";
1210
1213
  }
1214
+ const UNKNOWN = { browserName: "Unknown", browserVersion: "Unknown" };
1215
+ function getBrowserDetails() {
1216
+ var _a, _b, _c;
1217
+ try {
1218
+ const ua = navigator.userAgent;
1219
+ let browserName = "Unknown";
1220
+ let version = "Unknown";
1221
+ if (ua.indexOf("Firefox") > -1) {
1222
+ browserName = "Firefox";
1223
+ version = ua.split("Firefox/")[1] || "Unknown";
1224
+ } else if (ua.indexOf("Chrome") > -1 && ua.indexOf("Edg/") === -1) {
1225
+ browserName = "Chrome";
1226
+ version = ((_a = ua.split("Chrome/")[1]) == null ? void 0 : _a.split(" ")[0]) || "Unknown";
1227
+ } else if (ua.indexOf("Safari") > -1 && ua.indexOf("Chrome") === -1) {
1228
+ browserName = "Safari";
1229
+ version = ((_b = ua.split("Version/")[1]) == null ? void 0 : _b.split(" ")[0]) || "Unknown";
1230
+ } else if (ua.indexOf("Edg/") > -1) {
1231
+ browserName = "Edge";
1232
+ version = ua.split("Edg/")[1] || "Unknown";
1233
+ } else if (ua.indexOf("Trident/") > -1) {
1234
+ browserName = "Internet Explorer";
1235
+ version = ((_c = ua.split("rv:")[1]) == null ? void 0 : _c.split(")")[0]) || "Unknown";
1236
+ }
1237
+ return { browserName, browserVersion: version };
1238
+ } catch {
1239
+ return { ...UNKNOWN };
1240
+ }
1241
+ }
1211
1242
  const LOCALHOST_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
1212
1243
  function isLocalhostHost(hostname) {
1213
1244
  return LOCALHOST_HOSTS.has(hostname);
@@ -1271,6 +1302,7 @@ var IKEmbeddableFormBundle = function(exports) {
1271
1302
  ...openConfig.prefilledValues
1272
1303
  };
1273
1304
  const pageUrl = resolveWorkflowPageUrl(openConfig.pageUrl);
1305
+ const browser = getBrowserDetails();
1274
1306
  contextInstance = {
1275
1307
  ...attribution,
1276
1308
  landingPageUrl: normalizeLandingPageUrl(attribution.landingPageUrl, pageUrl),
@@ -1281,6 +1313,9 @@ var IKEmbeddableFormBundle = function(exports) {
1281
1313
  city: geo.city ?? "",
1282
1314
  region: geo.region ?? "",
1283
1315
  device: getDeviceType(),
1316
+ ipAddress: geo.ip,
1317
+ browserName: browser.browserName,
1318
+ browserVersion: browser.browserVersion,
1284
1319
  pageUrl,
1285
1320
  siteUrl: resolveStaticSiteUrl(openConfig.site),
1286
1321
  eventName: openConfig.eventName,
@@ -2088,13 +2123,13 @@ var IKEmbeddableFormBundle = function(exports) {
2088
2123
  }
2089
2124
  startSlotsPrefetch() {
2090
2125
  if (!this.needsSlotsPrefetch() || this.slotsPrefetchPromise) return;
2091
- this.mergeFormData({ slotsLoading: true });
2126
+ this.mergeFormData({ slotsLoading: true }, true);
2092
2127
  const earlyPrefetch = getSlotsPrefetchPromise();
2093
2128
  const prefetch = earlyPrefetch ? earlyPrefetch.then((result) => {
2094
2129
  this.applySlotFetchResult(result);
2095
2130
  }) : this.loadSlotsIntoFormData();
2096
2131
  this.slotsPrefetchPromise = prefetch.catch((err) => {
2097
- this.mergeFormData({ slotsLoading: false });
2132
+ this.mergeFormData({ slotsLoading: false }, true);
2098
2133
  this.analytics.trackError(err, {
2099
2134
  stepId: "prefetch-slots",
2100
2135
  formId: this.config.id
@@ -2126,6 +2161,7 @@ var IKEmbeddableFormBundle = function(exports) {
2126
2161
  slotDisplay: formatInviteeDisplay(firstSlot.inviteeStartTime, firstSlot.startTime)
2127
2162
  });
2128
2163
  }
2164
+ this.notifyListeners();
2129
2165
  }
2130
2166
  async ensureSlotsReady(step) {
2131
2167
  if (this.slotsPrefetchPromise) {
@@ -2437,14 +2473,18 @@ var IKEmbeddableFormBundle = function(exports) {
2437
2473
  });
2438
2474
  return data;
2439
2475
  }
2440
- mergeFormData(incoming) {
2476
+ mergeFormData(incoming, notify = false) {
2441
2477
  this.state = {
2442
2478
  ...this.state,
2443
2479
  formData: { ...this.state.formData, ...incoming }
2444
2480
  };
2481
+ if (notify) this.notifyListeners();
2445
2482
  }
2446
2483
  setState(partial) {
2447
2484
  this.state = { ...this.state, ...partial };
2485
+ this.notifyListeners();
2486
+ }
2487
+ notifyListeners() {
2448
2488
  this.listeners.forEach((l2) => l2(this.getState()));
2449
2489
  }
2450
2490
  }
@@ -2559,6 +2599,10 @@ var IKEmbeddableFormBundle = function(exports) {
2559
2599
  lastName: parts.slice(1).join(" ") || (parts[0] ?? "")
2560
2600
  };
2561
2601
  }
2602
+ function customerIdFields(context) {
2603
+ const customerId = str(context.openConfig.customerId);
2604
+ return customerId ? { customer_id: customerId } : {};
2605
+ }
2562
2606
  function resolveUtmMedium(context) {
2563
2607
  return resolveWordPressUtmMedium(
2564
2608
  context.visitorId,
@@ -2586,6 +2630,7 @@ var IKEmbeddableFormBundle = function(exports) {
2586
2630
  const { firstName, lastName } = resolveName(formData);
2587
2631
  const webinarType = resolveEffectiveWebinarType(formData, context.webinarType);
2588
2632
  return {
2633
+ ...customerIdFields(context),
2589
2634
  "First Name": firstName,
2590
2635
  "Last Name": lastName,
2591
2636
  "Email Address": str(formData.email),
@@ -2608,6 +2653,9 @@ var IKEmbeddableFormBundle = function(exports) {
2608
2653
  fbcId: context.fbcId ?? "",
2609
2654
  fbpId: context.fbpId ?? "",
2610
2655
  user_agent: navigator.userAgent,
2656
+ ipAddress: context.ipAddress,
2657
+ browserName: context.browserName,
2658
+ browserVersion: context.browserVersion,
2611
2659
  user_id: context.visitorId,
2612
2660
  li_fat_id: context.liFatId,
2613
2661
  cta_page_url: context.ctaPageUrl,
@@ -2659,6 +2707,7 @@ var IKEmbeddableFormBundle = function(exports) {
2659
2707
  const gaEventId = Date.now();
2660
2708
  const { firstName, lastName } = resolveName(formData);
2661
2709
  return {
2710
+ ...customerIdFields(context),
2662
2711
  "First Name": firstName,
2663
2712
  "Last Name": lastName,
2664
2713
  "Email Address": str(formData.email),
@@ -2729,6 +2778,7 @@ var IKEmbeddableFormBundle = function(exports) {
2729
2778
  const linkedIn = str(formData.linkedIn).trim();
2730
2779
  const resumeBase64 = str(formData.resumeFileBase64).trim();
2731
2780
  return {
2781
+ ...customerIdFields(context),
2732
2782
  Lead_Created_Time: formatLeadCreatedTime(formData.leadCreatedTime),
2733
2783
  Page_URL: encodeURIComponent(context.pageUrl),
2734
2784
  "First Name": firstName,
@@ -2879,7 +2929,13 @@ var IKEmbeddableFormBundle = function(exports) {
2879
2929
  }
2880
2930
  async fetchWithRetry(url, init, retriesLeft, timeoutMs) {
2881
2931
  const controller = new AbortController();
2882
- const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
2932
+ let timedOut = false;
2933
+ const timeoutId = setTimeout(() => {
2934
+ timedOut = true;
2935
+ controller.abort(
2936
+ new DOMException(`Request timed out after ${timeoutMs}ms`, "TimeoutError")
2937
+ );
2938
+ }, timeoutMs);
2883
2939
  try {
2884
2940
  const res = await fetch(url, { ...init, signal: controller.signal });
2885
2941
  clearTimeout(timeoutId);
@@ -2896,13 +2952,21 @@ var IKEmbeddableFormBundle = function(exports) {
2896
2952
  return { data, status: res.status, ok: true };
2897
2953
  } catch (err) {
2898
2954
  clearTimeout(timeoutId);
2899
- if (retriesLeft > 1 && this.isRetryable(err)) {
2955
+ const normalizedErr = timedOut ? this.buildTimeoutError(timeoutMs) : err;
2956
+ if (retriesLeft > 1 && this.isRetryable(normalizedErr)) {
2900
2957
  await this.delay(500 * (2 - retriesLeft));
2901
2958
  return this.fetchWithRetry(url, init, retriesLeft - 1, timeoutMs);
2902
2959
  }
2903
- throw err;
2960
+ throw normalizedErr;
2904
2961
  }
2905
2962
  }
2963
+ buildTimeoutError(timeoutMs) {
2964
+ return {
2965
+ code: "TIMEOUT",
2966
+ message: "This is taking longer than expected. Please try again.",
2967
+ details: { timeoutMs }
2968
+ };
2969
+ }
2906
2970
  applyResponseMapping(mapping, response) {
2907
2971
  if (!mapping) return {};
2908
2972
  const result = {};
@@ -2918,7 +2982,7 @@ var IKEmbeddableFormBundle = function(exports) {
2918
2982
  if (err instanceof TypeError) return true;
2919
2983
  if (err && typeof err === "object" && "code" in err) {
2920
2984
  const code = err.code;
2921
- return code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
2985
+ return code === "TIMEOUT" || code === "HTTP_429" || code === "HTTP_503" || code === "HTTP_502";
2922
2986
  }
2923
2987
  return false;
2924
2988
  }
@@ -20500,10 +20564,49 @@ var IKEmbeddableFormBundle = function(exports) {
20500
20564
  }
20501
20565
  }
20502
20566
  };
20567
+ const emailRegistrationVariant = {
20568
+ id: "email-registration",
20569
+ overrides: {
20570
+ layout: {
20571
+ leftPanel: {
20572
+ progressGroups: [
20573
+ {
20574
+ number: 1,
20575
+ title: "Webinar Registration",
20576
+ stepIds: ["slot-selection"]
20577
+ },
20578
+ {
20579
+ number: 2,
20580
+ title: "Profile Details",
20581
+ stepIds: ["profile-details", "goals-details"]
20582
+ }
20583
+ ]
20584
+ },
20585
+ rightPanel: {
20586
+ progressGroups: [
20587
+ { stepIds: ["slot-selection"] },
20588
+ { stepIds: ["profile-details"] },
20589
+ { stepIds: ["goals-details"] },
20590
+ { stepIds: ["consultation-prefs"] }
20591
+ ]
20592
+ }
20593
+ },
20594
+ steps: {
20595
+ // Lead is resolved from customer_id on the backend — skip contact collection.
20596
+ "contact-details": { show: false },
20597
+ "profile-details": {
20598
+ fields: {
20599
+ interviewTimeline: { show: false }
20600
+ }
20601
+ }
20602
+ }
20603
+ }
20604
+ };
20503
20605
  const GQL_WEBINAR_VARIANTS = [
20504
20606
  defaultVariant,
20505
20607
  indiaVariant,
20506
- eventVariant
20608
+ eventVariant,
20609
+ emailRegistrationVariant
20507
20610
  ];
20508
20611
  const gqlWebinarConfig = {
20509
20612
  ...gqlWebinarBaseConfig,