EMBR-10483: Switch to a buffered POST beacon for JS errors#82
Conversation
39e688e to
ac9d046
Compare
| // Return the connection type based on Network Information API. | ||
| // Note this API is in flux. | ||
| function connectionType() { | ||
| function connectionType(): string | undefined { |
There was a problem hiding this comment.
Originally the only change here was an explicit return type, but I felt the need to refactor the function body as well. navigator.connection is only ever slow-2g, 2g, 3g, or 4g. The SDK turns these into "friendly" values by upper-casing them, with the exception being "Slow 2G". The previous logic was overly complicated for such a simple transform.
| @@ -0,0 +1,15 @@ | |||
| const sendBeaconFallback = (url: string, data: string) => { | |||
There was a problem hiding this comment.
Extracted this from beacon.ts since it's now shared between two beacons.
| expect(nt.requestStart).toBeGreaterThan(0); | ||
| // requestStart can floor to 0 on fast localhost connections where the | ||
| // sub-millisecond time between navigationStart and requestStart is rounded down | ||
| expect(nt.requestStart).toBeGreaterThanOrEqual(0); |
There was a problem hiding this comment.
Unrelated but hopefully fixes a flaky integration test that was blocking the PR.
| return { | ||
| allowEmptyPostBeacon: getProperty(obj, "allowEmptyPostBeacon", false), | ||
| auto: autoMode, | ||
| errorBeaconDelay: getProperty(obj, "errorBeaconDelay", 200), |
There was a problem hiding this comment.
Note this is similar to interactionBeaconDelay below.
832ecb1 to
ee33a18
Compare
|
|
||
| export function navigationType() { | ||
| export function navigationType(): number | undefined { | ||
| if (performance.navigation && typeof performance.navigation.type !== "undefined") { |
There was a problem hiding this comment.
probably a separate PR but just noting this has been deprecated: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigation/type
There was a problem hiding this comment.
@jpmunz yeah there's quite a bit of old code in this SDK. Some of it is intentional to support old browsers, but I am definitely leaning towards just removing it these days. I don't think anyone will mind if IE11 doesn't have a navigation type :)
6cf3605 to
7823e0c
Compare
7823e0c to
717485a
Compare
Related: https://github.com/embrace-io/speedcurve-rum-beacons-edge-service/pull/31