Eitri Shopping Modules


Eitri Shopping Modules are collections of functions complementary to those available in Eitri Bifrost exclusive to Eitri Shopping apps that allow an eitri app to call native code to perform a multitude of operations, such as using the mobile device's camera, manipulating the navigation backstack, sending logs to Firebase, among others.

Operation

Provided that you already imported Eitri Bifrost, accessing the modules requires first calling the async modules() method to get the modules descriptor, then checking if the specific module exists (graceful degradation), and finally invoking the desired method.

For example, this is how you would use the logEvent method from the Firebase module:

// Get the modules descriptor
const modules = await Eitri.modules();

// Resolve the namespace: apps built before `firebase` shipped expose `fb` only
const firebase = modules?.firebase ?? modules?.fb;

// Check if the firebase module exists
if (!firebase?.logEvent) {
console.log("Firebase module is not available");
return;
}

// Use the method
await firebase.logEvent({eventName: "event", data: {key: "value"}})

Here, the namespace for the Firebase module functions is 'firebase', and the method that was called from this group of functions is logEvent

Note on the fb namespace

The Firebase module is also reachable through the legacy 'fb' namespace. Both namespaces reference the same native implementation, so modules.fb.logEvent(...) and modules.firebase.logEvent(...) behave identically.

fb is deprecated and kept for backwards compatibility — it remains fully supported and existing apps do not need to change. New code should use firebase, which names the service unambiguously: fb is easily read as Facebook, which is a separate module under the 'facebook' namespace.

Availability: firebase only exists on apps built with a native runtime that exposes it. On apps built before that, modules.firebase is undefined while modules.fb still works. Because the availability check is optional-chained, reading modules.firebase directly on an older app does not raise an error — it silently skips the call and analytics stop being recorded. Resolve the namespace with modules?.firebase ?? modules?.fb, as shown above, until every target app has been rebuilt.

Capabilities

Documentation of available methods