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.
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
fbnamespaceThe Firebase module is also reachable through the legacy 'fb' namespace. Both namespaces reference the same native implementation, so
modules.fb.logEvent(...)andmodules.firebase.logEvent(...)behave identically.
fbis deprecated and kept for backwards compatibility — it remains fully supported and existing apps do not need to change. New code should usefirebase, which names the service unambiguously:fbis easily read as Facebook, which is a separate module under the 'facebook' namespace.Availability:
firebaseonly exists on apps built with a native runtime that exposes it. On apps built before that,modules.firebaseisundefinedwhilemodules.fbstill works. Because the availability check is optional-chained, readingmodules.firebasedirectly on an older app does not raise an error — it silently skips the call and analytics stop being recorded. Resolve the namespace withmodules?.firebase ?? modules?.fb, as shown above, until every target app has been rebuilt.