@loop/events
Event definitions and Trigger.dev integration for Loop Health background jobs.
Installation
pnpm add @loop/eventsEvent Types
import { EventTypes } from '@loop/events';
EventTypes.USER_CREATED // 'user.created'
EventTypes.STACK_CREATED // 'stack.created'
EventTypes.LAB_UPLOADED // 'lab.uploaded'
EventTypes.CART_CHECKOUT // 'cart.checkout'
EventTypes.WEARABLE_SYNC // 'wearable.sync'
// ... and moreEmitting Events
import { emitEvent, EventTypes } from '@loop/events';
await emitEvent(EventTypes.LAB_UPLOADED, {
userId: 'user_123',
labId: 'lab_456',
provider: 'Quest Diagnostics',
});Events are published to Trigger.dev, which processes them via background jobs.
Event Schemas
Each event type has a corresponding Zod schema:
import { EventSchemas } from '@loop/events';
const validated = EventSchemas.LAB_UPLOADED.parse({
userId: 'user_123',
labId: 'lab_456',
});Trigger.dev Jobs
Events trigger background jobs defined in apps/trigger/:
| Event | Job | Description |
|---|---|---|
wearable.sync | syncWearablesDaily | Daily wearable data sync |
lab.uploaded | — | Process uploaded lab report |
user.created | — | Initialize user profile |
See Data Sync & Jobs for more details on background job configuration.