@revturbine/sdk 0.2.36 → 0.2.38

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.
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { type TrackPurpose } from './TelemetryScope';
3
+ /** Props for {@link EngagementArea}. */
4
+ export interface EngagementAreaProps {
5
+ /** Logical area name — set as the telemetry scope for descendants and stamped on emitted events. */
6
+ area: string;
7
+ /** Event emitted once when the area is first qualified-viewed. Default `engagement_view`. */
8
+ viewEvent?: string;
9
+ /** Event emitted with accrued dwell (`dwell_ms`) when the area unmounts. Default `engagement_dwell`. */
10
+ dwellEvent?: string;
11
+ /** Event emitted when a descendant is clicked. Default `engagement_interaction`. */
12
+ interactionEvent?: string;
13
+ /** Advisory purpose applied to the scope and emitted events. */
14
+ purpose?: TrackPurpose;
15
+ /** Visible fraction required to count as viewed / dwelling (0–1). Default 0.5. */
16
+ threshold?: number;
17
+ /** Host element tag. Default `'div'`. */
18
+ as?: keyof React.JSX.IntrinsicElements;
19
+ className?: string;
20
+ style?: React.CSSProperties;
21
+ children?: React.ReactNode;
22
+ }
23
+ /**
24
+ * A qualified engagement region (plan 144 TASK-13 / REQ-21). It:
25
+ * - establishes a {@link TelemetryScope} (`area` / `purpose`) for its descendants;
26
+ * - emits `viewEvent` **once** when first viewport-qualified — one-shot across
27
+ * React Strict Mode's double-mount (AC-12);
28
+ * - accrues dwell only while the region is **onscreen and the tab is visible**,
29
+ * emitting `dwellEvent` with `dwell_ms` when it unmounts;
30
+ * - bubbles descendant clicks as `interactionEvent`.
31
+ *
32
+ * Renders its children and never throws without a provider (AC-13).
33
+ */
34
+ export declare function EngagementArea({ area, viewEvent, dwellEvent, interactionEvent, purpose, threshold, as, className, style, children, }: EngagementAreaProps): React.ReactElement;
35
+ //# sourceMappingURL=EngagementArea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EngagementArea.d.ts","sourceRoot":"","sources":["../../../../react/EngagementArea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrE,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,oGAAoG;IACpG,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wGAAwG;IACxG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gEAAgE;IAChE,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,SAA6B,EAC7B,UAA+B,EAC/B,gBAA2C,EAC3C,OAAO,EACP,SAAe,EACf,EAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAuG1C"}
@@ -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"}
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { type TrackOptions } from './useTrack';
3
+ import type { SdkEventProperties } from '../customer-side';
4
+ /** Props for {@link TrackOnView}. */
5
+ export interface TrackOnViewProps {
6
+ /** Event name emitted once when the element is qualified-viewed. */
7
+ event: string;
8
+ /** Event data (reserved names are dropped by {@link useTrack}). */
9
+ data?: SdkEventProperties;
10
+ /** Track options (area / action / purpose / immediate). */
11
+ options?: TrackOptions;
12
+ /** Visible fraction required (0–1). Default 0.5. */
13
+ threshold?: number;
14
+ /** Minimum visible dwell before it counts, in ms. Default 0. */
15
+ minVisibleMs?: number;
16
+ /** Host element tag. Default `'div'`. */
17
+ as?: keyof React.JSX.IntrinsicElements;
18
+ className?: string;
19
+ style?: React.CSSProperties;
20
+ children?: React.ReactNode;
21
+ }
22
+ /**
23
+ * Emits `event` exactly once, the first time its host element is
24
+ * viewport-qualified (plan 144 TASK-13 / REQ-21). Falls back to firing on render
25
+ * when `IntersectionObserver` is unavailable (AC-10 degradation). The one-shot
26
+ * guard is a ref that survives React Strict Mode's development double-mount, so
27
+ * the event fires once, not twice (AC-12). Renders its children in the host
28
+ * element and never throws without a provider (AC-13).
29
+ */
30
+ export declare function TrackOnView({ event, data, options, threshold, minVisibleMs, as, className, style, children, }: TrackOnViewProps): React.ReactElement;
31
+ //# sourceMappingURL=TrackOnView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrackOnView.d.ts","sourceRoot":"","sources":["../../../../react/TrackOnView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,YAAY,EACZ,EAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,GACT,EAAE,gBAAgB,GAAG,KAAK,CAAC,YAAY,CAiCvC"}
@@ -6,6 +6,10 @@ 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';
11
+ export * from './TrackOnView';
12
+ export * from './EngagementArea';
9
13
  export * from './useCan';
10
14
  export * from './useUsageSnapshot';
11
15
  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,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revturbine/sdk",
3
- "version": "0.2.36",
3
+ "version": "0.2.38",
4
4
  "description": "RevTurbine customer-facing SDK — placement decisioning, entitlement checks, and usage tracking.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.12.0",