@jmp-technologies/analytics 0.1.27 → 0.1.30
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.
- package/dist/astro/client.cjs +226 -9
- package/dist/astro/client.cjs.map +1 -1
- package/dist/astro/client.d.cts +2 -2
- package/dist/astro/client.d.ts +2 -2
- package/dist/astro/client.js +2 -2
- package/dist/astro/content.cjs +253 -13
- package/dist/astro/content.cjs.map +1 -1
- package/dist/astro/content.d.cts +10 -3
- package/dist/astro/content.d.ts +10 -3
- package/dist/astro/content.js +5 -3
- package/dist/astro/integration.cjs +228 -10
- package/dist/astro/integration.cjs.map +1 -1
- package/dist/astro/integration.js +3 -3
- package/dist/astro/middleware.cjs +2 -1
- package/dist/astro/middleware.cjs.map +1 -1
- package/dist/astro/middleware.d.cts +2 -2
- package/dist/astro/middleware.d.ts +2 -2
- package/dist/astro/middleware.js +2 -2
- package/dist/astro/register.cjs +228 -10
- package/dist/astro/register.cjs.map +1 -1
- package/dist/astro/register.js +3 -3
- package/dist/{chunk-A4RRTY5D.js → chunk-AIFJ7DVO.js} +3 -2
- package/dist/{chunk-A4RRTY5D.js.map → chunk-AIFJ7DVO.js.map} +1 -1
- package/dist/{chunk-PG3IOI5O.js → chunk-FS4BZ7DR.js} +27 -6
- package/dist/chunk-FS4BZ7DR.js.map +1 -0
- package/dist/{chunk-UVYF33XE.js → chunk-GTPKRBFR.js} +230 -11
- package/dist/chunk-GTPKRBFR.js.map +1 -0
- package/dist/{chunk-HODG4NJQ.js → chunk-HFLU7HQE.js} +2 -2
- package/dist/{chunk-FNWE2DT5.js → chunk-LLTB7ZFC.js} +2 -2
- package/dist/{chunk-DNYJF7BG.js → chunk-LTPLLPOR.js} +3 -3
- package/dist/{chunk-KZ4WVDGL.js → chunk-ZEC22LFP.js} +3 -3
- package/dist/{create-jmp-analytics-DpG5Hdl5.d.ts → create-jmp-analytics-BeuuU6as.d.ts} +1 -1
- package/dist/{create-jmp-analytics-D4Qw_d6o.d.cts → create-jmp-analytics-Ce2CrhhR.d.cts} +1 -1
- package/dist/index.cjs +232 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +6 -2
- package/dist/next/content.cjs +253 -13
- package/dist/next/content.cjs.map +1 -1
- package/dist/next/content.d.cts +3 -3
- package/dist/next/content.d.ts +3 -3
- package/dist/next/content.js +5 -3
- package/dist/next/content.js.map +1 -1
- package/dist/next/instrumentation.cjs +228 -10
- package/dist/next/instrumentation.cjs.map +1 -1
- package/dist/next/instrumentation.js +2 -2
- package/dist/next/landing-pages.cjs +228 -12
- package/dist/next/landing-pages.cjs.map +1 -1
- package/dist/next/landing-pages.d.cts +2 -3
- package/dist/next/landing-pages.d.ts +2 -3
- package/dist/next/landing-pages.js +3 -5
- package/dist/next/landing-pages.js.map +1 -1
- package/dist/next/middleware.cjs +2 -1
- package/dist/next/middleware.cjs.map +1 -1
- package/dist/next/middleware.d.cts +2 -2
- package/dist/next/middleware.d.ts +2 -2
- package/dist/next/middleware.js +2 -2
- package/dist/next/site-root-server.cjs +228 -10
- package/dist/next/site-root-server.cjs.map +1 -1
- package/dist/next/site-root-server.js +4 -4
- package/dist/next.cjs +226 -9
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +3 -3
- package/dist/next.d.ts +3 -3
- package/dist/next.js +4 -4
- package/dist/react.cjs +226 -9
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +3 -3
- package/dist/{site-config-CJqYnZm7.d.cts → site-config-B4uEj4xX.d.ts} +22 -2
- package/dist/{site-config-UTzDG-UG.d.ts → site-config-DIFmnwqv.d.cts} +22 -2
- package/dist/{track-page-view-tX0Magkd.d.cts → track-page-view-Bv0BAvxG.d.cts} +1 -1
- package/dist/{track-page-view-CMAqyhD_.d.ts → track-page-view-CkgIp9-j.d.ts} +1 -1
- package/dist/{types-B-111Wht.d.cts → types-B2iP79lb.d.cts} +59 -1
- package/dist/{types-B-111Wht.d.ts → types-B2iP79lb.d.ts} +59 -1
- package/package.json +1 -1
- package/dist/chunk-PG3IOI5O.js.map +0 -1
- package/dist/chunk-UVYF33XE.js.map +0 -1
- /package/dist/{chunk-HODG4NJQ.js.map → chunk-HFLU7HQE.js.map} +0 -0
- /package/dist/{chunk-FNWE2DT5.js.map → chunk-LLTB7ZFC.js.map} +0 -0
- /package/dist/{chunk-DNYJF7BG.js.map → chunk-LTPLLPOR.js.map} +0 -0
- /package/dist/{chunk-KZ4WVDGL.js.map → chunk-ZEC22LFP.js.map} +0 -0
package/dist/astro/client.cjs
CHANGED
|
@@ -755,6 +755,209 @@ function createJmpAnalytics(config) {
|
|
|
755
755
|
};
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
+
// src/content/manifest.ts
|
|
759
|
+
var JMP_CONTENT_MANIFEST_VERSION = 1;
|
|
760
|
+
var TRUST_SECTIONS = /* @__PURE__ */ new Set([
|
|
761
|
+
"summary",
|
|
762
|
+
"testimonials",
|
|
763
|
+
"reviews",
|
|
764
|
+
"stats",
|
|
765
|
+
"logos",
|
|
766
|
+
"credentials"
|
|
767
|
+
]);
|
|
768
|
+
function normalizeKey(value) {
|
|
769
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
770
|
+
}
|
|
771
|
+
function isValidExtraKey(key) {
|
|
772
|
+
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(key);
|
|
773
|
+
}
|
|
774
|
+
var MAX_EXTERNAL_ADMIN_LINKS = 10;
|
|
775
|
+
var MAX_EXTERNAL_ADMIN_LINK_LABEL_LENGTH = 80;
|
|
776
|
+
var EXTERNAL_ADMIN_LINK_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
777
|
+
function tryNormalizeHttpUrl(input) {
|
|
778
|
+
if (typeof input !== "string" || !input.trim()) {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
try {
|
|
782
|
+
const url = new URL(input.trim());
|
|
783
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
784
|
+
return null;
|
|
785
|
+
}
|
|
786
|
+
return url.toString().replace(/\/$/, "");
|
|
787
|
+
} catch {
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function normalizeShopifyExternalSource(shopify) {
|
|
792
|
+
if (!shopify || typeof shopify !== "object") {
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
const adminUrl = tryNormalizeHttpUrl(shopify.adminUrl);
|
|
796
|
+
const storeUrl = tryNormalizeHttpUrl(shopify.storeUrl);
|
|
797
|
+
if (!adminUrl && !storeUrl) {
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
return {
|
|
801
|
+
...adminUrl ? { adminUrl } : {},
|
|
802
|
+
...storeUrl ? { storeUrl } : {}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function normalizeExternalAdminLinkEntries(links) {
|
|
806
|
+
if (!Array.isArray(links)) {
|
|
807
|
+
return [];
|
|
808
|
+
}
|
|
809
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
810
|
+
const out = [];
|
|
811
|
+
for (const raw of links) {
|
|
812
|
+
if (!raw || typeof raw !== "object" || out.length >= MAX_EXTERNAL_ADMIN_LINKS) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
const id = typeof raw.id === "string" ? raw.id.trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") : "";
|
|
816
|
+
const label = typeof raw.label === "string" ? raw.label.trim().slice(0, MAX_EXTERNAL_ADMIN_LINK_LABEL_LENGTH) : "";
|
|
817
|
+
const url = tryNormalizeHttpUrl(raw.url);
|
|
818
|
+
if (!id || !label || !url || !EXTERNAL_ADMIN_LINK_ID_PATTERN.test(id) || seenIds.has(id)) {
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
seenIds.add(id);
|
|
822
|
+
out.push({ id, label, url });
|
|
823
|
+
}
|
|
824
|
+
return out;
|
|
825
|
+
}
|
|
826
|
+
function normalizeExternalSources(externalSources) {
|
|
827
|
+
if (!externalSources || typeof externalSources !== "object") {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
const studioUrl = tryNormalizeHttpUrl(externalSources.sanity?.studioUrl);
|
|
831
|
+
const shopify = normalizeShopifyExternalSource(externalSources.shopify);
|
|
832
|
+
const links = normalizeExternalAdminLinkEntries(externalSources.links);
|
|
833
|
+
if (!studioUrl && !shopify && links.length === 0) {
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
return {
|
|
837
|
+
...studioUrl ? { sanity: { studioUrl } } : {},
|
|
838
|
+
...shopify ? { shopify } : {},
|
|
839
|
+
...links.length > 0 ? { links } : {}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function normalizeJmpContentManifest(input) {
|
|
843
|
+
if (!input || typeof input !== "object") {
|
|
844
|
+
return null;
|
|
845
|
+
}
|
|
846
|
+
const routes = normalizeRoutes(input.routes);
|
|
847
|
+
const externalSources = normalizeExternalSources(input.externalSources);
|
|
848
|
+
const trust = normalizeTrust(input.trust);
|
|
849
|
+
const contact = normalizeContact(input.contact);
|
|
850
|
+
if (routes.length === 0 && !externalSources && !trust && !contact) {
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
version: JMP_CONTENT_MANIFEST_VERSION,
|
|
855
|
+
...routes.length > 0 ? { routes } : {},
|
|
856
|
+
...externalSources ? { externalSources } : {},
|
|
857
|
+
...trust ? { trust } : {},
|
|
858
|
+
...contact ? { contact } : {}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function normalizeRoutes(routes) {
|
|
862
|
+
if (!Array.isArray(routes)) {
|
|
863
|
+
return [];
|
|
864
|
+
}
|
|
865
|
+
const seen = /* @__PURE__ */ new Set();
|
|
866
|
+
const out = [];
|
|
867
|
+
for (const raw of routes) {
|
|
868
|
+
if (!raw || typeof raw !== "object") continue;
|
|
869
|
+
const wrapper = typeof raw.wrapper === "string" ? raw.wrapper.trim().toLowerCase() : "";
|
|
870
|
+
const pattern = typeof raw.pattern === "string" ? raw.pattern.trim() : "";
|
|
871
|
+
if (!wrapper || !pattern) continue;
|
|
872
|
+
const dedupe = `${wrapper}:${pattern}`;
|
|
873
|
+
if (seen.has(dedupe)) continue;
|
|
874
|
+
seen.add(dedupe);
|
|
875
|
+
out.push({
|
|
876
|
+
wrapper,
|
|
877
|
+
pattern,
|
|
878
|
+
...typeof raw.index === "string" && raw.index.trim() ? { index: raw.index.trim() } : {},
|
|
879
|
+
...typeof raw.label === "string" && raw.label.trim() ? { label: raw.label.trim() } : {}
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
return out;
|
|
883
|
+
}
|
|
884
|
+
function normalizeTrust(trust) {
|
|
885
|
+
if (!trust || typeof trust !== "object") return null;
|
|
886
|
+
const blocks = normalizeTrustBlocks(trust.blocks);
|
|
887
|
+
const labels = normalizeTrustLabels(trust.labels);
|
|
888
|
+
const mergeTestimonialsReviews = trust.mergeTestimonialsReviews === true;
|
|
889
|
+
if (blocks.length === 0 && !labels && !mergeTestimonialsReviews) return null;
|
|
890
|
+
return {
|
|
891
|
+
...blocks.length > 0 ? { blocks } : {},
|
|
892
|
+
...labels ? { labels } : {},
|
|
893
|
+
...mergeTestimonialsReviews ? { mergeTestimonialsReviews: true } : {}
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
function normalizeTrustBlocks(blocks) {
|
|
897
|
+
if (!Array.isArray(blocks)) return [];
|
|
898
|
+
const seen = /* @__PURE__ */ new Set();
|
|
899
|
+
const out = [];
|
|
900
|
+
for (const raw of blocks) {
|
|
901
|
+
if (!raw || typeof raw !== "object") continue;
|
|
902
|
+
const section = typeof raw.section === "string" ? raw.section.trim().toLowerCase() : "";
|
|
903
|
+
if (!TRUST_SECTIONS.has(section) || seen.has(section)) continue;
|
|
904
|
+
seen.add(section);
|
|
905
|
+
out.push({
|
|
906
|
+
section,
|
|
907
|
+
...typeof raw.label === "string" && raw.label.trim() ? { label: raw.label.trim() } : {}
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return out;
|
|
911
|
+
}
|
|
912
|
+
function normalizeTrustLabels(labels) {
|
|
913
|
+
if (!labels || typeof labels !== "object") return null;
|
|
914
|
+
const out = {};
|
|
915
|
+
for (const [key, value] of Object.entries(labels)) {
|
|
916
|
+
if (TRUST_SECTIONS.has(key) && typeof value === "string" && value.trim()) {
|
|
917
|
+
out[key] = value.trim();
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
921
|
+
}
|
|
922
|
+
function normalizeContact(contact) {
|
|
923
|
+
if (!contact || typeof contact !== "object") return null;
|
|
924
|
+
const extras = normalizeContactExtras(contact.extras);
|
|
925
|
+
return extras.length > 0 ? { extras } : null;
|
|
926
|
+
}
|
|
927
|
+
function normalizeContactExtras(extras) {
|
|
928
|
+
if (!Array.isArray(extras)) return [];
|
|
929
|
+
const seen = /* @__PURE__ */ new Set();
|
|
930
|
+
const out = [];
|
|
931
|
+
for (const raw of extras) {
|
|
932
|
+
if (!raw || typeof raw !== "object") continue;
|
|
933
|
+
const label = typeof raw.label === "string" ? raw.label.trim() : "";
|
|
934
|
+
const key = normalizeKey(
|
|
935
|
+
typeof raw.key === "string" && raw.key.trim() ? raw.key : label
|
|
936
|
+
);
|
|
937
|
+
if (!key || !label || !isValidExtraKey(key) || seen.has(key)) continue;
|
|
938
|
+
seen.add(key);
|
|
939
|
+
out.push({ key, label });
|
|
940
|
+
}
|
|
941
|
+
return out;
|
|
942
|
+
}
|
|
943
|
+
function stableJmpManifestFingerprint(manifest) {
|
|
944
|
+
return manifest ? JSON.stringify(manifest) : "";
|
|
945
|
+
}
|
|
946
|
+
function inferWrapperSlotsFromManifest(manifest) {
|
|
947
|
+
const slots = /* @__PURE__ */ new Set();
|
|
948
|
+
for (const route of manifest?.routes ?? []) {
|
|
949
|
+
slots.add(route.wrapper);
|
|
950
|
+
}
|
|
951
|
+
for (const block of manifest?.trust?.blocks ?? []) {
|
|
952
|
+
slots.add(`trust.${block.section}`);
|
|
953
|
+
slots.add("trust");
|
|
954
|
+
}
|
|
955
|
+
if (manifest?.contact?.extras?.length) {
|
|
956
|
+
slots.add("contact");
|
|
957
|
+
}
|
|
958
|
+
return [...slots];
|
|
959
|
+
}
|
|
960
|
+
|
|
758
961
|
// src/content/wrapper-discovery.ts
|
|
759
962
|
var WRAPPER_SLOT_ORDER = [
|
|
760
963
|
"blog",
|
|
@@ -774,16 +977,22 @@ var syncHandler = null;
|
|
|
774
977
|
function getDiscoveredContentWrappers() {
|
|
775
978
|
return sortWrapperSlots([...discovered]);
|
|
776
979
|
}
|
|
980
|
+
function resolveContentManifestForReport(config) {
|
|
981
|
+
return normalizeJmpContentManifest(config.contentManifest);
|
|
982
|
+
}
|
|
777
983
|
function resolveContentWrappersForReport(config) {
|
|
778
984
|
const explicit = config.contentWrappers ?? [];
|
|
779
985
|
const auto = getDiscoveredContentWrappers();
|
|
986
|
+
const fromManifest = inferWrapperSlotsFromManifest(
|
|
987
|
+
resolveContentManifestForReport(config)
|
|
988
|
+
);
|
|
780
989
|
if (config.contentWrapperMode === "manual") {
|
|
781
|
-
return sortWrapperSlots([...explicit]);
|
|
990
|
+
return sortWrapperSlots([...explicit, ...fromManifest]);
|
|
782
991
|
}
|
|
783
992
|
if (config.contentWrapperMode === "explicit-only") {
|
|
784
|
-
return sortWrapperSlots([...explicit]);
|
|
993
|
+
return sortWrapperSlots([...explicit, ...fromManifest]);
|
|
785
994
|
}
|
|
786
|
-
const merged = /* @__PURE__ */ new Set([...explicit, ...auto]);
|
|
995
|
+
const merged = /* @__PURE__ */ new Set([...explicit, ...auto, ...fromManifest]);
|
|
787
996
|
return sortWrapperSlots([...merged]);
|
|
788
997
|
}
|
|
789
998
|
function hasReportedContentWrappers(dedupeKey) {
|
|
@@ -813,7 +1022,8 @@ async function registerJmpContentWrappers(config) {
|
|
|
813
1022
|
if (!wrappers.length) {
|
|
814
1023
|
return { ok: false, skipped: true };
|
|
815
1024
|
}
|
|
816
|
-
const
|
|
1025
|
+
const manifest = resolveContentManifestForReport(config);
|
|
1026
|
+
const dedupeKey = `${config.trackingKey}:${[...wrappers].sort().join(",")}:${stableJmpManifestFingerprint(manifest)}`;
|
|
817
1027
|
if (hasReportedContentWrappers(dedupeKey)) {
|
|
818
1028
|
return { ok: true, wrappers };
|
|
819
1029
|
}
|
|
@@ -826,7 +1036,17 @@ async function registerJmpContentWrappers(config) {
|
|
|
826
1036
|
}
|
|
827
1037
|
const url = `${baseUrl}/api/content/capabilities`;
|
|
828
1038
|
if (config.debug) {
|
|
829
|
-
console.debug("[@jmp-technologies/analytics]", "POST", url, {
|
|
1039
|
+
console.debug("[@jmp-technologies/analytics]", "POST", url, {
|
|
1040
|
+
wrappers,
|
|
1041
|
+
manifest
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
const body = {
|
|
1045
|
+
wrappers,
|
|
1046
|
+
sdkVersion: JMP_ANALYTICS_SDK_VERSION
|
|
1047
|
+
};
|
|
1048
|
+
if (manifest) {
|
|
1049
|
+
body.manifest = manifest;
|
|
830
1050
|
}
|
|
831
1051
|
const res = await resolvedFetch(url, {
|
|
832
1052
|
method: "POST",
|
|
@@ -834,10 +1054,7 @@ async function registerJmpContentWrappers(config) {
|
|
|
834
1054
|
"Content-Type": "application/json",
|
|
835
1055
|
"X-JMP-Tracking-Key": config.trackingKey
|
|
836
1056
|
},
|
|
837
|
-
body: JSON.stringify(
|
|
838
|
-
wrappers,
|
|
839
|
-
sdkVersion: JMP_ANALYTICS_SDK_VERSION
|
|
840
|
-
})
|
|
1057
|
+
body: JSON.stringify(body)
|
|
841
1058
|
});
|
|
842
1059
|
const text = await res.text();
|
|
843
1060
|
if (!res.ok) {
|