Closed imjoehaines closed 3 months ago
NPM build
Package | |
---|---|
Before | 191.13 kB |
After | 191.20 kB |
± | +75 bytes ⚠️ |
CDN build
Unminified | Minfied | Minified + gzipped | |
---|---|---|---|
Before | 96.10 kB |
36.09 kB |
10.91 kB |
After | 95.92 kB |
35.88 kB |
10.87 kB |
± | -171 bytes 🎉 |
-215 bytes 🎉 |
-36 bytes 🎉 |
Ok | File (✨=New File) | Lines | Branches | Functions | Statements |
---|---|---|---|---|---|
🔴 | /home/runner/work/bugsnag-js-performance/bugsnag-js-performance/packages/core/lib/batch-processor.ts | 96.55% (-0.06%) |
93.75% (-0.36%) |
100% (+0%) |
96.55% (-0.06%) |
✅ | /home/runner/work/bugsnag-js-performance/bugsnag-js-performance/packages/core/lib/core.ts | 100% (+0%) |
92.3% (+0.64%) |
92.85% (+0%) |
98.36% (+0.06%) |
Total:
Lines | Branches | Functions | Statements |
---|---|---|---|
86.95%(-0.06%) | 78.2%(-0.03%) | 87.74%(-0.03%) | 83.65%(-0.07%) |
Generated against 981b3da31ac6f5d303961be606d8410ddadee0a5 on 30 July 2024 at 13:31:12 UTC
Goal
Currently we set long running timers when the
ProbabilityManager
is created or when a probability value is set in order to ensure we check for a fresh probability value at least once a day. This is necessary because if the probability is set to 0 by the server then this is the only mechanism that will eventually reset the probability to a non-zero valueThe current design leads to a warning on some versions of React Native because there are possible correctness concerns — the timers aren't triggered in the background and so won't fire until the app returns to the foreground. For our purposes this is fine, but we can avoid the warning with a small refactor
Design
This PR replaces the current
setTimeout
mechanism with a newProbabilityManager#ensureFreshProbability
method. This method can be called by consuming classes, e.g. theBatchProcessor
, to ensure that the probability value is less than 24 hours old. If it is stale then a new probability is fetched from the serverThis is also called by the backgrounding listener when the app returns to the foreground, to ensure a non-zero probability value will eventually be fetched when the probability has been set to 0