@jmp-technologies/analytics 0.1.24 → 0.1.26
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/README.md +22 -1
- package/dist/astro/client.cjs +103 -0
- 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 +5 -3
- package/dist/astro/client.js.map +1 -1
- package/dist/astro/content.cjs +185 -1
- package/dist/astro/content.cjs.map +1 -1
- package/dist/astro/content.d.cts +2 -2
- package/dist/astro/content.d.ts +2 -2
- package/dist/astro/content.js +4 -3
- package/dist/astro/integration.cjs +56 -10
- package/dist/astro/integration.cjs.map +1 -1
- package/dist/astro/integration.js +4 -3
- package/dist/astro/integration.js.map +1 -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 +56 -10
- package/dist/astro/register.cjs.map +1 -1
- package/dist/astro/register.js +4 -3
- package/dist/chunk-2KAGOVRZ.js +45 -0
- package/dist/chunk-2KAGOVRZ.js.map +1 -0
- package/dist/{chunk-MOX7RJUU.js → chunk-A4RRTY5D.js} +1 -1
- package/dist/{chunk-MOX7RJUU.js.map → chunk-A4RRTY5D.js.map} +1 -1
- package/dist/{chunk-7MLPSL6T.js → chunk-HODG4NJQ.js} +2 -2
- package/dist/{chunk-CDORZ2YJ.js → chunk-PKGUBYZR.js} +3 -24
- package/dist/chunk-PKGUBYZR.js.map +1 -0
- package/dist/{chunk-2AUF7ENL.js → chunk-RCOHQAGL.js} +160 -157
- package/dist/chunk-RCOHQAGL.js.map +1 -0
- package/dist/chunk-TCZ6TC2L.js +149 -0
- package/dist/chunk-TCZ6TC2L.js.map +1 -0
- package/dist/{chunk-WCI6VOVY.js → chunk-TFHOTBOL.js} +3 -3
- package/dist/{chunk-ZP4L5DCM.js → chunk-WFTTIRDJ.js} +2 -2
- package/dist/{chunk-GPPQ3TYI.js → chunk-XQZOGWF2.js} +3 -3
- package/dist/chunk-YCVHRMM6.js +28 -0
- package/dist/chunk-YCVHRMM6.js.map +1 -0
- package/dist/{create-jmp-analytics-BdGOgPxl.d.ts → create-jmp-analytics-JKAsJAWb.d.ts} +1 -1
- package/dist/{create-jmp-analytics-DxhHOmtR.d.cts → create-jmp-analytics-Mau-oxji.d.cts} +1 -1
- package/dist/index.cjs +157 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +13 -3
- package/dist/next/content.cjs +185 -1
- package/dist/next/content.cjs.map +1 -1
- package/dist/next/content.d.cts +2 -2
- package/dist/next/content.d.ts +2 -2
- package/dist/next/content.js +4 -3
- package/dist/next/content.js.map +1 -1
- package/dist/next/google-tag.cjs +80 -0
- package/dist/next/google-tag.cjs.map +1 -0
- package/dist/next/google-tag.d.cts +17 -0
- package/dist/next/google-tag.d.ts +17 -0
- package/dist/next/google-tag.js +8 -0
- package/dist/next/google-tag.js.map +1 -0
- package/dist/next/instrumentation.cjs +56 -10
- package/dist/next/instrumentation.cjs.map +1 -1
- package/dist/next/instrumentation.js +3 -2
- package/dist/next/instrumentation.js.map +1 -1
- package/dist/next/landing-capture-script-server.cjs +61 -0
- package/dist/next/landing-capture-script-server.cjs.map +1 -0
- package/dist/next/landing-capture-script-server.d.cts +14 -0
- package/dist/next/landing-capture-script-server.d.ts +14 -0
- package/dist/next/landing-capture-script-server.js +8 -0
- package/dist/next/landing-capture-script-server.js.map +1 -0
- 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 +351 -82
- package/dist/next/site-root-server.cjs.map +1 -1
- package/dist/next/site-root-server.d.cts +9 -1
- package/dist/next/site-root-server.d.ts +9 -1
- package/dist/next/site-root-server.js +51 -16
- package/dist/next/site-root-server.js.map +1 -1
- package/dist/next.cjs +210 -85
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +8 -15
- package/dist/next.d.ts +8 -15
- package/dist/next.js +11 -7
- package/dist/react.cjs +103 -0
- 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 +4 -3
- package/dist/{site-config-DpMgrfeN.d.ts → site-config-CXUdGLqw.d.cts} +6 -3
- package/dist/{site-config-BXs91Yex.d.cts → site-config-w_Db9YSk.d.ts} +6 -3
- package/dist/{track-page-view-Cr8I4Unm.d.cts → track-page-view-CkuSYuco.d.cts} +1 -1
- package/dist/{track-page-view-CcPlzQNB.d.ts → track-page-view-QRSk8vap.d.ts} +1 -1
- package/dist/{types-BtiK_Acj.d.cts → types-C1eq8E5u.d.cts} +14 -4
- package/dist/{types-BtiK_Acj.d.ts → types-C1eq8E5u.d.ts} +14 -4
- package/docs/astro-integration.md +1 -1
- package/package.json +7 -2
- package/dist/chunk-2AUF7ENL.js.map +0 -1
- package/dist/chunk-CDORZ2YJ.js.map +0 -1
- /package/dist/{chunk-7MLPSL6T.js.map → chunk-HODG4NJQ.js.map} +0 -0
- /package/dist/{chunk-WCI6VOVY.js.map → chunk-TFHOTBOL.js.map} +0 -0
- /package/dist/{chunk-ZP4L5DCM.js.map → chunk-WFTTIRDJ.js.map} +0 -0
- /package/dist/{chunk-GPPQ3TYI.js.map → chunk-XQZOGWF2.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
createJmpContentClient: () => createJmpContentClient,
|
|
31
31
|
createJmpContentClientFromServerEnv: () => createJmpContentClientFromServerEnv,
|
|
32
32
|
defineJmpSite: () => defineJmpSite,
|
|
33
|
+
getDiscoveredContentWrappers: () => getDiscoveredContentWrappers,
|
|
33
34
|
getJmpBlogPost: () => getJmpBlogPost,
|
|
34
35
|
getJmpBlogPosts: () => getJmpBlogPosts,
|
|
35
36
|
getJmpBrowserAnalyticsConfigFromEnv: () => getJmpBrowserAnalyticsConfigFromEnv,
|
|
@@ -41,11 +42,14 @@ __export(index_exports, {
|
|
|
41
42
|
getJmpSiteProfile: () => getJmpSiteProfile,
|
|
42
43
|
getJmpTrustBundle: () => getJmpTrustBundle,
|
|
43
44
|
getOrCreateJmpAnalyticsFromBrowserEnv: () => getOrCreateJmpAnalyticsFromBrowserEnv,
|
|
45
|
+
inferTrustWrapperSlots: () => inferTrustWrapperSlots,
|
|
44
46
|
isJmpBrowserAnalyticsEnvConfigured: () => isJmpBrowserAnalyticsEnvConfigured,
|
|
45
47
|
isJmpServerContentEnvConfigured: () => isJmpServerContentEnvConfigured,
|
|
46
48
|
isJmpTrackingConsentGranted: () => isJmpTrackingConsentGranted,
|
|
49
|
+
markContentWrapper: () => markContentWrapper,
|
|
47
50
|
readJmpPublicEnvFromProcess: () => readJmpPublicEnvFromProcess,
|
|
48
51
|
registerJmpContentWrappers: () => registerJmpContentWrappers,
|
|
52
|
+
resetContentWrapperDiscoveryForTests: () => resetContentWrapperDiscoveryForTests,
|
|
49
53
|
setJmpTrackingConsent: () => setJmpTrackingConsent,
|
|
50
54
|
subscribeJmpTrackingConsent: () => subscribeJmpTrackingConsent,
|
|
51
55
|
trackJmpServerPageView: () => trackJmpServerPageView
|
|
@@ -314,7 +318,7 @@ function classifyContactHref(href) {
|
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
// src/constants.ts
|
|
317
|
-
var JMP_ANALYTICS_SDK_VERSION = "0.1.
|
|
321
|
+
var JMP_ANALYTICS_SDK_VERSION = "0.1.25";
|
|
318
322
|
var JMP_TRACKING_CONSENT_STORAGE_KEY = "jmp_analytics_consent_v1";
|
|
319
323
|
var DEFAULT_JMP_BROWSER_PAGE_VIEW_DEDUPE_MS = 2500;
|
|
320
324
|
|
|
@@ -902,12 +906,146 @@ async function getContentText(config, path) {
|
|
|
902
906
|
return text;
|
|
903
907
|
}
|
|
904
908
|
|
|
909
|
+
// src/content/wrapper-discovery.ts
|
|
910
|
+
var WRAPPER_SLOT_ORDER = [
|
|
911
|
+
"blog",
|
|
912
|
+
"faq",
|
|
913
|
+
"contact",
|
|
914
|
+
"trust",
|
|
915
|
+
"trust.summary",
|
|
916
|
+
"trust.testimonials",
|
|
917
|
+
"trust.reviews",
|
|
918
|
+
"trust.stats",
|
|
919
|
+
"trust.logos",
|
|
920
|
+
"trust.credentials"
|
|
921
|
+
];
|
|
922
|
+
var discovered = /* @__PURE__ */ new Set();
|
|
923
|
+
var syncTimer = null;
|
|
924
|
+
var pendingSyncConfig = null;
|
|
925
|
+
var reportedDedupeKeys = /* @__PURE__ */ new Set();
|
|
926
|
+
var syncHandler = null;
|
|
927
|
+
function markContentWrapper(slot) {
|
|
928
|
+
const normalized = slot.trim().toLowerCase();
|
|
929
|
+
if (!normalized) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
discovered.add(normalized);
|
|
933
|
+
}
|
|
934
|
+
function markTrustBundleWrappers(bundle) {
|
|
935
|
+
for (const slot of inferTrustWrapperSlots(bundle)) {
|
|
936
|
+
discovered.add(slot);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
function inferTrustWrapperSlots(bundle) {
|
|
940
|
+
const slots = /* @__PURE__ */ new Set(["trust"]);
|
|
941
|
+
const { summary, testimonials, stats, logos, credentials } = bundle;
|
|
942
|
+
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());
|
|
943
|
+
if (hasSummary) {
|
|
944
|
+
slots.add("trust.summary");
|
|
945
|
+
}
|
|
946
|
+
let hasTestimonials = false;
|
|
947
|
+
let hasReviews = false;
|
|
948
|
+
for (const item of testimonials) {
|
|
949
|
+
const bucket = item.placement?.trim().toLowerCase();
|
|
950
|
+
if (bucket === "reviews") {
|
|
951
|
+
hasReviews = true;
|
|
952
|
+
} else {
|
|
953
|
+
hasTestimonials = true;
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (hasTestimonials) {
|
|
957
|
+
slots.add("trust.testimonials");
|
|
958
|
+
}
|
|
959
|
+
if (hasReviews) {
|
|
960
|
+
slots.add("trust.reviews");
|
|
961
|
+
}
|
|
962
|
+
if (stats.length > 0) {
|
|
963
|
+
slots.add("trust.stats");
|
|
964
|
+
}
|
|
965
|
+
if (logos.length > 0) {
|
|
966
|
+
slots.add("trust.logos");
|
|
967
|
+
}
|
|
968
|
+
if (credentials.length > 0) {
|
|
969
|
+
slots.add("trust.credentials");
|
|
970
|
+
}
|
|
971
|
+
return sortWrapperSlots([...slots]);
|
|
972
|
+
}
|
|
973
|
+
function getDiscoveredContentWrappers() {
|
|
974
|
+
return sortWrapperSlots([...discovered]);
|
|
975
|
+
}
|
|
976
|
+
function resolveContentWrappersForReport(config) {
|
|
977
|
+
const explicit = config.contentWrappers ?? [];
|
|
978
|
+
const auto = getDiscoveredContentWrappers();
|
|
979
|
+
if (config.contentWrapperMode === "manual") {
|
|
980
|
+
return sortWrapperSlots([...explicit]);
|
|
981
|
+
}
|
|
982
|
+
if (config.contentWrapperMode === "explicit-only") {
|
|
983
|
+
return sortWrapperSlots([...explicit]);
|
|
984
|
+
}
|
|
985
|
+
const merged = /* @__PURE__ */ new Set([...explicit, ...auto]);
|
|
986
|
+
return sortWrapperSlots([...merged]);
|
|
987
|
+
}
|
|
988
|
+
function hasReportedContentWrappers(dedupeKey) {
|
|
989
|
+
return reportedDedupeKeys.has(dedupeKey);
|
|
990
|
+
}
|
|
991
|
+
function rememberReportedContentWrappers(dedupeKey) {
|
|
992
|
+
reportedDedupeKeys.add(dedupeKey);
|
|
993
|
+
}
|
|
994
|
+
function setContentWrapperSyncHandler(handler) {
|
|
995
|
+
syncHandler = handler;
|
|
996
|
+
}
|
|
997
|
+
function scheduleContentWrapperSync(config) {
|
|
998
|
+
if (!syncHandler) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
pendingSyncConfig = config;
|
|
1002
|
+
if (syncTimer) {
|
|
1003
|
+
clearTimeout(syncTimer);
|
|
1004
|
+
}
|
|
1005
|
+
syncTimer = setTimeout(() => {
|
|
1006
|
+
syncTimer = null;
|
|
1007
|
+
const cfg = pendingSyncConfig;
|
|
1008
|
+
pendingSyncConfig = null;
|
|
1009
|
+
if (!cfg || !syncHandler) {
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
void syncHandler(cfg).catch(() => {
|
|
1013
|
+
});
|
|
1014
|
+
}, 750);
|
|
1015
|
+
}
|
|
1016
|
+
function resetContentWrapperDiscoveryForTests() {
|
|
1017
|
+
discovered.clear();
|
|
1018
|
+
reportedDedupeKeys.clear();
|
|
1019
|
+
syncHandler = null;
|
|
1020
|
+
if (syncTimer) {
|
|
1021
|
+
clearTimeout(syncTimer);
|
|
1022
|
+
syncTimer = null;
|
|
1023
|
+
}
|
|
1024
|
+
pendingSyncConfig = null;
|
|
1025
|
+
}
|
|
1026
|
+
function sortWrapperSlots(slots) {
|
|
1027
|
+
const order = new Map(WRAPPER_SLOT_ORDER.map((slot, index) => [slot, index]));
|
|
1028
|
+
return [...new Set(slots)].sort((a, b) => {
|
|
1029
|
+
const ai = order.get(a) ?? 999;
|
|
1030
|
+
const bi = order.get(b) ?? 999;
|
|
1031
|
+
if (ai !== bi) {
|
|
1032
|
+
return ai - bi;
|
|
1033
|
+
}
|
|
1034
|
+
return a.localeCompare(b);
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
|
|
905
1038
|
// src/content/api.ts
|
|
1039
|
+
function afterContentWrapperUse(config) {
|
|
1040
|
+
scheduleContentWrapperSync(config);
|
|
1041
|
+
}
|
|
906
1042
|
async function getJmpBlogPosts(config) {
|
|
907
1043
|
const data = await getContent(
|
|
908
1044
|
config,
|
|
909
1045
|
"/api/content/blog"
|
|
910
1046
|
);
|
|
1047
|
+
markContentWrapper("blog");
|
|
1048
|
+
afterContentWrapperUse(config);
|
|
911
1049
|
return data.posts;
|
|
912
1050
|
}
|
|
913
1051
|
async function getJmpBlogPost(config, slug) {
|
|
@@ -916,6 +1054,8 @@ async function getJmpBlogPost(config, slug) {
|
|
|
916
1054
|
config,
|
|
917
1055
|
`/api/content/blog/${encodeURIComponent(slug)}`
|
|
918
1056
|
);
|
|
1057
|
+
markContentWrapper("blog");
|
|
1058
|
+
afterContentWrapperUse(config);
|
|
919
1059
|
return data.post;
|
|
920
1060
|
} catch (error) {
|
|
921
1061
|
if (error instanceof Error && error.message.includes("HTTP 404")) {
|
|
@@ -929,35 +1069,35 @@ async function getJmpFaqs(config) {
|
|
|
929
1069
|
config,
|
|
930
1070
|
"/api/content/faqs"
|
|
931
1071
|
);
|
|
1072
|
+
markContentWrapper("faq");
|
|
1073
|
+
afterContentWrapperUse(config);
|
|
932
1074
|
return data.faqs;
|
|
933
1075
|
}
|
|
934
1076
|
async function getJmpTrustBundle(config) {
|
|
935
|
-
|
|
1077
|
+
const bundle = await getContent(config, "/api/content/trust");
|
|
1078
|
+
markTrustBundleWrappers(bundle);
|
|
1079
|
+
afterContentWrapperUse(config);
|
|
1080
|
+
return bundle;
|
|
936
1081
|
}
|
|
937
1082
|
async function getJmpSiteProfile(config) {
|
|
938
1083
|
const data = await getContent(
|
|
939
1084
|
config,
|
|
940
1085
|
"/api/content/site"
|
|
941
1086
|
);
|
|
1087
|
+
markContentWrapper("contact");
|
|
1088
|
+
afterContentWrapperUse(config);
|
|
942
1089
|
return data.site;
|
|
943
1090
|
}
|
|
944
1091
|
async function getJmpRobotsTxt(config) {
|
|
945
1092
|
return getContentText(config, "/api/content/robots");
|
|
946
1093
|
}
|
|
947
|
-
var registeredContentWrappers = /* @__PURE__ */ new Set();
|
|
948
|
-
function resolveContentWrappersFromConfig(config) {
|
|
949
|
-
if (config.contentWrappers?.length) {
|
|
950
|
-
return [...config.contentWrappers];
|
|
951
|
-
}
|
|
952
|
-
return [];
|
|
953
|
-
}
|
|
954
1094
|
async function registerJmpContentWrappers(config) {
|
|
955
|
-
const wrappers =
|
|
1095
|
+
const wrappers = resolveContentWrappersForReport(config);
|
|
956
1096
|
if (!wrappers.length) {
|
|
957
1097
|
return { ok: false, skipped: true };
|
|
958
1098
|
}
|
|
959
1099
|
const dedupeKey = `${config.trackingKey}:${[...wrappers].sort().join(",")}`;
|
|
960
|
-
if (
|
|
1100
|
+
if (hasReportedContentWrappers(dedupeKey)) {
|
|
961
1101
|
return { ok: true, wrappers };
|
|
962
1102
|
}
|
|
963
1103
|
const baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
@@ -994,10 +1134,11 @@ async function registerJmpContentWrappers(config) {
|
|
|
994
1134
|
[`JMP content wrappers HTTP ${res.status}`, parsed.error, parsed.hint].filter(Boolean).join(" \u2014 ")
|
|
995
1135
|
);
|
|
996
1136
|
}
|
|
997
|
-
|
|
1137
|
+
rememberReportedContentWrappers(dedupeKey);
|
|
998
1138
|
const data = JSON.parse(text);
|
|
999
1139
|
return { ok: true, wrappers: data.wrappers ?? wrappers };
|
|
1000
1140
|
}
|
|
1141
|
+
setContentWrapperSyncHandler(registerJmpContentWrappers);
|
|
1001
1142
|
|
|
1002
1143
|
// src/content/client.ts
|
|
1003
1144
|
function createJmpContentClient(config) {
|
|
@@ -1135,6 +1276,7 @@ function createJmpContentClientFromServerEnv(overrides) {
|
|
|
1135
1276
|
createJmpContentClient,
|
|
1136
1277
|
createJmpContentClientFromServerEnv,
|
|
1137
1278
|
defineJmpSite,
|
|
1279
|
+
getDiscoveredContentWrappers,
|
|
1138
1280
|
getJmpBlogPost,
|
|
1139
1281
|
getJmpBlogPosts,
|
|
1140
1282
|
getJmpBrowserAnalyticsConfigFromEnv,
|
|
@@ -1146,11 +1288,14 @@ function createJmpContentClientFromServerEnv(overrides) {
|
|
|
1146
1288
|
getJmpSiteProfile,
|
|
1147
1289
|
getJmpTrustBundle,
|
|
1148
1290
|
getOrCreateJmpAnalyticsFromBrowserEnv,
|
|
1291
|
+
inferTrustWrapperSlots,
|
|
1149
1292
|
isJmpBrowserAnalyticsEnvConfigured,
|
|
1150
1293
|
isJmpServerContentEnvConfigured,
|
|
1151
1294
|
isJmpTrackingConsentGranted,
|
|
1295
|
+
markContentWrapper,
|
|
1152
1296
|
readJmpPublicEnvFromProcess,
|
|
1153
1297
|
registerJmpContentWrappers,
|
|
1298
|
+
resetContentWrapperDiscoveryForTests,
|
|
1154
1299
|
setJmpTrackingConsent,
|
|
1155
1300
|
subscribeJmpTrackingConsent,
|
|
1156
1301
|
trackJmpServerPageView
|