@jmp-technologies/analytics 0.1.38 → 0.1.39

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/astro/client.cjs +143 -4
  3. package/dist/astro/client.cjs.map +1 -1
  4. package/dist/astro/client.d.cts +2 -2
  5. package/dist/astro/client.d.ts +2 -2
  6. package/dist/astro/client.js +1 -1
  7. package/dist/astro/content.cjs +150 -5
  8. package/dist/astro/content.cjs.map +1 -1
  9. package/dist/astro/content.d.cts +3 -3
  10. package/dist/astro/content.d.ts +3 -3
  11. package/dist/astro/content.js +2 -2
  12. package/dist/astro/integration.cjs +143 -4
  13. package/dist/astro/integration.cjs.map +1 -1
  14. package/dist/astro/integration.js +2 -2
  15. package/dist/astro/middleware.d.cts +2 -2
  16. package/dist/astro/middleware.d.ts +2 -2
  17. package/dist/astro/register.cjs +143 -4
  18. package/dist/astro/register.cjs.map +1 -1
  19. package/dist/astro/register.js +2 -2
  20. package/dist/{chunk-NCF3J4HV.js → chunk-BXPMVR7M.js} +2 -2
  21. package/dist/{chunk-JVFN7MF2.js → chunk-JJ3JP3RV.js} +2 -2
  22. package/dist/{chunk-WHUHCTBQ.js → chunk-M66PHSBO.js} +2 -2
  23. package/dist/{chunk-PQOTEV6O.js → chunk-OCIOQIE4.js} +2 -2
  24. package/dist/{chunk-EBU4DKHW.js → chunk-XAEWXWSP.js} +153 -6
  25. package/dist/chunk-XAEWXWSP.js.map +1 -0
  26. package/dist/constants-DTZMYgi4.d.cts +12 -0
  27. package/dist/constants-DTZMYgi4.d.ts +12 -0
  28. package/dist/{create-jmp-analytics-DMSXmVIH.d.cts → create-jmp-analytics-C1IH32ZF.d.cts} +1 -1
  29. package/dist/{create-jmp-analytics-JZ3pqNBQ.d.ts → create-jmp-analytics-CjVYSmPJ.d.ts} +1 -1
  30. package/dist/index.cjs +154 -5
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +7 -13
  33. package/dist/index.d.ts +7 -13
  34. package/dist/index.js +5 -1
  35. package/dist/next/content.cjs +154 -5
  36. package/dist/next/content.cjs.map +1 -1
  37. package/dist/next/content.d.cts +3 -2
  38. package/dist/next/content.d.ts +3 -2
  39. package/dist/next/content.js +7 -2
  40. package/dist/next/content.js.map +1 -1
  41. package/dist/next/instrumentation.cjs +143 -4
  42. package/dist/next/instrumentation.cjs.map +1 -1
  43. package/dist/next/instrumentation.js +1 -1
  44. package/dist/next/landing-pages.cjs +150 -5
  45. package/dist/next/landing-pages.cjs.map +1 -1
  46. package/dist/next/landing-pages.d.cts +2 -2
  47. package/dist/next/landing-pages.d.ts +2 -2
  48. package/dist/next/landing-pages.js +2 -2
  49. package/dist/next/locations.cjs +150 -5
  50. package/dist/next/locations.cjs.map +1 -1
  51. package/dist/next/locations.d.cts +2 -2
  52. package/dist/next/locations.d.ts +2 -2
  53. package/dist/next/locations.js +2 -2
  54. package/dist/next/middleware.d.cts +2 -2
  55. package/dist/next/middleware.d.ts +2 -2
  56. package/dist/next/site-root-server.cjs +150 -5
  57. package/dist/next/site-root-server.cjs.map +1 -1
  58. package/dist/next/site-root-server.js +3 -3
  59. package/dist/next.cjs +143 -4
  60. package/dist/next.cjs.map +1 -1
  61. package/dist/next.d.cts +3 -3
  62. package/dist/next.d.ts +3 -3
  63. package/dist/next.js +3 -3
  64. package/dist/react.cjs +143 -4
  65. package/dist/react.cjs.map +1 -1
  66. package/dist/react.d.cts +2 -2
  67. package/dist/react.d.ts +2 -2
  68. package/dist/react.js +2 -2
  69. package/dist/{site-config-BLnwuRC2.d.ts → site-config-BEaYpZ3X.d.ts} +1 -1
  70. package/dist/{site-config-BZJS8Hp_.d.cts → site-config-BN6Z2zIf.d.cts} +1 -1
  71. package/dist/{track-page-view-DGKRUIxm.d.ts → track-page-view-B3OwUOYl.d.ts} +1 -1
  72. package/dist/{track-page-view-BJQqn2Bg.d.cts → track-page-view-BeVjC-pV.d.cts} +1 -1
  73. package/dist/{types-CYrgEwUF.d.ts → types-uwXEaMD6.d.cts} +29 -0
  74. package/dist/{types-CYrgEwUF.d.cts → types-uwXEaMD6.d.ts} +29 -0
  75. package/dist/{utils-B1Nt3sBU.d.ts → utils-6a6lNKsg.d.ts} +1 -1
  76. package/dist/{utils-U6TGMIAB.d.cts → utils-Cbb3CO3i.d.cts} +1 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-EBU4DKHW.js.map +0 -1
  79. /package/dist/{chunk-NCF3J4HV.js.map → chunk-BXPMVR7M.js.map} +0 -0
  80. /package/dist/{chunk-JVFN7MF2.js.map → chunk-JJ3JP3RV.js.map} +0 -0
  81. /package/dist/{chunk-WHUHCTBQ.js.map → chunk-M66PHSBO.js.map} +0 -0
  82. /package/dist/{chunk-PQOTEV6O.js.map → chunk-OCIOQIE4.js.map} +0 -0
