about summary refs log tree commit diff
path: root/src/lib/bitdrift.ts
blob: 3f892f6b8ca4301ae62dbf1a5919996e44433dab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import {init} from '@bitdrift/react-native'
import {Statsig} from 'statsig-react-native-expo'
export {debug, error, info, warn} from '@bitdrift/react-native'

import {initPromise} from './statsig/statsig'

const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY

initPromise.then(() => {
  let isEnabled = false
  try {
    if (Statsig.checkGate('enable_bitdrift')) {
      isEnabled = true
    }
  } catch (e) {
    // Statsig may complain about it being called too early.
  }
  if (isEnabled && BITDRIFT_API_KEY) {
    init(BITDRIFT_API_KEY, {url: 'https://api-bsky.bitdrift.io'})
  }
})