glitchless-dsh 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +84 -2
- package/cordis.patch.yml +20 -0
- package/icon.svg +15 -0
- package/index.js +55 -0
- package/package.json +55 -4
- package/skills/dashboard/SKILL.md +190 -0
- package/skills/dashboard/references/examples.md +98 -0
- package/skills/dashboard/references/genres.md +47 -0
- package/skills/instrument/SKILL.md +158 -0
- package/skills/instrument/references/babylon.md +81 -0
- package/skills/instrument/references/gamemaker.md +141 -0
- package/skills/instrument/references/godot.md +60 -0
- package/skills/instrument/references/phaser.md +82 -0
- package/skills/instrument/references/playcanvas.md +80 -0
- package/skills/instrument/references/threejs.md +210 -0
- package/skills/instrument/references/unity.md +150 -0
- package/skills/instrument/references/unreal.md +180 -0
- package/skills/triage/SKILL.md +41 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: instrument
|
|
3
|
+
description: Add Glitchless observability to a game (Three.js or React Three Fiber, Phaser 3 or 4, Babylon.js, PlayCanvas, Unity 6.3+, Godot 4.5+, Unreal Engine 5.8 or GameMaker 2024.2+). Frame-time percentiles, hitch attribution, errors, gameplay events, level heatmaps, and tools that let coding agents measure the running game. Use when the user wants telemetry, analytics, performance monitoring or "observability" in a game, or asks to add Glitchless.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Instrument a game with Glitchless
|
|
7
|
+
|
|
8
|
+
Goal: after this skill, every play session reports how the game *felt* (frame times, hitches and their causes),
|
|
9
|
+
what broke (errors, crashes) and what the player did (levels, deaths, pickups, positions), and you (the agent)
|
|
10
|
+
have a way to measure the running game before and after a change.
|
|
11
|
+
|
|
12
|
+
## 0. Find the engine, and the settings
|
|
13
|
+
|
|
14
|
+
| You find | Engine | Follow |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| `three` or `@react-three/fiber` in package.json | Three.js | [references/threejs.md](references/threejs.md) |
|
|
17
|
+
| `phaser` in package.json, or a `<script>` that loads Phaser | Phaser 3.60+ or 4 | [references/phaser.md](references/phaser.md) |
|
|
18
|
+
| `@babylonjs/core` or `babylonjs` in package.json, or a `<script>` that loads Babylon.js | Babylon.js 5+ | [references/babylon.md](references/babylon.md) |
|
|
19
|
+
| `playcanvas` in package.json, a PlayCanvas Editor project (scripts using `pc.createScript` or `pc.Script`), or a `<script>` that loads PlayCanvas | PlayCanvas 2.x | [references/playcanvas.md](references/playcanvas.md) |
|
|
20
|
+
| `ProjectSettings/ProjectVersion.txt` and `Packages/manifest.json` | Unity 6.3+ | [references/unity.md](references/unity.md) |
|
|
21
|
+
| `project.godot` | Godot 4.5+ | the Godot addon's README: `godot/addons/glitchless/README.md` in the Glitchless repo (`~/.glitchless/godot/addons/glitchless/README.md` if it's cloned there), then [references/godot.md](references/godot.md) for bug reports, streams, properties and multiplayer |
|
|
22
|
+
| a `*.uproject` file | Unreal Engine 5.8 (5.7 untested) | [references/unreal.md](references/unreal.md) |
|
|
23
|
+
| a `*.yyp` file | GameMaker 2024.2+ | [references/gamemaker.md](references/gamemaker.md) |
|
|
24
|
+
|
|
25
|
+
Read only the file for this game's engine: each one walks through reading the game, installing,
|
|
26
|
+
levels and events, bots and measuring, and checking it works. Apply these settings first.
|
|
27
|
+
|
|
28
|
+
Settings, for every engine:
|
|
29
|
+
|
|
30
|
+
- **Intake URL and client token.** If the user gave you them (a hosted Glitchless server prints both, for example
|
|
31
|
+
`Send telemetry to https://api.example.com with client token gl_pub_…`), use those. Otherwise use
|
|
32
|
+
`http://localhost:7777` and `gl_pub_dev`, a local server. On Glitchless Cloud with no token yet, call
|
|
33
|
+
`glitchless_create_game`: it returns the game's client token and intake URL. The hosted MCP server
|
|
34
|
+
(`https://api.glitchless.gg/mcp`) is signed in once it's connected; a local one signs in first
|
|
35
|
+
(`glitchless_sign_in`, or `npx -y glitchless-mcp login`; the user approves a code). The client token is public and
|
|
36
|
+
write-only, so it may live in the game's source. A secret or workspace key (`gl_sk_…`, `gl_ws_…`) never goes in
|
|
37
|
+
the game.
|
|
38
|
+
- **Privacy.** Keep the default anonymous mode: no player ID, coarse device facts, no positions. Ask the user
|
|
39
|
+
before choosing another mode, since the game's privacy policy and store answers must then say so (each SDK's
|
|
40
|
+
PRIVACY.md lists every field and has the wording). If they want to know whether players come back (retention:
|
|
41
|
+
D1, D7, D30), offer install mode: it adds only a random player ID kept on the device (`privacy: 'install'`;
|
|
42
|
+
Godot `"privacy": "install"`; Unity `Privacy = Privacy.Install`; Unreal `Privacy=Install`). Anonymous mode
|
|
43
|
+
can't count returning players. Full mode adds a stored player ID, device detail and positions.
|
|
44
|
+
- **A "share performance data" setting.** If the game has a settings or options menu, offer to add a toggle wired to
|
|
45
|
+
Glitchless's off switch, so players can turn it off and back on at any time (store rules such as the Unity Asset
|
|
46
|
+
Store's ask for it, and it lets the store forms answer "optional"): `glitchless.setEnabled(on)`; Godot
|
|
47
|
+
`Glitchless.set_enabled(on)`; Unity `Glitchless.SetEnabled(on)`; Unreal `FGlitchless::SetEnabled(bOn)` or the
|
|
48
|
+
Blueprint node Set Enabled; GameMaker `glitchless_set_enabled(on)`. Off stops measuring and sending at once and drops
|
|
49
|
+
what was waiting; on starts a new session. Glitchless saves the choice on the device itself, so it holds from the
|
|
50
|
+
first frame of the next launch: show the toggle from the game's own saved setting and call the switch when it
|
|
51
|
+
changes (calling it with the saved value at start changes nothing when they agree). If the user wants players to
|
|
52
|
+
agree before anything is collected, set the opt-in option (`optIn: true`; Godot and GameMaker `opt_in`; Unity
|
|
53
|
+
`OptIn`; Unreal `bOptIn` or Project Settings > Opt In) and call the switch with `true` when the player says yes.
|
|
54
|
+
Each SDK's reference below has the code.
|
|
55
|
+
- **Bots.** Sessions from autoplay bots and tests must be marked synthetic, so they stay out of player numbers.
|
|
56
|
+
- **Testers.** On iOS the Godot, Unity and Unreal SDKs tell a TestFlight install from an App Store one themselves
|
|
57
|
+
(`distribution` in the device fields) and mark its sessions `tester`, out of player numbers, even though a
|
|
58
|
+
TestFlight build is a release build that reports `prod`. Don't pass a session type that would undo this. On
|
|
59
|
+
Android, Google Play's testing tracks can't be told apart on the device: if the developer ships test builds there,
|
|
60
|
+
give the testing-track build its own env (`beta`) from a build flag.
|
|
61
|
+
- **Version.** Find where the game's version lives and pass it; bump it on every release so Glitchless can compare versions.
|
|
62
|
+
|
|
63
|
+
## Every engine: the game's own metrics, and its board
|
|
64
|
+
|
|
65
|
+
Games differ: a puzzle game cares about solve time and hints, a mobile game about opens, modes, the paywall and
|
|
66
|
+
purchases, a platformer about where players die. Glitchless doesn't assume a genre, so this part is yours.
|
|
67
|
+
|
|
68
|
+
1. Find the moments this game's designer would want counted, and send each with `track`: one event name per
|
|
69
|
+
moment, plus one word or a few attributes about it. Never anything about the player.
|
|
70
|
+
- Three.js or Phaser: `glitchless.track('play', { mode: 'endless' })`
|
|
71
|
+
- Godot: `Glitchless.track("play", "endless")` (one word becomes the attribute `what`) or a dictionary
|
|
72
|
+
- Unity: `Glitchless.Track("play", "endless");` or a `Dictionary<string, object>`
|
|
73
|
+
- Unreal: `FGlitchless::Track(TEXT("play"), TEXT("endless"));` (the attribute `what`) or a `TMap` of attributes
|
|
74
|
+
and one of numbers; in Blueprint, Track Event (What) or Track Event
|
|
75
|
+
- GameMaker: `glitchless_track("play", "endless");` (the attribute `what`) or a struct
|
|
76
|
+
|
|
77
|
+
Good candidates: the game opening (with the edition, free or full), a mode or run starting, a run ending and
|
|
78
|
+
how, shop and paywall views and where they were opened, purchases started and finished, hints, choices that
|
|
79
|
+
matter (difficulty), shares and rating prompts. Levels, stages and puzzles go through levelStart,
|
|
80
|
+
levelComplete and levelFail, not `track`. Attributes are strings, numbers, booleans or lists of them, at most 12
|
|
81
|
+
per event.
|
|
82
|
+
|
|
83
|
+
Send them in the shape boards can measure:
|
|
84
|
+
- **An outcome as a boolean**: `won: true`, `picked: true`, `top: true`, so a board can give its rate by hero,
|
|
85
|
+
weapon or banner, with how sure it is. A word (`result: 'win'`) works too, and can go next to the boolean.
|
|
86
|
+
Unreal: until its attributes take booleans, send the outcome as 1 or 0 in the numbers map; rates read both alike.
|
|
87
|
+
- **An amount as a number**: `duration_s: 184`, `wait_s: 41`, `placement: 17`, `floor: 14`, never `"3:04"`.
|
|
88
|
+
Boards give its median, its p90 and a histogram, and its average.
|
|
89
|
+
- **What a match or run used as a list**: `deck: ['hog_rider', 'fireball']`, `items: [...]`, `boons: [...]`. Each
|
|
90
|
+
element counts (the first 16), so a board shows "decks with each card" and their win rate. A list holds the
|
|
91
|
+
game's words, never people (party members' names, friends).
|
|
92
|
+
- **One event at the end of each match or run** with its outcome and numbers (`match_end`, `run_end`,
|
|
93
|
+
`battle_end`), not one per hit: rates and distributions split by another attribute read a session's first 16
|
|
94
|
+
of an event.
|
|
95
|
+
- **Bands, not exact values, for what describes the player**: `level_band: '30-39'`, `trophy_band: '3000-3499'`.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
glitchless.track('match_end', { hero: 'ember', won: true, duration_s: 1930, items: ['boots', 'blink', 'bkb'] });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
And four calls for what `track` shouldn't carry (each engine's reference has its spelling):
|
|
102
|
+
- **Track a moment, count a stream.** Anything that happens many times a second (shots, hits, kills, gold and XP
|
|
103
|
+
pickups, taps) goes through `count(name, attrs, n)`: the SDK adds it up per 5-second window (up to 4 words to
|
|
104
|
+
group by, up to 4 numbers summed: `count('gold', { source: 'loot', amount: 35 })`) and sends one `counts` event,
|
|
105
|
+
so the queue never fills with them. Boards read a counter by its name like any event. A `track` per hit would
|
|
106
|
+
push frame windows out of the queue.
|
|
107
|
+
- **Properties: what holds for the session.** `setProperties({ rank: 'gold', class: 'druid', region: 'eu' })` where
|
|
108
|
+
the game learns it (after sign-in, at the menu, at matchmaking); every board then splits and filters by it
|
|
109
|
+
(`$rank`). Bands and the game's words only, at most 12 keys, set again each session: never a name, an account or
|
|
110
|
+
device ID, an email, an exact level or amount (the SDKs and the server drop keys like `user_id` and values shaped
|
|
111
|
+
like an ID). They go in every privacy mode, so the game's privacy page should mention them (each PRIVACY.md has
|
|
112
|
+
the paragraph). What changes from match to match (hero, deck, map) goes on the event or the level start.
|
|
113
|
+
- **Level attributes.** `levelStart('nmd_ghoa', { tier: 'pit_80', party_size: 3 })`: what describes the attempt,
|
|
114
|
+
so boards show clears and wipes by tier, group size or build. The outcome after it needs nothing more.
|
|
115
|
+
- **Groups and zones.** `setGroup('match', id)` with the match ID the game's server made, the same on every
|
|
116
|
+
player and on the server (the SDKs hash it the same way before sending it, by default); `setGroup('match', null)`
|
|
117
|
+
ends it. `setGroup('party', id)` for a party (never a guild or friends list), `setGroup('run')` for a roguelite
|
|
118
|
+
run (the SDK makes its ID). `setZone(name)` for where the player is in an open world (an MMO zone, a room): not a
|
|
119
|
+
level, it never ends in a win or a fail.
|
|
120
|
+
|
|
121
|
+
Purchases have one convention in every engine, so boards can add them up into revenue: a `purchase` event
|
|
122
|
+
when the store confirms it, with `amount` (a number in the currency's units: 4.99, not 499), `currency` (the
|
|
123
|
+
ISO code the store charged in) and `item`. A game has one currency on its boards; purchases in another are
|
|
124
|
+
listed as left out, not added in. Never send receipts, order ids or payment details. A free test purchase
|
|
125
|
+
(TestFlight, Xcode, a Play licence tester) is not revenue: the engine SDKs add `sandbox: true` to purchases in a
|
|
126
|
+
TestFlight or development install on iOS by themselves, and where the game's billing library says a purchase is
|
|
127
|
+
a sandbox one (RevenueCat's `isSandbox`, on Android too) pass `sandbox: true` yourself. Boards count those
|
|
128
|
+
purchases but never add them into revenue.
|
|
129
|
+
- Web games (Three.js, Phaser, Babylon.js, PlayCanvas): `glitchless.track('purchase', { amount: 4.99, currency: 'USD', item: 'gems_500' })`
|
|
130
|
+
- Godot: `Glitchless.track("purchase", {"amount": 4.99, "currency": "USD", "item": "gems_500"})`
|
|
131
|
+
- Unity: `Glitchless.Track("purchase", new Dictionary<string, object> { ["amount"] = 4.99, ["currency"] = "USD", ["item"] = "gems_500" });`
|
|
132
|
+
- Unreal: `FGlitchless::Track(TEXT("purchase"), {{TEXT("currency"), TEXT("USD")}, {TEXT("item"), TEXT("gems_500")}}, {{TEXT("amount"), 4.99}});`
|
|
133
|
+
(in Blueprint, Track Event with `amount` in Numbers)
|
|
134
|
+
2. A multiplayer game also reports its network, and its dedicated servers (follow the engine reference's
|
|
135
|
+
multiplayer section):
|
|
136
|
+
- **Ping, loss and disconnects.** The Unity SDK reads Netcode for GameObjects and Mirror by itself, Godot its
|
|
137
|
+
MultiplayerAPI with ENet or WebSocket, Unreal its own net driver; a web game passes its ping with
|
|
138
|
+
`netSample({ rtt_ms })` about once a second (or `instrumentNet` for WebRTC), GameMaker with
|
|
139
|
+
`glitchless_net_sample`, and any engine on another library (Steam Networking Sockets, Photon, Nakama, a game's
|
|
140
|
+
own) the same way. Call `disconnect({ reason })` when the connection drops and `reconnect()` when it comes back,
|
|
141
|
+
where the netcode doesn't say: a disconnect ends a level attempt as an abandon, never a fail. Nothing about the
|
|
142
|
+
other end is sent (no addresses).
|
|
143
|
+
- **Server mode.** A dedicated or authoritative server runs the SDK as a server: `glitchless/server` on a Node
|
|
144
|
+
server (with `instrumentWs`, `instrumentSocketIO` or `glitchlessRoom` for Colyseus), the Unity and Godot SDKs in a
|
|
145
|
+
dedicated-server build (or `--glitchless-server`), the Unreal plugin on a dedicated server. It sends its tick time
|
|
146
|
+
against its tick rate, players connected, CPU, memory and crashes, never anything about players, and Glitchless
|
|
147
|
+
keeps it apart from players under `<game>.server`. It uses the game's own service and client token, and sets
|
|
148
|
+
the same match groups as its players. It needs a Glitchless server that lists `server_mode` in `GET /v1/health`
|
|
149
|
+
(any current one does) and sends nothing to an older one.
|
|
150
|
+
3. Once events arrive, design the game's own dashboard: follow the `dashboard` skill (next to this one), which
|
|
151
|
+
turns the developer's questions into collectors, panels and pages and saves them with the
|
|
152
|
+
`glitchless_set_dashboard` MCP tool.
|
|
153
|
+
|
|
154
|
+
## Report
|
|
155
|
+
|
|
156
|
+
Tell the user what you wired (with file:line), the gauges you chose and why, the events you track and count, the
|
|
157
|
+
properties and groups you set, the netcode and server mode you wired for a multiplayer game, and the board you
|
|
158
|
+
designed, the agent tools or measure commands you set up, and anything you weren't sure about.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Babylon.js
|
|
2
|
+
|
|
3
|
+
Part of the `instrument` skill. Apply its settings first (section 0 of [SKILL.md](../SKILL.md): the
|
|
4
|
+
intake URL and client token, privacy, bots, testers and the version), and finish with its last two
|
|
5
|
+
sections: the game's own metrics and dashboard, and the report.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
The same `glitchless` package, with a Babylon.js adapter (Babylon.js 5+, WebGL or WebGPU). It times frames from the
|
|
9
|
+
engine's own loop, reads Babylon's draw-call, triangle and shader-compile counters, reports scenes as levels, and
|
|
10
|
+
catches shader errors, failed textures, context loss and a render loop that stopped.
|
|
11
|
+
|
|
12
|
+
## 1. Read the game
|
|
13
|
+
|
|
14
|
+
Note file:line for: `new Engine(...)` (or `WebGPUEngine`), each `new Scene(engine)` and whether each level is its own
|
|
15
|
+
scene or one scene rebuilt; the render loop (`engine.runRenderLoop`) and the game update (`scene.onBeforeRenderObservable`
|
|
16
|
+
or `registerBeforeRender`); player death and respawn, level complete, game over, pickups; anything created in bulk at
|
|
17
|
+
runtime (meshes, `ShaderMaterial`s, particle systems, `DynamicTexture`s); where the version lives.
|
|
18
|
+
|
|
19
|
+
## 2. Install and initialize
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install glitchless
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Init before the engine starts, and hand over the engine and the first scene right after creating them:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import * as BABYLON from '@babylonjs/core';
|
|
29
|
+
import { Glitchless } from 'glitchless';
|
|
30
|
+
import { instrumentBabylon } from 'glitchless/babylon';
|
|
31
|
+
|
|
32
|
+
const glitchless = Glitchless.init({
|
|
33
|
+
service: '<game-id>',
|
|
34
|
+
version: GAME_VERSION,
|
|
35
|
+
intake: 'http://localhost:7777',
|
|
36
|
+
clientToken: 'gl_pub_dev',
|
|
37
|
+
sessionType: isBot ? 'synthetic' : 'user',
|
|
38
|
+
});
|
|
39
|
+
const engine = new BABYLON.Engine(canvas, true);
|
|
40
|
+
const scene = new BABYLON.Scene(engine);
|
|
41
|
+
instrumentBabylon(glitchless, { engine, scene, BABYLON }); // BABYLON (the namespace) lets captureMap draw levels
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
A game that imports single modules (`import { Engine } from '@babylonjs/core/Engines/engine'`) can leave `BABYLON`
|
|
45
|
+
out; then `captureMap` is off. Script-tag games: `Glitchless.instrumentBabylon(glitchless, { engine, scene })` (the
|
|
46
|
+
`BABYLON` global is found on its own).
|
|
47
|
+
|
|
48
|
+
## 3. Levels
|
|
49
|
+
|
|
50
|
+
- Each level is its own scene: set `scene.metadata = { level: 'forest' }` when you create it. The level starts when the
|
|
51
|
+
scene first renders and ends when it is disposed; scenes created later are picked up on their own.
|
|
52
|
+
- One scene rebuilt for each level: set `scene.metadata.level` to the next name, or call `glitchless.levelStart('forest-2')`
|
|
53
|
+
(any manual call turns scene levels off).
|
|
54
|
+
- Odd cases: `instrumentBabylon(glitchless, { engine, scene, levels: (scene) => name or null })`.
|
|
55
|
+
|
|
56
|
+
## 4. Wire game semantics
|
|
57
|
+
|
|
58
|
+
The same calls as for Three.js: `levelComplete`, `levelFail`, `death({ x, y, z, cause })`, `track`, `setPosition`
|
|
59
|
+
(every frame, from the player's mesh position), `setContext`, `error`. The adapter already sends `meshes`,
|
|
60
|
+
`active_meshes`, `materials`, `textures`, `particles` and `render_observers` as gauges; add the game's own counts with
|
|
61
|
+
`setContext`. After a level is built, `glitchless.captureMap(level, { axis: 'xz', bounds: { min: [x0, z0], max: [x1, z1] }, exclude: [player] })`
|
|
62
|
+
draws its picture for the heatmaps (pass `BABYLON` for it). Register WebMCP tools, bug reports and source maps as for
|
|
63
|
+
Three.js ([4](threejs.md#4-give-agents-hands-register-game-tools-webmcp), [4b](threejs.md#4b-bug-reports-from-players-ask-first),
|
|
64
|
+
[4c](threejs.md#4c-readable-errors-from-the-production-build-source-maps)).
|
|
65
|
+
|
|
66
|
+
Streams (`count`), session properties (`setProperties`), level attributes and zones are the same calls as in
|
|
67
|
+
[step 3 for Three.js](threejs.md#3-wire-game-semantics). A multiplayer game adds match groups, ping and disconnects,
|
|
68
|
+
and its Node server `glitchless/server`: [step 4a](threejs.md#4a-multiplayer-matches-ping-disconnects-and-the-games-server).
|
|
69
|
+
If the game has a settings screen, offer a "share performance data" toggle wired to `glitchless.setEnabled(on)`
|
|
70
|
+
([step 4d](threejs.md#4d-a-share-performance-data-setting-offer-it)).
|
|
71
|
+
|
|
72
|
+
## 5. Bots and playtests
|
|
73
|
+
|
|
74
|
+
As for Phaser ([5](phaser.md#5-bots-and-playtests)): `?autoplay=1&seed=N&skill=0..1&level=N`, synthetic sessions and
|
|
75
|
+
`window.__GLITCHLESS_PLAYTEST_DONE__`. `apps/babylon-demo` in the Glitchless repo is a working example.
|
|
76
|
+
|
|
77
|
+
## 6. Verify
|
|
78
|
+
|
|
79
|
+
Run the game, press `` ` `` for the overlay (draw calls, triangles, the gauges, the level), play a level and die
|
|
80
|
+
once, then call `glitchless_list_games`. With WebMCP connected, `glitchless_inspect_scene` lists each scene's mesh
|
|
81
|
+
groups and flags copies that should be instances or thin instances.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# GameMaker
|
|
2
|
+
|
|
3
|
+
Part of the `instrument` skill. Apply its settings first (section 0 of [SKILL.md](../SKILL.md): the
|
|
4
|
+
intake URL and client token, privacy, bots, testers and the version), and finish with its last two
|
|
5
|
+
sections: the game's own metrics and dashboard, and the report.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
The Glitchless SDK for GameMaker (`gamemaker/` in the Glitchless repo; `~/.glitchless/gamemaker` if it's cloned
|
|
9
|
+
there) is GML: nine scripts and two objects. Its README (`gamemaker/README.md`) has the whole API; this is the
|
|
10
|
+
order to wire it in.
|
|
11
|
+
|
|
12
|
+
## 1. Read the project
|
|
13
|
+
|
|
14
|
+
Note: the `.yyp` (it must be GameMaker 2024.2 or later: `"$GMProject"` at its top; an older project needs opening
|
|
15
|
+
once in a newer GameMaker), the first room in `RoomOrderNodes` and its creation code, the controller objects that
|
|
16
|
+
live through the game (`persistent`), which rooms are levels and which are menus, the objects for the player, its
|
|
17
|
+
death and respawn, level complete and fail, pickups, and anything created in bulk (bullets, enemies, particles,
|
|
18
|
+
sparks). Check for an existing `exception_unhandled_handler` call and any analytics the game already sends.
|
|
19
|
+
|
|
20
|
+
## 2. Install
|
|
21
|
+
|
|
22
|
+
Without the IDE (an agent), from the Glitchless repo:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
node ~/.glitchless/gamemaker/tools/install.mjs path/to/Game.yyp
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
It copies the scripts and objects into the project and lists them in the `.yyp` under a *Glitchless* folder; run it
|
|
29
|
+
again to update. In the IDE, **Tools → Import Local Package** with `Glitchless-<version>.yymps` does the same. Never
|
|
30
|
+
place `obj_glitchless` in a room: `glitchless_init` makes it.
|
|
31
|
+
|
|
32
|
+
## 3. Initialize
|
|
33
|
+
|
|
34
|
+
Once, as early as possible: the first room's creation code, or the Create event of the game's first persistent
|
|
35
|
+
controller.
|
|
36
|
+
|
|
37
|
+
```gml
|
|
38
|
+
glitchless_init("my-game", "", "prod", "<intake URL>", { client_token: "<client token>" }); // "" = GM_version
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A build run from the IDE sends nothing without `-glitchless`; executables send. If the game sets its own
|
|
42
|
+
`exception_unhandled_handler`, move it into the `exception_handler` option, or call `glitchless_crash(ex)` first
|
|
43
|
+
thing in it, or crashes go unreported.
|
|
44
|
+
|
|
45
|
+
## 4. Levels and game semantics
|
|
46
|
+
|
|
47
|
+
- **Levels:** a room that reads as a level (`rm_cave_2`, not `rm_main_menu` or `rm_title`) starts that level on its
|
|
48
|
+
own. A game whose levels aren't rooms calls `glitchless_level_start(id)` (the first call turns the rooms off), and
|
|
49
|
+
every game calls `glitchless_level_complete(undefined, score)` and `glitchless_level_fail(undefined, cause)` where
|
|
50
|
+
a level ends, and `glitchless_level_abandon()` where the player leaves one mid-level (the menu, a restart): never a
|
|
51
|
+
fail. Quitting mid-level sends the abandon by itself. Where an attempt has a difficulty, mode, party size or build,
|
|
52
|
+
pass it: `glitchless_level_start("nmd_ghoa", { tier: "pit_80", party_size: 3 })` (lists of words are fine).
|
|
53
|
+
- **Deaths:** `glitchless_death(x, y, cause)` where the player dies.
|
|
54
|
+
- **Gauges:** `glitchless_set_context({ enemies: instance_number(obj_enemy), bullets: instance_number(obj_bullet) })`
|
|
55
|
+
in a controller's End Step: whatever is created in bulk. The SDK already sends `instances`, `surfaces`, `ds_maps`,
|
|
56
|
+
`ds_lists` and `buffers`.
|
|
57
|
+
- **Errors the game catches:** `glitchless_error(_e)` in its `catch` blocks.
|
|
58
|
+
- **Quit button:** `glitchless_quit()` in place of `game_end()`, so the last batch goes now, not next launch.
|
|
59
|
+
|
|
60
|
+
## 4c. Streams, properties, groups and zones
|
|
61
|
+
|
|
62
|
+
- **Track a moment, count a stream.** Anything that happens many times a minute per player (a shot, a kill, a coin,
|
|
63
|
+
a tap, XP and gold) is `glitchless_count("kill", { monster: "elite" })` or `glitchless_count("gold", { source:
|
|
64
|
+
"loot", amount: 35 })`, never `glitchless_track`: counts are added up on the device and go once a window. Words and
|
|
65
|
+
true/false split the count (at most 4), numbers are added up (at most 4). Outcomes stay `glitchless_track`, once a
|
|
66
|
+
match or run, with booleans and numbers: `glitchless_track("match_end", { hero: "ember", won: true, duration_s:
|
|
67
|
+
1930 })`.
|
|
68
|
+
- **Properties** are what holds for the whole session: rank tier, class, region, mode, input, a spender band.
|
|
69
|
+
Call `glitchless_set_properties({ rank: "diamond", region: "eu-west" })` where the game learns them (after
|
|
70
|
+
sign-in, at the menu, at matchmaking), or pass `properties` in the options. Bands, not exact numbers
|
|
71
|
+
(`level_band: "30-39"`); never a name, account or anything the player typed (the SDK drops keys such as `email`
|
|
72
|
+
and values shaped like an ID). What changes per match (hero, deck, map) goes on events or level attributes.
|
|
73
|
+
- **Groups:** `glitchless_set_group("match", id)` when the game's server hands out a match or lobby ID (shared by
|
|
74
|
+
everyone in it), `glitchless_set_group("party", id)` while a party lasts, and `glitchless_set_group("match",
|
|
75
|
+
undefined)` when it ends. IDs are sent hashed. A roguelite calls `glitchless_set_group("run")` at a run's start
|
|
76
|
+
(it returns the run's ID; save it with the run to resume it with `glitchless_set_group("run", saved_id)`) and
|
|
77
|
+
`glitchless_set_group("run", undefined)` at its end.
|
|
78
|
+
- **Zones:** in an open world (MMO regions, metroidvania rooms) where levels don't start and end,
|
|
79
|
+
`glitchless_set_zone(name)` as the player moves between areas. Keep levels for things that end.
|
|
80
|
+
|
|
81
|
+
## 4d. Multiplayer (GameMaker's `network_*`)
|
|
82
|
+
|
|
83
|
+
Look for `network_create_socket`, `network_connect`/`network_connect_async`, `network_create_server` and the
|
|
84
|
+
`Async - Networking` events. GameMaker doesn't measure the connection, so:
|
|
85
|
+
|
|
86
|
+
- On the client, ping the server about once a second with a timestamp it sends straight back, and call
|
|
87
|
+
`glitchless_net_sample(current_time - sent)` when the answer comes (`loss_pct` and `jitter_ms` too, if the game
|
|
88
|
+
counts them). The host of a listen server sends none.
|
|
89
|
+
- Call `glitchless_disconnect(reason)` where the game sees the connection go: `failed_to_connect` from a failed
|
|
90
|
+
`network_type_non_blocking_connect`, `connection_lost` when `network_send_packet` returns below 0, `timeout`
|
|
91
|
+
after several seconds without an answer, `kicked` or `server_closed` when the server says so. `glitchless_reconnect()`
|
|
92
|
+
when it gets back in. A level going ends as an abandon with reason `disconnect`.
|
|
93
|
+
- `gamemaker/README.md` ("Multiplayer: ping and disconnects") has a whole client and server example to adapt.
|
|
94
|
+
|
|
95
|
+
## 4b. Bug reports from players (ask first)
|
|
96
|
+
|
|
97
|
+
As for [Three.js](threejs.md#4b-bug-reports-from-players-ask-first), and the same question to the user first. In GameMaker,
|
|
98
|
+
`bug_reports: true` in the options of `glitchless_init` adds the F8 form; it deactivates the game's instances while
|
|
99
|
+
it's open, so a game with its own pause passes `bug_reports: { pause: false, on_open: f, on_close: g }`. A pause menu
|
|
100
|
+
calls `glitchless_open_bug_report()`, and the game's own form `glitchless_report_bug(note, true, callback)`. The
|
|
101
|
+
screenshot is a PNG of the application surface. Privacy wording: `gamemaker/PRIVACY.md`.
|
|
102
|
+
|
|
103
|
+
## 4e. A "Share performance data" setting (where the game has a settings menu)
|
|
104
|
+
|
|
105
|
+
If the game has a settings or options menu, offer the user a toggle there, so players can turn Glitchless off and back
|
|
106
|
+
on (ask before adding UI). Keep the setting with the game's others, and call `glitchless_set_enabled` with it as the game
|
|
107
|
+
starts and whenever the player flips it:
|
|
108
|
+
|
|
109
|
+
```gml
|
|
110
|
+
glitchless_set_enabled(global.settings.share_data); // at start (safe before glitchless_init) and in the toggle
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Off stops measuring and sending at once, drops what was waiting (the outbox too) and is remembered in
|
|
114
|
+
`glitchless/enabled`, so later launches send nothing until it's on again; a call that changes nothing does nothing. The
|
|
115
|
+
menu shows the game's own setting, not `glitchless_is_enabled()`, which is false in a build run from the IDE without
|
|
116
|
+
`-glitchless` whatever the player chose. For a game that asks players before collecting anything, pass `opt_in: true`
|
|
117
|
+
to `glitchless_init` and call `glitchless_set_enabled(true)` when they say yes. With a toggle, the store forms can answer
|
|
118
|
+
that collection is optional, and the privacy page gets a sentence about it (`gamemaker/PRIVACY.md`).
|
|
119
|
+
|
|
120
|
+
## 5. Bots and measuring
|
|
121
|
+
|
|
122
|
+
Give the game an `-autoplay` flag (read it with `glitchless_has_flag("autoplay")`) that plays a few levels and
|
|
123
|
+
calls `glitchless_quit()`. Sessions run with `-autoplay` are synthetic. GameMaker must be set up once by a person
|
|
124
|
+
(`gamemaker/README.md`, "Setting up GameMaker for the end-to-end test"). Igor's `Run` (the IDE's, and `gm-cli run`)
|
|
125
|
+
starts the game with macOS's `open`, which passes no command line or environment on, so for a run from the IDE or
|
|
126
|
+
Igor put the flags in `glitchless/args.txt` in the runner's save area:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
mkdir -p ~/Library/Application\ Support/com.yoyogames.macyoyorunner/glitchless
|
|
130
|
+
echo "-autoplay -glitchless-measure=10" > ~/Library/Application\ Support/com.yoyogames.macyoyorunner/glitchless/args.txt
|
|
131
|
+
npx @gamemaker/gm-cli@2.4.1 run Game.yyp --target=mac --runtime=vm # or Run in the IDE
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Or compile once and start the runner with the flags on its command line, as `gamemaker/test/e2e.mjs` does. The run
|
|
135
|
+
prints the stats as one line of JSON and where it saved them (`glitchless/measure.json` in the save area). Delete
|
|
136
|
+
`args.txt` afterwards. Measure before and after a change.
|
|
137
|
+
|
|
138
|
+
## 6. Verify
|
|
139
|
+
|
|
140
|
+
Run the game with `-glitchless` (from the IDE or gm-cli, in `args.txt` as above), play a level and die once, then
|
|
141
|
+
call `glitchless_list_games` or open the dashboard. `-glitchless-debug` logs each batch as it is sent.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Godot
|
|
2
|
+
|
|
3
|
+
Part of the `instrument` skill. Apply its settings first (section 0 of [SKILL.md](../SKILL.md): the
|
|
4
|
+
intake URL and client token, privacy, bots, testers and the version), and finish with its last two
|
|
5
|
+
sections: the game's own metrics and dashboard, and the report.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Follow the addon's README (`godot/addons/glitchless/README.md`): install, `Glitchless.init`, levels, deaths,
|
|
9
|
+
`track`, and `--glitchless-measure` for bots.
|
|
10
|
+
|
|
11
|
+
## Bug reports from players (ask first)
|
|
12
|
+
|
|
13
|
+
As for [Three.js](threejs.md#4b-bug-reports-from-players-ask-first), and the same question to the user first. In Godot,
|
|
14
|
+
`"bug_reports": true` in the options of `Glitchless.init` adds the F8 form; it pauses the tree while it's open, so
|
|
15
|
+
a game with its own pause logic passes `"bug_reports": {"pause": false}` and connects `Glitchless.bug_report_opened` and
|
|
16
|
+
`bug_report_closed`. A pause menu can call `Glitchless.open_bug_report()`, and the game's own form
|
|
17
|
+
`await Glitchless.report_bug(note)`. The screenshot is the root viewport; headless runs have none. Privacy wording:
|
|
18
|
+
`godot/addons/glitchless/PRIVACY.md`.
|
|
19
|
+
|
|
20
|
+
## The player's off switch (where the game has a settings menu)
|
|
21
|
+
|
|
22
|
+
If the game has a settings or options menu, offer the user a "Share performance data" toggle there (ask first, as for
|
|
23
|
+
bug reports). Store it with the game's own settings, show that saved value in the menu, and call
|
|
24
|
+
`Glitchless.set_enabled(on)` when it changes; calling it again at start-up with the saved value does nothing. Use a
|
|
25
|
+
`CheckButton` like the game's other toggles (README, "The player's off switch"). Don't show `Glitchless.is_enabled()`
|
|
26
|
+
there: it is false in a debug build without `--glitchless`. Glitchless saves the choice itself
|
|
27
|
+
(`user://glitchless/enabled`), so it holds from the first frame of the next launch. For a game that asks before
|
|
28
|
+
collecting anything, pass `"opt_in": true` to `init` and call `set_enabled(true)` when the player says yes. With the
|
|
29
|
+
toggle, Google Play's Data safety form can say collection is optional (PRIVACY.md, "For the store forms").
|
|
30
|
+
|
|
31
|
+
## Streams, properties, matches and zones
|
|
32
|
+
|
|
33
|
+
- **Count a stream, track a moment.** Shots, hits, kills, loot and gold go through
|
|
34
|
+
`Glitchless.count("kill", {"monster": "elite"})` (numbers are summed: `{"source": "loot", "amount": 35}`), never
|
|
35
|
+
one `track()` each: the queue holds 2,000 events. A debug build warns when a name is tracked over 20 times a second.
|
|
36
|
+
- **Properties** hold for the session, in the game's words: `Glitchless.set_properties({"mode": "squads", "rank": "gold"})`
|
|
37
|
+
where the game knows them (after sign-in, at the menu, at matchmaking), or `"properties"` in the options. Bands, not
|
|
38
|
+
exact numbers (`"level_band": "30-39"`); never a name, account, email or ID (they are dropped). Hero, deck and map
|
|
39
|
+
change per match: put them on events or on `level_start`.
|
|
40
|
+
- **Level attributes:** `Glitchless.level_start("pit", {"tier": "pit_80", "party_size": 3})`.
|
|
41
|
+
- **Groups:** `Glitchless.set_group("match", match_id)` with the ID the game's server made for the match (the client
|
|
42
|
+
and the server set the same one; Glitchless hashes it), `set_group("party", id)`, and for a roguelite
|
|
43
|
+
`var run_id := Glitchless.set_group("run")` at the run's start (save it, and pass it back to resume).
|
|
44
|
+
`set_group("match", null)` when it ends.
|
|
45
|
+
- **Zones** for open worlds and metroidvania rooms: `Glitchless.set_zone("ashen_wastes")` as the player moves.
|
|
46
|
+
|
|
47
|
+
## Multiplayer
|
|
48
|
+
|
|
49
|
+
- **Godot's MultiplayerAPI with ENet** (the usual Godot multiplayer): nothing to add. Glitchless reads ping, jitter,
|
|
50
|
+
packet loss and bytes from the ENet peer, and disconnects from `multiplayer`'s signals. If the game knows why a
|
|
51
|
+
connection dropped (it was kicked), call `Glitchless.net_disconnect("kicked")` in its `server_disconnected` handler.
|
|
52
|
+
- **WebSocket (web exports) or other netcode** (Steam Networking Sockets, Nakama, a custom protocol): call
|
|
53
|
+
`Glitchless.net_sample(rtt_ms, loss_pct, jitter_ms)` once a second with the game's own ping while connected,
|
|
54
|
+
`Glitchless.net_disconnect(reason)` and `Glitchless.net_reconnect()`.
|
|
55
|
+
- **A dedicated server** (a dedicated-server export, or started with `--server`) reports as the game's server on its
|
|
56
|
+
own: tick time against `Engine.physics_ticks_per_second`, players from `multiplayer.get_peers()`. In its `init`, pass
|
|
57
|
+
`{"region": "eu-west", "max_players": 100}`; call `level_start(map)` for the map and `set_group("match", id)` with
|
|
58
|
+
the match's ID. A game whose `--server` flag means something else passes `{"role": "player"}`; one that starts its
|
|
59
|
+
server another way passes `{"role": "server"}`. With other netcode, `Glitchless.set_players(n)`.
|
|
60
|
+
- A server sends nothing to a Glitchless server that predates server mode, and says so in its log.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Phaser
|
|
2
|
+
|
|
3
|
+
Part of the `instrument` skill. Apply its settings first (section 0 of [SKILL.md](../SKILL.md): the
|
|
4
|
+
intake URL and client token, privacy, bots, testers and the version), and finish with its last two
|
|
5
|
+
sections: the game's own metrics and dashboard, and the report.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
The same `glitchless` package, with a Phaser adapter (Phaser 3.60+ and 4). It times frames from Phaser's own loop,
|
|
9
|
+
counts draw calls, reports scenes as levels, and catches failed loads and a game loop that stopped.
|
|
10
|
+
|
|
11
|
+
## 1. Read the game
|
|
12
|
+
|
|
13
|
+
Note file:line for: `new Phaser.Game(config)` and the scene list; which scene keys are levels and which are
|
|
14
|
+
boot/preload/menu/UI/game-over scenes; player death and respawn, level complete, game over, pickups; anything
|
|
15
|
+
spawned in bulk (Groups, particle emitters, bullets); where the version lives.
|
|
16
|
+
|
|
17
|
+
## 2. Install and initialize
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install glitchless
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Init before the game is created, so the session starts with the page, and hand the game over right after:
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import * as Phaser from 'phaser';
|
|
27
|
+
import { Glitchless } from 'glitchless';
|
|
28
|
+
import { instrumentPhaser } from 'glitchless/phaser';
|
|
29
|
+
|
|
30
|
+
const glitchless = Glitchless.init({
|
|
31
|
+
service: '<game-id>',
|
|
32
|
+
version: GAME_VERSION,
|
|
33
|
+
intake: 'http://localhost:7777',
|
|
34
|
+
clientToken: 'gl_pub_dev',
|
|
35
|
+
sessionType: isBot ? 'synthetic' : 'user',
|
|
36
|
+
});
|
|
37
|
+
const game = new Phaser.Game(config);
|
|
38
|
+
instrumentPhaser(glitchless, { game, Phaser });
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Script-tag games: load `{GLITCHLESS_URL}/sdk/glitchless.js`, then `Glitchless.instrumentPhaser(glitchless, { game })`.
|
|
42
|
+
|
|
43
|
+
## 3. Levels
|
|
44
|
+
|
|
45
|
+
A scene that starts is a level, named by its key, unless the key reads as a loader, menu, overlay or end screen
|
|
46
|
+
(`Boot`, `Preloader`, `MainMenu`, `UIScene`, `HUD`, `GameOver`, `Pause`, `Settings`, `Credits`…). Check the
|
|
47
|
+
game's keys against that:
|
|
48
|
+
|
|
49
|
+
- Levels are scenes (`Level1`, `Level2`): nothing to do.
|
|
50
|
+
- One `Game` scene plays every level: call `glitchless.levelStart('world-1-2')` in its `create()` with the real
|
|
51
|
+
level name. Any manual call turns scene levels off.
|
|
52
|
+
- Odd keys: `instrumentPhaser(glitchless, { game, Phaser, levels: ['Forest', 'Cave'] })` or `levels: (scene) => name or null`.
|
|
53
|
+
|
|
54
|
+
## 4. Wire game semantics
|
|
55
|
+
|
|
56
|
+
The same calls as for Three.js: `levelComplete`, `levelFail`, `death({ x, y, cause })`, `track`, `setPosition`,
|
|
57
|
+
`setContext`, `error`. The adapter already sends `game_objects`, `physics_bodies`, `particles`, `tweens`,
|
|
58
|
+
`listeners` and `sounds` as gauges; add the game's own counts (enemies, bullets) with `setContext`.
|
|
59
|
+
Phaser's y axis points down, so heatmaps show a Phaser level upside down for now; leave the coordinates as they are.
|
|
60
|
+
|
|
61
|
+
Register WebMCP tools as for Three.js (`glitchless.registerTool`). Bug reports work as for Three.js too
|
|
62
|
+
(`bugReports` in init, [step 4b](threejs.md#4b-bug-reports-from-players-ask-first)): the form's screenshot is the Phaser canvas.
|
|
63
|
+
So do source maps for the production build ([step 4c](threejs.md#4c-readable-errors-from-the-production-build-source-maps)).
|
|
64
|
+
|
|
65
|
+
Streams (`count`), session properties (`setProperties`), level attributes and zones are the same calls as in
|
|
66
|
+
[step 3 for Three.js](threejs.md#3-wire-game-semantics). A multiplayer game adds match groups, ping and disconnects,
|
|
67
|
+
and its Node server `glitchless/server`: [step 4a](threejs.md#4a-multiplayer-matches-ping-disconnects-and-the-games-server).
|
|
68
|
+
If the game has a settings screen, offer a "share performance data" toggle wired to `glitchless.setEnabled(on)`
|
|
69
|
+
([step 4d](threejs.md#4d-a-share-performance-data-setting-offer-it)).
|
|
70
|
+
|
|
71
|
+
## 5. Bots and playtests
|
|
72
|
+
|
|
73
|
+
If the game has (or can get) an autoplay bot, make it read `?autoplay=1&seed=N&skill=0..1&level=N`, mark its
|
|
74
|
+
sessions synthetic, and set `window.__GLITCHLESS_PLAYTEST_DONE__ = true` when a run is over. Then
|
|
75
|
+
`glitchless-playtest` can compare builds. `apps/phaser-demo` in the Glitchless repo is a working example,
|
|
76
|
+
including `glitchless.playtest.json`.
|
|
77
|
+
|
|
78
|
+
## 6. Verify
|
|
79
|
+
|
|
80
|
+
Run the game, press `` ` `` for the overlay (draw calls, the gauges, the current level), play a level and die once,
|
|
81
|
+
then call `glitchless_list_games`. With WebMCP connected, `glitchless_inspect_scene` lists each running scene's
|
|
82
|
+
display list, physics bodies and busiest event listeners.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# PlayCanvas
|
|
2
|
+
|
|
3
|
+
Part of the `instrument` skill. Apply its settings first (section 0 of [SKILL.md](../SKILL.md): the
|
|
4
|
+
intake URL and client token, privacy, bots, testers and the version), and finish with its last two
|
|
5
|
+
sections: the game's own metrics and dashboard, and the report.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
The same `glitchless` package, with a PlayCanvas adapter (the PlayCanvas engine 2.x, WebGL2 or WebGPU; editor
|
|
9
|
+
projects and engine-only games). It times frames from the app's loop, reads the device's draw calls and shaders,
|
|
10
|
+
counts triangles, reports editor scenes as levels, and catches failed assets, context loss and script errors.
|
|
11
|
+
|
|
12
|
+
## 1. Read the game
|
|
13
|
+
|
|
14
|
+
Note file:line for: where the `pc.Application` (or `AppBase`) is created, or for an editor project the scripts and
|
|
15
|
+
scenes; how levels load (`app.scenes.changeScene()`, `loadSceneHierarchy()`, or built in code); the scripts that handle
|
|
16
|
+
death, level complete, pickups; anything spawned in bulk (entities cloned or built per effect, meshes made at runtime);
|
|
17
|
+
where the version lives.
|
|
18
|
+
|
|
19
|
+
## 2. Install and initialize
|
|
20
|
+
|
|
21
|
+
Engine-only game (`npm install glitchless`):
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import * as pc from 'playcanvas';
|
|
25
|
+
import { Glitchless } from 'glitchless';
|
|
26
|
+
import { instrumentPlayCanvas } from 'glitchless/playcanvas';
|
|
27
|
+
|
|
28
|
+
const glitchless = Glitchless.init({
|
|
29
|
+
service: '<game-id>',
|
|
30
|
+
version: GAME_VERSION,
|
|
31
|
+
intake: 'http://localhost:7777',
|
|
32
|
+
clientToken: 'gl_pub_dev',
|
|
33
|
+
sessionType: isBot ? 'synthetic' : 'user',
|
|
34
|
+
});
|
|
35
|
+
const app = new pc.Application(canvas);
|
|
36
|
+
instrumentPlayCanvas(glitchless, { app, pc }); // pc (the namespace) lets captureMap draw levels
|
|
37
|
+
app.start();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
PlayCanvas Editor project: add `{GLITCHLESS_URL}/sdk/glitchless.js` as an external script in the project settings,
|
|
41
|
+
then a script on the first entity that loads:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const GlitchlessInit = pc.createScript('glitchlessInit');
|
|
45
|
+
GlitchlessInit.prototype.initialize = function () {
|
|
46
|
+
const glitchless = Glitchless.init({ service: '<game-id>', version: '1.0.0', intake: 'http://localhost:7777', clientToken: 'gl_pub_dev' });
|
|
47
|
+
Glitchless.instrumentPlayCanvas(glitchless, { app: this.app });
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 3. Levels
|
|
52
|
+
|
|
53
|
+
- Editor scenes: `app.scenes.changeScene('Level2')` and `loadSceneHierarchy()` start a level named after the scene,
|
|
54
|
+
unless the name reads as a loader, menu, overlay or end screen. Odd names: `levels: ['Forest', 'Cave']` or
|
|
55
|
+
`levels: (name) => name or null`.
|
|
56
|
+
- Levels built in code: call `glitchless.levelStart('track-2')` where the level is built (this turns scene levels off).
|
|
57
|
+
|
|
58
|
+
## 4. Wire game semantics
|
|
59
|
+
|
|
60
|
+
The same calls as for Three.js, from the scripts that handle them (`levelComplete`, `levelFail`, `death`, `track`,
|
|
61
|
+
`setPosition` every frame from the player entity's `getPosition()`, `setContext`, `error`). The adapter already sends
|
|
62
|
+
`entities`, `mesh_instances`, `materials`, `textures` and `lights` as gauges. After a level is built,
|
|
63
|
+
`glitchless.captureMap(level, { axis: 'xz', bounds, exclude: [player] })` draws its picture (pass `pc` for it). WebMCP
|
|
64
|
+
tools, bug reports and source maps work as for Three.js. Vite's dev server runs PlayCanvas's debug build, which turns
|
|
65
|
+
a script off after it throws; the adapter reports those errors too.
|
|
66
|
+
|
|
67
|
+
Streams (`count`), session properties (`setProperties`), level attributes and zones are the same calls as in
|
|
68
|
+
[step 3 for Three.js](threejs.md#3-wire-game-semantics). A multiplayer game adds match groups, ping and disconnects,
|
|
69
|
+
and its Node server `glitchless/server`: [step 4a](threejs.md#4a-multiplayer-matches-ping-disconnects-and-the-games-server).
|
|
70
|
+
If the game has a settings screen, offer a "share performance data" toggle wired to `glitchless.setEnabled(on)`
|
|
71
|
+
([step 4d](threejs.md#4d-a-share-performance-data-setting-offer-it)).
|
|
72
|
+
|
|
73
|
+
## 5. Bots and playtests
|
|
74
|
+
|
|
75
|
+
As for Phaser ([5](phaser.md#5-bots-and-playtests)). `apps/playcanvas-demo` in the Glitchless repo is a working example.
|
|
76
|
+
|
|
77
|
+
## 6. Verify
|
|
78
|
+
|
|
79
|
+
Run the game, press `` ` `` for the overlay, play a level and fail once, then call `glitchless_list_games`. With
|
|
80
|
+
WebMCP connected, `glitchless_inspect_scene` lists entity groups and flags copies that should be instanced or batched.
|