@jmp-technologies/analytics 0.1.27 → 0.1.32

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 (100) hide show
  1. package/dist/astro/client.cjs +256 -11
  2. package/dist/astro/client.cjs.map +1 -1
  3. package/dist/astro/client.d.cts +2 -2
  4. package/dist/astro/client.d.ts +2 -2
  5. package/dist/astro/client.js +2 -2
  6. package/dist/astro/content.cjs +308 -13
  7. package/dist/astro/content.cjs.map +1 -1
  8. package/dist/astro/content.d.cts +12 -3
  9. package/dist/astro/content.d.ts +12 -3
  10. package/dist/astro/content.js +9 -3
  11. package/dist/astro/integration.cjs +228 -10
  12. package/dist/astro/integration.cjs.map +1 -1
  13. package/dist/astro/integration.js +3 -3
  14. package/dist/astro/middleware.cjs +2 -1
  15. package/dist/astro/middleware.cjs.map +1 -1
  16. package/dist/astro/middleware.d.cts +2 -2
  17. package/dist/astro/middleware.d.ts +2 -2
  18. package/dist/astro/middleware.js +2 -2
  19. package/dist/astro/register.cjs +228 -10
  20. package/dist/astro/register.cjs.map +1 -1
  21. package/dist/astro/register.js +3 -3
  22. package/dist/{chunk-KZ4WVDGL.js → chunk-7623G3XL.js} +3 -3
  23. package/dist/{chunk-A4RRTY5D.js → chunk-AIFJ7DVO.js} +3 -2
  24. package/dist/{chunk-A4RRTY5D.js.map → chunk-AIFJ7DVO.js.map} +1 -1
  25. package/dist/{chunk-YCVHRMM6.js → chunk-G5BMWPQ6.js} +2 -3
  26. package/dist/{chunk-YCVHRMM6.js.map → chunk-G5BMWPQ6.js.map} +1 -1
  27. package/dist/{chunk-HODG4NJQ.js → chunk-HFLU7HQE.js} +2 -2
  28. package/dist/{chunk-PG3IOI5O.js → chunk-HKMDWTA2.js} +53 -6
  29. package/dist/chunk-HKMDWTA2.js.map +1 -0
  30. package/dist/{chunk-DNYJF7BG.js → chunk-KPTMZQCY.js} +3 -3
  31. package/dist/{chunk-FNWE2DT5.js → chunk-NDSPSAWQ.js} +18 -8
  32. package/dist/chunk-NDSPSAWQ.js.map +1 -0
  33. package/dist/{chunk-UVYF33XE.js → chunk-NI7R6QZQ.js} +293 -13
  34. package/dist/chunk-NI7R6QZQ.js.map +1 -0
  35. package/dist/chunk-RI3KKDPX.js +75 -0
  36. package/dist/chunk-RI3KKDPX.js.map +1 -0
  37. package/dist/{create-jmp-analytics-D4Qw_d6o.d.cts → create-jmp-analytics-D1dUsqCQ.d.cts} +1 -2
  38. package/dist/{create-jmp-analytics-DpG5Hdl5.d.ts → create-jmp-analytics-htx2oOEf.d.ts} +1 -2
  39. package/dist/index.cjs +295 -12
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +8 -6
  42. package/dist/index.d.ts +8 -6
  43. package/dist/index.js +10 -2
  44. package/dist/next/content.cjs +310 -13
  45. package/dist/next/content.cjs.map +1 -1
  46. package/dist/next/content.d.cts +7 -5
  47. package/dist/next/content.d.ts +7 -5
  48. package/dist/next/content.js +11 -3
  49. package/dist/next/content.js.map +1 -1
  50. package/dist/next/instrumentation.cjs +228 -10
  51. package/dist/next/instrumentation.cjs.map +1 -1
  52. package/dist/next/instrumentation.js +2 -2
  53. package/dist/next/landing-capture-script-server.cjs +1 -2
  54. package/dist/next/landing-capture-script-server.cjs.map +1 -1
  55. package/dist/next/landing-capture-script-server.js +1 -1
  56. package/dist/next/landing-pages.cjs +228 -12
  57. package/dist/next/landing-pages.cjs.map +1 -1
  58. package/dist/next/landing-pages.d.cts +4 -16
  59. package/dist/next/landing-pages.d.ts +4 -16
  60. package/dist/next/landing-pages.js +13 -67
  61. package/dist/next/landing-pages.js.map +1 -1
  62. package/dist/next/locations.cjs +737 -0
  63. package/dist/next/locations.cjs.map +1 -0
  64. package/dist/next/locations.d.cts +55 -0
  65. package/dist/next/locations.d.ts +55 -0
  66. package/dist/next/locations.js +158 -0
  67. package/dist/next/locations.js.map +1 -0
  68. package/dist/next/middleware.cjs +2 -1
  69. package/dist/next/middleware.cjs.map +1 -1
  70. package/dist/next/middleware.d.cts +2 -2
  71. package/dist/next/middleware.d.ts +2 -2
  72. package/dist/next/middleware.js +2 -2
  73. package/dist/next/site-root-server.cjs +259 -14
  74. package/dist/next/site-root-server.cjs.map +1 -1
  75. package/dist/next/site-root-server.js +5 -5
  76. package/dist/next.cjs +270 -17
  77. package/dist/next.cjs.map +1 -1
  78. package/dist/next.d.cts +3 -3
  79. package/dist/next.d.ts +3 -3
  80. package/dist/next.js +4 -4
  81. package/dist/react.cjs +389 -136
  82. package/dist/react.cjs.map +1 -1
  83. package/dist/react.d.cts +2 -2
  84. package/dist/react.d.ts +2 -2
  85. package/dist/react.js +3 -3
  86. package/dist/{site-config-UTzDG-UG.d.ts → site-config-B7USGGzu.d.cts} +22 -2
  87. package/dist/{site-config-CJqYnZm7.d.cts → site-config-C4bcUoLI.d.ts} +22 -2
  88. package/dist/{track-page-view-tX0Magkd.d.cts → track-page-view-C4TbbULE.d.cts} +1 -1
  89. package/dist/{track-page-view-CMAqyhD_.d.ts → track-page-view-RiB-xgIx.d.ts} +1 -1
  90. package/dist/{types-B-111Wht.d.ts → types-DRljY1Yy.d.cts} +92 -2
  91. package/dist/{types-B-111Wht.d.cts → types-DRljY1Yy.d.ts} +92 -2
  92. package/dist/utils-BajG58pj.d.cts +15 -0
  93. package/dist/utils-CHT3SQFv.d.ts +15 -0
  94. package/package.json +7 -2
  95. package/dist/chunk-FNWE2DT5.js.map +0 -1
  96. package/dist/chunk-PG3IOI5O.js.map +0 -1
  97. package/dist/chunk-UVYF33XE.js.map +0 -1
  98. /package/dist/{chunk-KZ4WVDGL.js.map → chunk-7623G3XL.js.map} +0 -0
  99. /package/dist/{chunk-HODG4NJQ.js.map → chunk-HFLU7HQE.js.map} +0 -0
  100. /package/dist/{chunk-DNYJF7BG.js.map → chunk-KPTMZQCY.js.map} +0 -0