@@ -55,10 +55,12 @@ var import_navigation = require("next/navigation");
55
55
  var LANDING_REFERER_COOKIE_MAX_AGE_SEC = 30 * 60;
56
56
 
57
57
  // package.json
58
- var version = "0.1.38";
58
+ var version = "0.1.39";
59
59
 
60
60
  // src/constants.ts
61
61
  var JMP_ANALYTICS_SDK_VERSION = version;
62
+ var JMP_CONTENT_CACHE_TAG = "jmp-content";
63
+ var JMP_CONTENT_REVALIDATE_SECONDS = 3600;
62
64
 
63
65
  // src/http.ts
64
66
  function responseLooksLikeHtml(body) {
@@ -307,7 +309,8 @@ function normalizeJmpContentManifest(input) {
307
309
  const externalSources = normalizeExternalSources(input.externalSources);
308
310
  const trust = normalizeTrust(input.trust);
309
311
  const contact = normalizeContact(input.contact);
310
- if (routes.length === 0 && !externalSources && !trust && !contact) {
312
+ const defaults = normalizeManifestDefaults(input.defaults);
313
+ if (routes.length === 0 && !externalSources && !trust && !contact && !defaults) {
311
314
  return null;
312
315
  }
313
316
  return {
@@ -315,7 +318,8 @@ function normalizeJmpContentManifest(input) {
315
318
  ...routes.length > 0 ? { routes } : {},
316
319
  ...externalSources ? { externalSources } : {},
317
320
  ...trust ? { trust } : {},
318
- ...contact ? { contact } : {}
321
+ ...contact ? { contact } : {},
322
+ ...defaults ? { defaults } : {}
319
323
  };
320
324
  }
321
325
  function normalizeRoutes(routes) {
@@ -379,6 +383,85 @@ function normalizeTrustLabels(labels) {
379
383
  }
380
384
  return Object.keys(out).length > 0 ? out : null;
381
385
  }
386
+ function readDefaultText(value, max = 500) {
387
+ if (typeof value !== "string") return void 0;
388
+ const trimmed = value.trim();
389
+ if (!trimmed) return void 0;
390
+ return trimmed.slice(0, max);
391
+ }
392
+ function normalizeManifestDefaults(defaults) {
393
+ if (!defaults || typeof defaults !== "object") return null;
394
+ const contactRaw = defaults.contact;
395
+ const contact = {};
396
+ if (contactRaw && typeof contactRaw === "object") {
397
+ const displayName = readDefaultText(contactRaw.displayName, 120);
398
+ const email = readDefaultText(contactRaw.email, 200);
399
+ const phone = readDefaultText(contactRaw.phone, 40);
400
+ const address = readDefaultText(contactRaw.address, 400);
401
+ const hours = readDefaultText(contactRaw.hours, 400);
402
+ const serviceArea = readDefaultText(contactRaw.serviceArea, 200);
403
+ const googleMapsUrl = readDefaultText(contactRaw.googleMapsUrl, 2048);
404
+ const linkedinUrl = readDefaultText(contactRaw.linkedinUrl, 2048);
405
+ const instagramUrl = readDefaultText(contactRaw.instagramUrl, 2048);
406
+ const facebookUrl = readDefaultText(contactRaw.facebookUrl, 2048);
407
+ const xUrl = readDefaultText(contactRaw.xUrl, 2048);
408
+ const youtubeUrl = readDefaultText(contactRaw.youtubeUrl, 2048);
409
+ if (displayName) contact.displayName = displayName;
410
+ if (email) contact.email = email;
411
+ if (phone) contact.phone = phone;
412
+ if (address) contact.address = address;
413
+ if (hours) contact.hours = hours;
414
+ if (serviceArea) contact.serviceArea = serviceArea;
415
+ if (googleMapsUrl) contact.googleMapsUrl = googleMapsUrl;
416
+ if (linkedinUrl) contact.linkedinUrl = linkedinUrl;
417
+ if (instagramUrl) contact.instagramUrl = instagramUrl;
418
+ if (facebookUrl) contact.facebookUrl = facebookUrl;
419
+ if (xUrl) contact.xUrl = xUrl;
420
+ if (youtubeUrl) contact.youtubeUrl = youtubeUrl;
421
+ if (contactRaw.extras && typeof contactRaw.extras === "object") {
422
+ const extras = {};
423
+ for (const [rawKey, rawValue] of Object.entries(contactRaw.extras)) {
424
+ if (Object.keys(extras).length >= 10) break;
425
+ const key = normalizeKey(rawKey);
426
+ const value = readDefaultText(rawValue, 200);
427
+ if (key && isValidExtraKey(key) && value) extras[key] = value;
428
+ }
429
+ if (Object.keys(extras).length > 0) contact.extras = extras;
430
+ }
431
+ }
432
+ const faq = [];
433
+ if (Array.isArray(defaults.faq)) {
434
+ for (const raw of defaults.faq) {
435
+ if (!raw || typeof raw !== "object" || faq.length >= 40) continue;
436
+ const question = readDefaultText(raw.question, 300);
437
+ const answer = readDefaultText(raw.answer, 8e3);
438
+ if (!question || !answer) continue;
439
+ const category = readDefaultText(raw.category, 80);
440
+ faq.push({ question, answer, ...category ? { category } : {} });
441
+ }
442
+ }
443
+ const trustRaw = defaults.trust;
444
+ const trust = {};
445
+ if (trustRaw && typeof trustRaw === "object") {
446
+ const assign = (key, max) => {
447
+ const value = readDefaultText(trustRaw[key], max);
448
+ if (value) trust[key] = value;
449
+ };
450
+ assign("googleReviewsUrl", 2048);
451
+ assign("googlePlaceId", 128);
452
+ assign("yelpUrl", 2048);
453
+ assign("trustpilotUrl", 2048);
454
+ assign("disclaimer", 1e3);
455
+ }
456
+ const hasContact = Object.keys(contact).length > 0;
457
+ const hasTrust = Object.keys(trust).length > 0;
458
+ if (!hasContact && faq.length === 0 && !hasTrust) return null;
459
+ return {
460
+ ...hasContact ? { contact } : {},
461
+ ...faq.length > 0 ? { faq } : {},
462
+ ...hasTrust ? { trust } : {}
463
+ };
464
+ }
382
465
  function normalizeContact(contact) {
383
466
  if (!contact || typeof contact !== "object") return null;
384
467
  const extras = normalizeContactExtras(contact.extras);
@@ -446,7 +529,11 @@ async function getContentText(config, path) {
446
529
  }
447
530
  const res = await resolvedFetch(url, {
448
531
  method: "GET",
449
- headers: jmpContentRequestHeaders(config)
532
+ headers: jmpContentRequestHeaders(config),
533
+ next: {
534
+ revalidate: JMP_CONTENT_REVALIDATE_SECONDS,
535
+ tags: [JMP_CONTENT_CACHE_TAG]
536
+ }
450
537
  });
451
538
  const text = await res.text();
452
539
  if (!res.ok) {
@@ -498,7 +585,65 @@ function getDiscoveredContentWrappers() {
498
585
  return sortWrapperSlots([...discovered]);
499
586
  }
500
587
  function resolveContentManifestForReport(config) {
501
- return normalizeJmpContentManifest(config.contentManifest);
588
+ const site = getJmpSiteDefinition();
589
+ const fallback = site?.contactFallback;
590
+ const existing = config.contentManifest;
591
+ const fromFallback = fallbackToManifestDefaults(fallback);
592
+ if (!existing && !fromFallback) {
593
+ return null;
594
+ }
595
+ const merged = {
596
+ ...existing ?? {},
597
+ defaults: {
598
+ ...fromFallback ?? {},
599
+ ...existing?.defaults ?? {},
600
+ contact: {
601
+ ...fromFallback?.contact ?? {},
602
+ ...existing?.defaults?.contact ?? {},
603
+ extras: {
604
+ ...fromFallback?.contact?.extras ?? {},
605
+ ...existing?.defaults?.contact?.extras ?? {}
606
+ }
607
+ },
608
+ trust: {
609
+ ...fromFallback?.trust ?? {},
610
+ ...existing?.defaults?.trust ?? {}
611
+ },
612
+ faq: existing?.defaults?.faq?.length ? existing.defaults.faq : fromFallback?.faq
613
+ }
614
+ };
615
+ return normalizeJmpContentManifest(merged);
616
+ }
617
+ function fallbackToManifestDefaults(fallback) {
618
+ if (!fallback) return null;
619
+ const contact = {};
620
+ if (fallback.displayName?.trim()) contact.displayName = fallback.displayName.trim();
621
+ if (fallback.email?.trim()) contact.email = fallback.email.trim();
622
+ if (typeof fallback.phone === "string" && fallback.phone.trim()) {
623
+ contact.phone = fallback.phone.trim();
624
+ }
625
+ if (fallback.address?.trim()) contact.address = fallback.address.trim();
626
+ if (fallback.hours?.trim()) contact.hours = fallback.hours.trim();
627
+ if (fallback.serviceArea?.trim()) contact.serviceArea = fallback.serviceArea.trim();
628
+ if (fallback.googleMapsUrl?.trim()) {
629
+ contact.googleMapsUrl = fallback.googleMapsUrl.trim();
630
+ }
631
+ if (fallback.linkedin?.trim()) contact.linkedinUrl = fallback.linkedin.trim();
632
+ if (fallback.instagram?.trim()) contact.instagramUrl = fallback.instagram.trim();
633
+ if (fallback.facebook?.trim()) contact.facebookUrl = fallback.facebook.trim();
634
+ if (fallback.x?.trim()) contact.xUrl = fallback.x.trim();
635
+ if (fallback.youtube?.trim()) contact.youtubeUrl = fallback.youtube.trim();
636
+ const trust = {};
637
+ if (fallback.googleMapsUrl?.trim()) {
638
+ trust.googleReviewsUrl = fallback.googleMapsUrl.trim();
639
+ }
640
+ const hasContact = Object.keys(contact).length > 0;
641
+ const hasTrust = Object.keys(trust).length > 0;
642
+ if (!hasContact && !hasTrust) return null;
643
+ return {
644
+ ...hasContact ? { contact } : {},
645
+ ...hasTrust ? { trust } : {}
646
+ };
502
647
  }
503
648
  function resolveContentWrappersForReport(config) {
504
649
  const explicit = config.contentWrappers ?? [];