@jmp-technologies/analytics 0.1.37 → 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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/astro/client.cjs +144 -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 +2 -2
  7. package/dist/astro/content.cjs +190 -8
  8. package/dist/astro/content.cjs.map +1 -1
  9. package/dist/astro/content.d.cts +5 -4
  10. package/dist/astro/content.d.ts +5 -4
  11. package/dist/astro/content.js +5 -3
  12. package/dist/astro/integration.cjs +149 -6
  13. package/dist/astro/integration.cjs.map +1 -1
  14. package/dist/astro/integration.js +3 -3
  15. package/dist/astro/middleware.cjs +5 -2
  16. package/dist/astro/middleware.cjs.map +1 -1
  17. package/dist/astro/middleware.d.cts +2 -2
  18. package/dist/astro/middleware.d.ts +2 -2
  19. package/dist/astro/middleware.js +2 -2
  20. package/dist/astro/register.cjs +149 -6
  21. package/dist/astro/register.cjs.map +1 -1
  22. package/dist/astro/register.js +3 -3
  23. package/dist/{chunk-EMZXL6VF.js → chunk-6WQMWPEY.js} +6 -3
  24. package/dist/chunk-6WQMWPEY.js.map +1 -0
  25. package/dist/{chunk-D43AEUXU.js → chunk-BXPMVR7M.js} +3 -3
  26. package/dist/{chunk-TN6PGIB5.js → chunk-JJ3JP3RV.js} +2 -2
  27. package/dist/{chunk-UHXWHKHJ.js → chunk-M66PHSBO.js} +16 -3
  28. package/dist/chunk-M66PHSBO.js.map +1 -0
  29. package/dist/{chunk-VQF6QYLR.js → chunk-OCIOQIE4.js} +3 -3
  30. package/dist/{chunk-PTXPNIMF.js → chunk-ONIPLMOY.js} +2 -2
  31. package/dist/{chunk-RT2YYDCK.js → chunk-XAEWXWSP.js} +189 -8
  32. package/dist/chunk-XAEWXWSP.js.map +1 -0
  33. package/dist/constants-DTZMYgi4.d.cts +12 -0
  34. package/dist/constants-DTZMYgi4.d.ts +12 -0
  35. package/dist/{create-jmp-analytics-Bz0-K0Af.d.cts → create-jmp-analytics-C1IH32ZF.d.cts} +1 -1
  36. package/dist/{create-jmp-analytics-DRjrlWUn.d.ts → create-jmp-analytics-CjVYSmPJ.d.ts} +1 -1
  37. package/dist/index.cjs +196 -8
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +11 -13
  40. package/dist/index.d.ts +11 -13
  41. package/dist/index.js +10 -2
  42. package/dist/next/content.cjs +195 -8
  43. package/dist/next/content.cjs.map +1 -1
  44. package/dist/next/content.d.cts +6 -4
  45. package/dist/next/content.d.ts +6 -4
  46. package/dist/next/content.js +11 -3
  47. package/dist/next/content.js.map +1 -1
  48. package/dist/next/instrumentation.cjs +149 -6
  49. package/dist/next/instrumentation.cjs.map +1 -1
  50. package/dist/next/instrumentation.js +2 -2
  51. package/dist/next/landing-pages.cjs +156 -7
  52. package/dist/next/landing-pages.cjs.map +1 -1
  53. package/dist/next/landing-pages.d.cts +2 -2
  54. package/dist/next/landing-pages.d.ts +2 -2
  55. package/dist/next/landing-pages.js +3 -3
  56. package/dist/next/locations.cjs +156 -7
  57. package/dist/next/locations.cjs.map +1 -1
  58. package/dist/next/locations.d.cts +2 -2
  59. package/dist/next/locations.d.ts +2 -2
  60. package/dist/next/locations.js +3 -3
  61. package/dist/next/middleware.cjs +5 -2
  62. package/dist/next/middleware.cjs.map +1 -1
  63. package/dist/next/middleware.d.cts +2 -2
  64. package/dist/next/middleware.d.ts +2 -2
  65. package/dist/next/middleware.js +2 -2
  66. package/dist/next/site-root-server.cjs +156 -7
  67. package/dist/next/site-root-server.cjs.map +1 -1
  68. package/dist/next/site-root-server.js +4 -4
  69. package/dist/next.cjs +144 -4
  70. package/dist/next.cjs.map +1 -1
  71. package/dist/next.d.cts +3 -3
  72. package/dist/next.d.ts +3 -3
  73. package/dist/next.js +4 -4
  74. package/dist/react.cjs +144 -4
  75. package/dist/react.cjs.map +1 -1
  76. package/dist/react.d.cts +2 -2
  77. package/dist/react.d.ts +2 -2
  78. package/dist/react.js +3 -3
  79. package/dist/{site-config-BxEmJxBB.d.ts → site-config-BEaYpZ3X.d.ts} +9 -3
  80. package/dist/{site-config-Cgq67uQ1.d.cts → site-config-BN6Z2zIf.d.cts} +9 -3
  81. package/dist/{track-page-view-74Su6lQY.d.ts → track-page-view-B3OwUOYl.d.ts} +1 -1
  82. package/dist/{track-page-view-BCX1Dsfk.d.cts → track-page-view-BeVjC-pV.d.cts} +1 -1
  83. package/dist/{types-yNgoakwk.d.ts → types-uwXEaMD6.d.cts} +45 -2
  84. package/dist/{types-yNgoakwk.d.cts → types-uwXEaMD6.d.ts} +45 -2
  85. package/dist/{utils-BLoWWfSw.d.ts → utils-6a6lNKsg.d.ts} +1 -1
  86. package/dist/{utils-UPTIdK1D.d.cts → utils-Cbb3CO3i.d.cts} +1 -1
  87. package/docs/legal-and-privacy.md +2 -2
  88. package/package.json +1 -1
  89. package/dist/chunk-EMZXL6VF.js.map +0 -1
  90. package/dist/chunk-RT2YYDCK.js.map +0 -1
  91. package/dist/chunk-UHXWHKHJ.js.map +0 -1
  92. /package/dist/{chunk-D43AEUXU.js.map → chunk-BXPMVR7M.js.map} +0 -0
  93. /package/dist/{chunk-TN6PGIB5.js.map → chunk-JJ3JP3RV.js.map} +0 -0
  94. /package/dist/{chunk-VQF6QYLR.js.map → chunk-OCIOQIE4.js.map} +0 -0
  95. /package/dist/{chunk-PTXPNIMF.js.map → chunk-ONIPLMOY.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  DEFAULT_JMP_BROWSER_PAGE_VIEW_DEDUPE_MS,
3
3
  createJmpAnalytics
4
- } from "../chunk-RT2YYDCK.js";
4
+ } from "../chunk-XAEWXWSP.js";
5
5
  import {
6
6
  buildLandingCaptureInlineScript
7
7
  } from "../chunk-TCZ6TC2L.js";
