Skip to content

Commit

Permalink
Reduce log trash on native
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 17, 2024
1 parent 0a549b8 commit b0446c6
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/lib/statsig/statsig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,11 @@ export function logEvent<E extends keyof LogEvents>(
if (Statsig.initializeCalled()) {
Statsig.logEvent(eventName, null, fullMetadata)
}
// Intentionally call console and bitdrift directly so we can pass rich objects.
if (isWeb) {
console.groupCollapsed(eventName)
console.log(fullMetadata)
console.groupEnd()
} else {
bitdrift.info(eventName, fullMetadata)
console.log(
eventName,
'\x1b[2m', // dim
fullMetadata,
'\x1b[0m', // undim
)
}
// Intentionally bypass the logger abstraction to log rich objects.
console.groupCollapsed(eventName)
console.log(fullMetadata)
console.groupEnd()
bitdrift.info(eventName, fullMetadata)
} catch (e) {
// A log should never interrupt the calling code, whatever happens.
logger.error('Failed to log an event', {message: e})
Expand Down

0 comments on commit b0446c6

Please sign in to comment.