skillprint-js-sdk 1.1.0-beta.6 โ 1.1.0-beta.7
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/README.md +50 -1
- package/dist/index.cjs +308 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +218 -12
- package/dist/index.d.ts +218 -12
- package/dist/index.global.js +305 -86
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +305 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A professional JavaScript & TypeScript SDK for integrating Skillprint's real-tim
|
|
|
14
14
|
- ๐ธ **Automated Screenshot Capture**: Asynchronous, throttled gameplay screenshot captures for Canvas and WebGL contexts without dropping game frame rates.
|
|
15
15
|
- ๐ **Real-Time Dynamic Parameters**: Receive, convert, clamp, and apply AI-driven parameter modifications seamlessly during active sessions.
|
|
16
16
|
- ๐ฎ **Built-In Engine Adapters**: Ready-to-use adapter wrappers for Phaser.js, Three.js, PixiJS, and Generic Canvas.
|
|
17
|
+
- ๐ **Discrete Telemetry Events**: Optional `logEvent()` for precise, low-latency gameplay signals (a fixed vocabulary, or your own custom event names) alongside screenshot capture. See [Discrete Telemetry Events](#discrete-telemetry-events).
|
|
17
18
|
- ๐ **WebGL & URL Extraction**: Automatic query parameter extraction for web deployments (`mood`, `playerId`).
|
|
18
19
|
- ๐งช **100% Test Coverage Ready**: Fully tested with Vitest and jsdom.
|
|
19
20
|
|
|
@@ -188,6 +189,38 @@ manager.startGameSessionWithOverrides(
|
|
|
188
189
|
|
|
189
190
|
---
|
|
190
191
|
|
|
192
|
+
## Discrete Telemetry Events
|
|
193
|
+
|
|
194
|
+
Screenshot capture is the SDK's primary telemetry mechanism and covers every game automatically. `logEvent()` is an **optional, additive** layer on top of it for games that want precise, low-latency event signals alongside the vision-based scoring โ it doesn't replace or interact with the screenshot loop.
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
import { GameEvent } from 'skillprint-js-sdk';
|
|
198
|
+
|
|
199
|
+
manager.logEvent(GameEvent.LEVEL_START);
|
|
200
|
+
manager.logEvent(GameEvent.LEVEL_COMPLETE, { level: 3, score: 1200 });
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`logEvent` is fire-and-forget: a failed request is logged as a warning and does not throw, so it can never interrupt gameplay. Calling it with no active session is a no-op (also just a warning).
|
|
204
|
+
|
|
205
|
+
### Two ways to use it
|
|
206
|
+
|
|
207
|
+
**1. The fixed `GameEvent` vocabulary** โ recommended for most integrations. Events logged with one of these names are automatically read as a clear positive or negative signal, with nothing else to configure:
|
|
208
|
+
|
|
209
|
+
| Event | Signal |
|
|
210
|
+
|---|---|
|
|
211
|
+
| `LEVEL_START`, `LEVEL_COMPLETE` | Positive |
|
|
212
|
+
| `LEVEL_QUIT`, `LEVEL_FAILED`, `LEVEL_RESTART`, `HINT` | Negative |
|
|
213
|
+
| `GENERIC_POSITIVE`, `GENERIC_NEGATIVE` | Use for anything else that's clearly good or bad for the player and doesn't fit the events above |
|
|
214
|
+
|
|
215
|
+
**2. A custom event name** (any string) โ for a richer, game-specific vocabulary:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
manager.logEvent('CLOCKWISE_TAP', { comboCount: 4 });
|
|
219
|
+
manager.logEvent('TWO_COLORS_MATCHED', { color: 'red' });
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Custom event names don't need to be registered in advance โ send whatever your game already tracks. They're picked up by Skillprint's scoring as additional context alongside screenshots. If you want a custom event to map to a specific improvement in scoring accuracy for your game, talk to your Skillprint contact about setting up a custom scoring configuration.
|
|
223
|
+
|
|
191
224
|
## API Reference
|
|
192
225
|
|
|
193
226
|
### Core Classes
|
|
@@ -202,7 +235,8 @@ manager.startGameSessionWithOverrides(
|
|
|
202
235
|
- `static getInstance(): SkillprintManager | null`
|
|
203
236
|
- `registerParameterModifier(parameterName: string, updateAction: ParameterModifierAction, expectedType?: string | null): void`
|
|
204
237
|
- `startGameSession(targetMood: Mood | string, customPlayerId?: string | null): Promise<void>`
|
|
205
|
-
- `stopGameSession(): void`
|
|
238
|
+
- `stopGameSession(): Promise<void>` โ stops capture, uploads any queued screenshots with the final batch marked `is_last_chunk` so the backend scores it and closes the session; never rejects
|
|
239
|
+
- `logEvent(event: GameEvent | string, data?: Record<string, unknown>): Promise<void>` โ see [Discrete Telemetry Events](#discrete-telemetry-events) below
|
|
206
240
|
- `getCurrentSessionId(): string | null`
|
|
207
241
|
- `getConfig(): SkillprintConfig`
|
|
208
242
|
|
|
@@ -211,6 +245,21 @@ manager.startGameSessionWithOverrides(
|
|
|
211
245
|
- `isValid(value: unknown): boolean`
|
|
212
246
|
- `convertValue(rawValue: unknown): number | boolean | string | null`
|
|
213
247
|
|
|
248
|
+
#### `SkillprintAPIClient`
|
|
249
|
+
The HTTP client `SkillprintManager` uses. Use it directly when your page already captures its own frames, or when you need session scores.
|
|
250
|
+
- `constructor(baseUrl: string, partnerApiKey?: string, logger?: SDKLogger)`
|
|
251
|
+
- `startSession(sessionId, targetMood, customPlayerId?, gameName?, gameParameters?: ParameterInfo[], options?: { deviceContext? })`
|
|
252
|
+
- `postScreenshots(sessionId, screenshots: Blob[], isLastChunk?, options?: { gameStates? })`: `gameStates[n]` (for example `{ score: 1200 }`) is sent with the n-th screenshot, and the latest `score` becomes the session's score. `inputCount` is how many player inputs the batch covers; a batch with 0 is left out of skill scores. `isLastChunk: true` scores the batch and closes the session.
|
|
253
|
+
- `getSession(sessionId): Promise<SessionResult>`: the session's `state` (`OPEN`, then `CLOSED` once scored), `skillScores`, `moodScores`, `score`, `telemetry` (adjustments and logged events) and `parameterUpdates`
|
|
254
|
+
- `pollParameterResults(sessionId)`: only the parameter updates
|
|
255
|
+
- `getUserProfile()`: the player's skill profile; needs a player token
|
|
256
|
+
- `setPlayerToken(token: string | null)`: the token of a player your page has already signed in, used when `startSession` gets no `customPlayerId`
|
|
257
|
+
- `createOrGetUserToken(customPlayerId)`, `createUser(internalId)`, `getUserToken(internalId)`: need a partner key
|
|
258
|
+
|
|
259
|
+
A failed call throws `SkillprintApiError`, which carries the HTTP `status` and response `body`.
|
|
260
|
+
|
|
261
|
+
**Host mode.** A page on an origin the Skillprint API allows, such as the Skillprint portal, can sign its own players in and skip the partner key: pass `''` as `partnerApiKey` and call `setPlayerToken()`. The client then sends no `Api-Key`, and sends the player token on every session call. Sessions started this way belong to the player, not to a partner organization. When the token expires (a `401`), get a new one, call `setPlayerToken()` and retry.
|
|
262
|
+
|
|
214
263
|
---
|
|
215
264
|
|
|
216
265
|
## Development & Testing
|