Don't log downsample warning when unnecessary (#4291)
* fix log use process.env ensure the log happens regardless of `isDownsampledSession` fix log * oops, revert test
This commit is contained in:
@@ -102,16 +102,19 @@ export function logEvent<E extends keyof LogEvents>(
|
|||||||
rawMetadata: LogEvents[E] & FlatJSONRecord,
|
rawMetadata: LogEvents[E] & FlatJSONRecord,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
if (
|
||||||
|
process.env.NODE_ENV === 'development' &&
|
||||||
|
eventName.endsWith(':sampled') &&
|
||||||
|
!DOWNSAMPLED_EVENTS.has(eventName)
|
||||||
|
) {
|
||||||
|
logger.error(
|
||||||
|
'Did you forget to add ' + eventName + ' to DOWNSAMPLED_EVENTS?',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) {
|
if (isDownsampledSession && DOWNSAMPLED_EVENTS.has(eventName)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (process.env.NODE_ENV === 'development') {
|
|
||||||
if (eventName.endsWith(':sampled')) {
|
|
||||||
logger.error(
|
|
||||||
'Did you forget to add ' + eventName + ' to DOWNSAMPLED_EVENTS?',
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const fullMetadata = {
|
const fullMetadata = {
|
||||||
...rawMetadata,
|
...rawMetadata,
|
||||||
} as Record<string, string> // Statsig typings are unnecessarily strict here.
|
} as Record<string, string> // Statsig typings are unnecessarily strict here.
|
||||||
|
|||||||
Reference in New Issue
Block a user