@@ -286,6 +286,26 @@ function classifyContactHref(href) {
286
286
  }
287
287
  return null;
288
288
  }
289
+ function extractTelTarget(href) {
290
+ const raw = href.trim();
291
+ if (!raw.toLowerCase().startsWith("tel:")) {
292
+ return null;
293
+ }
294
+ const target = decodeURIComponent(
295
+ raw.slice(4).split("?")[0]?.split(";")[0] ?? ""
296
+ ).trim();
297
+ return target || null;
298
+ }
299
+ function extractMailtoTarget(href) {
300
+ const raw = href.trim();
301
+ if (!raw.toLowerCase().startsWith("mailto:")) {
302
+ return null;
303
+ }
304
+ const target = decodeURIComponent(
305
+ raw.slice(7).split("?")[0]?.split(",")[0] ?? ""
306
+ ).trim();
307
+ return target || null;
308
+ }
289
309
 
290
310
  // src/constants.ts
291
311
  var JMP_ANALYTICS_SDK_VERSION = "0.1.26";
@@ -702,14 +722,22 @@ function createJmpAnalytics(config) {
702
722
  if (dedupeContactClick(`call_click:${path}`)) {
703
723
  return;
704
724
  }
705
- void trackCallClick(path);
725
+ const contactTarget = extractTelTarget(href);
726
+ void trackCallClick(
727
+ path,
728
+ contactTarget ? { contactTarget } : void 0
729
+ );
706
730
  return;
707
731
  }
