@uptimizr/playcanvas 1.0.1 → 1.0.3

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/AGENTS.md ADDED
@@ -0,0 +1,102 @@
1
+ # AGENTS.md — @uptimizr/playcanvas
2
+
3
+ > Packaged agent guide. For the human reference see [README.md](./README.md); for design
4
+ > rationale see the project ADRs at https://github.com/RaananW/Uptimizr/tree/main/docs/adr.
5
+
6
+ ## What this package is
7
+
8
+ The PlayCanvas connector for Uptimizr. It registers as an `@uptimizr/sdk-core` **collector** and
9
+ captures camera pose (view-direction heatmap), pointer move/click/button transitions (screen
10
+ heatmaps), camera gestures, mesh picks (object engagement), FPS, context loss and asset-load
11
+ timing (perf / reliability), plus opt-in mesh visibility, hover dwell, world-space gaze, resource
12
+ samples and node transforms.
13
+
14
+ `playcanvas` is a **peer dependency** — the connector reads the host application's PlayCanvas
15
+ instance and never bundles or mutates it. World-space data is normalized from PlayCanvas' native
16
+ **right-handed, y-up** frame to the canonical wire frame (**left-handed, y-up**) at the emission
17
+ boundary (ADR 0018).
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pnpm add @uptimizr/playcanvas
23
+ # `playcanvas` is a peer dependency provided by your app.
24
+ ```
25
+
26
+ ## Canonical usage
27
+
28
+ PlayCanvas supports multiple camera entities with no single "active" camera, and FPS and the
29
+ canvas come from `app.graphicsDevice`, so the camera `Entity` is an explicit argument:
30
+
31
+ ```ts
32
+ import { trackScene } from "@uptimizr/playcanvas";
33
+
34
+ const client = trackScene(app, cameraEntity, {
35
+ projectId: "your-project",
36
+ endpoint: "https://collect.example.com",
37
+ });
38
+ // ... later, on teardown
39
+ await client.stop("manual");
40
+ ```
41
+
42
+ `trackScene` returns the `@uptimizr/sdk-core` `UptimizrClient`, so you can read
43
+ `client.sessionId`, emit custom events with `client.track(name, props)`, switch scene with
44
+ `client.setScene(sceneId)`, and `client.stop(reason)` to tear everything down (there is no
45
+ separate `dispose()` — stopping the client removes every DOM listener, timer and `frameend`
46
+ handler).
47
+
48
+ ### Advanced (compose it yourself)
49
+
50
+ ```ts
51
+ import { UptimizrClient } from "@uptimizr/sdk-core";
52
+ import { playcanvasCollector, readDeviceCaps } from "@uptimizr/playcanvas";
53
+
54
+ const client = new UptimizrClient({
55
+ projectId: "your-project",
56
+ endpoint: "https://collect.example.com",
57
+ });
58
+ client.use(playcanvasCollector({ app, camera: cameraEntity }));
59
+ client.start({ device: readDeviceCaps(app) });
60
+ ```
61
+
62
+ Use `playcanvasCollector` directly for collector-only tuning: `meshVisibility`, `hoverDwell`,
63
+ `resourceSample`, `raycast`, `cameraGestureSensitivity`.
64
+
65
+ ## Capture knobs
66
+
67
+ `sampleCameraMs` (1000), `samplePerfMs` (2000), `pointerMoveThrottleMs` (250),
68
+ `suppressIdleSamples`, `suppressIdlePerfSamples`, `cameraEpsilon`, `perfFpsThreshold`, and a
69
+ `capture` toggle map (`PlayCanvasCaptureOptions`, including `assetLoad`, on by default). The
70
+ `sampling` profile sets per-channel fidelity in Hz (`0` = off, `"frame"` = every tick) for
71
+ continuous channels only — camera, pointer move, perf (ADR 0012). Discrete events (clicks, picks,
72
+ custom) are always captured. `"frame"` cadence rides the engine's own `frameend` event, which the
73
+ connector subscribes to and removes on stop.
74
+
75
+ Other `TrackSceneOptions`: `gaze`, `actors` (+ `sampling.nodes`, ADR 0027), `keyBindings`
76
+ (ADR 0023 — **only bound keys** are ever recorded), `cameraType` (ADR 0026), `sceneDescription`,
77
+ `user`, `meta`, `flushIntervalMs`, `transport`, `disabled`, `debug`.
78
+
79
+ ## Rules for agents
80
+
81
+ - Treat `playcanvas` as a peer dependency; the connector reads the host's instance structurally.
82
+ - Emit only `@uptimizr/schema` events; do not redefine event shapes.
83
+ - Pointer/mesh events carry an input `source` (`mouse`/`touch`/`pen`, ADR 0011) — do not strip it.
84
+ - Privacy (ADR 0003): no cookies, no persistent client identifier. `asset_load` records the
85
+ app-defined asset **name**, never the file URL. `keyBindings` is an allow-list, never a
86
+ keylogger; `user.id` must be pseudonymous. Attention channels (`meshVisibility`, `hoverDwell`,
87
+ `gaze`, `resourceSample`) are **off by default** — keep them opt-in.
88
+ - Picking is **physics-free** (`pc.Ray` against mesh-instance world AABBs) so the connector adds
89
+ no `ammo` dependency — do not route picks through the rigidbody system.
90
+ - `registerRegions(sceneId, regions, { endpoint, apiKey })` (from `@uptimizr/sdk-core`) declares a
91
+ scene's named regions. It **replaces** the scene's set and needs an **`annotate`**-capable key —
92
+ never ship that key in a public bundle; call it from build/deploy/admin code.
93
+ - Not captured on PlayCanvas, by design: `compile_stall` (no public compile hook) and
94
+ `capability_change` (report it yourself via `client.reportCapabilityChange(...)`).
95
+ - To support another engine, create a sibling package depending only on `@uptimizr/sdk-core` and
96
+ `@uptimizr/schema`; see the repo `add-connector` skill.
97
+
98
+ ## More
99
+
100
+ - Package reference: [README.md](./README.md)
101
+ - Connector guide: https://uptimizr.com/docs/connectors/playcanvas/
102
+ - Integration guide: https://github.com/RaananW/Uptimizr/blob/main/docs/integration.md