Skip to Content
Packages@loop/events

@loop/events

Event definitions and Trigger.dev integration for Loop Health background jobs.

Installation

pnpm add @loop/events

Event 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 more

Emitting 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/:

EventJobDescription
wearable.syncsyncWearablesDailyDaily wearable data sync
lab.uploadedProcess uploaded lab report
user.createdInitialize user profile

See Data Sync & Jobs for more details on background job configuration.