Custom Events¶
Part of the Human Scoring use case.
Mark meaningful moments in your app on the session timeline — a level starting, a form step completing, a checkout opening. Custom events annotate the session. They never change the score or the classification, so they cannot be used to make a session look more human.
Note: In the production SDK, custom events do not leave the browser: they are not sent to DEA, and the score does not read them.
When to use it¶
- To mark the steps of a flow:
checkout_open,payment_submit - To mark game or task boundaries:
level_start,round_end
Prerequisites¶
- The SDK is installed and initialized. See the Quick Start.
Usage¶
Record an event¶
Record an event with data¶
import { DeaSdk } from '@dea/sdk';
DeaSdk.current?.captureEvent('level_start', { level: 3, mode: 'hard' });
Limits¶
| Limit | If exceeded | |
|---|---|---|
| Name | 1–64 characters | The event is dropped and captureEvent returns false |
| Data | 1024 bytes as JSON | The event is kept without its data |
Data that cannot be converted to JSON (a circular reference, a BigInt) is treated as over the
limit. captureEvent also returns false while capture is paused, while
the consent gate is closed, and after dispose().
Do not put personal information in names or data.
Examples¶
Mark the steps of a checkout¶
import { DeaSdk } from '@dea/sdk';
const dea = DeaSdk.current;
dea?.captureEvent('checkout_open', { items: cart.length });
// …
dea?.captureEvent('checkout_submit', { method: 'card' });
cart stands for your own code.
API¶
| Member | Returns | Description |
|---|---|---|
captureEvent(name, data?) |
boolean |
true when the event was recorded |