Skip to content

Commit

Permalink
Remove remaining feature flag test warning noise (#2185)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan authored Apr 25, 2023
1 parent 9b61225 commit 4bf5a36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('featureFlagContexts', () => {
})

afterEach(() => {
featureFlagContexts.stop()
resetExperimentalFeatures()
setupBuilder.cleanup()
})
Expand Down
5 changes: 4 additions & 1 deletion packages/rum-core/src/domain/contexts/featureFlagContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface FeatureFlagContexts {
findFeatureFlagEvaluations: (startTime?: RelativeTime) => FeatureFlagContext | undefined
getFeatureFlagBytesCount: () => number
addFeatureFlagEvaluation: (key: string, value: ContextValue) => void
stop: () => void
}

/**
Expand All @@ -42,6 +43,7 @@ export function startFeatureFlagContexts(
findFeatureFlagEvaluations: () => undefined,
getFeatureFlagBytesCount: () => 0,
addFeatureFlagEvaluation: noop,
stop: noop,
}
}

Expand All @@ -60,7 +62,7 @@ export function startFeatureFlagContexts(

// Throttle the bytes computation to minimize the impact on performance.
// Especially useful if the user call addFeatureFlagEvaluation API synchronously multiple times in a row
const { throttled: computeBytesCountThrottled } = throttle((context: Context) => {
const { throttled: computeBytesCountThrottled, cancel: cancelPendingComputation } = throttle((context: Context) => {
bytesCountCache = computeBytesCountImpl(jsonStringify(context)!)
if (!alreadyWarned) {
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, CustomerDataType.FeatureFlag)
Expand All @@ -84,5 +86,6 @@ export function startFeatureFlagContexts(
computeBytesCountThrottled(currentContext)
}
},
stop: cancelPendingComputation,
}
}
1 change: 1 addition & 0 deletions packages/rum-core/test/testSetupBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function setup(): TestSetupBuilder {
let featureFlagContexts: FeatureFlagContexts = {
findFeatureFlagEvaluations: () => undefined,
addFeatureFlagEvaluation: noop,
stop: noop,
getFeatureFlagBytesCount: () => 0,
}
let actionContexts: ActionContexts = {
Expand Down

0 comments on commit 4bf5a36

Please sign in to comment.