@sentientui/react 0.45.0 → 0.45.1

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/llms.txt CHANGED
@@ -23,6 +23,26 @@
23
23
  domains). Until then every request gets 403 origin_not_allowed — the body and a console warning
24
24
  name the origin — and nothing is recorded. A project under 14 days old with no live domain yet
25
25
  allows its first https origin by itself, once.
26
+ - Shopify Hydrogen (the Shopify app's theme embed does not reach it; use this package):
27
+ - CSP first, or every SDK request is blocked silently. In app/entry.server.tsx add
28
+ 'https://api.sentient-ui.com' to connect-src: createContentSecurityPolicy({ shop, connectSrc: [...] })
29
+ on Hydrogen 2026.4, createContentSecurityPolicy({ shop, directives: { connectSrc: [...] } }) on
30
+ 2026.10. The array extends Hydrogen's defaults. A custom apiBaseUrl needs its own origin instead.
31
+ - The key is on the server (context.env on 2026.4, context.get(envContext) on 2026.10): return the
32
+ pk_ from the root loader (never the sk_; loader data is public) and read it with
33
+ useRouteLoaderData('root').
34
+ - root.tsx: <html suppressHydrationWarning>; <SentientPersonaScript apiKey nonce={useNonce()}
35
+ consentFrom="shopify" /> in <head>; <AdaptiveProvider apiKey nonce={useNonce()}
36
+ consentFrom="shopify"> around the <Outlet />. useNonce comes from '@shopify/hydrogen' on 2026.4,
37
+ from the template's '~/lib/csp' on 2026.10.
38
+ - Goals: useGoal('add_to_cart') on the product form; Hydrogen's analytics events are not forwarded.
39
+ - Never import '@sentientui/react/next' (it needs next/headers). Decisions happen in the browser.
40
+ - Allow the Hydrogen storefront's domain (dashboard Settings → Allowed domains, or MCP add_origin):
41
+ connecting the Shopify app allows only the myshopify.com and Online Store domains.
42
+ - Purchases come only from the Shopify app's orders/paid webhook. They are credited to versions
43
+ only if the checkout is on the storefront's site (shop.brand.com + checkout.brand.com), and
44
+ whether the app's checkout pixel runs on a Hydrogen checkout is unconfirmed. Otherwise the
45
+ order counts as unattributed revenue.
26
46
  - Non-React site: use @sentientui/snippet (one script tag, Style rung only) or
27
47
  @sentientui/core (full JS SDK).
28
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -83,8 +83,8 @@
83
83
  "llms.txt"
84
84
  ],
85
85
  "dependencies": {
86
- "@sentientui/core": "0.45.0",
87
- "@sentientui/policy": "0.18.0"
86
+ "@sentientui/policy": "0.18.0",
87
+ "@sentientui/core": "0.45.0"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@testing-library/react": ">=14.0.0 <17.0.0",
package/dist/server.d.cts DELETED
@@ -1,123 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- /**
55
- * Your team / a test site — the same flag as `<AdaptiveProvider internal>`,
56
- * sent on the SSR upsert and decide so a server-rendered first page is
57
- * never counted or learned from. The request's `sentient_internal` cookie
58
- * (the "mark this browser" link) is read from `cookies` and forwarded too.
59
- */
60
- internal?: boolean;
61
- };
62
- /**
63
- * Fetches bandit assignments on the server for SEO-safe HTML.
64
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
65
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
66
- */
67
- declare function loadAdaptiveAssignments(components: Array<{
68
- id: string;
69
- variantIds: string[];
70
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
71
-
72
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
73
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
74
- sessionId: string;
75
- };
76
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
77
- /**
78
- * Section IDs in default order. Passed to /v1/decide as the candidate
79
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
80
- * one of `sections`/`components`/`slots` must be non-empty).
81
- */
82
- sections?: string[];
83
- /** Components to assign in the same decide call. */
84
- components?: Array<{
85
- id: string;
86
- variantIds?: string[];
87
- }>;
88
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
89
- slots?: _sentientui_core_server.SlotDeclInput[];
90
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
91
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
92
- * Requires `registrySlotIds`. */
93
- slotsFrom?: 'request' | 'registry';
94
- /**
95
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
96
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
97
- * the call downgrades to request mode (with a console.error) instead of
98
- * recording a close-out trial for every published slot on every page.
99
- */
100
- registrySlotIds?: string[];
101
- /**
102
- * Registry mode: what each slot on this page can render, keyed by slot id
103
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
104
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
105
- * server draws `authored.<key>` only for keys the page declares here.
106
- */
107
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
108
- };
109
- /**
110
- * SSR helper for pages with a declared section layout and/or adaptive slots.
111
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
112
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
113
- * adopts the same session on first visit.
114
- *
115
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
116
- * Under the `development` export condition the decision is computed by the
117
- * deterministic local engine with the same sessionId the client will adopt —
118
- * server and client agree by construction. In production the engine resolves
119
- * to a stub and defaults are returned with one console.error.
120
- */
121
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
122
-
123
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };
package/dist/server.d.ts DELETED
@@ -1,123 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- /**
55
- * Your team / a test site — the same flag as `<AdaptiveProvider internal>`,
56
- * sent on the SSR upsert and decide so a server-rendered first page is
57
- * never counted or learned from. The request's `sentient_internal` cookie
58
- * (the "mark this browser" link) is read from `cookies` and forwarded too.
59
- */
60
- internal?: boolean;
61
- };
62
- /**
63
- * Fetches bandit assignments on the server for SEO-safe HTML.
64
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
65
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
66
- */
67
- declare function loadAdaptiveAssignments(components: Array<{
68
- id: string;
69
- variantIds: string[];
70
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
71
-
72
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
73
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
74
- sessionId: string;
75
- };
76
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
77
- /**
78
- * Section IDs in default order. Passed to /v1/decide as the candidate
79
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
80
- * one of `sections`/`components`/`slots` must be non-empty).
81
- */
82
- sections?: string[];
83
- /** Components to assign in the same decide call. */
84
- components?: Array<{
85
- id: string;
86
- variantIds?: string[];
87
- }>;
88
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
89
- slots?: _sentientui_core_server.SlotDeclInput[];
90
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
91
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
92
- * Requires `registrySlotIds`. */
93
- slotsFrom?: 'request' | 'registry';
94
- /**
95
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
96
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
97
- * the call downgrades to request mode (with a console.error) instead of
98
- * recording a close-out trial for every published slot on every page.
99
- */
100
- registrySlotIds?: string[];
101
- /**
102
- * Registry mode: what each slot on this page can render, keyed by slot id
103
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
104
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
105
- * server draws `authored.<key>` only for keys the page declares here.
106
- */
107
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
108
- };
109
- /**
110
- * SSR helper for pages with a declared section layout and/or adaptive slots.
111
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
112
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
113
- * adopts the same session on first visit.
114
- *
115
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
116
- * Under the `development` export condition the decision is computed by the
117
- * deterministic local engine with the same sessionId the client will adopt —
118
- * server and client agree by construction. In production the engine resolves
119
- * to a stub and defaults are returned with one console.error.
120
- */
121
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
122
-
123
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };