25a1ed1209
* WIP * Clean up growthbook code, integrate into init and sessions * Move everything out of React * Add metrics client * Move to separate file * Shared metadata cache * Ensure we update metadata when session ID changes * Ensure userMetadata is cleared when logging out * WIP revamp * Integrate feature gates into analytics context * Clean up old code * Fix useMeta util * Some comments and cleanup * Add logger to base analytics context * Refactor current route handling * Rip out LogEvent from navigation * Update tracking endpoint * Migrate toClout * Clear out statsig client * Add todo, reset logger readme * Ope fix statsig noop * Refactor logging in feed-feedback, add debug logging to metrics client * Remove LogEvents alias for Metrics * Prefer root package export * Remove Metrics alias from logger * [APP-1782] Migrate to new analytics APIs (#9735) * Migrate logEvent to useAnalytics * Migrate logger.metric to useAnalytics * Migrate tricky spot, fix types * Migrate remaining tricky spot * Missed one * Remove metric() from logger * Migrate useGate to useAnalytics * Remove all other StatSig mentions * Update event payload * Update logger tests * Mock expo method * Fix session ID bug * Add session ID test * Add test for metrics client * Clarify intent * Clean up core analytics file * Clean up the call once utils * Fix TODO * Fix TODO * Fix TODO * Fix TODO * Fix TODO * Remove debug code * Fix navigation context * OK nav context is not working, todo * Checkpoint: works but feels hacky * Fix navigation context issue * Improve feature API * Improve metric logging * Update logger tests
100 lines
2.2 KiB
TypeScript
100 lines
2.2 KiB
TypeScript
/**
|
|
* DO NOT IMPORT THIS DIRECTLY
|
|
*
|
|
* Logger contexts, defined here and used via `Logger.Context.*` static prop.
|
|
*/
|
|
export enum LogContext {
|
|
Default = 'logger',
|
|
Session = 'session',
|
|
Notifications = 'notifications',
|
|
ConversationAgent = 'conversation-agent',
|
|
DMsAgent = 'dms-agent',
|
|
ReportDialog = 'report-dialog',
|
|
FeedFeedback = 'feed-feedback',
|
|
PostSource = 'post-source',
|
|
AgeAssurance = 'age-assurance',
|
|
PolicyUpdate = 'policy-update',
|
|
Geolocation = 'geolocation',
|
|
|
|
/**
|
|
* METRIC IS FOR INTERNAL USE ONLY, don't create any other loggers using this
|
|
* context
|
|
*/
|
|
Metric = 'metric',
|
|
}
|
|
|
|
export enum LogLevel {
|
|
Debug = 'debug',
|
|
Info = 'info',
|
|
Log = 'log',
|
|
Warn = 'warn',
|
|
Error = 'error',
|
|
}
|
|
|
|
export type Transport = (
|
|
level: LogLevel,
|
|
context: LogContext | undefined,
|
|
message: string | Error,
|
|
metadata: Metadata,
|
|
timestamp: number,
|
|
) => void
|
|
|
|
/**
|
|
* A union of some of Sentry's breadcrumb properties as well as Sentry's
|
|
* `captureException` parameter, `CaptureContext`.
|
|
*/
|
|
export type Metadata = {
|
|
/**
|
|
* Reserved for appending `LogContext` in logging payloads
|
|
*/
|
|
__context__?: undefined
|
|
|
|
/**
|
|
* Reserved for inherited metadata gathered in ambient context
|
|
*/
|
|
__metadata__?: Record<string, unknown>
|
|
|
|
/**
|
|
* Applied as Sentry breadcrumb types. Defaults to `default`.
|
|
*
|
|
* @see https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/#breadcrumb-types
|
|
*/
|
|
type?:
|
|
| 'default'
|
|
| 'debug'
|
|
| 'error'
|
|
| 'navigation'
|
|
| 'http'
|
|
| 'info'
|
|
| 'query'
|
|
| 'transaction'
|
|
| 'ui'
|
|
| 'user'
|
|
|
|
/**
|
|
* Passed through to `Sentry.captureException`
|
|
*
|
|
* @see https://github.com/getsentry/sentry-javascript/blob/903addf9a1a1534a6cb2ba3143654b918a86f6dd/packages/types/src/misc.ts#L65
|
|
*/
|
|
tags?: {
|
|
[key: string]: number | string | boolean | null | undefined
|
|
}
|
|
|
|
/**
|
|
* Any additional data, passed through to Sentry as `extra` param on
|
|
* exceptions, or the `data` param on breadcrumbs.
|
|
*/
|
|
[key: string]: Serializable | Error | unknown
|
|
}
|
|
|
|
export type Serializable =
|
|
| string
|
|
| number
|
|
| boolean
|
|
| null
|
|
| undefined
|
|
| Serializable[]
|
|
| {
|
|
[key: string]: Serializable
|
|
}
|