@syntrologie/runtime-sdk 2.8.0-canary.207 → 2.8.0-canary.209
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/bootstrap-init.d.ts +12 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/index.js +88 -23
- package/dist/index.js.map +3 -3
- package/dist/smart-canvas.esm.js +198 -198
- package/dist/smart-canvas.esm.js.map +3 -3
- package/dist/smart-canvas.js +89 -24
- package/dist/smart-canvas.js.map +3 -3
- package/dist/smart-canvas.min.js +198 -198
- package/dist/smart-canvas.min.js.map +3 -3
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/smart-canvas.js
CHANGED
|
@@ -16728,7 +16728,7 @@ Please report this to https://github.com/markedjs/marked.`, e10) {
|
|
|
16728
16728
|
}
|
|
16729
16729
|
|
|
16730
16730
|
// src/version.ts
|
|
16731
|
-
var SDK_VERSION = "2.8.0-canary.
|
|
16731
|
+
var SDK_VERSION = "2.8.0-canary.209";
|
|
16732
16732
|
|
|
16733
16733
|
// src/types.ts
|
|
16734
16734
|
var SDK_SCHEMA_VERSION = "2.0";
|
|
@@ -22095,30 +22095,40 @@ ${cssRules}
|
|
|
22095
22095
|
}
|
|
22096
22096
|
return void 0;
|
|
22097
22097
|
}
|
|
22098
|
-
|
|
22099
|
-
|
|
22100
|
-
if (typeof window === "undefined") return {};
|
|
22098
|
+
function loadCached(key, ttlMs) {
|
|
22099
|
+
if (typeof window === "undefined") return null;
|
|
22101
22100
|
try {
|
|
22102
|
-
const
|
|
22103
|
-
if (
|
|
22104
|
-
|
|
22105
|
-
|
|
22106
|
-
|
|
22107
|
-
|
|
22108
|
-
} catch
|
|
22109
|
-
|
|
22101
|
+
const raw = localStorage.getItem(key);
|
|
22102
|
+
if (!raw) return null;
|
|
22103
|
+
const envelope = JSON.parse(raw);
|
|
22104
|
+
if (!envelope || typeof envelope.ts !== "number" || !("data" in envelope)) return null;
|
|
22105
|
+
if (ttlMs != null && Date.now() - envelope.ts > ttlMs) return null;
|
|
22106
|
+
return envelope.data;
|
|
22107
|
+
} catch {
|
|
22108
|
+
return null;
|
|
22110
22109
|
}
|
|
22111
|
-
return {};
|
|
22112
22110
|
}
|
|
22113
|
-
function
|
|
22111
|
+
function writeCached(key, data) {
|
|
22114
22112
|
if (typeof window === "undefined") return;
|
|
22115
22113
|
try {
|
|
22116
|
-
|
|
22117
|
-
|
|
22118
|
-
} catch
|
|
22119
|
-
warn("Syntro Bootstrap", "Failed to cache segment attributes:", err);
|
|
22114
|
+
const envelope = { ts: Date.now(), data };
|
|
22115
|
+
localStorage.setItem(key, JSON.stringify(envelope));
|
|
22116
|
+
} catch {
|
|
22120
22117
|
}
|
|
22121
22118
|
}
|
|
22119
|
+
var SEGMENT_CACHE_KEY = "syntro_segment_attributes";
|
|
22120
|
+
function loadCachedSegmentAttributes() {
|
|
22121
|
+
const cached = loadCached(SEGMENT_CACHE_KEY);
|
|
22122
|
+
if (cached) {
|
|
22123
|
+
debug("Syntro Bootstrap", "Loaded cached segment attributes:", cached);
|
|
22124
|
+
return cached;
|
|
22125
|
+
}
|
|
22126
|
+
return {};
|
|
22127
|
+
}
|
|
22128
|
+
function cacheSegmentAttributes(attrs) {
|
|
22129
|
+
writeCached(SEGMENT_CACHE_KEY, attrs);
|
|
22130
|
+
debug("Syntro Bootstrap", "Cached segment attributes:", attrs);
|
|
22131
|
+
}
|
|
22122
22132
|
function extractSegmentFlags(allFlags) {
|
|
22123
22133
|
if (!allFlags) return {};
|
|
22124
22134
|
const segmentFlags = {};
|
|
@@ -22208,6 +22218,51 @@ ${cssRules}
|
|
|
22208
22218
|
}
|
|
22209
22219
|
return attrs;
|
|
22210
22220
|
}
|
|
22221
|
+
var INITIAL_ATTRS_KEY = "syntro_initial_attrs";
|
|
22222
|
+
var INITIAL_ATTRS_TTL = 30 * 60 * 1e3;
|
|
22223
|
+
var UTM_KEYS = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"];
|
|
22224
|
+
function isInternalReferrer(referrerHostname) {
|
|
22225
|
+
if (typeof window === "undefined") return false;
|
|
22226
|
+
try {
|
|
22227
|
+
return referrerHostname === window.location.hostname;
|
|
22228
|
+
} catch {
|
|
22229
|
+
return false;
|
|
22230
|
+
}
|
|
22231
|
+
}
|
|
22232
|
+
function computeInitialAttrs(fresh, cached) {
|
|
22233
|
+
const result = {};
|
|
22234
|
+
const hasFreshUtms = UTM_KEYS.some((k5) => typeof fresh[k5] === "string");
|
|
22235
|
+
for (const key of UTM_KEYS) {
|
|
22236
|
+
const value = hasFreshUtms ? fresh[key] : cached?.[key];
|
|
22237
|
+
if (value) result[key] = value;
|
|
22238
|
+
}
|
|
22239
|
+
const freshReferrerHostname = typeof fresh.referrer_hostname === "string" ? fresh.referrer_hostname : void 0;
|
|
22240
|
+
const isInternal = freshReferrerHostname ? isInternalReferrer(freshReferrerHostname) : true;
|
|
22241
|
+
if (!isInternal && typeof fresh.referrer === "string") {
|
|
22242
|
+
result.referrer = fresh.referrer;
|
|
22243
|
+
if (freshReferrerHostname) result.referrer_hostname = freshReferrerHostname;
|
|
22244
|
+
} else if (cached?.referrer) {
|
|
22245
|
+
result.referrer = cached.referrer;
|
|
22246
|
+
if (cached.referrer_hostname) result.referrer_hostname = cached.referrer_hostname;
|
|
22247
|
+
}
|
|
22248
|
+
if (cached?.initial_page_url) {
|
|
22249
|
+
result.initial_page_url = cached.initial_page_url;
|
|
22250
|
+
if (cached.initial_page_path) result.initial_page_path = cached.initial_page_path;
|
|
22251
|
+
if (cached.initial_page_query) result.initial_page_query = cached.initial_page_query;
|
|
22252
|
+
} else {
|
|
22253
|
+
if (typeof fresh.page_url === "string") result.initial_page_url = fresh.page_url;
|
|
22254
|
+
if (typeof fresh.page_path === "string") result.initial_page_path = fresh.page_path;
|
|
22255
|
+
if (typeof fresh.page_query === "string") result.initial_page_query = fresh.page_query;
|
|
22256
|
+
}
|
|
22257
|
+
return result;
|
|
22258
|
+
}
|
|
22259
|
+
function loadInitialAttrs() {
|
|
22260
|
+
return loadCached(INITIAL_ATTRS_KEY, INITIAL_ATTRS_TTL);
|
|
22261
|
+
}
|
|
22262
|
+
function saveInitialAttrs(attrs) {
|
|
22263
|
+
writeCached(INITIAL_ATTRS_KEY, attrs);
|
|
22264
|
+
debug("Syntro Bootstrap", "Cached initial attrs:", attrs);
|
|
22265
|
+
}
|
|
22211
22266
|
var GEO_CACHE_KEY = "syntro_geo";
|
|
22212
22267
|
var GEO_DEFAULT_HOST = "https://geo.syntrologie.com";
|
|
22213
22268
|
async function fetchGeo(geoHost) {
|
|
@@ -22433,7 +22488,7 @@ ${cssRules}
|
|
|
22433
22488
|
}
|
|
22434
22489
|
|
|
22435
22490
|
// src/defaults/initialProperties.ts
|
|
22436
|
-
var
|
|
22491
|
+
var UTM_KEYS2 = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"];
|
|
22437
22492
|
function isStrictRegion(geo) {
|
|
22438
22493
|
if (geo.is_eu === "true") return true;
|
|
22439
22494
|
if (geo.country_code === "GB" || geo.country_code === "CH") return true;
|
|
@@ -22462,7 +22517,7 @@ ${cssRules}
|
|
|
22462
22517
|
$initial_referrer: referrer,
|
|
22463
22518
|
$initial_referring_domain: safeReferringDomain(referrer)
|
|
22464
22519
|
};
|
|
22465
|
-
for (const key of
|
|
22520
|
+
for (const key of UTM_KEYS2) {
|
|
22466
22521
|
const value = params.get(key);
|
|
22467
22522
|
if (value) {
|
|
22468
22523
|
props[`$initial_${key}`] = value;
|
|
@@ -33870,8 +33925,17 @@ ${cssRules}
|
|
|
33870
33925
|
const cachedSegmentAttrs = loadCachedSegmentAttributes();
|
|
33871
33926
|
const browserMetadata = collectBrowserMetadata();
|
|
33872
33927
|
const appSignalsInit = options.appSignalsInit ?? {};
|
|
33873
|
-
const
|
|
33928
|
+
const cachedInitialAttrs = loadInitialAttrs();
|
|
33929
|
+
const initialAttrs = computeInitialAttrs(browserMetadata, cachedInitialAttrs);
|
|
33930
|
+
saveInitialAttrs(initialAttrs);
|
|
33931
|
+
const phaseOneAttrs = {
|
|
33932
|
+
...browserMetadata,
|
|
33933
|
+
...initialAttrs,
|
|
33934
|
+
...cachedSegmentAttrs,
|
|
33935
|
+
...appSignalsInit
|
|
33936
|
+
};
|
|
33874
33937
|
debug("Syntro Bootstrap", "Phase 1: Browser metadata:", browserMetadata);
|
|
33938
|
+
debug("Syntro Bootstrap", "Phase 1: Initial attrs:", initialAttrs);
|
|
33875
33939
|
debug("Syntro Bootstrap", "Phase 1: Cached segment attributes:", cachedSegmentAttrs);
|
|
33876
33940
|
if (Object.keys(appSignalsInit).length > 0) {
|
|
33877
33941
|
debug("Syntro Bootstrap", "Phase 1: App signals:", appSignalsInit);
|
|
@@ -33965,6 +34029,7 @@ ${cssRules}
|
|
|
33965
34029
|
const sessionAttrs = sessionMetrics?.getAll?.() ?? {};
|
|
33966
34030
|
const updatedAttrs = {
|
|
33967
34031
|
...browserMetadata,
|
|
34032
|
+
...initialAttrs,
|
|
33968
34033
|
...sessionAttrs,
|
|
33969
34034
|
...segmentFlags,
|
|
33970
34035
|
...appSignalsInit
|
|
@@ -34183,7 +34248,7 @@ ${cssRules}
|
|
|
34183
34248
|
}
|
|
34184
34249
|
const geoData = await geoPromise;
|
|
34185
34250
|
if (experiments && Object.keys(geoData).length > 0) {
|
|
34186
|
-
const mergedAttrs = { ...browserMetadata, ...geoData, ...appSignalsInit };
|
|
34251
|
+
const mergedAttrs = { ...browserMetadata, ...initialAttrs, ...geoData, ...appSignalsInit };
|
|
34187
34252
|
debug("Syntro Bootstrap", "Merging geo data into GrowthBook attributes:", geoData);
|
|
34188
34253
|
experiments.setAttributes?.(mergedAttrs);
|
|
34189
34254
|
}
|
|
@@ -34191,7 +34256,7 @@ ${cssRules}
|
|
|
34191
34256
|
if (mcpHost && experiments) {
|
|
34192
34257
|
browserMetadata.surface_type = "mcp-app";
|
|
34193
34258
|
browserMetadata.surface_host = mcpHost.name;
|
|
34194
|
-
experiments.setAttributes?.({ ...browserMetadata, ...geoData });
|
|
34259
|
+
experiments.setAttributes?.({ ...browserMetadata, ...initialAttrs, ...geoData });
|
|
34195
34260
|
runtime5.context.setSurfaceType("mcp-app");
|
|
34196
34261
|
runtime5.context.setSurfaceHost(mcpHost.name);
|
|
34197
34262
|
debug("Syntro Bootstrap", "MCP App detected:", mcpHost.name);
|
|
@@ -34803,7 +34868,7 @@ ${cssRules}
|
|
|
34803
34868
|
}
|
|
34804
34869
|
|
|
34805
34870
|
// src/index.ts
|
|
34806
|
-
var RUNTIME_SDK_BUILD = true ? `${"2026-05-
|
|
34871
|
+
var RUNTIME_SDK_BUILD = true ? `${"2026-05-08T20:29:05.447Z"} (${"38b78b3f250"})` : "dev";
|
|
34807
34872
|
if (typeof window !== "undefined") {
|
|
34808
34873
|
console.log(`[Syntro Runtime] Build: ${RUNTIME_SDK_BUILD} (Lit)`);
|
|
34809
34874
|
const existing = window.SynOS;
|