@syntrologie/runtime-sdk 2.8.0-canary.184 → 2.8.0-canary.186
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/defaults/clickIds.d.ts +14 -0
- package/dist/defaults/identifyOnEmail.d.ts +23 -0
- package/dist/defaults/identifyOnUrlParam.d.ts +29 -0
- package/dist/defaults/index.d.ts +51 -0
- package/dist/defaults/initialProperties.d.ts +26 -0
- package/dist/defaults/jsonLd.d.ts +17 -0
- package/dist/index.js +729 -1
- package/dist/index.js.map +4 -4
- package/dist/smart-canvas.esm.js +100 -100
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +711 -2
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +101 -101
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/telemetry/adapters/posthog.d.ts +26 -0
- package/dist/telemetry/consent/ConsentDetector.d.ts +26 -0
- package/dist/telemetry/{consent.d.ts → consent/ConsentGate.d.ts} +33 -1
- package/dist/telemetry/consent/adapters/gtmConsentMode.d.ts +18 -0
- package/dist/telemetry/consent/adapters/iabTcf.d.ts +21 -0
- package/dist/telemetry/consent/adapters/shopify.d.ts +17 -0
- package/dist/telemetry/consent/index.d.ts +17 -0
- package/dist/telemetry/consent/types.d.ts +47 -0
- package/dist/telemetry/types.d.ts +24 -0
- package/dist/version.d.ts +1 -1
- package/package.json +3 -5
- package/schema/canvas-config.schema.json +352 -1
- package/CAPABILITIES.md +0 -1450
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-4 — promote click IDs to person properties.
|
|
3
|
+
*
|
|
4
|
+
* Reads platform click-ID parameters (fbclid, ttclid, gclid, etc.)
|
|
5
|
+
* from the entry URL and writes them as $initial_<param> via
|
|
6
|
+
* setPersonPropertiesOnce. Survives the lifetime of the person record;
|
|
7
|
+
* pairs with Conversions API back-channels (Meta CAPI, TikTok Events
|
|
8
|
+
* API, etc.) when clients eventually run paid ads.
|
|
9
|
+
*
|
|
10
|
+
* See docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md (D-4).
|
|
11
|
+
*/
|
|
12
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
13
|
+
export declare const CLICK_ID_KEYS: readonly ["fbclid", "ttclid", "gclid", "gbraid", "wbraid", "msclkid", "twclid", "li_fat_id", "epik", "ScCid", "yclid", "_kx", "mc_eid", "mc_cid"];
|
|
14
|
+
export declare function promoteClickIds(telemetry: TelemetryClient): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-1 — auto-identify-or-alias on email entry.
|
|
3
|
+
*
|
|
4
|
+
* Listens for `change` events on email-typed inputs anywhere on the page.
|
|
5
|
+
* When a well-formed, non-denylisted email is detected:
|
|
6
|
+
* - If the current distinct_id is anonymous (PostHog UUID): identify(email)
|
|
7
|
+
* - If the current distinct_id is a different email: alias(email)
|
|
8
|
+
* - If the same email was already seen this session: no-op
|
|
9
|
+
*
|
|
10
|
+
* Per-element opt-out via `data-syntro-no-identify` on the input or a
|
|
11
|
+
* parent form.
|
|
12
|
+
*
|
|
13
|
+
* Consent: when a ConsentGate is provided, the actual identify/alias
|
|
14
|
+
* call is gated on the gate's resolved status. Listener is always
|
|
15
|
+
* installed; the call only fires if the gate is (or resolves to) granted.
|
|
16
|
+
*
|
|
17
|
+
* See docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md (D-1).
|
|
18
|
+
*/
|
|
19
|
+
import type { ConsentGate } from '../telemetry/consent';
|
|
20
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
21
|
+
export declare function isValidEmail(value: string): boolean;
|
|
22
|
+
export declare function isEmailDenylisted(value: string): boolean;
|
|
23
|
+
export declare function installEmailIdentifyListener(telemetry: TelemetryClient, consentGate?: ConsentGate): () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-2 — auto-identify-or-alias on URL param `?_syu=`.
|
|
3
|
+
*
|
|
4
|
+
* Reads the `_syu` (Syntro UID) param from the entry URL. If present:
|
|
5
|
+
* - If the current distinct_id is anonymous: identify(value)
|
|
6
|
+
* - If already identified as a different id: alias(value)
|
|
7
|
+
* - If already this id: no-op
|
|
8
|
+
*
|
|
9
|
+
* v1 watches one hardcoded param (`_syu`). Clients embed it in their
|
|
10
|
+
* transactional emails. The config layer will eventually let clients
|
|
11
|
+
* register their own param keys; until then, `_syu` is the convention.
|
|
12
|
+
*
|
|
13
|
+
* Consent: param value is read at boot. The actual identify/alias call
|
|
14
|
+
* is deferred until the gate reaches `granted`. Importantly, we wait
|
|
15
|
+
* for the FIRST `granted` ever observed — not the first definitive
|
|
16
|
+
* status. Most CMPs (WPConsent, OneTrust, Cookiebot) push a
|
|
17
|
+
* `consent default { analytics_storage: 'denied' }` on page load,
|
|
18
|
+
* which would make our gate go denied → user clicks Accept → granted.
|
|
19
|
+
* If we used subscribeOnce, we'd unsubscribe on the initial denied
|
|
20
|
+
* and miss the user's actual decision. The fire-on-first-granted
|
|
21
|
+
* pattern preserves the magic-link identify even through the
|
|
22
|
+
* default-denied → granted flow.
|
|
23
|
+
*
|
|
24
|
+
* See docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md (D-2).
|
|
25
|
+
*/
|
|
26
|
+
import type { ConsentGate } from '../telemetry/consent';
|
|
27
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
28
|
+
export declare const SYNTRO_UID_PARAM = "_syu";
|
|
29
|
+
export declare function identifyFromUrlParam(telemetry: TelemetryClient, consentGate?: ConsentGate): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Default Instrumentation — public entry point.
|
|
3
|
+
*
|
|
4
|
+
* Wires up the five default behaviors specified in
|
|
5
|
+
* docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md:
|
|
6
|
+
*
|
|
7
|
+
* D-1: auto-identify-or-alias on email entry
|
|
8
|
+
* D-2: auto-identify-or-alias on URL param ?_syu=
|
|
9
|
+
* D-3: capture $initial_* properties pre-identify
|
|
10
|
+
* D-4: promote click IDs to person properties
|
|
11
|
+
* D-5: extract JSON-LD raw and ship as event property
|
|
12
|
+
*
|
|
13
|
+
* All five are always on in v1. Per-element opt-outs via DOM
|
|
14
|
+
* attributes (data-syntro-no-track, data-syntro-no-identify,
|
|
15
|
+
* data-syntro-no-jsonld) are the only escape hatch.
|
|
16
|
+
*/
|
|
17
|
+
import type { ConsentGate } from '../telemetry/consent';
|
|
18
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
19
|
+
export { CLICK_ID_KEYS, promoteClickIds } from './clickIds';
|
|
20
|
+
export { installEmailIdentifyListener, isEmailDenylisted, isValidEmail } from './identifyOnEmail';
|
|
21
|
+
export { identifyFromUrlParam, SYNTRO_UID_PARAM } from './identifyOnUrlParam';
|
|
22
|
+
export { captureInitialProperties } from './initialProperties';
|
|
23
|
+
export { extractAndRegisterJsonLd, MAX_DESCRIPTION_LENGTH, MAX_IMAGE_ARRAY_LENGTH, PII_KEYS, stripBloat, stripPii, } from './jsonLd';
|
|
24
|
+
interface GeoLike {
|
|
25
|
+
is_eu?: string;
|
|
26
|
+
country_code?: string;
|
|
27
|
+
}
|
|
28
|
+
interface InstallDefaultsOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Promise resolving to geo info ({is_eu, country_code, ...}). Used by
|
|
31
|
+
* D-3 to decide whether to capture full URL (ROW) or origin+pathname
|
|
32
|
+
* only (EU/UK/CH). When omitted, D-3 captures the safe version.
|
|
33
|
+
*/
|
|
34
|
+
geoPromise?: Promise<GeoLike>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Install all SDK defaults. Returns a teardown function that removes
|
|
38
|
+
* any listeners that were attached.
|
|
39
|
+
*
|
|
40
|
+
* Safe to call when running in SSR / non-browser contexts; each
|
|
41
|
+
* default no-ops when the relevant browser APIs are unavailable.
|
|
42
|
+
*
|
|
43
|
+
* @param telemetry — the TelemetryClient (PostHog adapter, noop, etc.)
|
|
44
|
+
* @param consentGate — optional. When provided, D-1 (email entry) and
|
|
45
|
+
* D-2 (URL param) consult the gate before calling identify/alias.
|
|
46
|
+
* D-3, D-4, D-5 fire unconditionally — they're anonymous-only
|
|
47
|
+
* operations against the current (likely anonymous) distinct_id.
|
|
48
|
+
* @param options — optional. `geoPromise` enables geo-aware URL capture
|
|
49
|
+
* in D-3 (full URL for ROW, sanitized for EU/UK/CH).
|
|
50
|
+
*/
|
|
51
|
+
export declare function installDefaults(telemetry: TelemetryClient, consentGate?: ConsentGate, options?: InstallDefaultsOptions): () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-3 — capture $initial_* properties pre-identify.
|
|
3
|
+
*
|
|
4
|
+
* On SDK init, write attribution properties to the (currently anonymous)
|
|
5
|
+
* person record via setPersonPropertiesOnce. PostHog's $set_once semantics
|
|
6
|
+
* mean these are immutable — first value wins. They survive across the
|
|
7
|
+
* lifetime of the person record and merge in retroactively when identify
|
|
8
|
+
* eventually fires.
|
|
9
|
+
*
|
|
10
|
+
* URL capture is geo-aware:
|
|
11
|
+
* - ROW: capture full URL (`window.location.href`) including query string —
|
|
12
|
+
* query params can carry useful attribution (custom ref codes, campaigns)
|
|
13
|
+
* and ROW visitors can be tracked normally.
|
|
14
|
+
* - EU/UK/CH: capture origin + pathname only. Query strings on entry URLs
|
|
15
|
+
* can contain identifying info (`?_syu=alice@…`, `?email=…`, `?token=…`)
|
|
16
|
+
* that we MUST NOT ship as a person property pre-consent.
|
|
17
|
+
*
|
|
18
|
+
* See docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md (D-3).
|
|
19
|
+
*/
|
|
20
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
21
|
+
interface GeoLike {
|
|
22
|
+
is_eu?: string;
|
|
23
|
+
country_code?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function captureInitialProperties(telemetry: TelemetryClient, geoPromise?: Promise<GeoLike>): void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D-5 — extract JSON-LD raw and ship as event property.
|
|
3
|
+
*
|
|
4
|
+
* On every page navigation, scrape <script type="application/ld+json">
|
|
5
|
+
* blocks, strip PII keys + bloated fields, register the resulting
|
|
6
|
+
* array as `json_ld` so it flows onto subsequent events. Server-side
|
|
7
|
+
* picks what to make of it later — no schema vocabulary in SDK code.
|
|
8
|
+
*
|
|
9
|
+
* See docs/plans/current/2026-05-04-sdk-default-instrumentation-spec.md (D-5).
|
|
10
|
+
*/
|
|
11
|
+
import type { TelemetryClient } from '../telemetry/types';
|
|
12
|
+
export declare const PII_KEYS: Set<string>;
|
|
13
|
+
export declare const MAX_DESCRIPTION_LENGTH = 500;
|
|
14
|
+
export declare const MAX_IMAGE_ARRAY_LENGTH = 3;
|
|
15
|
+
export declare function stripPii(obj: unknown): unknown;
|
|
16
|
+
export declare function stripBloat(obj: unknown): unknown;
|
|
17
|
+
export declare function extractAndRegisterJsonLd(telemetry: TelemetryClient): void;
|