@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
@@ -47,10 +47,12 @@ var import_navigation = require("next/navigation");
47
47
  var LANDING_REFERER_COOKIE_MAX_AGE_SEC = 30 * 60;
48
48
 
49
49
  // package.json
50
- var version = "0.1.38";
50
+ var version = "0.1.39";
51
51
 
52
52
  // src/constants.ts
53
53
  var JMP_ANALYTICS_SDK_VERSION = version;
54
+ var JMP_CONTENT_CACHE_TAG = "jmp-content";
55
+ var JMP_CONTENT_REVALIDATE_SECONDS = 3600;
54
56
 
55
57
  // src/http.ts
56
58
  function responseLooksLikeHtml(body) {
@@ -258,7 +260,8 @@ function normalizeJmpContentManifest(input) {
258
260
  const externalSources = normalizeExternalSources(input.externalSources);
259
261
  const trust = normalizeTrust(input.trust);
260
262
  const contact = normalizeContact(input.contact);
261
- if (routes.length === 0 && !externalSources && !trust && !contact) {
263
+ const defaults = normalizeManifestDefaults(input.defaults);
264
+ if (routes.length === 0 && !externalSources && !trust && !contact && !defaults) {
262
265
  return null;
263
266
  }
264
267
  return {
@@ -266,7 +269,8 @@ function normalizeJmpContentManifest(input) {
266
269
  ...routes.length > 0 ? { routes } : {},
267
270
  ...externalSources ? { externalSources } : {},
268
271
  ...trust ? { trust } : {},
269
- ...contact ? { contact } : {}
272
+ ...contact ? { contact } : {},
273
+ ...defaults ? { defaults } : {}
270
274
  };
271
275
  }
272
276
  function normalizeRoutes(routes) {
@@ -330,6 +334,85 @@ function normalizeTrustLabels(labels) {
330
334
  }
331
335
  return Object.keys(out).length > 0 ? out : null;
332
336
  }
337
+ function readDefaultText(value, max = 500) {
338
+ if (typeof value !== "string") return void 0;
339
+ const trimmed = value.trim();
340
+ if (!trimmed) return void 0;
341
+ return trimmed.slice(0, max);
342
+ }
343
+ function normalizeManifestDefaults(defaults) {
344
+ if (!defaults || typeof defaults !== "object") return null;
345
+ const contactRaw = defaults.contact;
346
+ const contact = {};
347
+ if (contactRaw && typeof contactRaw === "object") {
348
+ const displayName = readDefaultText(contactRaw.displayName, 120);
349
+ const email = readDefaultText(contactRaw.email, 200);
350
+ const phone = readDefaultText(contactRaw.phone, 40);
351
+ const address = readDefaultText(contactRaw.address, 400);
352
+ const hours = readDefaultText(contactRaw.hours, 400);
353
+ const serviceArea = readDefaultText(contactRaw.serviceArea, 200);
354
+ const googleMapsUrl = readDefaultText(contactRaw.googleMapsUrl, 2048);
355
+ const linkedinUrl = readDefaultText(contactRaw.linkedinUrl, 2048);
356
+ const instagramUrl = readDefaultText(contactRaw.instagramUrl, 2048);
357
+ const facebookUrl = readDefaultText(contactRaw.facebookUrl, 2048);
358
+ const xUrl = readDefaultText(contactRaw.xUrl, 2048);
359
+ const youtubeUrl = readDefaultText(contactRaw.youtubeUrl, 2048);
360
+ if (displayName) contact.displayName = displayName;
361
+ if (email) contact.email = email;
362
+ if (phone) contact.phone = phone;
363
+ if (address) contact.address = address;
364
+ if (hours) contact.hours = hours;
365
+ if (serviceArea) contact.serviceArea = serviceArea;
366
+ if (googleMapsUrl) contact.googleMapsUrl = googleMapsUrl;
367
+ if (linkedinUrl) contact.linkedinUrl = linkedinUrl;
368
+ if (instagramUrl) contact.instagramUrl = instagramUrl;
369
+ if (facebookUrl) contact.facebookUrl = facebookUrl;
370
+ if (xUrl) contact.xUrl = xUrl;
371
+ if (youtubeUrl) contact.youtubeUrl = youtubeUrl;
372
+ if (contactRaw.extras && typeof contactRaw.extras === "object") {
373
+ const extras = {};
374
+ for (const [rawKey, rawValue] of Object.entries(contactRaw.extras)) {
375
+ if (Object.keys(extras).length >= 10) break;
376
+ const key = normalizeKey(rawKey);
377
+ const value = readDefaultText(rawValue, 200);
378
+ if (key && isValidExtraKey(key) && value) extras[key] = value;
379
+ }
380
+ if (Object.keys(extras).length > 0) contact.extras = extras;
381
+ }
382
+ }
383
+ const faq = [];
384
+ if (Array.isArray(defaults.faq)) {
385
+ for (const raw of defaults.faq) {
386
+ if (!raw || typeof raw !== "object" || faq.length >= 40) continue;
387
+ const question = readDefaultText(raw.question, 300);
388
+ const answer = readDefaultText(raw.answer, 8e3);
389
+ if (!question || !answer) continue;
390
+ const category = readDefaultText(raw.category, 80);
391
+ faq.push({ question, answer, ...category ? { category } : {} });
392
+ }
393
+ }
394
+ const trustRaw = defaults.trust;
395
+ const trust = {};
396
+ if (trustRaw && typeof trustRaw === "object") {
397
+ const assign = (key, max) => {
398
+ const value = readDefaultText(trustRaw[key], max);
399
+ if (value) trust[key] = value;
400
+ };
401
+ assign("googleReviewsUrl", 2048);
402
+ assign("googlePlaceId", 128);
403
+ assign("yelpUrl", 2048);
404
+ assign("trustpilotUrl", 2048);
405
+ assign("disclaimer", 1e3);
406
+ }
407
+ const hasContact = Object.keys(contact).length > 0;
408
+ const hasTrust = Object.keys(trust).length > 0;
409
+ if (!hasContact && faq.length === 0 && !hasTrust) return null;
410
+ return {
411
+ ...hasContact ? { contact } : {},
412
+ ...faq.length > 0 ? { faq } : {},
413
+ ...hasTrust ? { trust } : {}
414
+ };
415
+ }
333
416
  function normalizeContact(contact) {
334
417
  if (!contact || typeof contact !== "object") return null;
335
418
  const extras = normalizeContactExtras(contact.extras);
@@ -397,7 +480,11 @@ async function getContentText(config, path) {
397
480
  }
398
481
  const res = await resolvedFetch(url, {
399
482
  method: "GET",
400
- headers: jmpContentRequestHeaders(config)
483
+ headers: jmpContentRequestHeaders(config),
484
+ next: {
485
+ revalidate: JMP_CONTENT_REVALIDATE_SECONDS,
486
+ tags: [JMP_CONTENT_CACHE_TAG]
487
+ }
401
488
  });
402
489
  const text = await res.text();
403
490
  if (!res.ok) {
@@ -449,7 +536,65 @@ function getDiscoveredContentWrappers() {
449
536
  return sortWrapperSlots([...discovered]);
450
537
  }
451
538
  function resolveContentManifestForReport(config) {
452
- return normalizeJmpContentManifest(config.contentManifest);
539
+ const site = getJmpSiteDefinition();
540
+ const fallback = site?.contactFallback;
541
+ const existing = config.contentManifest;
542
+ const fromFallback = fallbackToManifestDefaults(fallback);
543
+ if (!existing && !fromFallback) {
544
+ return null;
545
+ }
546
+ const merged = {
547
+ ...existing ?? {},
548
+ defaults: {
549
+ ...fromFallback ?? {},
550
+ ...existing?.defaults ?? {},
551
+ contact: {
552
+ ...fromFallback?.contact ?? {},
553
+ ...existing?.defaults?.contact ?? {},
554
+ extras: {
555
+ ...fromFallback?.contact?.extras ?? {},
556
+ ...existing?.defaults?.contact?.extras ?? {}
557
+ }
558
+ },
559
+ trust: {
560
+ ...fromFallback?.trust ?? {},
561
+ ...existing?.defaults?.trust ?? {}
562
+ },
563
+ faq: existing?.defaults?.faq?.length ? existing.defaults.faq : fromFallback?.faq
564
+ }
565
+ };
566
+ return normalizeJmpContentManifest(merged);
567
+ }
568
+ function fallbackToManifestDefaults(fallback) {
569
+ if (!fallback) return null;
570
+ const contact = {};
571
+ if (fallback.displayName?.trim()) contact.displayName = fallback.displayName.trim();
572
+ if (fallback.email?.trim()) contact.email = fallback.email.trim();
573
+ if (typeof fallback.phone === "string" && fallback.phone.trim()) {
574
+ contact.phone = fallback.phone.trim();
575
+ }
576
+ if (fallback.address?.trim()) contact.address = fallback.address.trim();
577
+ if (fallback.hours?.trim()) contact.hours = fallback.hours.trim();
578
+ if (fallback.serviceArea?.trim()) contact.serviceArea = fallback.serviceArea.trim();
579
+ if (fallback.googleMapsUrl?.trim()) {
580
+ contact.googleMapsUrl = fallback.googleMapsUrl.trim();
581
+ }
582
+ if (fallback.linkedin?.trim()) contact.linkedinUrl = fallback.linkedin.trim();
583
+ if (fallback.instagram?.trim()) contact.instagramUrl = fallback.instagram.trim();
584
+ if (fallback.facebook?.trim()) contact.facebookUrl = fallback.facebook.trim();
585
+ if (fallback.x?.trim()) contact.xUrl = fallback.x.trim();
586
+ if (fallback.youtube?.trim()) contact.youtubeUrl = fallback.youtube.trim();
587
+ const trust = {};
588
+ if (fallback.googleMapsUrl?.trim()) {
589
+ trust.googleReviewsUrl = fallback.googleMapsUrl.trim();
590
+ }
591
+ const hasContact = Object.keys(contact).length > 0;
592
+ const hasTrust = Object.keys(trust).length > 0;
593
+ if (!hasContact && !hasTrust) return null;
594
+ return {
595
+ ...hasContact ? { contact } : {},
596
+ ...hasTrust ? { trust } : {}
597
+ };
453
598
  }
454
599
  function resolveContentWrappersForReport(config) {
455
600
  const explicit = config.contentWrappers ?? [];