708
732
  if (classified.kind === "email") {
709
733
  if (dedupeContactClick(`email_click:${path}`)) {
710
734
  return;
711
735
  }
712
- void trackEmailClick(path);
736
+ const contactTarget = extractMailtoTarget(href);
737
+ void trackEmailClick(
738
+ path,
739
+ contactTarget ? { contactTarget } : void 0
740
+ );
713
741
  return;
714
742
  }
715
743
  if (dedupeContactClick(`contact_click:${classified.channel}:${path}`)) {
@@ -755,6 +783,209 @@ function createJmpAnalytics(config) {
755
783
  };
756
784
  }
757
785
 
786
+ // src/content/manifest.ts
787
+ var JMP_CONTENT_MANIFEST_VERSION = 1;
788
+ var TRUST_SECTIONS = /* @__PURE__ */ new Set([
789
+ "summary",
790
+ "testimonials",
791
+ "reviews",
792
+ "stats",
793
+ "logos",
794
+ "credentials"
795
+ ]);
796
+ function normalizeKey(value) {
797
+ return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
798
+ }
799
+ function isValidExtraKey(key) {
800
+ return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(key);
801
+ }
802
+ var MAX_EXTERNAL_ADMIN_LINKS = 10;
803
+ var MAX_EXTERNAL_ADMIN_LINK_LABEL_LENGTH = 80;
804
+ var EXTERNAL_ADMIN_LINK_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
805
+ function tryNormalizeHttpUrl(input) {
806
+ if (typeof input !== "string" || !input.trim()) {
807
+ return null;
808
+ }
809
+ try {
810
+ const url = new URL(input.trim());
811
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
812
+ return null;
813
+ }
814
+ return url.toString().replace(/\/$/, "");
815
+ } catch {
816
+ return null;
817
+ }
818
+ }
819
+ function normalizeShopifyExternalSource(shopify) {
820
+ if (!shopify || typeof shopify !== "object") {
821
+ return null;
822
+ }
823
+ const adminUrl = tryNormalizeHttpUrl(shopify.adminUrl);
824
+ const storeUrl = tryNormalizeHttpUrl(shopify.storeUrl);
825
+ if (!adminUrl && !storeUrl) {
826
+ return null;
827
+ }
828
+ return {
829
+ ...adminUrl ? { adminUrl } : {},
830
+ ...storeUrl ? { storeUrl } : {}
831
+ };
832
+ }
833
+ function normalizeExternalAdminLinkEntries(links) {
834
+ if (!Array.isArray(links)) {
835
+ return [];
836
+ }
837
+ const seenIds = /* @__PURE__ */ new Set();
838
+ const out = [];
839
+ for (const raw of links) {
840
+ if (!raw || typeof raw !== "object" || out.length >= MAX_EXTERNAL_ADMIN_LINKS) {
841
+ continue;
842
+ }
843
+ const id = typeof raw.id === "string" ? raw.id.trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") : "";
844
+ const label = typeof raw.label === "string" ? raw.label.trim().slice(0, MAX_EXTERNAL_ADMIN_LINK_LABEL_LENGTH) : "";
845
+ const url = tryNormalizeHttpUrl(raw.url);
846
+ if (!id || !label || !url || !EXTERNAL_ADMIN_LINK_ID_PATTERN.test(id) || seenIds.has(id)) {
847
+ continue;
848
+ }
849
+ seenIds.add(id);
850
+ out.push({ id, label, url });
851
+ }
852
+ return out;
853
+ }
854
+ function normalizeExternalSources(externalSources) {
855
+ if (!externalSources || typeof externalSources !== "object") {
856
+ return null;
857
+ }
858
+ const studioUrl = tryNormalizeHttpUrl(externalSources.sanity?.studioUrl);
859
+ const shopify = normalizeShopifyExternalSource(externalSources.shopify);
860
+ const links = normalizeExternalAdminLinkEntries(externalSources.links);
861
+ if (!studioUrl && !shopify && links.length === 0) {
862
+ return null;
863
+ }
864
+ return {
865
+ ...studioUrl ? { sanity: { studioUrl } } : {},
866
+ ...shopify ? { shopify } : {},
867
+ ...links.length > 0 ? { links } : {}
868
+ };
869
+ }
870
+ function normalizeJmpContentManifest(input) {
871
+ if (!input || typeof input !== "object") {
872
+ return null;
873
+ }
874
+ const routes = normalizeRoutes(input.routes);
875
+ const externalSources = normalizeExternalSources(input.externalSources);
876
+ const trust = normalizeTrust(input.trust);
877
+ const contact = normalizeContact(input.contact);
878
+ if (routes.length === 0 && !externalSources && !trust && !contact) {
879
+ return null;
880
+ }
881
+ return {
882
+ version: JMP_CONTENT_MANIFEST_VERSION,
883
+ ...routes.length > 0 ? { routes } : {},
884
+ ...externalSources ? { externalSources } : {},
885
+ ...trust ? { trust } : {},
886
+ ...contact ? { contact } : {}
887
+ };
888
+ }
889
+ function normalizeRoutes(routes) {
890
+ if (!Array.isArray(routes)) {
891
+ return [];
892
+ }
893
+ const seen = /* @__PURE__ */ new Set();
894
+ const out = [];
895
+ for (const raw of routes) {
896
+ if (!raw || typeof raw !== "object") continue;
897
+ const wrapper = typeof raw.wrapper === "string" ? raw.wrapper.trim().toLowerCase() : "";
898
+ const pattern = typeof raw.pattern === "string" ? raw.pattern.trim() : "";
899
+ if (!wrapper || !pattern) continue;
900
+ const dedupe = `${wrapper}:${pattern}`;
901
+ if (seen.has(dedupe)) continue;
902
+ seen.add(dedupe);
903
+ out.push({
904
+ wrapper,
905
+ pattern,
906
+ ...typeof raw.index === "string" && raw.index.trim() ? { index: raw.index.trim() } : {},
907
+ ...typeof raw.label === "string" && raw.label.trim() ? { label: raw.label.trim() } : {}
908
+ });
909
+ }
910
+ return out;
911
+ }
912
+ function normalizeTrust(trust) {
913
+ if (!trust || typeof trust !== "object") return null;
914
+ const blocks = normalizeTrustBlocks(trust.blocks);
915
+ const labels = normalizeTrustLabels(trust.labels);
916
+ const mergeTestimonialsReviews = trust.mergeTestimonialsReviews === true;
917
+ if (blocks.length === 0 && !labels && !mergeTestimonialsReviews) return null;
918
+ return {
919
+ ...blocks.length > 0 ? { blocks } : {},
920
+ ...labels ? { labels } : {},
921
+ ...mergeTestimonialsReviews ? { mergeTestimonialsReviews: true } : {}
922
+ };
923
+ }
924
+ function normalizeTrustBlocks(blocks) {
925
+ if (!Array.isArray(blocks)) return [];
926
+ const seen = /* @__PURE__ */ new Set();
927
+ const out = [];
928
+ for (const raw of blocks) {
929
+ if (!raw || typeof raw !== "object") continue;
930
+ const section = typeof raw.section === "string" ? raw.section.trim().toLowerCase() : "";
931
+ if (!TRUST_SECTIONS.has(section) || seen.has(section)) continue;
932
+ seen.add(section);
933
+ out.push({
934
+ section,
935
+ ...typeof raw.label === "string" && raw.label.trim() ? { label: raw.label.trim() } : {}
936
+ });
937
+ }
938
+ return out;
939
+ }
940
+ function normalizeTrustLabels(labels) {
941
+ if (!labels || typeof labels !== "object") return null;
942
+ const out = {};
943
+ for (const [key, value] of Object.entries(labels)) {
944
+ if (TRUST_SECTIONS.has(key) && typeof value === "string" && value.trim()) {
945
+ out[key] = value.trim();
946
+ }
947
+ }
948
+ return Object.keys(out).length > 0 ? out : null;
949
+ }
950
+ function normalizeContact(contact) {
951
+ if (!contact || typeof contact !== "object") return null;
952
+ const extras = normalizeContactExtras(contact.extras);
953
+ return extras.length > 0 ? { extras } : null;
954
+ }
955
+ function normalizeContactExtras(extras) {
956
+ if (!Array.isArray(extras)) return [];
957
+ const seen = /* @__PURE__ */ new Set();
958
+ const out = [];
959
+ for (const raw of extras) {
960
+ if (!raw || typeof raw !== "object") continue;
961
+ const label = typeof raw.label === "string" ? raw.label.trim() : "";
962
+ const key = normalizeKey(
963
+ typeof raw.key === "string" && raw.key.trim() ? raw.key : label
964
+ );
965
+ if (!key || !label || !isValidExtraKey(key) || seen.has(key)) continue;
966
+ seen.add(key);
967
+ out.push({ key, label });
968
+ }
969
+ return out;
970
+ }
971
+ function stableJmpManifestFingerprint(manifest) {
972
+ return manifest ? JSON.stringify(manifest) : "";
973
+ }
974
+ function inferWrapperSlotsFromManifest(manifest) {
975
+ const slots = /* @__PURE__ */ new Set();
976
+ for (const route of manifest?.routes ?? []) {
977
+ slots.add(route.wrapper);
978
+ }
979
+ for (const block of manifest?.trust?.blocks ?? []) {
980
+ slots.add(`trust.${block.section}`);
981
+ slots.add("trust");
982
+ }
983
+ if (manifest?.contact?.extras?.length) {
984
+ slots.add("contact");
985
+ }
986
+ return [...slots];
987
+ }
988
+
758
989
  // src/content/wrapper-discovery.ts
