Skip to content

Commit

Permalink
Update protocol namings
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Sep 10, 2021
1 parent f5f0411 commit 0e585c2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/browser/src/transports/fetch.ts
Expand Up @@ -113,7 +113,7 @@ export class FetchTransport extends BaseTransport {
*/
private _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response> {
if (this._isRateLimited(sentryRequest.type)) {
this.recordLostEvent(Outcome.RateLimit, sentryRequest.type);
this.recordLostEvent(Outcome.RateLimitBackoff, sentryRequest.type);

return Promise.reject({
event: originalPayload,
Expand Down Expand Up @@ -164,7 +164,7 @@ export class FetchTransport extends BaseTransport {
)
.then(undefined, reason => {
if (reason instanceof SentryError) {
this.recordLostEvent(Outcome.QueueSize, sentryRequest.type);
this.recordLostEvent(Outcome.QueueOverflow, sentryRequest.type);
} else {
this.recordLostEvent(Outcome.NetworkError, sentryRequest.type);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/transports/xhr.ts
Expand Up @@ -26,7 +26,7 @@ export class XHRTransport extends BaseTransport {
*/
private _sendRequest(sentryRequest: SentryRequest, originalPayload: Event | Session): PromiseLike<Response> {
if (this._isRateLimited(sentryRequest.type)) {
this.recordLostEvent(Outcome.RateLimit, sentryRequest.type);
this.recordLostEvent(Outcome.RateLimitBackoff, sentryRequest.type);

return Promise.reject({
event: originalPayload,
Expand Down Expand Up @@ -65,7 +65,7 @@ export class XHRTransport extends BaseTransport {
)
.then(undefined, reason => {
if (reason instanceof SentryError) {
this.recordLostEvent(Outcome.QueueSize, sentryRequest.type);
this.recordLostEvent(Outcome.QueueOverflow, sentryRequest.type);
} else {
this.recordLostEvent(Outcome.NetworkError, sentryRequest.type);
}
Expand Down
12 changes: 6 additions & 6 deletions packages/browser/test/unit/transports/base.test.ts
Expand Up @@ -49,7 +49,7 @@ describe('BaseTransport', () => {
visibilityState = 'hidden';
document.dispatchEvent(new Event('visibilitychange'));

const outcomes = [{ reason: 'before_send', category: 'error', quantity: 1 }];
const outcomes = [{ reason: Outcome.BeforeSend, category: 'error', quantity: 1 }];

expect(sendBeaconSpy).toHaveBeenCalledWith(
envelopeEndpoint,
Expand All @@ -75,16 +75,16 @@ describe('BaseTransport', () => {
transport.recordLostEvent(Outcome.SampleRate, 'transaction');
transport.recordLostEvent(Outcome.NetworkError, 'session');
transport.recordLostEvent(Outcome.NetworkError, 'session');
transport.recordLostEvent(Outcome.RateLimit, 'event');
transport.recordLostEvent(Outcome.RateLimitBackoff, 'event');

visibilityState = 'hidden';
document.dispatchEvent(new Event('visibilitychange'));

const outcomes = [
{ reason: 'before_send', category: 'error', quantity: 2 },
{ reason: 'sample_rate', category: 'transaction', quantity: 1 },
{ reason: 'network_error', category: 'session', quantity: 2 },
{ reason: 'rate_limit', category: 'error', quantity: 1 },
{ 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 },
];

expect(sendBeaconSpy).toHaveBeenCalledWith(
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/test/unit/transports/fetch.test.ts
Expand Up @@ -129,7 +129,7 @@ describe('FetchTransport', () => {
try {
await transport.sendEvent(transactionPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.QueueSize, 'transaction');
expect(spy).toHaveBeenCalledWith(Outcome.QueueOverflow, 'transaction');
}
});

Expand Down Expand Up @@ -490,13 +490,13 @@ describe('FetchTransport', () => {
try {
await transport.sendEvent(eventPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.RateLimit, 'event');
expect(spy).toHaveBeenCalledWith(Outcome.RateLimitBackoff, 'event');
}

try {
await transport.sendEvent(transactionPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.RateLimit, 'transaction');
expect(spy).toHaveBeenCalledWith(Outcome.RateLimitBackoff, 'transaction');
}
});
});
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/test/unit/transports/xhr.test.ts
Expand Up @@ -91,7 +91,7 @@ describe('XHRTransport', () => {
try {
await transport.sendEvent(transactionPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.QueueSize, 'transaction');
expect(spy).toHaveBeenCalledWith(Outcome.QueueOverflow, 'transaction');
}
});

Expand Down Expand Up @@ -416,13 +416,13 @@ describe('XHRTransport', () => {
try {
await transport.sendEvent(eventPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.RateLimit, 'event');
expect(spy).toHaveBeenCalledWith(Outcome.RateLimitBackoff, 'event');
}

try {
await transport.sendEvent(transactionPayload);
} catch (_) {
expect(spy).toHaveBeenCalledWith(Outcome.RateLimit, 'transaction');
expect(spy).toHaveBeenCalledWith(Outcome.RateLimitBackoff, 'transaction');
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/transport.ts
Expand Up @@ -9,8 +9,8 @@ export enum Outcome {
BeforeSend = 'before_send',
EventProcessor = 'event_processor',
NetworkError = 'network_error',
QueueSize = 'queue_size',
RateLimit = 'rate_limit',
QueueOverflow = 'queue_overflow',
RateLimitBackoff = 'ratelimit_backoff',
SampleRate = 'sample_rate',
}

Expand Down

0 comments on commit 0e585c2

Please sign in to comment.