@fiit/record-relay
v0.2.3
Published
Browser-safe client for emitting events to a [record-relay](https://github.com/getfiit/sre-recordrelay) server.
Downloads
6,073
Maintainers
Keywords
Readme
@fiit/record-relay
Browser-safe client for emitting events to a record-relay server.
Installation
yarn add @fiit/record-relayUsage
import { createRecordRelayClient } from '@fiit/record-relay';
const relay = createRecordRelayClient({
baseUrl: 'https://your-relay-server.example.com',
writeKey: 'your-write-key',
});
await relay.emit('user.signed_in', { userId: '123' });The writeKey is a write-only credential scoped to your project — it is safe to include in browser bundles.
API
createRecordRelayClient(config)
| Option | Type | Description |
|---|---|---|
| baseUrl | string | Base URL of your record-relay server |
| writeKey | string | Project write key |
Returns a RecordRelayClient with a single method:
client.emit(event, data)
Emits an event. Always resolves — network errors and non-2xx responses are logged as warnings and swallowed so they never interrupt your application.
| Param | Type | Description |
|---|---|---|
| event | string | Event name, e.g. "user.signed_in" |
| data | Record<string, unknown> | Arbitrary event payload |
