Events Reference

All Qariyb components emit custom events that follow a consistent naming pattern and structure.


Event Naming

Events follow the pattern: qariyb:{component}:{action}

ComponentPrefix
Checkoutqariyb:checkout:*
Ticketsqariyb:tickets:*
Buttonqariyb:button:*
Event Cardqariyb:card:*
Event Listqariyb:list:*
SDKqariyb:initialized

Event Structure

All events have a consistent detail structure:

interface QariybEventDetail<T> {
  timestamp: number;      // Unix timestamp (ms)
  component: string;      // Component that emitted
  action: string;         // Action that occurred
  data: T;                // Event-specific payload
}

Access via event.detail:

element.addEventListener('qariyb:checkout:success', (e) => {
  console.log(e.detail.timestamp);   // 1706745600000
  console.log(e.detail.component);   // 'checkout'
  console.log(e.detail.action);      // 'success'
  console.log(e.detail.data);        // { order, tickets, ... }
});

Event Characteristics

All events:

  • Bubble: Yes (bubbles: true)
  • Cross Shadow DOM: Yes (composed: true)
  • Cancelable: Yes (cancelable: true)
  • Also dispatch on window: Yes (for global listeners)

Checkout Events

qariyb:checkout:ready

Component mounted and initialized.

{ eventId: string }

qariyb:checkout:event-loaded

Event data successfully fetched.

{ event: QariybEvent }

qariyb:checkout:event-error

Failed to load event data.

{ error: string, eventId: string }

qariyb:checkout:step-changed

Checkout step changed.

{
  from: CheckoutStep,
  to: CheckoutStep,
  eventId: string
}

// CheckoutStep = 'loading' | 'tickets' | 'details' | 'payment' | 'processing' | 'success' | 'error'

qariyb:checkout:cart-updated

Cart items modified.

{
  cart: Cart,
  action: 'add' | 'remove' | 'clear',
  ticketId?: string,
  ticketName?: string
}

qariyb:checkout:details-submitted

Customer details form submitted.

{
  email: string,
  name: string,
  phone?: string
}

qariyb:checkout:payment-started

Stripe payment initiated.

{
  cartId: string,
  amount: number,    // cents
  currency: string
}

qariyb:checkout:payment-processing

Payment being processed.

{ paymentIntentId?: string }

qariyb:checkout:discount-applied

A discount code was accepted and the PaymentIntent repriced. discount.new_total is what the card will be charged.

{
  discount: DiscountApplication,
  previousTotal: number
}

qariyb:checkout:discount-failed

A discount code was rejected. error is the server's reason — show it verbatim.

{
  code: string,
  error: string
}

qariyb:checkout:success

Checkout completed successfully.

{
  order: Order,
  tickets: OrderTicket[],
  requiresApproval: boolean
}

qariyb:checkout:error

Checkout error occurred.

{
  error: string,
  code?: string,
  step?: CheckoutStep
}

Tickets Events

qariyb:tickets:ready

Component mounted.

{ eventId: string }

qariyb:tickets:loaded

Ticket data fetched.

{
  tickets: TicketType[],
  event: QariybEvent
}

qariyb:tickets:quantity-changed

User changed ticket quantity.

{
  ticketId: string,
  ticketName: string,
  quantity: number,
  previousQuantity: number,
  price: number,       // cents
  currency: string
}

qariyb:tickets:selected

User clicked continue (via on-continue).

{
  cart: Cart,
  eventId: string
}

qariyb:tickets:error

Error loading tickets.

{
  error: string,
  eventId: string
}

Button Events

qariyb:button:ready

Component mounted.

{ eventId: string }

qariyb:button:modal-opened

Modal opened.

{ eventId: string }

qariyb:button:modal-closed

Modal closed.

{
  eventId: string,
  reason: 'success' | 'cancel' | 'escape' | 'overlay'
}

Card Events

qariyb:card:ready

Component mounted.

{ eventId: string }

qariyb:card:loaded

Event data fetched.

{ event: QariybEvent }

qariyb:card:clicked

Card interaction.

{
  event: QariybEvent,
  action: 'view' | 'tickets'
}

qariyb:card:error

Error loading event.

{
  error: string,
  eventId: string
}

List Events

qariyb:list:ready

Component mounted.

{ organizationId: string }

qariyb:list:loaded

Events fetched.

{
  events: QariybEvent[],
  total: number,
  hasMore: boolean
}

qariyb:list:error

Error loading events.

{
  error: string,
  organizationId: string
}

Global SDK Event

qariyb:initialized

SDK loaded (fires once on window).

{
  version: string,
  config: QariybConfig | undefined
}
window.addEventListener('qariyb:initialized', (e) => {
  console.log('SDK loaded:', e.detail.data.version);
});

Listening Patterns

On Specific Element

const checkout = document.querySelector('qariyb-checkout');
checkout.addEventListener('qariyb:checkout:success', handler);

On Window (Global)

window.addEventListener('qariyb:checkout:success', handler);

Using Callback Attributes

<qariyb-checkout on-success="handleSuccess"></qariyb-checkout>
<script>
  function handleSuccess(data) {
    // data = e.detail.data (unwrapped)
  }
</script>

TypeScript Event Handling

import type { QariybCustomEvent, CheckoutSuccessDetail } from '@qariyb/js';

const handler = (e: QariybCustomEvent<CheckoutSuccessDetail>) => {
  const { order, tickets } = e.detail.data;
  // Fully typed!
};

document.addEventListener('qariyb:checkout:success', handler as EventListener);

Complete Events List

EventComponentCallback Attr
qariyb:checkout:readyCheckouton-ready
qariyb:checkout:event-loadedCheckouton-event-loaded
qariyb:checkout:event-errorCheckouton-event-error
qariyb:checkout:step-changedCheckouton-step-changed
qariyb:checkout:cart-updatedCheckouton-cart-updated
qariyb:checkout:details-submittedCheckouton-details-submitted
qariyb:checkout:payment-startedCheckouton-payment-started
qariyb:checkout:payment-processingCheckouton-payment-processing
qariyb:checkout:discount-appliedCheckouton-discount-applied
qariyb:checkout:discount-failedCheckouton-discount-failed
qariyb:checkout:successCheckouton-success
qariyb:checkout:errorCheckouton-error
qariyb:tickets:readyTicketson-ready
qariyb:tickets:loadedTicketson-loaded
qariyb:tickets:quantity-changedTicketson-quantity-changed
qariyb:tickets:selectedTicketson-continue
qariyb:tickets:errorTicketson-error
qariyb:button:readyButtonon-ready
qariyb:button:modal-openedButtonon-modal-opened
qariyb:button:modal-closedButtonon-modal-closed
qariyb:card:readyCardon-ready
qariyb:card:loadedCardon-loaded
qariyb:card:clickedCardon-clicked
qariyb:card:errorCardon-error
qariyb:list:readyListon-ready
qariyb:list:loadedListon-loaded
qariyb:list:errorListon-error
qariyb:initializedSDK-

Was this page helpful?