8
8
  import {
9
9
  readJmpPublicEnvFromImportMeta
10
- } from "../chunk-EMZXL6VF.js";
10
+ } from "../chunk-6WQMWPEY.js";
11
11
 
12
12
  // src/astro/client.ts
13
13
  var jmpAnalyticsSingleton = null;
@@ -32,6 +32,7 @@ __export(content_exports, {
32
32
  loadLandingPageDetail: () => loadLandingPageDetail,
33
33
  loadLandingPageSitemap: () => loadLandingPageSitemap,
34
34
  loadLandingPages: () => loadLandingPages,
35
+ loadLegalDocument: () => loadLegalDocument,
35
36
  loadLocationDetail: () => loadLocationDetail,
36
37
  loadLocations: () => loadLocations,
37
38
  loadPopularPages: () => loadPopularPages,
@@ -45,10 +46,12 @@ module.exports = __toCommonJS(content_exports);
45
46
  var LANDING_REFERER_COOKIE_MAX_AGE_SEC = 30 * 60;
46
47
 
47
48
  // package.json
48
- var version = "0.1.37";
49
+ var version = "0.1.39";
49
50
 
50
51
  // src/constants.ts
51
52
  var JMP_ANALYTICS_SDK_VERSION = version;
53
+ var JMP_CONTENT_CACHE_TAG = "jmp-content";
54
+ var JMP_CONTENT_REVALIDATE_SECONDS = 3600;
52
55
 
53
56
  // src/http.ts
54
57
  function responseLooksLikeHtml(body) {
@@ -115,11 +118,14 @@ function getJmpContentConfig() {
115
118
  return null;
116
119
  }
117
120
  const site = getJmpSiteDefinition();
121
+ const contentWrappers = site?.contentWrappers ?? void 0;
122
+ const inferredMode = contentWrappers && contentWrappers.length > 0 ? "manual" : void 0;
118
123
  return {
119
124
  baseUrl: analyticsUrl,
120
125
  trackingKey,
121
- contentWrappers: site?.contentWrappers ?? void 0,
122
- contentManifest: site?.contentManifest ?? void 0
126
+ contentWrappers,
127
+ contentManifest: site?.contentManifest ?? void 0,
128
+ contentWrapperMode: site?.contentWrapperMode ?? inferredMode
123
129
  };
124
130
  }
125
131
 
@@ -242,7 +248,8 @@ function normalizeJmpContentManifest(input) {
242
248
  const externalSources = normalizeExternalSources(input.externalSources);
243
249
  const trust = normalizeTrust(input.trust);
244
250
  const contact = normalizeContact(input.contact);
245
- if (routes.length === 0 && !externalSources && !trust && !contact) {
251
+ const defaults = normalizeManifestDefaults(input.defaults);
252
+ if (routes.length === 0 && !externalSources && !trust && !contact && !defaults) {
246
253
  return null;
247
254
  }
248
255
  return {
@@ -250,7 +257,8 @@ function normalizeJmpContentManifest(input) {
250
257
  ...routes.length > 0 ? { routes } : {},
251
258
  ...externalSources ? { externalSources } : {},
252
259
  ...trust ? { trust } : {},
253
- ...contact ? { contact } : {}
260
+ ...contact ? { contact } : {},
261
+ ...defaults ? { defaults } : {}
254
262
  };
255
263
  }
256
264
  function normalizeRoutes(routes) {
@@ -314,6 +322,85 @@ function normalizeTrustLabels(labels) {
314
322
  }
315
323
  return Object.keys(out).length > 0 ? out : null;
316
324
  }
325
+ function readDefaultText(value, max = 500) {
326
+ if (typeof value !== "string") return void 0;
327
+ const trimmed = value.trim();
328
+ if (!trimmed) return void 0;
329
+ return trimmed.slice(0, max);
330
+ }
331
+ function normalizeManifestDefaults(defaults) {
332
+ if (!defaults || typeof defaults !== "object") return null;
333
+ const contactRaw = defaults.contact;
334
+ const contact = {};
335
+ if (contactRaw && typeof contactRaw === "object") {
336
+ const displayName = readDefaultText(contactRaw.displayName, 120);
337
+ const email = readDefaultText(contactRaw.email, 200);
338
+ const phone = readDefaultText(contactRaw.phone, 40);
339
+ const address = readDefaultText(contactRaw.address, 400);
340
+ const hours = readDefaultText(contactRaw.hours, 400);
341
+ const serviceArea = readDefaultText(contactRaw.serviceArea, 200);
342
+ const googleMapsUrl = readDefaultText(contactRaw.googleMapsUrl, 2048);
343
+ const linkedinUrl = readDefaultText(contactRaw.linkedinUrl, 2048);
344
+ const instagramUrl = readDefaultText(contactRaw.instagramUrl, 2048);
345
+ const facebookUrl = readDefaultText(contactRaw.facebookUrl, 2048);
346
+ const xUrl = readDefaultText(contactRaw.xUrl, 2048);
347
+ const youtubeUrl = readDefaultText(contactRaw.youtubeUrl, 2048);
348
+ if (displayName) contact.displayName = displayName;
349
+ if (email) contact.email = email;
350
+ if (phone) contact.phone = phone;
351
+ if (address) contact.address = address;
352
+ if (hours) contact.hours = hours;
353
+ if (serviceArea) contact.serviceArea = serviceArea;
354
+ if (googleMapsUrl) contact.googleMapsUrl = googleMapsUrl;
355
+ if (linkedinUrl) contact.linkedinUrl = linkedinUrl;
356
+ if (instagramUrl) contact.instagramUrl = instagramUrl;
357
+ if (facebookUrl) contact.facebookUrl = facebookUrl;
358
+ if (xUrl) contact.xUrl = xUrl;
359
+ if (youtubeUrl) contact.youtubeUrl = youtubeUrl;
360
+ if (contactRaw.extras && typeof contactRaw.extras === "object") {
361
+ const extras = {};
362
+ for (const [rawKey, rawValue] of Object.entries(contactRaw.extras)) {
363
+ if (Object.keys(extras).length >= 10) break;
364
+ const key = normalizeKey(rawKey);
365
+ const value = readDefaultText(rawValue, 200);
366
+ if (key && isValidExtraKey(key) && value) extras[key] = value;
367
+ }
368
+ if (Object.keys(extras).length > 0) contact.extras = extras;
369
+ }
370
+ }
371
+ const faq = [];
372
+ if (Array.isArray(defaults.faq)) {
373
+ for (const raw of defaults.faq) {
374
+ if (!raw || typeof raw !== "object" || faq.length >= 40) continue;
375
+ const question = readDefaultText(raw.question, 300);
376
+ const answer = readDefaultText(raw.answer, 8e3);
377
+ if (!question || !answer) continue;
378
+ const category = readDefaultText(raw.category, 80);
379
+ faq.push({ question, answer, ...category ? { category } : {} });
380
+ }
381
+ }
382
+ const trustRaw = defaults.trust;
383
+ const trust = {};
384
+ if (trustRaw && typeof trustRaw === "object") {
385
+ const assign = (key, max) => {
386
+ const value = readDefaultText(trustRaw[key], max);
387
+ if (value) trust[key] = value;
388
+ };
389
+ assign("googleReviewsUrl", 2048);
390
+ assign("googlePlaceId", 128);
391
+ assign("yelpUrl", 2048);
392
+ assign("trustpilotUrl", 2048);
393
+ assign("disclaimer", 1e3);
394
+ }
395
+ const hasContact = Object.keys(contact).length > 0;
396
+ const hasTrust = Object.keys(trust).length > 0;
397
+ if (!hasContact && faq.length === 0 && !hasTrust) return null;
398
+ return {
399
+ ...hasContact ? { contact } : {},
400
+ ...faq.length > 0 ? { faq } : {},
401
+ ...hasTrust ? { trust } : {}
402
+ };
403
+ }
317
404
  function normalizeContact(contact) {
318
405
  if (!contact || typeof contact !== "object") return null;
319
406
  const extras = normalizeContactExtras(contact.extras);
@@ -381,7 +468,11 @@ async function getContentText(config, path) {
381
468
  }
382
469
  const res = await resolvedFetch(url, {
383
470
  method: "GET",
384
- headers: jmpContentRequestHeaders(config)
471
+ headers: jmpContentRequestHeaders(config),
472
+ next: {
473
+ revalidate: JMP_CONTENT_REVALIDATE_SECONDS,
474
+ tags: [JMP_CONTENT_CACHE_TAG]
475
+ }
385
476
  });
386
477
  const text = await res.text();
387
478
  if (!res.ok) {
@@ -408,6 +499,7 @@ var WRAPPER_SLOT_ORDER = [
408
499
  "blog",
409
500
  "faq",
410
501
  "contact",
502
+ "legal",
411
503
  "trust",
412
504
  "trust.summary",
413
505
  "trust.testimonials",
@@ -434,7 +526,7 @@ function markTrustBundleWrappers(bundle) {
434
526
  }
435
527
  }
436
528
  function inferTrustWrapperSlots(bundle) {
437
- const slots = /* @__PURE__ */ new Set(["trust"]);
529
+ const slots = /* @__PURE__ */ new Set();
438
530
  const { summary, testimonials, stats, logos, credentials } = bundle;
439
531
  const hasSummary = summary.google_rating != null || summary.google_review_count != null || Boolean(summary.google_reviews_url?.trim()) || Boolean(summary.yelp_url?.trim()) || Boolean(summary.trustpilot_url?.trim()) || Boolean(summary.disclaimer?.trim());
440
532
  if (hasSummary) {
@@ -471,7 +563,65 @@ function getDiscoveredContentWrappers() {
471
563
  return sortWrapperSlots([...discovered]);
472
564
  }
473
565
  function resolveContentManifestForReport(config) {
474
- return normalizeJmpContentManifest(config.contentManifest);
566
+ const site = getJmpSiteDefinition();
567
+ const fallback = site?.contactFallback;
568
+ const existing = config.contentManifest;
569
+ const fromFallback = fallbackToManifestDefaults(fallback);
570
+ if (!existing && !fromFallback) {
571
+ return null;
572
+ }
573
+ const merged = {
574
+ ...existing ?? {},
575
+ defaults: {
576
+ ...fromFallback ?? {},
577
+ ...existing?.defaults ?? {},
578
+ contact: {
579
+ ...fromFallback?.contact ?? {},
580
+ ...existing?.defaults?.contact ?? {},
581
+ extras: {
582
+ ...fromFallback?.contact?.extras ?? {},
583
+ ...existing?.defaults?.contact?.extras ?? {}
584
+ }
585
+ },
586
+ trust: {
587
+ ...fromFallback?.trust ?? {},
588
+ ...existing?.defaults?.trust ?? {}
589
+ },
590
+ faq: existing?.defaults?.faq?.length ? existing.defaults.faq : fromFallback?.faq
591
+ }
592
+ };
593
+ return normalizeJmpContentManifest(merged);
594
+ }
595
+ function fallbackToManifestDefaults(fallback) {
596
+ if (!fallback) return null;
597
+ const contact = {};
598
+ if (fallback.displayName?.trim()) contact.displayName = fallback.displayName.trim();
599
+ if (fallback.email?.trim()) contact.email = fallback.email.trim();
600
+ if (typeof fallback.phone === "string" && fallback.phone.trim()) {
601
+ contact.phone = fallback.phone.trim();
602
+ }
603
+ if (fallback.address?.trim()) contact.address = fallback.address.trim();
604
+ if (fallback.hours?.trim()) contact.hours = fallback.hours.trim();
605
+ if (fallback.serviceArea?.trim()) contact.serviceArea = fallback.serviceArea.trim();
606
+ if (fallback.googleMapsUrl?.trim()) {
607
+ contact.googleMapsUrl = fallback.googleMapsUrl.trim();
608
+ }
609
+ if (fallback.linkedin?.trim()) contact.linkedinUrl = fallback.linkedin.trim();
610
+ if (fallback.instagram?.trim()) contact.instagramUrl = fallback.instagram.trim();
611
+ if (fallback.facebook?.trim()) contact.facebookUrl = fallback.facebook.trim();
612
+ if (fallback.x?.trim()) contact.xUrl = fallback.x.trim();
613
+ if (fallback.youtube?.trim()) contact.youtubeUrl = fallback.youtube.trim();
614
+ const trust = {};
615
+ if (fallback.googleMapsUrl?.trim()) {
616
+ trust.googleReviewsUrl = fallback.googleMapsUrl.trim();
617
+ }
618
+ const hasContact = Object.keys(contact).length > 0;
619
+ const hasTrust = Object.keys(trust).length > 0;
620
+ if (!hasContact && !hasTrust) return null;
621
+ return {
622
+ ...hasContact ? { contact } : {},
623
+ ...hasTrust ? { trust } : {}
624
+ };
475
625
  }
476
626
  function resolveContentWrappersForReport(config) {
477
627
  const explicit = config.contentWrappers ?? [];
@@ -581,6 +731,26 @@ async function getJmpFaqs(config, filters) {
581
731
  afterContentWrapperUse(config);
582
732
  return data.faqs;
583
733
  }
734
+ async function getJmpLegalDocument(config, slug) {
735
+ const key = slug.trim().toLowerCase();
736
+ if (!key) {
737
+ return null;
738
+ }
739
+ try {
740
+ const data = await getContent(
741
+ config,
742
+ `/api/content/legal?slug=${encodeURIComponent(key)}`
743
+ );
744
+ markContentWrapper("legal");
745
+ afterContentWrapperUse(config);
746
+ return data.document;
747
+ } catch (error) {
748
+ if (error instanceof Error && error.message.includes("HTTP 404")) {
749
+ return null;
750
+ }
751
+ throw error;
752
+ }
753
+ }
584
754
  async function getJmpLandingPages(config, filters) {
585
755
  const params = new URLSearchParams();
586
756
  if (filters?.kind) {
@@ -882,6 +1052,17 @@ async function loadFaqs(locale) {
882
1052
  return [];
883
1053
  }
884
1054
  }
1055
+ async function loadLegalDocument(slug) {
1056
+ const c = getJmpContentConfig();
1057
+ if (!c) {
1058
+ return null;
1059
+ }
1060
+ try {
1061
+ return await getJmpLegalDocument(c, slug);
1062
+ } catch {
1063
+ return null;
1064
+ }
1065
+ }
885
1066
  async function loadFaqBySlug(slug, locale) {
886
1067
  const normalized = slug.trim();
887
1068
  if (!normalized) {
@@ -993,6 +1174,7 @@ async function loadPopularPages(filters) {
993
1174
  loadLandingPageDetail,
994
1175
  loadLandingPageSitemap,
995
1176
  loadLandingPages,
1177
+ loadLegalDocument,
996
1178
  loadLocationDetail,
997
1179
  loadLocations,
998
1180
  loadPopularPages,