@syntrologie/runtime-sdk 0.2.0
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 +185 -0
- package/dist/SmartCanvasApp.d.ts +29 -0
- package/dist/SmartCanvasApp.js +68 -0
- package/dist/SmartCanvasApp.js.map +1 -0
- package/dist/SmartCanvasElement.d.ts +29 -0
- package/dist/SmartCanvasElement.js +133 -0
- package/dist/SmartCanvasElement.js.map +1 -0
- package/dist/SmartCanvasPortal.d.ts +7 -0
- package/dist/SmartCanvasPortal.js +17 -0
- package/dist/SmartCanvasPortal.js.map +1 -0
- package/dist/antiFlicker.d.ts +10 -0
- package/dist/antiFlicker.js +39 -0
- package/dist/antiFlicker.js.map +1 -0
- package/dist/api.d.ts +60 -0
- package/dist/api.js +159 -0
- package/dist/api.js.map +1 -0
- package/dist/bootstrap.d.ts +62 -0
- package/dist/bootstrap.js +83 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/bundle-entry.d.ts +4 -0
- package/dist/bundle-entry.js +9 -0
- package/dist/bundle-entry.js.map +1 -0
- package/dist/components/RectangleCard.d.ts +15 -0
- package/dist/components/RectangleCard.js +226 -0
- package/dist/components/RectangleCard.js.map +1 -0
- package/dist/components/RectangleWheel.d.ts +8 -0
- package/dist/components/RectangleWheel.js +30 -0
- package/dist/components/RectangleWheel.js.map +1 -0
- package/dist/components/ShadowCanvasOverlay.d.ts +26 -0
- package/dist/components/ShadowCanvasOverlay.js +163 -0
- package/dist/components/ShadowCanvasOverlay.js.map +1 -0
- package/dist/configFetcher.d.ts +15 -0
- package/dist/configFetcher.js +90 -0
- package/dist/configFetcher.js.map +1 -0
- package/dist/controller.d.ts +15 -0
- package/dist/controller.js +34 -0
- package/dist/controller.js.map +1 -0
- package/dist/earlyPatcher.d.ts +23 -0
- package/dist/earlyPatcher.js +70 -0
- package/dist/earlyPatcher.js.map +1 -0
- package/dist/editorLoader.d.ts +17 -0
- package/dist/editorLoader.js +95 -0
- package/dist/editorLoader.js.map +1 -0
- package/dist/experiments/adapters/growthbook.d.ts +45 -0
- package/dist/experiments/adapters/growthbook.js +79 -0
- package/dist/experiments/adapters/growthbook.js.map +1 -0
- package/dist/experiments/index.d.ts +3 -0
- package/dist/experiments/index.js +4 -0
- package/dist/experiments/index.js.map +1 -0
- package/dist/experiments/registry.d.ts +13 -0
- package/dist/experiments/registry.js +30 -0
- package/dist/experiments/registry.js.map +1 -0
- package/dist/experiments/types.d.ts +25 -0
- package/dist/experiments/types.js +2 -0
- package/dist/experiments/types.js.map +1 -0
- package/dist/fetchers/cdnFetcher.d.ts +35 -0
- package/dist/fetchers/cdnFetcher.js +100 -0
- package/dist/fetchers/cdnFetcher.js.map +1 -0
- package/dist/fetchers/experimentsFetcher.d.ts +33 -0
- package/dist/fetchers/experimentsFetcher.js +42 -0
- package/dist/fetchers/experimentsFetcher.js.map +1 -0
- package/dist/fetchers/index.d.ts +3 -0
- package/dist/fetchers/index.js +5 -0
- package/dist/fetchers/index.js.map +1 -0
- package/dist/fetchers/registry.d.ts +14 -0
- package/dist/fetchers/registry.js +58 -0
- package/dist/fetchers/registry.js.map +1 -0
- package/dist/fetchers/types.d.ts +26 -0
- package/dist/fetchers/types.js +2 -0
- package/dist/fetchers/types.js.map +1 -0
- package/dist/hooks/useCanvasOverlays.d.ts +13 -0
- package/dist/hooks/useCanvasOverlays.js +59 -0
- package/dist/hooks/useCanvasOverlays.js.map +1 -0
- package/dist/hooks/useHostPatches.d.ts +9 -0
- package/dist/hooks/useHostPatches.js +40 -0
- package/dist/hooks/useHostPatches.js.map +1 -0
- package/dist/hooks/useShadowCanvasConfig.d.ts +20 -0
- package/dist/hooks/useShadowCanvasConfig.js +46 -0
- package/dist/hooks/useShadowCanvasConfig.js.map +1 -0
- package/dist/hostPatcher/core/patcher.d.ts +3 -0
- package/dist/hostPatcher/core/patcher.js +173 -0
- package/dist/hostPatcher/core/patcher.js.map +1 -0
- package/dist/hostPatcher/core/sanitizer.d.ts +1 -0
- package/dist/hostPatcher/core/sanitizer.js +45 -0
- package/dist/hostPatcher/core/sanitizer.js.map +1 -0
- package/dist/hostPatcher/core/types.d.ts +94 -0
- package/dist/hostPatcher/core/types.js +2 -0
- package/dist/hostPatcher/core/types.js.map +1 -0
- package/dist/hostPatcher/index.d.ts +6 -0
- package/dist/hostPatcher/index.js +7 -0
- package/dist/hostPatcher/index.js.map +1 -0
- package/dist/hostPatcher/policy/defaultPolicy.d.ts +2 -0
- package/dist/hostPatcher/policy/defaultPolicy.js +41 -0
- package/dist/hostPatcher/policy/defaultPolicy.js.map +1 -0
- package/dist/hostPatcher/utils/anchors.d.ts +13 -0
- package/dist/hostPatcher/utils/anchors.js +107 -0
- package/dist/hostPatcher/utils/anchors.js.map +1 -0
- package/dist/hostPatcher/utils/observer.d.ts +3 -0
- package/dist/hostPatcher/utils/observer.js +11 -0
- package/dist/hostPatcher/utils/observer.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/overlays/fetcher.d.ts +4 -0
- package/dist/overlays/fetcher.js +17 -0
- package/dist/overlays/fetcher.js.map +1 -0
- package/dist/overlays/runtime/anchor/resolve.d.ts +4 -0
- package/dist/overlays/runtime/anchor/resolve.js +87 -0
- package/dist/overlays/runtime/anchor/resolve.js.map +1 -0
- package/dist/overlays/runtime/index.d.ts +6 -0
- package/dist/overlays/runtime/index.js +7 -0
- package/dist/overlays/runtime/index.js.map +1 -0
- package/dist/overlays/runtime/overlay/highlight.d.ts +10 -0
- package/dist/overlays/runtime/overlay/highlight.js +152 -0
- package/dist/overlays/runtime/overlay/highlight.js.map +1 -0
- package/dist/overlays/runtime/overlay/root.d.ts +4 -0
- package/dist/overlays/runtime/overlay/root.js +165 -0
- package/dist/overlays/runtime/overlay/root.js.map +1 -0
- package/dist/overlays/runtime/overlay/runner.d.ts +2 -0
- package/dist/overlays/runtime/overlay/runner.js +101 -0
- package/dist/overlays/runtime/overlay/runner.js.map +1 -0
- package/dist/overlays/runtime/overlay/tooltip.d.ts +14 -0
- package/dist/overlays/runtime/overlay/tooltip.js +174 -0
- package/dist/overlays/runtime/overlay/tooltip.js.map +1 -0
- package/dist/overlays/runtime/utils/dom.d.ts +2 -0
- package/dist/overlays/runtime/utils/dom.js +9 -0
- package/dist/overlays/runtime/utils/dom.js.map +1 -0
- package/dist/overlays/schema.d.ts +907 -0
- package/dist/overlays/schema.js +48 -0
- package/dist/overlays/schema.js.map +1 -0
- package/dist/overlays/types.d.ts +68 -0
- package/dist/overlays/types.js +2 -0
- package/dist/overlays/types.js.map +1 -0
- package/dist/react.d.ts +99 -0
- package/dist/react.js +119 -0
- package/dist/react.js.map +1 -0
- package/dist/smart-canvas.esm.js +202 -0
- package/dist/smart-canvas.esm.js.map +7 -0
- package/dist/smart-canvas.js +40406 -0
- package/dist/smart-canvas.js.map +7 -0
- package/dist/smart-canvas.min.js +202 -0
- package/dist/smart-canvas.min.js.map +7 -0
- package/dist/telemetry/adapters/posthog.d.ts +67 -0
- package/dist/telemetry/adapters/posthog.js +61 -0
- package/dist/telemetry/adapters/posthog.js.map +1 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.js +3 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/registry.d.ts +13 -0
- package/dist/telemetry/registry.js +27 -0
- package/dist/telemetry/registry.js.map +1 -0
- package/dist/telemetry/types.d.ts +28 -0
- package/dist/telemetry/types.js +2 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/token.d.ts +36 -0
- package/dist/token.js +47 -0
- package/dist/token.js.map +1 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -0
- package/schema/canvas-config.schema.json +329 -0
- package/scripts/validate-config.mjs +80 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostHog adapter for the TelemetryClient interface.
|
|
3
|
+
*
|
|
4
|
+
* This file is INTERNAL - consumers should only import from telemetry/types.ts
|
|
5
|
+
* and use the TelemetryClient interface.
|
|
6
|
+
*/
|
|
7
|
+
import type { PostHog, Properties } from "posthog-js";
|
|
8
|
+
import type { TelemetryClient, CanvasSurface } from "../types";
|
|
9
|
+
export interface PostHogAdapterOptions {
|
|
10
|
+
/**
|
|
11
|
+
* PostHog API key.
|
|
12
|
+
*/
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* PostHog API host.
|
|
16
|
+
* @default "https://telemetry.syntrologie.com"
|
|
17
|
+
*/
|
|
18
|
+
apiHost?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Existing PostHog client to wrap.
|
|
21
|
+
*/
|
|
22
|
+
client?: PostHog;
|
|
23
|
+
/**
|
|
24
|
+
* Enable full-page autocapture (clicks, form submissions, etc.)
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
autocapture?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Enable session recording.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
sessionRecording?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Enable pageview capture.
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
capturePageview?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Enable page leave capture.
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
capturePageleave?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface CanvasAnalyticsPayload extends Properties {
|
|
45
|
+
rectangleId?: string;
|
|
46
|
+
surface?: CanvasSurface;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Internal adapter that implements TelemetryClient using PostHog.
|
|
50
|
+
*/
|
|
51
|
+
export declare class PostHogAdapter implements TelemetryClient {
|
|
52
|
+
private readonly options;
|
|
53
|
+
private client?;
|
|
54
|
+
constructor(options?: PostHogAdapterOptions);
|
|
55
|
+
identify(id: string, props?: Properties): void;
|
|
56
|
+
alias(id: string, aliasId: string): void;
|
|
57
|
+
track(eventName: string, payload?: CanvasAnalyticsPayload): void;
|
|
58
|
+
trackCanvasOpened(surface: CanvasSurface): void;
|
|
59
|
+
trackCanvasClosed(surface: CanvasSurface): void;
|
|
60
|
+
trackRectangleViewed(rectangleId: string, surface: CanvasSurface): void;
|
|
61
|
+
trackAction(action: string, rectangleId: string, surface: CanvasSurface): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a TelemetryClient backed by PostHog.
|
|
65
|
+
*/
|
|
66
|
+
export declare function createPostHogClient(options?: PostHogAdapterOptions): TelemetryClient;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import posthog from "posthog-js";
|
|
2
|
+
/**
|
|
3
|
+
* Internal adapter that implements TelemetryClient using PostHog.
|
|
4
|
+
*/
|
|
5
|
+
export class PostHogAdapter {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
var _a, _b, _c, _d, _e;
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.client = options.client;
|
|
10
|
+
if (!this.client && typeof window !== "undefined" && options.apiKey) {
|
|
11
|
+
this.client = posthog;
|
|
12
|
+
this.client.init(options.apiKey, {
|
|
13
|
+
api_host: (_a = options.apiHost) !== null && _a !== void 0 ? _a : "https://telemetry.syntrologie.com",
|
|
14
|
+
// Full-page tracking - all ON by default
|
|
15
|
+
autocapture: (_b = options.autocapture) !== null && _b !== void 0 ? _b : true,
|
|
16
|
+
capture_pageview: (_c = options.capturePageview) !== null && _c !== void 0 ? _c : true,
|
|
17
|
+
capture_pageleave: (_d = options.capturePageleave) !== null && _d !== void 0 ? _d : true,
|
|
18
|
+
disable_session_recording: !((_e = options.sessionRecording) !== null && _e !== void 0 ? _e : true),
|
|
19
|
+
// Cross-domain iframe recording for embeds
|
|
20
|
+
session_recording: {
|
|
21
|
+
recordCrossDomainIFrames: true,
|
|
22
|
+
},
|
|
23
|
+
// Capture performance metrics
|
|
24
|
+
capture_performance: true,
|
|
25
|
+
// Enable web vitals
|
|
26
|
+
enable_recording_console_log: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
identify(id, props) {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.identify(id, props);
|
|
33
|
+
}
|
|
34
|
+
alias(id, aliasId) {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.alias(id, aliasId);
|
|
37
|
+
}
|
|
38
|
+
track(eventName, payload) {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.capture(eventName, payload);
|
|
41
|
+
}
|
|
42
|
+
trackCanvasOpened(surface) {
|
|
43
|
+
this.track("shadow_canvas_opened", { surface });
|
|
44
|
+
}
|
|
45
|
+
trackCanvasClosed(surface) {
|
|
46
|
+
this.track("shadow_canvas_closed", { surface });
|
|
47
|
+
}
|
|
48
|
+
trackRectangleViewed(rectangleId, surface) {
|
|
49
|
+
this.track("shadow_canvas_rectangle_viewed", { rectangleId, surface });
|
|
50
|
+
}
|
|
51
|
+
trackAction(action, rectangleId, surface) {
|
|
52
|
+
this.track("shadow_canvas_action", { action, rectangleId, surface });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Create a TelemetryClient backed by PostHog.
|
|
57
|
+
*/
|
|
58
|
+
export function createPostHogClient(options = {}) {
|
|
59
|
+
return new PostHogAdapter(options);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=posthog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posthog.js","sourceRoot":"","sources":["../../../src/telemetry/adapters/posthog.ts"],"names":[],"mappings":"AAOA,OAAO,OAAO,MAAM,YAAY,CAAC;AAkDjC;;GAEG;AACH,MAAM,OAAO,cAAc;IAGzB,YAA6B,UAAiC,EAAE;;QAAnC,YAAO,GAAP,OAAO,CAA4B;QAC9D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACpE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;gBAC/B,QAAQ,EAAE,MAAA,OAAO,CAAC,OAAO,mCAAI,mCAAmC;gBAChE,yCAAyC;gBACzC,WAAW,EAAE,MAAA,OAAO,CAAC,WAAW,mCAAI,IAAI;gBACxC,gBAAgB,EAAE,MAAA,OAAO,CAAC,eAAe,mCAAI,IAAI;gBACjD,iBAAiB,EAAE,MAAA,OAAO,CAAC,gBAAgB,mCAAI,IAAI;gBACnD,yBAAyB,EAAE,CAAC,CAAC,MAAA,OAAO,CAAC,gBAAgB,mCAAI,IAAI,CAAC;gBAC9D,2CAA2C;gBAC3C,iBAAiB,EAAE;oBACjB,wBAAwB,EAAE,IAAI;iBAC/B;gBACD,8BAA8B;gBAC9B,mBAAmB,EAAE,IAAI;gBACzB,oBAAoB;gBACpB,4BAA4B,EAAE,IAAI;aACnC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,KAAkB;;QACrC,MAAA,IAAI,CAAC,MAAM,0CAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,EAAU,EAAE,OAAe;;QAC/B,MAAA,IAAI,CAAC,MAAM,0CAAE,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,SAAiB,EAAE,OAAgC;;QACvD,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,iBAAiB,CAAC,OAAsB;QACtC,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,iBAAiB,CAAC,OAAsB;QACtC,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,oBAAoB,CAAC,WAAmB,EAAE,OAAsB;QAC9D,IAAI,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,WAAW,CAAC,MAAc,EAAE,WAAmB,EAAE,OAAsB;QACrE,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAiC,EAAE;IAEnC,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAGA,yDAAyD;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TelemetryClient } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a telemetry client for the specified provider.
|
|
4
|
+
*
|
|
5
|
+
* @param provider - Provider name (e.g., "posthog")
|
|
6
|
+
* @param config - Provider-specific configuration
|
|
7
|
+
* @returns A TelemetryClient instance
|
|
8
|
+
* @throws Error if the provider is not supported
|
|
9
|
+
*/
|
|
10
|
+
export declare function createTelemetryClient(provider: string, config: {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
apiHost?: string;
|
|
13
|
+
}): TelemetryClient;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry provider registry.
|
|
3
|
+
*
|
|
4
|
+
* Maps provider names to their adapter factories.
|
|
5
|
+
* This allows the bootstrap module to dynamically create
|
|
6
|
+
* telemetry clients based on token configuration.
|
|
7
|
+
*/
|
|
8
|
+
import { createPostHogClient } from "./adapters/posthog";
|
|
9
|
+
const adapters = {
|
|
10
|
+
posthog: (config) => createPostHogClient(config),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Create a telemetry client for the specified provider.
|
|
14
|
+
*
|
|
15
|
+
* @param provider - Provider name (e.g., "posthog")
|
|
16
|
+
* @param config - Provider-specific configuration
|
|
17
|
+
* @returns A TelemetryClient instance
|
|
18
|
+
* @throws Error if the provider is not supported
|
|
19
|
+
*/
|
|
20
|
+
export function createTelemetryClient(provider, config) {
|
|
21
|
+
const factory = adapters[provider];
|
|
22
|
+
if (!factory) {
|
|
23
|
+
throw new Error(`Unknown telemetry provider: ${provider}. Supported: ${Object.keys(adapters).join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
return factory(config);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/telemetry/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAyB,MAAM,oBAAoB,CAAC;AAKhF,MAAM,QAAQ,GAAmC;IAC/C,OAAO,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC;CACxE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,MAA4C;IAE5C,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,+BAA+B,QAAQ,gBAAgB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC1F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface where the canvas UI is displayed.
|
|
3
|
+
*/
|
|
4
|
+
export type CanvasSurface = "overlay" | "wheel";
|
|
5
|
+
/**
|
|
6
|
+
* Clean interface for telemetry/analytics clients.
|
|
7
|
+
*
|
|
8
|
+
* This is the ONLY interface consumers should use. The underlying
|
|
9
|
+
* implementation (PostHog, Segment, etc.) is an internal detail.
|
|
10
|
+
*/
|
|
11
|
+
export interface TelemetryClient {
|
|
12
|
+
/**
|
|
13
|
+
* Track when the canvas is opened.
|
|
14
|
+
*/
|
|
15
|
+
trackCanvasOpened(surface: CanvasSurface): void;
|
|
16
|
+
/**
|
|
17
|
+
* Track when the canvas is closed.
|
|
18
|
+
*/
|
|
19
|
+
trackCanvasClosed(surface: CanvasSurface): void;
|
|
20
|
+
/**
|
|
21
|
+
* Track when a rectangle/tile is viewed.
|
|
22
|
+
*/
|
|
23
|
+
trackRectangleViewed(rectangleId: string, surface: CanvasSurface): void;
|
|
24
|
+
/**
|
|
25
|
+
* Track a user action.
|
|
26
|
+
*/
|
|
27
|
+
trackAction(action: string, rectangleId: string, surface: CanvasSurface): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":""}
|
package/dist/token.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token encoding/decoding utilities for Syntro client keys.
|
|
3
|
+
*
|
|
4
|
+
* A Syntro token is a base64url-encoded JSON payload prefixed with "syn_".
|
|
5
|
+
* It bundles all necessary credentials (experiments, telemetry, config) into
|
|
6
|
+
* a single string that clients can use to initialize the SDK.
|
|
7
|
+
*/
|
|
8
|
+
export interface SyntroTokenPayload {
|
|
9
|
+
/** Token version for future compatibility */
|
|
10
|
+
v: 1;
|
|
11
|
+
/** Experiments key (assumes growthbook provider by default) */
|
|
12
|
+
e?: string;
|
|
13
|
+
/** Telemetry key (assumes posthog provider by default) */
|
|
14
|
+
t?: string;
|
|
15
|
+
/** Config fetcher type (e.g., "cdn", "experiments") */
|
|
16
|
+
f?: string;
|
|
17
|
+
/** Fetcher-specific options (e.g., configId for cdn fetcher) */
|
|
18
|
+
o?: Record<string, string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Decode a Syntro token into its payload.
|
|
22
|
+
*
|
|
23
|
+
* @param token - The token string (e.g., "syn_eyJ2IjoxfQ")
|
|
24
|
+
* @returns The decoded payload
|
|
25
|
+
* @throws Error if the token is invalid or unsupported version
|
|
26
|
+
*/
|
|
27
|
+
export declare function decodeToken(token: string): SyntroTokenPayload;
|
|
28
|
+
/**
|
|
29
|
+
* Encode a payload into a Syntro token.
|
|
30
|
+
*
|
|
31
|
+
* This is primarily for admin/dashboard use, but exported for testing.
|
|
32
|
+
*
|
|
33
|
+
* @param payload - The payload to encode
|
|
34
|
+
* @returns The encoded token string
|
|
35
|
+
*/
|
|
36
|
+
export declare function encodeToken(payload: SyntroTokenPayload): string;
|
package/dist/token.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token encoding/decoding utilities for Syntro client keys.
|
|
3
|
+
*
|
|
4
|
+
* A Syntro token is a base64url-encoded JSON payload prefixed with "syn_".
|
|
5
|
+
* It bundles all necessary credentials (experiments, telemetry, config) into
|
|
6
|
+
* a single string that clients can use to initialize the SDK.
|
|
7
|
+
*/
|
|
8
|
+
const TOKEN_PREFIX = "syn_";
|
|
9
|
+
/**
|
|
10
|
+
* Decode a Syntro token into its payload.
|
|
11
|
+
*
|
|
12
|
+
* @param token - The token string (e.g., "syn_eyJ2IjoxfQ")
|
|
13
|
+
* @returns The decoded payload
|
|
14
|
+
* @throws Error if the token is invalid or unsupported version
|
|
15
|
+
*/
|
|
16
|
+
export function decodeToken(token) {
|
|
17
|
+
if (!token.startsWith(TOKEN_PREFIX)) {
|
|
18
|
+
throw new Error("Invalid Syntro token: must start with 'syn_'");
|
|
19
|
+
}
|
|
20
|
+
const base64 = token.slice(TOKEN_PREFIX.length);
|
|
21
|
+
// Convert base64url to standard base64
|
|
22
|
+
const standardBase64 = base64.replace(/-/g, "+").replace(/_/g, "/");
|
|
23
|
+
const json = atob(standardBase64);
|
|
24
|
+
const payload = JSON.parse(json);
|
|
25
|
+
if (payload.v !== 1) {
|
|
26
|
+
throw new Error(`Unsupported token version: ${payload.v}`);
|
|
27
|
+
}
|
|
28
|
+
return payload;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Encode a payload into a Syntro token.
|
|
32
|
+
*
|
|
33
|
+
* This is primarily for admin/dashboard use, but exported for testing.
|
|
34
|
+
*
|
|
35
|
+
* @param payload - The payload to encode
|
|
36
|
+
* @returns The encoded token string
|
|
37
|
+
*/
|
|
38
|
+
export function encodeToken(payload) {
|
|
39
|
+
const json = JSON.stringify(payload);
|
|
40
|
+
// Convert to base64url (URL-safe, no padding)
|
|
41
|
+
const base64 = btoa(json)
|
|
42
|
+
.replace(/\+/g, "-")
|
|
43
|
+
.replace(/\//g, "_")
|
|
44
|
+
.replace(/=+$/, "");
|
|
45
|
+
return TOKEN_PREFIX + base64;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,YAAY,GAAG,MAAM,CAAC;AAmB5B;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChD,uCAAuC;IACvC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAuB,CAAC;IAEvD,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACrC,8CAA8C;IAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,OAAO,YAAY,GAAG,MAAM,CAAC;AAC/B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props passed to every tile component when mounted
|
|
3
|
+
*/
|
|
4
|
+
export interface TileComponentProps {
|
|
5
|
+
config: TileConfig;
|
|
6
|
+
isExpanded: boolean;
|
|
7
|
+
surface: "overlay" | "wheel";
|
|
8
|
+
telemetry?: import("./telemetry/types").TelemetryClient;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Interface for registering custom tile components
|
|
12
|
+
*/
|
|
13
|
+
export interface TileComponent {
|
|
14
|
+
mount(container: HTMLElement, props: TileComponentProps): void | (() => void);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Grid width: "full" = spans both columns, "half" = one column
|
|
18
|
+
*/
|
|
19
|
+
export type TileSize = "full" | "half";
|
|
20
|
+
/**
|
|
21
|
+
* Built-in tile types (convenience components we ship)
|
|
22
|
+
*/
|
|
23
|
+
export type BuiltInTileType = "text" | "metric" | "chatbot" | "embed";
|
|
24
|
+
/**
|
|
25
|
+
* Content configuration for built-in tile types
|
|
26
|
+
*/
|
|
27
|
+
export interface BuiltInTileContent {
|
|
28
|
+
type: BuiltInTileType;
|
|
29
|
+
headline?: string;
|
|
30
|
+
body?: string;
|
|
31
|
+
metricValue?: string;
|
|
32
|
+
metricUnit?: string;
|
|
33
|
+
embedUrl?: string;
|
|
34
|
+
actions?: TileAction[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Content configuration for custom tile components
|
|
38
|
+
*/
|
|
39
|
+
export interface CustomTileContent {
|
|
40
|
+
type: "custom";
|
|
41
|
+
component: string;
|
|
42
|
+
props?: Record<string, unknown>;
|
|
43
|
+
actions?: TileAction[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Union of all content types
|
|
47
|
+
*/
|
|
48
|
+
export type TileContent = BuiltInTileContent | CustomTileContent;
|
|
49
|
+
/**
|
|
50
|
+
* Action button displayed in expanded tile
|
|
51
|
+
*/
|
|
52
|
+
export interface TileAction {
|
|
53
|
+
label: string;
|
|
54
|
+
href?: string;
|
|
55
|
+
onClickId?: string;
|
|
56
|
+
style?: "primary" | "secondary";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Visual styling for tile chrome
|
|
60
|
+
*/
|
|
61
|
+
export interface TileStyle {
|
|
62
|
+
accentColor?: string;
|
|
63
|
+
background?: string;
|
|
64
|
+
textColor?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Experiment targeting for A/B tests
|
|
68
|
+
*/
|
|
69
|
+
export interface TileExperiment {
|
|
70
|
+
featureKey?: string;
|
|
71
|
+
variationId?: number;
|
|
72
|
+
variationValue?: string | number | boolean;
|
|
73
|
+
predicate?: (value: unknown) => boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Full tile configuration
|
|
77
|
+
*/
|
|
78
|
+
export interface TileConfig {
|
|
79
|
+
id: string;
|
|
80
|
+
title: string;
|
|
81
|
+
subtitle?: string;
|
|
82
|
+
icon?: string;
|
|
83
|
+
preview?: string;
|
|
84
|
+
size?: TileSize;
|
|
85
|
+
order?: number;
|
|
86
|
+
expandable?: boolean;
|
|
87
|
+
defaultExpanded?: boolean;
|
|
88
|
+
content: TileContent;
|
|
89
|
+
style?: TileStyle;
|
|
90
|
+
experiment?: TileExperiment;
|
|
91
|
+
analyticsKey?: string;
|
|
92
|
+
}
|
|
93
|
+
import type { Patch } from "./hostPatcher/core/types";
|
|
94
|
+
export interface CanvasConfigResponse {
|
|
95
|
+
tiles: TileConfig[];
|
|
96
|
+
fetchedAt: string;
|
|
97
|
+
configVersion?: string;
|
|
98
|
+
canvasTitle?: string;
|
|
99
|
+
patches?: Patch[];
|
|
100
|
+
overlayRecipe?: import('./overlays/types').CanvasRecipe;
|
|
101
|
+
}
|
|
102
|
+
export type CanvasConfigFetcher = () => Promise<CanvasConfigResponse>;
|
|
103
|
+
/** @deprecated Use TileSize */
|
|
104
|
+
export type RectangleSize = TileSize | "quarter";
|
|
105
|
+
/** @deprecated Use TileContent */
|
|
106
|
+
export type RectangleContentType = "text" | "metric" | "chatbot" | "embed" | "custom";
|
|
107
|
+
/** @deprecated Use TileAction */
|
|
108
|
+
export type RectangleAction = TileAction;
|
|
109
|
+
/** @deprecated Use TileContent */
|
|
110
|
+
export interface RectangleContent {
|
|
111
|
+
type: RectangleContentType;
|
|
112
|
+
headline?: string;
|
|
113
|
+
body?: string;
|
|
114
|
+
metricValue?: string;
|
|
115
|
+
metricUnit?: string;
|
|
116
|
+
embedUrl?: string;
|
|
117
|
+
customRendererKey?: string;
|
|
118
|
+
actions?: TileAction[];
|
|
119
|
+
}
|
|
120
|
+
/** @deprecated Use TileStyle */
|
|
121
|
+
export type RectangleStyle = TileStyle;
|
|
122
|
+
/** @deprecated Use TileExperiment */
|
|
123
|
+
export type RectangleExperimentConfig = TileExperiment;
|
|
124
|
+
/** @deprecated Use TileConfig */
|
|
125
|
+
export interface RectangleConfig {
|
|
126
|
+
id: string;
|
|
127
|
+
title: string;
|
|
128
|
+
subtitle?: string;
|
|
129
|
+
icon?: string;
|
|
130
|
+
size?: RectangleSize;
|
|
131
|
+
order?: number;
|
|
132
|
+
style?: TileStyle;
|
|
133
|
+
content: RectangleContent;
|
|
134
|
+
experiment?: TileExperiment;
|
|
135
|
+
analyticsKey?: string;
|
|
136
|
+
}
|
|
137
|
+
/** @deprecated Use CanvasConfigResponse */
|
|
138
|
+
export interface ShadowCanvasConfigResponse {
|
|
139
|
+
rectangles?: RectangleConfig[];
|
|
140
|
+
tiles?: TileConfig[];
|
|
141
|
+
fetchedAt: string;
|
|
142
|
+
configVersion?: string;
|
|
143
|
+
canvasTitle?: string;
|
|
144
|
+
patches?: Patch[];
|
|
145
|
+
overlayRecipe?: import('./overlays/types').CanvasRecipe;
|
|
146
|
+
displayMode?: 'standard' | 'focused';
|
|
147
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@syntrologie/runtime-sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Syntrologie Runtime SDK for web experimentation and analytics",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"private": false,
|
|
7
|
+
"author": "Syntrologie Team <team@syntrologie.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/syntrologie/tech-core.git",
|
|
11
|
+
"directory": "sdks/runtime-sdk"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./react": {
|
|
24
|
+
"types": "./dist/react.d.ts",
|
|
25
|
+
"import": "./dist/react.js",
|
|
26
|
+
"require": "./dist/react.js"
|
|
27
|
+
},
|
|
28
|
+
"./cdn": {
|
|
29
|
+
"import": "./dist/smart-canvas.esm.js",
|
|
30
|
+
"require": "./dist/smart-canvas.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"schema",
|
|
36
|
+
"scripts/validate-config.mjs",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"build": "npm run build:lib && npm run build:cdn",
|
|
42
|
+
"build:lib": "tsc --project tsconfig.build.json",
|
|
43
|
+
"build:cdn": "node ./scripts/build-cdn.js",
|
|
44
|
+
"validate-config": "node ./scripts/validate-config.mjs",
|
|
45
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@floating-ui/dom": "~1.6.13",
|
|
49
|
+
"@growthbook/growthbook": "~1.6.2",
|
|
50
|
+
"@growthbook/growthbook-react": "~1.6.2",
|
|
51
|
+
"posthog-js": "~1.302.2",
|
|
52
|
+
"react": "~18.3.1",
|
|
53
|
+
"react-dom": "~18.3.1",
|
|
54
|
+
"zod": "~3.25.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": ">=18.0.0",
|
|
58
|
+
"react-dom": ">=18.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"esbuild": "~0.25.0",
|
|
62
|
+
"typescript": "~5.7.0"
|
|
63
|
+
}
|
|
64
|
+
}
|