@plitzi/plitzi-sdk 0.32.25 → 0.33.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/CHANGELOG.md +21 -0
- package/dist/App.d.ts +3 -2
- package/dist/index.d.ts +8 -4
- package/dist/index.html +1 -1
- package/dist/modules/Analytics/AnalyticsReporter.d.ts +16 -0
- package/dist/modules/Analytics/createReporter.d.ts +37 -0
- package/dist/modules/Analytics/index.d.ts +3 -0
- package/dist/modules/Analytics/reporterRegistry.d.ts +6 -0
- package/dist/modules/Analytics/reporterRegistry.test.d.ts +1 -0
- package/dist/modules/App/AppMain.d.ts +3 -3
- package/dist/modules/App/useDebugShortcut.d.ts +13 -0
- package/dist/modules/App/useDebugShortcut.test.d.ts +1 -0
- package/dist/modules/Navigation/NavigationProvider.d.ts +7 -0
- package/dist/modules/Network/NetworkContextProvider.d.ts +2 -4
- package/dist/modules/Plugins/PluginsContextProvider.d.ts +2 -3
- package/dist/modules/Sdk/Sdk.d.ts +2 -7
- package/dist/plitzi-sdk-dev-vendor.js.map +1 -1
- package/dist/plitzi-sdk-dev-vendor.js.map.gz +0 -0
- package/dist/plitzi-sdk-devtools.css +1 -1
- package/dist/plitzi-sdk-devtools.css.gz +0 -0
- package/dist/plitzi-sdk.css +1 -1
- package/dist/plitzi-sdk.css.gz +0 -0
- package/dist/plitzi-sdk.js +370 -477
- package/dist/plitzi-sdk.js.gz +0 -0
- package/package.json +27 -29
- package/dist/modules/Collection/CollectionContextProvider.d.ts +0 -8
- package/dist/modules/Navigation/NavigationContextProvider.d.ts +0 -11
- /package/dist/modules/{Collection/index.d.ts → Analytics/createReporter.test.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @plitzi/plitzi-sdk
|
|
2
2
|
|
|
3
|
+
## 0.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- v0.33.0
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @plitzi/sdk-auth@0.33.0
|
|
13
|
+
- @plitzi/sdk-dev-tools@0.33.0
|
|
14
|
+
- @plitzi/sdk-elements@0.33.0
|
|
15
|
+
- @plitzi/sdk-event-bridge@0.33.0
|
|
16
|
+
- @plitzi/sdk-interactions@0.33.0
|
|
17
|
+
- @plitzi/sdk-navigation@0.33.0
|
|
18
|
+
- @plitzi/sdk-plugins@0.33.0
|
|
19
|
+
- @plitzi/sdk-schema@0.33.0
|
|
20
|
+
- @plitzi/sdk-shared@0.33.0
|
|
21
|
+
- @plitzi/sdk-style@0.33.0
|
|
22
|
+
- @plitzi/sdk-variables@0.33.0
|
|
23
|
+
|
|
3
24
|
## 0.32.25
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/App.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, EventBridgeContextValue, OfflineDataRaw, RenderMode, Server, RuntimeStateInstance
|
|
1
|
+
import { AnalyticsConfig, Environment, EventBridgeContextValue, OfflineDataRaw, RenderMode, Server, RuntimeStateInstance } from '@plitzi/sdk-shared';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export type AppProps = {
|
|
4
4
|
className?: string;
|
|
@@ -19,10 +19,11 @@ export type AppProps = {
|
|
|
19
19
|
* own (an MCP widget rendered inside a chat, a component mounted in a host app). */
|
|
20
20
|
branding?: boolean;
|
|
21
21
|
externalStyle?: string;
|
|
22
|
+
/** Reporting channel for this render — see {@link AnalyticsConfig}. Absent means report nothing. */
|
|
23
|
+
analytics?: AnalyticsConfig;
|
|
22
24
|
state?: Record<string, unknown>;
|
|
23
25
|
onInitStateManager?: (instance: RuntimeStateInstance) => void;
|
|
24
26
|
onInitEventBridge?: (instance: EventBridgeContextValue) => void;
|
|
25
|
-
ssrResult?: SSRRenderResult;
|
|
26
27
|
};
|
|
27
28
|
declare const App: ({ className, children, webKey, server, renderMode, debugMode: debugModeProp, state, ...sdkProps }: AppProps) => import("react").JSX.Element;
|
|
28
29
|
export default App;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,12 @@ import { default as ReplicaProvider } from '@plitzi/sdk-elements/Element/Replica
|
|
|
10
10
|
import { default as RootElement } from '@plitzi/sdk-elements/Element/RootElement';
|
|
11
11
|
import { default as ComponentContext } from '@plitzi/sdk-shared/elements/ComponentContext';
|
|
12
12
|
import { PlitziServiceProvider } from '@plitzi/sdk-shared/hooks/usePlitziServiceContext';
|
|
13
|
+
import { useSdkStore } from '@plitzi/sdk-shared/store';
|
|
14
|
+
import { track } from './modules/Analytics';
|
|
13
15
|
import { ElementContextValue } from '@plitzi/sdk-elements/Element/ElementContext';
|
|
14
16
|
import { default as EventBridge } from '@plitzi/sdk-event-bridge';
|
|
15
17
|
import { default as InteractionsManager } from '@plitzi/sdk-interactions/InteractionsManager';
|
|
16
|
-
import { Element, Schema, Style, ComponentPluginFC, ComponentPlugin, InteractionCallback, InteractionCallbackParamValues, Environment, EventBridgeContextValue, OfflineDataRaw, RenderMode, Server, RuntimeStateInstance,
|
|
18
|
+
import { AnalyticsConfig, Element, Schema, Style, ComponentPluginFC, ComponentPlugin, InteractionCallback, InteractionCallbackParamValues, Environment, EventBridgeContextValue, OfflineDataRaw, RenderMode, Server, RuntimeStateInstance, PlitziServiceContextValue as BasePlitziServiceContextValue } from '@plitzi/sdk-shared';
|
|
17
19
|
import { ReactNode } from 'react';
|
|
18
20
|
export declare function render(widgetContainer: string, params?: PlitziSdkProps, plugins?: Record<string, {
|
|
19
21
|
component: ComponentPlugin;
|
|
@@ -44,8 +46,10 @@ export type PlitziSdkProps = {
|
|
|
44
46
|
branding?: boolean;
|
|
45
47
|
externalStyle?: string;
|
|
46
48
|
sdkDevToolsStylePath?: string;
|
|
49
|
+
/** Where this render reports SPA navigations and interactions, and with what key. Injected by a server that
|
|
50
|
+
* renders the page; derived from `server` + `webKey` for a client-side render; absent means report nothing. */
|
|
51
|
+
analytics?: AnalyticsConfig;
|
|
47
52
|
state?: Record<string, unknown>;
|
|
48
|
-
ssrResult?: SSRRenderResult;
|
|
49
53
|
};
|
|
50
54
|
declare const PlitziSdk: {
|
|
51
55
|
({ debugMode, isHydrating, children, webKey, environment, renderMode, ...otherProps }: PlitziSdkProps): import("react").JSX.Element;
|
|
@@ -53,8 +57,8 @@ declare const PlitziSdk: {
|
|
|
53
57
|
};
|
|
54
58
|
type PlitziServiceContextValue = BasePlitziServiceContextValue<InstanceType<typeof EventBridge>, InstanceType<typeof InteractionsManager>>;
|
|
55
59
|
declare const usePlitziServiceContext: () => PlitziServiceContextValue;
|
|
56
|
-
export { ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData };
|
|
57
|
-
export type { ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues };
|
|
60
|
+
export { track, useSdkStore as useStore, ComponentProvider, ComponentContext, usePlitziServiceContext, PlitziServiceProvider, RootElement, withElement, JsxManager, PluginManager, sdkComponents, PluginRemote, ReplicaProvider, useElement, useRscData };
|
|
61
|
+
export type { AnalyticsConfig, ElementContextValue, Element, Schema, Style, ComponentPlugin, ComponentPluginFC, PlitziServiceContextValue, OfflineDataRaw, InteractionCallback, InteractionCallbackParamValues };
|
|
58
62
|
export declare const version: string;
|
|
59
63
|
export declare const getStateManager: () => RuntimeStateInstance;
|
|
60
64
|
export declare const getEventBridge: () => EventBridgeContextValue;
|
package/dist/index.html
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
'plitzi',
|
|
59
59
|
{
|
|
60
60
|
webKey:
|
|
61
|
-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
|
|
61
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwib3JpZ2lucyI6WyJodHRwczovL3dlYnNpdGUucGxpdHppLmFwcCIsImh0dHBzOi8vcGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9hcHAucGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9hcHAucGxpdHppLmxvY2FsOjMwMDAiLCJodHRwczovL2FwcC5wbGl0emkubG9jYWw6MzAwMSIsImh0dHBzOi8vc3NyLnBsaXR6aS5sb2NhbCIsImh0dHBzOi8vc2VydmVyLnBsaXR6aS5sb2NhbCIsImh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCIsImh0dHA6Ly9sb2NhbGhvc3Q6ODA4MCIsImh0dHA6Ly8xMjcuMC4wLjE6ODA4MCJdLCJpc3MiOiJodHRwczovL3NlcnZlci5wbGl0emkubG9jYWwiLCJhdWQiOlsiaHR0cHM6Ly9wbGl0emkubG9jYWwiLCJodHRwczovL2FwcC5wbGl0emkubG9jYWwiLCJodHRwczovL2FwcC5wbGl0emkubG9jYWw6MzAwMCIsImh0dHBzOi8vYXBwLnBsaXR6aS5sb2NhbDozMDAxIiwiaHR0cHM6Ly9hcGkucGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9zc3IucGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9zZXJ2ZXIucGxpdHppLmxvY2FsIiwiaHR0cHM6Ly9tY3AucGxpdHppLmxvY2FsIl0sInNjb3BlIjoic3BhY2U6cmVuZGVyIiwiaWF0IjoxNzg2NjU5NTg5LCJqdGkiOiJjMjRhZjMwN2Q1YTgzZmNjIiwibmJmIjoxNzg2NjU5NTg5fQ.q3-yIi5TmY8SLghX5q3jpN2qqsGJbDIF9dcVJvfLbfY',
|
|
62
62
|
environment: 'main',
|
|
63
63
|
revision: 0,
|
|
64
64
|
renderMode: 'raw',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnalyticsConfig } from '@plitzi/sdk-shared';
|
|
2
|
+
export type AnalyticsReporterProps = {
|
|
3
|
+
analytics?: AnalyticsConfig;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Renders nothing; reports what only the browser can see.
|
|
7
|
+
*
|
|
8
|
+
* It exists at all because the server sees a visit once — the SSR render, or the schema fetch of a
|
|
9
|
+
* client-side render — and then never again, however long the visitor stays or however many routes they move
|
|
10
|
+
* through. Those are this component's, along with named interactions.
|
|
11
|
+
*
|
|
12
|
+
* `firstViewCounted` is the seam between the two: when the server already counted this page load, the first
|
|
13
|
+
* render here would be the same view a second time, so it is skipped and only subsequent routes are reported.
|
|
14
|
+
*/
|
|
15
|
+
declare const AnalyticsReporter: ({ analytics }: AnalyticsReporterProps) => null;
|
|
16
|
+
export default AnalyticsReporter;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AnalyticsConfig } from '@plitzi/sdk-shared';
|
|
2
|
+
export type ReporterEvent = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: 'render' | 'interaction' | 'custom';
|
|
5
|
+
ts: number;
|
|
6
|
+
page: {
|
|
7
|
+
path: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
};
|
|
10
|
+
ref?: {
|
|
11
|
+
referrer?: string;
|
|
12
|
+
utm?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
name?: string;
|
|
15
|
+
props?: Record<string, string | number | boolean>;
|
|
16
|
+
};
|
|
17
|
+
export type Reporter = {
|
|
18
|
+
/** A page came into view — the first paint of a client-side render, or an SPA route change. */
|
|
19
|
+
trackRender: () => void;
|
|
20
|
+
/** A named thing the visitor did. */
|
|
21
|
+
track: (name: string, props?: Record<string, string | number | boolean>) => void;
|
|
22
|
+
/** Sends whatever is queued. Called on a full batch, on a timer, and when the page goes away. */
|
|
23
|
+
flush: () => void;
|
|
24
|
+
/** Stops the timer and sends what is left. */
|
|
25
|
+
stop: () => void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The browser's half of analytics: SPA route changes, named interactions, and the first view of a render the
|
|
29
|
+
* server never saw. It reports what only the browser knows, and it is trusted with nothing else — the page
|
|
30
|
+
* views behind an invoice are counted server-side, at the SSR render and the schema fetch, where a visitor
|
|
31
|
+
* has no say. So a hostile client here can pollute a dashboard, never a bill.
|
|
32
|
+
*
|
|
33
|
+
* Events are batched and sent with `sendBeacon`, which survives the page going away — the flush on
|
|
34
|
+
* `visibilitychange` is the only one that reliably runs on a real navigation, and it is exactly the one that
|
|
35
|
+
* `fetch` would have lost.
|
|
36
|
+
*/
|
|
37
|
+
export declare const createReporter: (config: AnalyticsConfig, batchSize?: number, flushIntervalMs?: number) => Reporter;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Reporter } from './createReporter';
|
|
2
|
+
export declare const setReporter: (reporter: Reporter | undefined) => void;
|
|
3
|
+
export declare const getReporter: () => Reporter | undefined;
|
|
4
|
+
/** Reports a named interaction. A no-op when this render reports nothing (an offline export, an embedded
|
|
5
|
+
* widget, a deployment with no collector configured) — never an error a page has to guard against. */
|
|
6
|
+
export declare const track: (name: string, props?: Record<string, string | number | boolean>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, Server, RenderMode, RuntimeStateInstance, EventBridgeContextValue, OfflineDataRaw
|
|
1
|
+
import { AnalyticsConfig, Environment, Server, RenderMode, RuntimeStateInstance, EventBridgeContextValue, OfflineDataRaw } from '@plitzi/sdk-shared';
|
|
2
2
|
export type AppMainProps = {
|
|
3
3
|
revision?: number;
|
|
4
4
|
webKey?: string;
|
|
@@ -17,10 +17,10 @@ export type AppMainProps = {
|
|
|
17
17
|
previewMode?: boolean;
|
|
18
18
|
debugMode?: boolean;
|
|
19
19
|
branding?: boolean;
|
|
20
|
+
analytics?: AnalyticsConfig;
|
|
20
21
|
state?: Record<string, unknown>;
|
|
21
22
|
onInitStateManager?: (instance: RuntimeStateInstance) => void;
|
|
22
23
|
onInitEventBridge?: (instance: EventBridgeContextValue) => void;
|
|
23
|
-
ssrResult?: SSRRenderResult;
|
|
24
24
|
};
|
|
25
|
-
declare const AppMain: ({ revision, webKey, webId, environment, currentPageId, server, isHydrating, offlineMode, offlineData, offlineDataType, instanceId, renderMode, sdkStylePath, sdkDevToolsStylePath, previewMode, debugMode, onInitEventBridge, onInitStateManager,
|
|
25
|
+
declare const AppMain: ({ revision, webKey, webId, environment, currentPageId, server, isHydrating, offlineMode, offlineData, offlineDataType, instanceId, renderMode, sdkStylePath, sdkDevToolsStylePath, previewMode, debugMode, analytics, onInitEventBridge, onInitStateManager, ...sdkProps }: AppMainProps) => import("react").JSX.Element;
|
|
26
26
|
export default AppMain;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type UseDebugShortcutProps = {
|
|
2
|
+
/** The page's own authorization — the `debugMode` the SDK was mounted with, never anything the visitor can set. */
|
|
3
|
+
authorized: boolean;
|
|
4
|
+
onToggle: () => void;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* shift+F12 shows or hides the dev tools on a page that was already allowed to show them; it cannot grant that
|
|
8
|
+
* permission. The environment is deliberately not part of the rule — whoever mounts the SDK may well want to debug a
|
|
9
|
+
* production space — but a visitor of a site that never asked for debugging must not reach the panel, the element
|
|
10
|
+
* ids or the store by knowing the shortcut.
|
|
11
|
+
*/
|
|
12
|
+
declare const useDebugShortcut: ({ authorized, onToggle }: UseDebugShortcutProps) => void;
|
|
13
|
+
export default useDebugShortcut;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type NavigationProviderProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
currentPageId?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const NavigationProvider: ({ children, currentPageId: currentPageIdProp }: NavigationProviderProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
7
|
+
export default NavigationProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OfflineDataRaw, Server } from '@plitzi/sdk-shared';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export type NetworkContextProviderProps = {
|
|
4
4
|
children: ReactNode;
|
|
@@ -8,11 +8,9 @@ export type NetworkContextProviderProps = {
|
|
|
8
8
|
webId: number;
|
|
9
9
|
userKey?: string;
|
|
10
10
|
instanceId?: string;
|
|
11
|
-
environment?: Environment;
|
|
12
11
|
offlineMode?: boolean;
|
|
13
12
|
offlineData?: OfflineDataRaw;
|
|
14
13
|
offlineDataType?: 'json' | 'yaml';
|
|
15
|
-
debugMode?: boolean;
|
|
16
14
|
};
|
|
17
|
-
declare const NetworkContextProvider: ({ children, server, revision, webKey, webId, userKey, instanceId,
|
|
15
|
+
declare const NetworkContextProvider: ({ children, server, revision, webKey, webId, userKey, instanceId, offlineMode, offlineData, offlineDataType }: NetworkContextProviderProps) => import("react").JSX.Element | null;
|
|
18
16
|
export default NetworkContextProvider;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ComponentDefinition
|
|
1
|
+
import { ComponentDefinition } from '@plitzi/sdk-shared';
|
|
2
2
|
export type PluginsContextProviderProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
renderMode?: RenderMode;
|
|
5
4
|
plugins?: Record<string, ComponentDefinition>;
|
|
6
5
|
sdkStylePath?: string;
|
|
7
6
|
};
|
|
8
|
-
declare const PluginsContextProvider: ({ children,
|
|
7
|
+
declare const PluginsContextProvider: ({ children, plugins: pluginsProp, sdkStylePath }: PluginsContextProviderProps) => import("react").JSX.Element;
|
|
9
8
|
export default PluginsContextProvider;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Server } from '@plitzi/sdk-shared';
|
|
2
2
|
export type SdkProps = {
|
|
3
|
-
renderMode?: RenderMode;
|
|
4
3
|
externalStyle?: string;
|
|
5
|
-
environment?: Environment;
|
|
6
|
-
isHydrating?: boolean;
|
|
7
|
-
previewMode?: boolean;
|
|
8
|
-
debugMode?: boolean;
|
|
9
4
|
/** Shows the "Made in Plitzi" link over the rendered space. Off for embeds that are not a Plitzi site of their
|
|
10
5
|
* own — an MCP widget inside a chat, a component mounted in a host app. */
|
|
11
6
|
branding?: boolean;
|
|
@@ -13,7 +8,7 @@ export type SdkProps = {
|
|
|
13
8
|
server?: Server;
|
|
14
9
|
};
|
|
15
10
|
declare const Sdk: {
|
|
16
|
-
({
|
|
11
|
+
({ externalStyle, branding, sdkStylePath, server }: SdkProps): import("react").JSX.Element;
|
|
17
12
|
Plugin: (_props: import('./SdkPlugin').SdkPluginProps) => undefined;
|
|
18
13
|
};
|
|
19
14
|
export default Sdk;
|