Skip to content

EventsService

Track user activities and transactions.

Methods

MethodDescription
create(data)Create a single event
createBatch(events)Create multiple events
list(options)List events
listForPass(passId, options?)List events for a pass
get(id)Get a single event
aggregate(query)Aggregate event data
getTypes(workspaceId)Get distinct event types
getSources(workspaceId)Get distinct event sources
deleteBatch(options)Delete multiple events
recordPurchase(passId, data)Record a purchase
recordRefund(passId, data)Record a refund
recordCheckIn(passId, data)Record a check-in
recordActivity(passId, data)Record an activity
recordFieldChange(passId, data)Record a field change

Convenience Methods

typescript
// Record a purchase transaction
await client.events.recordPurchase('pass-uuid', {
  amount: 49.99,
  currency: 'USD',
  source: 'pos-terminal-1',
  metadata: {
    order_id: 'ORD-12345',
    items: ['Coffee', 'Sandwich']
  }
});

// Record a refund
await client.events.recordRefund('pass-uuid', {
  amount: 10.00,
  currency: 'USD',
  metadata: { reason: 'Item out of stock' }
});

// Record a check-in
await client.events.recordCheckIn('pass-uuid', {
  source: 'store-downtown',
  metadata: { location: 'Main Entrance' }
});

// Record custom activity
await client.events.recordActivity('pass-uuid', {
  event_type: 'custom',
  source: 'mobile-app',
  metadata: { action: 'viewed_offers' }
});

// Record a field change
await client.events.recordFieldChange('pass-uuid', {
  field_name: 'points',
  old_value: '100',
  new_value: '150',
  source: 'loyalty-engine'
});

create()

Create a single event with full control.

typescript
await client.events.create({
  pass_id: 'pass-uuid',
  event_category: 'transaction',
  event_type: 'purchase',
  amount: 25.00,
  currency: 'USD',
  event_timestamp: '2024-01-15T14:30:00Z',
  external_id: 'ext-12345',
  source: 'website',
  metadata: {
    order_id: 'WEB-789',
    channel: 'online'
  }
});

createBatch()

Create up to 1000 events at once.

typescript
const result = await client.events.createBatch([
  {
    pass_id: 'pass-1',
    event_category: 'activity',
    event_type: 'check_in'
  },
  {
    pass_id: 'pass-2',
    event_category: 'transaction',
    event_type: 'purchase',
    amount: 15.00,
    currency: 'USD'
  }
]);

console.log(`Created: ${result.created}, Failed: ${result.failed}`);
if (result.errors) {
  console.log('Errors:', result.errors);
}

list() / listForPass()

Query events.

typescript
// List events for workspace
const events = await client.events.list({
  workspace_id: 'ws-uuid',
  event_category: 'transaction',
  limit: 50
});

// List events for specific pass
const passEvents = await client.events.listForPass('pass-uuid', {
  event_category: 'activity',
  limit: 20
});

aggregate()

Compute aggregated statistics.

typescript
// Total revenue this month
const revenue = await client.events.aggregate({
  workspace_id: 'ws-uuid',
  function: 'sum',
  field: 'amount',
  event_category: 'transaction',
  event_types: ['purchase'],
  time_window: 'month'
});
console.log(`Monthly revenue: $${revenue.value}`);

// Average transaction amount
const avgTransaction = await client.events.aggregate({
  workspace_id: 'ws-uuid',
  function: 'avg',
  field: 'amount',
  event_category: 'transaction',
  time_window: 'quarter'
});

// Check-in count this week
const checkins = await client.events.aggregate({
  workspace_id: 'ws-uuid',
  function: 'count',
  event_category: 'activity',
  event_types: ['check_in'],
  time_window: 'week'
});

// Per-pass totals
const topSpenders = await client.events.aggregate({
  workspace_id: 'ws-uuid',
  function: 'sum',
  field: 'amount',
  event_category: 'transaction',
  time_window: 'year',
  group_by_pass: true
});

Event Categories

CategoryTypesFields
transactionpurchase, refund, payment, charge, creditamount, currency
activitycheck_in, check_out, visit, scan, app_open, link_click, notification_received, notification_opened, pass_installed, pass_uninstalled, pass_registered, custom-
field_changefield_updated, field_increment, field_decrementfield_name, old_value, new_value

Activity Event Types Reference

TypeDescriptionUse Case
check_inCustomer checks in at a locationGym entries, store visits, event attendance
check_outCustomer checks out from a locationGym departures, session end tracking
visitGeneral visit without formal check-inStore browsing, location tracking
scanPass barcode/QR code scannedPOS lookups, access control
app_openUser opens the wallet appApp engagement tracking
link_clickUser clicks a link on the passWeb traffic attribution
notification_receivedPush notification deliveredDelivery confirmation
notification_openedUser opens a notificationEngagement measurement
pass_installedPass added to walletOnboarding tracking
pass_uninstalledPass removed from walletChurn tracking
pass_registeredUser completes registrationSignup funnel tracking
customAny custom activity typeFlexible tracking

Activity Event Examples

typescript
// Record a check-out (gym departure)
await client.events.recordActivity('pass-uuid', {
  event_type: 'check_out',
  source: 'gym-entrance',
  metadata: { duration_minutes: 75 }
});

// Record pass installation
await client.events.recordActivity('pass-uuid', {
  event_type: 'pass_installed',
  source: 'wallet-callback',
  metadata: { platform: 'apple_wallet' }
});

// Record notification opened
await client.events.recordActivity('pass-uuid', {
  event_type: 'notification_opened',
  source: 'push-service',
  metadata: { campaign_id: 'camp-123', notification_id: 'notif-456' }
});

// Record pass registration
await client.events.recordActivity('pass-uuid', {
  event_type: 'pass_registered',
  source: 'registration-form',
  metadata: { registration_source: 'website', referral_code: 'SUMMER2024' }
});

// Record link click
await client.events.recordActivity('pass-uuid', {
  event_type: 'link_click',
  source: 'pass-back-link',
  metadata: { link_url: 'https://example.com/offers', link_label: 'View Offers' }
});

WalletHero Documentation