keystone-design-bootstrap 1.0.60 → 1.0.62

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.
@@ -6172,13 +6172,55 @@ function DynamicFormFields({ form, jobSlug, privacyPolicyUrl, termsOfServiceUrl
6172
6172
  }
6173
6173
 
6174
6174
  // src/tracking/firePixelEvent.ts
6175
+ var STORAGE_KEY = "ks_pud";
6176
+ async function sha256Hex(str) {
6177
+ const buffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(str));
6178
+ return Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
6179
+ }
6180
+ function getFbq() {
6181
+ if (typeof window === "undefined") return void 0;
6182
+ return window.fbq;
6183
+ }
6184
+ function getRegisteredPixelIds() {
6185
+ var _a;
6186
+ return (_a = window.__ks_pixel_ids) != null ? _a : [];
6187
+ }
6188
+ function applyStoredUserData(fbq) {
6189
+ try {
6190
+ const raw = sessionStorage.getItem(STORAGE_KEY);
6191
+ if (!raw) return;
6192
+ const hashed = JSON.parse(raw);
6193
+ if (Object.keys(hashed).length === 0) return;
6194
+ getRegisteredPixelIds().forEach((id3) => fbq("init", id3, hashed));
6195
+ } catch (e) {
6196
+ }
6197
+ }
6198
+ async function setPixelUserData(userData) {
6199
+ const hashed = {};
6200
+ if (userData.email) {
6201
+ hashed.em = await sha256Hex(userData.email.trim().toLowerCase());
6202
+ }
6203
+ if (userData.phone) {
6204
+ const digits = userData.phone.replace(/\D/g, "");
6205
+ if (digits) hashed.ph = await sha256Hex(digits);
6206
+ }
6207
+ if (Object.keys(hashed).length === 0) return;
6208
+ try {
6209
+ sessionStorage.setItem(STORAGE_KEY, JSON.stringify(hashed));
6210
+ } catch (e) {
6211
+ }
6212
+ const fbq = getFbq();
6213
+ if (fbq) {
6214
+ getRegisteredPixelIds().forEach((id3) => fbq("init", id3, hashed));
6215
+ }
6216
+ }
6175
6217
  function firePixelEvent(event, params) {
6176
- if (typeof window === "undefined") return;
6177
- const fbq = window.fbq;
6218
+ const fbq = getFbq();
6178
6219
  if (!fbq) {
6179
6220
  console.debug("[MetaPixel] skipped \u2014 fbq not loaded", { event });
6180
6221
  return;
6181
6222
  }
6223
+ applyStoredUserData(fbq);
6182
6224
  const normalized = {};
6183
6225
  if (params == null ? void 0 : params.contentName) normalized.content_name = params.contentName;
6184
6226
  if (params == null ? void 0 : params.contentCategory) normalized.content_category = params.contentCategory;
@@ -6240,6 +6282,7 @@ var ContactSectionForm = ({
6240
6282
  setStatusMessage(result.message || successMessage);
6241
6283
  (_a = formRef.current) == null ? void 0 : _a.reset();
6242
6284
  onSuccess == null ? void 0 : onSuccess();
6285
+ await setPixelUserData({ email: data.email, phone: data.phone });
6243
6286
  firePixelEvent("Lead");
6244
6287
  setTimeout(() => setSubmitStatus("idle"), 5e3);
6245
6288
  } else {
@@ -9001,6 +9044,7 @@ var ContactSectionForm2 = ({
9001
9044
  setStatusMessage(result.message || successMessage);
9002
9045
  (_a = formRef.current) == null ? void 0 : _a.reset();
9003
9046
  onSuccess == null ? void 0 : onSuccess();
9047
+ await setPixelUserData({ email: data.email, phone: data.phone });
9004
9048
  firePixelEvent("Lead");
9005
9049
  setTimeout(() => setSubmitStatus("idle"), 5e3);
9006
9050
  } else {
@@ -18202,6 +18246,7 @@ var ContactSectionForm3 = ({
18202
18246
  setStatusMessage(result.message || successMessage);
18203
18247
  (_a = formRef.current) == null ? void 0 : _a.reset();
18204
18248
  onSuccess == null ? void 0 : onSuccess();
18249
+ await setPixelUserData({ email: data.email, phone: data.phone });
18205
18250
  firePixelEvent("Lead");
18206
18251
  setTimeout(() => setSubmitStatus("idle"), 5e3);
18207
18252
  } else {
@@ -18695,6 +18740,7 @@ var ContactSectionForm4 = ({
18695
18740
  setStatusMessage(result.message || successMessage);
18696
18741
  (_a = formRef.current) == null ? void 0 : _a.reset();
18697
18742
  onSuccess == null ? void 0 : onSuccess();
18743
+ await setPixelUserData({ email: data.email, phone: data.phone });
18698
18744
  firePixelEvent("Lead");
18699
18745
  setTimeout(() => setSubmitStatus("idle"), 5e3);
18700
18746
  } else {