@syntrologie/runtime-sdk 2.6.0-canary.2 → 2.6.0-canary.4

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.
@@ -93,6 +93,12 @@ export interface SyntroInitResult {
93
93
  */
94
94
  appLoader: AppLoader;
95
95
  }
96
+ /**
97
+ * Collect browser metadata for instant GrowthBook targeting.
98
+ * This data is available synchronously from browser APIs — no network call needed.
99
+ * Only non-empty values are included.
100
+ */
101
+ export declare function collectBrowserMetadata(): Record<string, string | string[]>;
96
102
  /**
97
103
  * Initialize the Syntro SDK with a single token.
98
104
  *
@@ -3358,7 +3358,7 @@ function getAntiFlickerSnippet(config = {}) {
3358
3358
  }
3359
3359
 
3360
3360
  // src/version.ts
3361
- var SDK_VERSION = "2.6.0-canary.2";
3361
+ var SDK_VERSION = "2.6.0-canary.4";
3362
3362
 
3363
3363
  // src/types.ts
3364
3364
  var SDK_SCHEMA_VERSION = "2.0";
@@ -10926,6 +10926,45 @@ function extractSegmentFlags(allFlags) {
10926
10926
  }
10927
10927
  return segmentFlags;
10928
10928
  }
10929
+ function collectBrowserMetadata() {
10930
+ var _a2;
10931
+ if (typeof window === "undefined") return {};
10932
+ const attrs = {};
10933
+ try {
10934
+ const params = new URLSearchParams(window.location.search);
10935
+ for (const key of ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"]) {
10936
+ const val = params.get(key);
10937
+ if (val) attrs[key] = val;
10938
+ }
10939
+ } catch {
10940
+ }
10941
+ try {
10942
+ if (navigator.language) attrs.browser_language = navigator.language;
10943
+ if ((_a2 = navigator.languages) == null ? void 0 : _a2.length) attrs.browser_languages = [...navigator.languages];
10944
+ } catch {
10945
+ }
10946
+ try {
10947
+ const w = window.innerWidth;
10948
+ attrs.device_type = w < 768 ? "mobile" : w < 1024 ? "tablet" : "desktop";
10949
+ } catch {
10950
+ }
10951
+ try {
10952
+ if (document.referrer) {
10953
+ attrs.referrer = document.referrer;
10954
+ try {
10955
+ attrs.referrer_hostname = new URL(document.referrer).hostname;
10956
+ } catch {
10957
+ }
10958
+ }
10959
+ } catch {
10960
+ }
10961
+ try {
10962
+ attrs.page_url = window.location.href;
10963
+ attrs.page_path = window.location.pathname;
10964
+ } catch {
10965
+ }
10966
+ return attrs;
10967
+ }
10929
10968
  async function init(options) {
10930
10969
  var _a2, _b, _c, _d, _e, _f;
10931
10970
  initLogger();
@@ -10998,7 +11037,10 @@ async function init(options) {
10998
11037
  const telemetryHost = getEnvVar("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST") || getEnvVar("VITE_SYNTRO_TELEMETRY_HOST") || (payload == null ? void 0 : payload.th);
10999
11038
  const editorUrl = getEnvVar("NEXT_PUBLIC_SYNTRO_EDITOR_URL") || getEnvVar("VITE_SYNTRO_EDITOR_URL") || ((_b = options.canvas) == null ? void 0 : _b.editorUrl);
11000
11039
  const cachedSegmentAttrs = loadCachedSegmentAttributes();
11001
- debug("Syntro Bootstrap", "Phase 1: Using cached segment attributes:", cachedSegmentAttrs);
11040
+ const browserMetadata = collectBrowserMetadata();
11041
+ const phaseOneAttrs = { ...browserMetadata, ...cachedSegmentAttrs };
11042
+ debug("Syntro Bootstrap", "Phase 1: Browser metadata:", browserMetadata);
11043
+ debug("Syntro Bootstrap", "Phase 1: Cached segment attributes:", cachedSegmentAttrs);
11002
11044
  let experiments;
11003
11045
  const events = createEventBus();
11004
11046
  console.log("[Syntro Bootstrap] EventBus created");
@@ -11013,7 +11055,7 @@ async function init(options) {
11013
11055
  cacheSegmentAttributes(segmentFlags);
11014
11056
  if (experiments) {
11015
11057
  const sessionAttrs = (_b2 = (_a3 = sessionMetrics == null ? void 0 : sessionMetrics.getAll) == null ? void 0 : _a3.call(sessionMetrics)) != null ? _b2 : {};
11016
- const updatedAttrs = { ...sessionAttrs, ...segmentFlags };
11058
+ const updatedAttrs = { ...browserMetadata, ...sessionAttrs, ...segmentFlags };
11017
11059
  debug("Syntro Bootstrap", "Updating GrowthBook with attributes:", updatedAttrs);
11018
11060
  (_c2 = experiments.setAttributes) == null ? void 0 : _c2.call(experiments, updatedAttrs);
11019
11061
  }
@@ -11040,8 +11082,8 @@ async function init(options) {
11040
11082
  clientKey: payload.e,
11041
11083
  apiHost: experimentHost,
11042
11084
  // undefined falls back to adapter default
11043
- // Phase 1: Use cached segment attributes for instant evaluation
11044
- attributes: cachedSegmentAttrs,
11085
+ // Phase 1: Use browser metadata + cached segment attributes for instant evaluation
11086
+ attributes: phaseOneAttrs,
11045
11087
  // Wire experiment tracking to telemetry provider
11046
11088
  onExperimentViewed: (telemetry == null ? void 0 : telemetry.trackExperiment) ? (key, variationId, variationName) => {
11047
11089
  telemetry.trackExperiment(key, variationId, variationName);
@@ -11326,4 +11368,4 @@ export {
11326
11368
  encodeToken,
11327
11369
  Syntro
11328
11370
  };
11329
- //# sourceMappingURL=chunk-FXRARX6K.js.map
11371
+ //# sourceMappingURL=chunk-DLW4A4JJ.js.map