Skip to content

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 add no evidence of their own, so they cannot be used to make a session look more human.

Note: With a production appId, custom events stay on the device. The SDK sends none of them to DEA, so DEA cannot see them when you ask about a session.

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.
  • The user has consented. Events are not recorded before consent.

Usage

Record an event

import * as Dea from '@dea/react-native';

await Dea.captureEvent('level_start');

Record an event with data

const recorded = await Dea.captureEvent('level_start', {level: 3, mode: 'hard'});

captureEvent resolves true when the event was recorded and false when it was not.

Limits

Limit If exceeded
Name 1 to 64 characters The whole event is dropped
Data 1024 bytes as JSON The whole event is dropped

Data values should be strings, numbers, booleans or null. Events are also dropped — resolving false — while capture is paused and before consent.

Do not put personal information in names or data.

Examples

Mark the rounds of a game

import {useRef} from 'react';
import * as Dea from '@dea/react-native';

export function useRounds() {
  const round = useRef(0);

  const startRound = () => {
    round.current += 1;
    Dea.captureEvent('round_start', {round: round.current}).catch(() => {});
  };

  const endRound = (won: boolean) => {
    Dea.captureEvent('round_end', {round: round.current, won}).catch(() => {});
  };

  return {startRound, endRound};
}

API

Member Returns Description
captureEvent(name, data?) Promise<boolean> Records an event on the session timeline; false when it was dropped