Set of methods allow eitri shopping apps to use Firebase native code methods. Through these methods, it is possible to log events, errors, crashes, the name of screens where functions have been called and it's class set an user's ID and set user properties.

Availability: the firebase namespace is only present on apps built with a native runtime that exposes it. Apps built before it shipped expose the same methods under fb only, and modules.firebase is undefined there — an optional-chained guard such as if (!modules?.firebase?.logEvent) return; would silently skip the call and stop recording analytics rather than raise an error.

To support apps already in the field, resolve the namespace before use:

const modules = await Eitri.modules();
const firebase = modules?.firebase ?? modules?.fb;
if (!firebase?.logEvent) {
console.log("Firebase module is not available");
return;
}
await firebase.logEvent({eventName: "event", data: {appLanguage: "en-US"}})

Hierarchy (View Summary)

  • Firebase

Methods

  • Logs a crash message in Firebase. This API is avaliable to maintain retrocompatibility with legacy code. It's internal implementation is the same as implementation for logError.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.crashLog) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.crashLog({message: "App Crashed"})

    Parameters

    • param: { message: string }

      Object for future destructuring containing the message of the error as it's single attribute

      • message: string

        The message of the error.

    Returns Promise<undefined>

  • Logs screen_view events in Firebase, sending the name of the screen and it's class.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.currentScreen) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.currentScreen({screen: "Home", screenClass: "HomeScreen"})

    Parameters

    • param: { screen: string; screenClass: string }

      Object for future destructuring containing the name of the screen and it's class.

      • screen: string

        Name of the screen.

      • screenClass: string

        Name of the class that represents the screen.

    Returns Promise<undefined>

  • Returns the Firebase Analytics app instance ID for this installation. This is the identifier Firebase/GA4 uses to key a single app installation (e.g. as app_instance_id in BigQuery exports).

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.getAppInstanceId) {
    console.log("Firebase module is not available");
    return;
    }
    const appInstanceId = await firebase.getAppInstanceId()

    Returns Promise<null | string>

    • The Analytics app instance ID, or null if unavailable (e.g. when analytics collection is disabled).
  • Returns the Firebase Cloud Messaging (FCM) registration token for this installation. This is the token used to address push notifications to this device through FCM. It may rotate over time (e.g. after a reinstall or when the app data is cleared), so read it when needed instead of persisting it indefinitely.

    Requirements: this method is only exposed when enabled in the Eitri Shopping App native configuration by setting firebaseFcmToken: { active: true } in the brand's app configuration file. When disabled, it is absent from the namespace and modules.firebase.getFcmToken is undefined.

    const modules = await Eitri.modules();
    const getFcmToken = modules?.firebase?.getFcmToken;
    if (!getFcmToken) {
    console.log("firebase.getFcmToken is not available");
    return;
    }
    const fcmToken = await getFcmToken()

    Returns Promise<null | string>

    • The FCM registration token, or null if unavailable (e.g. on iOS before the device has registered for remote notifications with APNs, or when the token request fails).
  • Returns the current Firebase Analytics session ID for this installation. This identifies the active analytics session and changes between sessions — it is not a stable per-user or per-installation identifier.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.getSessionId) {
    console.log("Firebase module is not available");
    return;
    }
    const sessionId = await firebase.getSessionId()

    Returns Promise<null | string>

    • The Analytics session ID as a string, or null if unavailable (e.g. when analytics collection is disabled or the session has expired).
  • Logs a error message in Firebase.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.logError) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.logError({message: "Error message"})

    Parameters

    • param: { message: string }

      Object for future destructuring containing the message of the error as it's single attribute

      • message: string

        The message of the error.

    Returns Promise<undefined>

  • Logs an app event in Firebase. The event can have up to 25 parameters, each being represented by the key-value pairs contained in the data object.

    Example:

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.logEvent) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.logEvent({eventName: "event", data: {appLanguage: "en-US"}})

    Parameters

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

      Object describing the event.

      • data: Record<string, string | number>

        Object describing the event's data.

        Keys for a parameter's name can be up to 40 characters long, must start with an alphabetic character and contain only alphanumeric characters and underscores, as dictated by Firebase.

        The value for a key can be up to 100 characters long if it is a string.

      • eventName: string

        Name of the event.

        Firebase dictates it must contain 1 to 40 alphanumeric characters or udndescores and start with an alphabetic character.

    Returns Promise<undefined>

  • Sets the user ID property.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.setUserId) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.setUserId({id: "123456"})

    Parameters

    • param: { id: string }

      Object containing an 'id' attribute for future destructuring.

      • id: string

        ID property for the user.

    Returns Promise<undefined>

  • Sets a user property.

    const modules = await Eitri.modules();
    const firebase = modules?.firebase ?? modules?.fb;
    if (!firebase?.setUserProperty) {
    console.log("Firebase module is not available");
    return;
    }
    await firebase.setUserProperty({key: "age", value: "23"})

    Parameters

    • param: { key: string; value: string }

      Object containing key/value pairs for future destructuring.

      • key: string

        Name for the user's property.

      • value: string

        Value for the user's property of name defined in param.key.

    Returns Promise<undefined>