Step 1: trackUserAction
⏱ 3 mintrackUserAction() records audit events. Examples below use the global transcodes after the CDN script. With npm, import { trackUserAction } from '@bigstrider/transcodes-sdk' after init({ projectId }).
trackUserAction()
transcodes.trackUserAction(
event: {
tag: string;
severity?: 'low' | 'medium' | 'high';
status?: boolean;
error?: string;
metadata?: Record<string, unknown>;
},
options?: {
requireAuth?: boolean;
webhookNotification?: boolean;
}
): Promise<void>Event Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tag | string | Yes | Tag identifying the action (e.g., user:login) |
severity | 'low' | 'medium' | 'high' | No | Severity level. Default: 'low' |
status | boolean | No | Success/failure. Default: true |
error | string | No | Error message when status: false |
metadata | Record<string, unknown> | No | Additional metadata (e.g., { method: 'passkey' }) |
Options
| Parameter | Type | Description |
|---|---|---|
requireAuth | boolean | If true, opens login modal when user not authenticated |
webhookNotification | boolean | Send Slack webhook regardless of severity |
Basic Examples
// Success event
await transcodes.trackUserAction({
tag: 'document:create',
status: true,
metadata: { documentId: 'doc_123' },
});
// Failed event with error
await transcodes.trackUserAction({
tag: 'payment:process',
severity: 'high',
status: false,
error: 'Payment gateway timeout',
metadata: { amount: 99.99 },
});
// With webhook alert
await transcodes.trackUserAction(
{ tag: 'sensitive:action', severity: 'high', status: true },
{ webhookNotification: true }
);What’s Next
Last updated on