Set of methods that allow Eitri shopping apps to interact with Inngage.

User identity is not set here, but in session.notifyLogin and session.notifyLogout.

Methods

  • Fetches the in-app message Inngage has pending for this device, as data. The Eitri-App renders it with its own components — Inngage draws no UI.

    The app resolves everything the Inngage API needs (app token, push token, first-access flag), so this method takes no parameters.

    A message is delivered only once. The first call that returns it consumes it, and later calls return null until Inngage has a new message for the device. Render what you received instead of fetching again to re-display it.

    Returns null when there is no pending message, when Inngage is disabled in the app, when the push token is not available yet, or when the request fails. Otherwise the message is returned exactly as Inngage sends it; switch on type to render it:

    type Interface What it is
    "Message" InngageInAppMessageCard Banner. One item in media.items is a card; more is a carousel.
    "Countdown" InngageInAppCountdown Timer until endDate + endTime. No actions.
    "Scratch" InngageInAppScratch Scratch card game with prizes.
    "Wheel" InngageInAppWheel Prize wheel game.

    A good moment to call it is when a screen mounts (e.g. the home).

    Returns Promise<null | InngageInAppMessage>

    The pending in-app message, or null.

    Not confirmed by Inngage yet: how impressions and clicks are reported (probably via notId), and how a deeplink action that targets the app itself should be routed.

    Example:

    const modules = await Eitri.modules();
    const fetchInAppMessage = modules?.inngage?.fetchInAppMessage;
    if (!fetchInAppMessage) return;

    const message = await fetchInAppMessage();
    if (!message) return;

    switch (message.type) {
    case "Message":
    if (message.media.items.length > 1) {
    // render a carousel, one slide per item
    } else {
    // render a single card from message.media.items[0]
    }
    break;
    case "Countdown":
    // render message.countdown until endDate + endTime
    break;
    case "Scratch":
    // render the scratch card from message.scratch, then message.result
    break;
    case "Wheel":
    // render the wheel from message.wheel, then message.result
    break;
    }
  • Logs an event with Inngage, where each parameter of the event is defined as a key-value pair within the data object.

    To receive the event in Inngage, you must create a new event in the Inngage dashboard and ensure the event name matches the value of the eventName parameter.

    Example:

    const modules = await Eitri.modules();
    const logEvent = modules?.inngage?.logEvent;
    if (!logEvent) return;
    await logEvent({
    eventName: "event",
    data: { appLanguage: "en-US" }
    })

    Parameters

    • param: { data: Record<string, any>; eventName: string }

      Object describing the event.

      • data: Record<string, any>

        Object describing the event's data.

      • eventName: string

        Name of the event.

    Returns Promise<undefined>