2.1.0 • Published 1 year ago

@execonline-inc/firebase-analytics-wrapper v2.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

firebase-analytics-wrapper

This package abstracts the use of the Firebase analytics package primarily to prevent compilation errors for non-mobile platforms.

Why?

The web requires the use of standard Google Analytics, but that is not compatible with mobile apps, where Google's Firebase Analytics must be used instead.

Unfortunately, the reference of the Firebase Analytics package by any web code causes compilation errors during bundling. The bundler must include the package during compilation for the chance that it is referenced at runtime, but there is some incompatible code for the package import which the bundler cannot resolve.

Since static imports are required, there needs to be some abstraction between the use of the Firebase analytics package and its implementation so that reference of the package does not cause compilation or runtime errors for the platform(s) where the code does not need to be executed.

How?

Abstracting the implementations within a JS package allows such decoupling of the implementations where each build can reference only the implementation relevant to its target platform, avoiding any unintended reference on other platforms.

This decoupling is achieved with the react-native (and browser when relevant) fields in the package.json file which reference separate web/mobile implementations that can conform to a singular interface.

Currently, this package is specific to the mobile implementation using Firebase, but it could be updated to add a web implementation.