Colocate bitdrift in logger, use logger for transport (#7868)
* Colocate bitdrift in logger, use logger for transport (cherry picked from commitcdd6941fd7) * Fix mocks, format (cherry picked from commit9de88660c6) * Ok I guess mocks dir doesn't work (cherry picked from commit9f37e52011)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export {debug, error, info, warn} from '@bitdrift/react-native'
|
||||
@@ -0,0 +1,4 @@
|
||||
export function debug() {}
|
||||
export function error() {}
|
||||
export function info() {}
|
||||
export function warn() {}
|
||||
@@ -0,0 +1,28 @@
|
||||
import {init, SessionStrategy} from '@bitdrift/react-native'
|
||||
import {Statsig} from 'statsig-react-native-expo'
|
||||
|
||||
import {initPromise} from '#/lib/statsig/statsig'
|
||||
|
||||
const BITDRIFT_API_KEY = process.env.BITDRIFT_API_KEY
|
||||
|
||||
initPromise.then(() => {
|
||||
let isEnabled = false
|
||||
let isNetworkEnabled = false
|
||||
try {
|
||||
if (Statsig.checkGate('enable_bitdrift_v2')) {
|
||||
isEnabled = true
|
||||
}
|
||||
if (Statsig.checkGate('enable_bitdrift_v2_networking')) {
|
||||
isNetworkEnabled = true
|
||||
}
|
||||
} catch (e) {
|
||||
// Statsig may complain about it being called too early.
|
||||
}
|
||||
if (isEnabled && BITDRIFT_API_KEY) {
|
||||
init(BITDRIFT_API_KEY, SessionStrategy.Activity, {
|
||||
url: 'https://api-bsky.bitdrift.io',
|
||||
// Only effects iOS, Android instrumentation is set via Gradle Plugin
|
||||
enableNetworkInstrumentation: isNetworkEnabled,
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user