759
990
  var WRAPPER_SLOT_ORDER = [
760
991
  "blog",
@@ -774,16 +1005,22 @@ var syncHandler = null;
774
1005
  function getDiscoveredContentWrappers() {
775
1006
  return sortWrapperSlots([...discovered]);
776
1007
  }
1008
+ function resolveContentManifestForReport(config) {
1009
+ return normalizeJmpContentManifest(config.contentManifest);
1010
+ }
777
1011
  function resolveContentWrappersForReport(config) {
778
1012
  const explicit = config.contentWrappers ?? [];
779
1013
  const auto = getDiscoveredContentWrappers();
1014
+ const fromManifest = inferWrapperSlotsFromManifest(
1015
+ resolveContentManifestForReport(config)
1016
+ );
780
1017
  if (config.contentWrapperMode === "manual") {
781
- return sortWrapperSlots([...explicit]);
1018
+ return sortWrapperSlots([...explicit, ...fromManifest]);
782
1019
  }
783
1020
  if (config.contentWrapperMode === "explicit-only") {
784
- return sortWrapperSlots([...explicit]);
1021
+ return sortWrapperSlots([...explicit, ...fromManifest]);
785
1022
  }
786
- const merged = /* @__PURE__ */ new Set([...explicit, ...auto]);
1023
+ const merged = /* @__PURE__ */ new Set([...explicit, ...auto, ...fromManifest]);
787
1024
  return sortWrapperSlots([...merged]);
788
1025
  }
789
1026
  function hasReportedContentWrappers(dedupeKey) {
@@ -813,7 +1050,8 @@ async function registerJmpContentWrappers(config) {
813
1050
  if (!wrappers.length) {
814
1051
  return { ok: false, skipped: true };
815
1052
  }
816
- const dedupeKey = `${config.trackingKey}:${[...wrappers].sort().join(",")}`;
1053
+ const manifest = resolveContentManifestForReport(config);
1054
+ const dedupeKey = `${config.trackingKey}:${[...wrappers].sort().join(",")}:${stableJmpManifestFingerprint(manifest)}`;
817
1055
  if (hasReportedContentWrappers(dedupeKey)) {
818
1056
  return { ok: true, wrappers };
819
1057
  }
@@ -826,7 +1064,17 @@ async function registerJmpContentWrappers(config) {
826
1064
  }
827
1065
  const url = `${baseUrl}/api/content/capabilities`;
828
1066
  if (config.debug) {
829
- console.debug("[@jmp-technologies/analytics]", "POST", url, { wrappers });
1067
+ console.debug("[@jmp-technologies/analytics]", "POST", url, {
1068
+ wrappers,
1069
+ manifest
1070
+ });
1071
+ }
1072
+ const body = {
1073
+ wrappers,
1074
+ sdkVersion: JMP_ANALYTICS_SDK_VERSION
1075
+ };
1076
+ if (manifest) {
1077
+ body.manifest = manifest;
830
1078
  }
831
1079
  const res = await resolvedFetch(url, {
832
1080
  method: "POST",
@@ -834,10 +1082,7 @@ async function registerJmpContentWrappers(config) {
834
1082
  "Content-Type": "application/json",
835
1083
  "X-JMP-Tracking-Key": config.trackingKey
836
1084
  },
837
- body: JSON.stringify({
838
- wrappers,
839
- sdkVersion: JMP_ANALYTICS_SDK_VERSION
840
- })
1085
+ body: JSON.stringify(body)
841
1086
  });
842
1087
  const text = await res.text();
843
1088
  if (!res.ok) {