@revturbine/sdk 0.2.36 → 0.2.37
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/headless.js +1 -1
- package/dist/headless.js.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/types/web-sdk/react/TelemetryScope.d.ts +37 -0
- package/dist/types/web-sdk/react/TelemetryScope.d.ts.map +1 -0
- package/dist/types/web-sdk/react/index.d.ts +2 -0
- package/dist/types/web-sdk/react/index.d.ts.map +1 -1
- package/dist/types/web-sdk/react/useTrack.d.ts +36 -0
- package/dist/types/web-sdk/react/useTrack.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Advisory event purpose (plan 144 TASK-12 / REQ-28). A **server-side allowlist**
|
|
4
|
+
* — never this client-declared value — decides whether an event feeds engagement
|
|
5
|
+
* scoring. The listed values are suggestions; any string is accepted.
|
|
6
|
+
*/
|
|
7
|
+
export type TrackPurpose = 'engagement' | 'conversion' | 'operational' | 'diagnostic' | (string & {});
|
|
8
|
+
/**
|
|
9
|
+
* Ambient telemetry context established by {@link TelemetryScope} and merged into
|
|
10
|
+
* every event emitted by {@link useTrack} beneath it.
|
|
11
|
+
*/
|
|
12
|
+
export interface TelemetryScopeValue {
|
|
13
|
+
/** Logical product area (e.g. `'billing'`, `'editor'`). */
|
|
14
|
+
area?: string;
|
|
15
|
+
/** Default action label for events in this scope. */
|
|
16
|
+
action?: string;
|
|
17
|
+
/** Advisory {@link TrackPurpose}. */
|
|
18
|
+
purpose?: TrackPurpose;
|
|
19
|
+
}
|
|
20
|
+
declare const TelemetryScopeContext: React.Context<TelemetryScopeValue>;
|
|
21
|
+
/** Props for {@link TelemetryScope}. */
|
|
22
|
+
export interface TelemetryScopeProps extends TelemetryScopeValue {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Establishes ambient telemetry context (`area` / `action` / `purpose`) for its
|
|
27
|
+
* descendants (plan 144 TASK-12 / REQ-21). Nested scopes merge
|
|
28
|
+
* **inner-over-outer**, and per-event {@link useTrack} options override the
|
|
29
|
+
* scope (the outer → inner → invocation precedence). It is renderless — renders
|
|
30
|
+
* its children unchanged, adds no DOM node (REQ-19), and works with or without a
|
|
31
|
+
* RevTurbine provider (AC-13).
|
|
32
|
+
*/
|
|
33
|
+
export declare function TelemetryScope({ children, ...scope }: TelemetryScopeProps): React.ReactElement;
|
|
34
|
+
/** The current merged telemetry scope (plan 144 TASK-12). Empty when outside any {@link TelemetryScope}. */
|
|
35
|
+
export declare function useTelemetryScope(): TelemetryScopeValue;
|
|
36
|
+
export { TelemetryScopeContext };
|
|
37
|
+
//# sourceMappingURL=TelemetryScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TelemetryScope.d.ts","sourceRoot":"","sources":["../../../../react/TelemetryScope.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEtG;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,QAAA,MAAM,qBAAqB,oCAAyC,CAAC;AAErE,wCAAwC;AACxC,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAW9F;AAED,4GAA4G;AAC5G,wBAAgB,iBAAiB,IAAI,mBAAmB,CAEvD;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -6,6 +6,8 @@ export * from './SurfaceTypes';
|
|
|
6
6
|
export * from './PlacementDecisionInspector';
|
|
7
7
|
export * from './UserProfile';
|
|
8
8
|
export * from './useEntitlement';
|
|
9
|
+
export * from './TelemetryScope';
|
|
10
|
+
export * from './useTrack';
|
|
9
11
|
export * from './useCan';
|
|
10
12
|
export * from './useUsageSnapshot';
|
|
11
13
|
export { useRevTurbineTheme } from '../theme/ThemeContext';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../react/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../react/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TrackPurpose } from './TelemetryScope';
|
|
2
|
+
import type { SdkEventProperties } from '../customer-side';
|
|
3
|
+
/**
|
|
4
|
+
* Per-event options for {@link useTrack} — the one shared shape scope defaults
|
|
5
|
+
* and later telemetry components also draw from (plan 144 TASK-12).
|
|
6
|
+
*/
|
|
7
|
+
export interface TrackOptions {
|
|
8
|
+
/** Overrides the scope `area` for this event. */
|
|
9
|
+
area?: string;
|
|
10
|
+
/** Overrides the scope `action` for this event. */
|
|
11
|
+
action?: string;
|
|
12
|
+
/** Advisory {@link TrackPurpose}; overrides the scope purpose. */
|
|
13
|
+
purpose?: TrackPurpose;
|
|
14
|
+
/** Emit at most once per distinct key, for this hook instance's lifetime. */
|
|
15
|
+
dedupeKey?: string;
|
|
16
|
+
/** Emit at most once (keyed on the event name), for this hook instance's lifetime. */
|
|
17
|
+
once?: boolean;
|
|
18
|
+
/** Send immediately instead of batching. */
|
|
19
|
+
immediate?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The tracking function returned by {@link useTrack}. */
|
|
22
|
+
export type TrackFn = (name: string, data?: SdkEventProperties, options?: TrackOptions) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a `track(name, data?, options?)` function bound to the enclosing
|
|
25
|
+
* {@link TelemetryScope} (plan 144 TASK-12 / REQ-21).
|
|
26
|
+
*
|
|
27
|
+
* - Scope context (`area` / `action` / `purpose`) merges **outer → inner →
|
|
28
|
+
* invocation** — the per-event option wins.
|
|
29
|
+
* - `once` and `dedupeKey` suppress repeats for this hook instance's lifetime.
|
|
30
|
+
* - Reserved property names are dropped so a caller can't overwrite canonical
|
|
31
|
+
* fields.
|
|
32
|
+
* - Without a RevTurbine provider (absent or failed init) the function is a safe
|
|
33
|
+
* no-op and never throws (AC-13).
|
|
34
|
+
*/
|
|
35
|
+
export declare function useTrack(): TrackFn;
|
|
36
|
+
//# sourceMappingURL=useTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrack.d.ts","sourceRoot":"","sources":["../../../../react/useTrack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAuB3D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sFAAsF;IACtF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,0DAA0D;AAC1D,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;AAyBhG;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CA8BlC"}
|
package/package.json
CHANGED