Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

docs(canvas): teach origins and refreshable reads (#82939)

Peter Kirkham4164d0d5a032
diff --git a/products/canvas/skills/building-react-quill-canvases/SKILL.md b/products/canvas/skills/building-react-quill-canvases/SKILL.md
index aeb7d37b3eec..7e91a66ff5d8 100644
--- a/products/canvas/skills/building-react-quill-canvases/SKILL.md
+++ b/products/canvas/skills/building-react-quill-canvases/SKILL.md
@@ -20,10 +20,14 @@ typed-node result reading. Keep that wiring; replace the sample metric and layou
## Imports
-Import only from: `react`, `react-dom`, `react-dom/client`, `@posthog/quill`, `recharts`,
-`lucide-react`, `dayjs`. Anything else — including dynamic `import()`, `require()`, `fetch()`,
-`<script>` tags, or remote code — fails validation. Use `@posthog/quill` for UI, `recharts` for
-charts, `lucide-react` for icons, `dayjs` for dates.
+Use React, Quill, Recharts, Lucide, and Day.js for the standard application shell. The platform
+also admits ten optional libraries for specialized work. Read
+[references/platform-libraries.md](references/platform-libraries.md) before choosing one.
+
+Other bare imports, dynamic `import()`, `require()`, `<script>` tags, and remote code fail
+validation. Direct `fetch()` requires an exact HTTPS origin in `capabilities.network.origins`,
+and works only in the **published** canvas — the edit-mode preview blocks all direct network
+access regardless of declaration, so verify origin-fetching code after publishing, not in preview.
## Quill component rules
diff --git a/products/canvas/skills/building-react-quill-canvases/references/platform-libraries.md b/products/canvas/skills/building-react-quill-canvases/references/platform-libraries.md
new file mode 100644
index 000000000000..1a9f6fcb5ad9
--- /dev/null
+++ b/products/canvas/skills/building-react-quill-canvases/references/platform-libraries.md
@@ -0,0 +1,37 @@
+# Platform libraries
+
+The canvas builder pins ten optional libraries. Choose the smallest one that matches the job and
+keep the dependency map returned by `canvas-source-retrieve` unchanged.
+
+| Library | Use it for | Main capabilities |
+| ------------------------- | --------------------------- | -------------------------------------------------------------------------------------------- |
+| `d3` | Bespoke data visualization | Scales, shapes, layouts, geographic projections, interpolation, and SVG helpers |
+| `three` | 3D and WebGL scenes | Cameras, geometry, materials, lighting, animation, and raycasting |
+| `framer-motion` | Coordinated React animation | Enter and exit transitions, layout animation, gestures, springs, and reduced-motion handling |
+| `zod` | Runtime data validation | Schemas, parsing, coercion, transformations, unions, and typed validation errors |
+| `@tanstack/react-table` | Complex data tables | Sorting, filtering, grouping, pagination, selection, and column state |
+| `@tanstack/react-virtual` | Large tables and lists | Windowed rows and columns, dynamic measurements, scrolling, and overscan |
+| `react-hook-form` | Multi-field forms | Field registration, validation, dirty state, controlled inputs, and submission state |
+| `lodash-es` | Data transformation | Grouping, ordering, deduplication, aggregation, object selection, and collection helpers |
+| `react-markdown` | Safe Markdown presentation | Markdown parsing into React elements without `dangerouslySetInnerHTML` |
+| `papaparse` | CSV input and output | CSV parsing, header mapping, type conversion, malformed-row reporting, and CSV generation |
+
+## Selection guidance
+
+- Prefer Recharts for standard charts. Use D3 when the visual needs a layout, projection, or shape
+ that Recharts does not provide.
+- Prefer Quill's `Table` for small static tables. Use TanStack Table for table behavior and TanStack
+ Virtual when the rendered row count is large. These libraries provide behavior, not visual styles.
+- Use React Hook Form with Quill inputs. Keep the network submit button disabled while submission is
+ active.
+- Use Zod at untrusted boundaries, including declared external API responses and parsed CSV rows.
+- Use lodash-es named imports so the builder can remove unused helpers.
+- React Markdown does not enable raw HTML by default. Do not add plugins or renderers that execute
+ HTML from untrusted content.
+- Papa Parse processes text already available to the canvas. Loading a remote CSV still requires its
+ exact HTTPS origin in `capabilities.network.origins` (published canvases only — the edit-mode
+ preview blocks direct network access regardless of declaration).
+- Three.js owns its `<canvas>` element. React can own the surrounding Quill application shell.
+
+The standard imports remain `react`, `react-dom`, `react-dom/client`, `@posthog/quill`, `recharts`,
+`lucide-react`, and `dayjs`.
diff --git a/products/canvas/skills/querying-canvas-data/SKILL.md b/products/canvas/skills/querying-canvas-data/SKILL.md
index d0a9169a33f4..684d89cf7abf 100644
--- a/products/canvas/skills/querying-canvas-data/SKILL.md
+++ b/products/canvas/skills/querying-canvas-data/SKILL.md
@@ -12,7 +12,9 @@ description: >
The global `ph` object (injected by the host — never imported, never initialized) is the only way
a canvas talks to PostHog. Credentials stay in the host; `fetch()`, posthog-js, and hand-rolled
-clients fail in the sandbox.
+clients cannot reach PostHog from the sandbox. The one sanctioned use of `fetch()` is a non-PostHog
+origin declared in `capabilities.network.origins`, and only in the published canvas — the
+edit-mode preview blocks all direct network access.
## Data hierarchy — back every metric with a saved insight
@@ -36,6 +38,14 @@ Whatever tier you use, **declare it in the project's `capabilities`** before pub
`captureEvents`, and `inlineQueries: true` for any `ph.query` use. The host rejects undeclared
calls at runtime, and validation fails on undeclared literals.
+For a status board, set `refresh` to the cache lifetime in seconds. Use a whole number from 30 to
+86400 (one day); values outside that range, or fractional ones, fail at runtime:
+
+```js
+await ph.loadInsight(shortId, { refresh: 30 })
+await ph.query(queryNode, {}, { refresh: 30 })
+```
+
## Result shapes — read them correctly or every value renders 0
- **Trends-style results** (insight query types, via `ph.loadInsight` or a typed node): `results`
diff --git a/products/canvas/skills/validating-and-publishing-canvases/SKILL.md b/products/canvas/skills/validating-and-publishing-canvases/SKILL.md
index 79cb901ec40a..1de24a9d4acc 100644
--- a/products/canvas/skills/validating-and-publishing-canvases/SKILL.md
+++ b/products/canvas/skills/validating-and-publishing-canvases/SKILL.md
@@ -39,6 +39,12 @@ then dies in the rendered canvas. Declare:
- `capabilities.posthog.captureEvents` — every event name it passes to `ph.capture`.
- `capabilities.posthog.inlineQueries: true` — when it calls `ph.query` at all.
- `capabilities.posthog.agentRequests: true` — when it calls `ph.agent.request`.
+- `capabilities.network.origins` — each exact HTTPS origin used by `fetch` or `XMLHttpRequest`.
+ Do not include paths, credentials, queries, fragments, or wildcards. The host must be public:
+ loopback and private IPs, single-label names like `intranet`, and the `.local`, `.localhost`,
+ `.internal`, and `.home.arpa` suffixes are all rejected, so a local dev host such as
+ `https://localhost:8010` fails validation with an `invalid_network_origin` error. Data sent to a
+ declared origin leaves PostHog and appears in the capability review before promotion.
Validation rejects undeclared literal calls (`capability_missing_*` diagnostics) so you can fix
them before publishing; dynamic ids it can only warn about, so keep the declarations complete.
@@ -50,13 +56,13 @@ Diagnostics carry `severity`, a stable `code`, a `message`, and (for file-specif
`path` and `line`:
- `error` diagnostics block publishing — fix all of them. Common ones: `import_not_allowed`
- (bare imports are limited to react, react-dom, @posthog/quill, recharts, lucide-react, and dayjs),
+ (bare imports are limited to the dependencies returned in the source project),
`forbidden_dynamic_import` / `forbidden_require` / `forbidden_inline_script`,
`invalid_path`, `capability_missing_insight` / `capability_missing_capture_event` /
`capability_missing_inline_queries` / `capability_missing_agent_requests`,
`dependency_not_admitted` / `dependency_version_mismatch`, and path/size violations.
- `warning` diagnostics don't block, but heed them: `network_fetch` / `network_xhr` mean the code
- reaches for the network directly — the sandbox will block it at runtime; use the `ph` bridge.
+ reaches for the network directly. Declare the exact HTTPS origin or use the `ph` bridge.
## Publish guarded