How to use the react-native-firebase.isMock function in react-native-firebase

To help you get started, we’ve selected a few react-native-firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EdgeApp / edge-react-gui / src / util / tracking.js View on Github external
/**
 * Why was this account created?
 */
type CreationReason = {
  creationDate: string,
  installerId?: string
}

const CREATION_REASON_FILE = 'CreationReason.json'
const UTILITY_SERVER_FILE = 'utilityServer.json'

// Install information powered by the util server:
let installReason: InstallReason = {}

// Set up the global Firebase instance at boot:
if (ENV.USE_FIREBASE && !firebase.isMock) {
  firebase.analytics().setUserId(DeviceInfo.getUniqueID())
  global.firebase = firebase
}

/**
 * Tracks a user event, like navigating or logging in.
 */
export async function trackEvent (event: TrackingEvent, opts?: TrackingOptions = {}) {
  if (global.firebase) {
    const { accountDate, currencyCode, dollarValue, installerId, pluginId } = opts

    const params: Object = {}
    if (accountDate != null) params.adate = accountDate
    if (currencyCode != null) params.currency = currencyCode
    if (dollarValue != null) {
      params.currency = 'USD'