-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
58 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import { Outcome } from '@sentry/types'; | ||
|
||
import { BaseTransport } from '../../../src/transports/base'; | ||
|
||
const testDsn = 'https://[email protected]/42'; | ||
|
@@ -44,12 +42,12 @@ describe('BaseTransport', () => { | |
it('sends beacon request when there are outcomes captured and visibility changed to `hidden`', () => { | ||
const transport = new SimpleTransport({ dsn: testDsn, sendClientReports: true }); | ||
|
||
transport.recordLostEvent(Outcome.BeforeSend, 'event'); | ||
transport.recordLostEvent('before_send', 'event'); | ||
|
||
visibilityState = 'hidden'; | ||
document.dispatchEvent(new Event('visibilitychange')); | ||
|
||
const outcomes = [{ reason: Outcome.BeforeSend, category: 'error', quantity: 1 }]; | ||
const outcomes = [{ reason: 'before_send', category: 'error', quantity: 1 }]; | ||
|
||
expect(sendBeaconSpy).toHaveBeenCalledWith( | ||
envelopeEndpoint, | ||
|
@@ -59,7 +57,7 @@ describe('BaseTransport', () => { | |
|
||
it('doesnt send beacon request when there are outcomes captured, but visibility state did not change to `hidden`', () => { | ||
const transport = new SimpleTransport({ dsn: testDsn, sendClientReports: true }); | ||
transport.recordLostEvent(Outcome.BeforeSend, 'event'); | ||
transport.recordLostEvent('before_send', 'event'); | ||
|
||
visibilityState = 'visible'; | ||
document.dispatchEvent(new Event('visibilitychange')); | ||
|
@@ -70,21 +68,21 @@ describe('BaseTransport', () => { | |
it('correctly serializes request with different categories/reasons pairs', () => { | ||
const transport = new SimpleTransport({ dsn: testDsn, sendClientReports: true }); | ||
|
||
transport.recordLostEvent(Outcome.BeforeSend, 'event'); | ||
transport.recordLostEvent(Outcome.BeforeSend, 'event'); | ||
transport.recordLostEvent(Outcome.SampleRate, 'transaction'); | ||
transport.recordLostEvent(Outcome.NetworkError, 'session'); | ||
transport.recordLostEvent(Outcome.NetworkError, 'session'); | ||
transport.recordLostEvent(Outcome.RateLimitBackoff, 'event'); | ||
transport.recordLostEvent('before_send', 'event'); | ||
transport.recordLostEvent('before_send', 'event'); | ||
transport.recordLostEvent('sample_rate', 'transaction'); | ||
transport.recordLostEvent('network_error', 'session'); | ||
transport.recordLostEvent('network_error', 'session'); | ||
transport.recordLostEvent('ratelimit_backoff', 'event'); | ||
|
||
visibilityState = 'hidden'; | ||
document.dispatchEvent(new Event('visibilitychange')); | ||
|
||
const outcomes = [ | ||
{ reason: Outcome.BeforeSend, category: 'error', quantity: 2 }, | ||
{ reason: Outcome.SampleRate, category: 'transaction', quantity: 1 }, | ||
{ reason: Outcome.NetworkError, category: 'session', quantity: 2 }, | ||
{ reason: Outcome.RateLimitBackoff, category: 'error', quantity: 1 }, | ||
{ reason: 'before_send', category: 'error', quantity: 2 }, | ||
{ reason: 'sample_rate', category: 'transaction', quantity: 1 }, | ||
{ reason: 'network_error', category: 'session', quantity: 2 }, | ||
{ reason: 'ratelimit_backoff', category: 'error', quantity: 1 }, | ||
]; | ||
|
||
expect(sendBeaconSpy).toHaveBeenCalledWith( | ||
|
@@ -97,12 +95,12 @@ describe('BaseTransport', () => { | |
const tunnel = 'https://hello.com/world'; | ||
const transport = new SimpleTransport({ dsn: testDsn, sendClientReports: true, tunnel }); | ||
|
||
transport.recordLostEvent(Outcome.BeforeSend, 'event'); | ||
transport.recordLostEvent('before_send', 'event'); | ||
|
||
visibilityState = 'hidden'; | ||
document.dispatchEvent(new Event('visibilitychange')); | ||
|
||
const outcomes = [{ reason: Outcome.BeforeSend, category: 'error', quantity: 1 }]; | ||
const outcomes = [{ reason: 'before_send', category: 'error', quantity: 1 }]; | ||
|
||
expect(sendBeaconSpy).toHaveBeenCalledWith( | ||
tunnel, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** JSDoc | ||
* @deprecated Use string literals - if you require type casting, cast to Outcome type | ||
*/ | ||
export enum Outcome { | ||
BeforeSend = 'before_send', | ||
EventProcessor = 'event_processor', | ||
NetworkError = 'network_error', | ||
QueueOverflow = 'queue_overflow', | ||
RateLimitBackoff = 'ratelimit_backoff', | ||
SampleRate = 'sample_rate', | ||
} |