Skip to content

Commit b4226c6

Browse files
committed
fix: Remove beacon transport
1 parent 737ee34 commit b4226c6

File tree

10 files changed

+93
-289
lines changed

10 files changed

+93
-289
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 5.0.0-rc.2
4+
5+
- [browser] fix: Remove beacon transport.
6+
37
## 5.0.0-rc.1
48

59
- [node] fix: Check if buffer isReady before sending/creating Promise for request.

packages/browser/examples/app.js

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Very happy integration that'll prepend and append very happy stick figure to the message
22
class HappyIntegration {
33
constructor() {
4-
this.name = "HappyIntegration";
4+
this.name = 'HappyIntegration';
55
}
66

77
setupOnce() {
8-
Sentry.addGlobalEventProcessor(async (event) => {
8+
Sentry.addGlobalEventProcessor(async event => {
99
const self = getCurrentHub().getIntegration(HappyIntegration);
1010
// Run the integration ONLY when it was installed on the current Hub
1111
if (self) {
12-
if (event.message === "Happy Message") {
12+
if (event.message === 'Happy Message') {
1313
event.message = `\\o/ ${event.message} \\o/`;
1414
}
1515
}
@@ -18,141 +18,144 @@ class HappyIntegration {
1818
}
1919
}
2020

21-
class HappyTransport extends Sentry.Transports.BaseTransport {
22-
captureEvent(event) {
23-
console.log(`This is the place where you'd implement your own sending logic. It'd get url: ${this.url} and an event itself:`, event);
21+
// class HappyTransport extends Sentry.Transports.BaseTransport {
22+
// captureEvent(event) {
23+
// console.log(
24+
// `This is the place where you'd implement your own sending logic. It'd get url: ${this.url} and an event itself:`,
25+
// event,
26+
// );
2427

25-
return {
26-
status: 'success'
27-
}
28-
}
29-
}
28+
// return {
29+
// status: 'success',
30+
// };
31+
// }
32+
// }
3033

3134
Sentry.init({
3235
// Client's DSN.
33-
dsn: "https://363a337c11a64611be4845ad6e24f3ac@sentry.io/297378",
36+
dsn: 'https://2838816694c54bf3973d9b08eeb429c1@dgriesser-7b0957b1732f38a5e205.eu.ngrok.io/11',
3437
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message
35-
ignoreErrors: [/PickleRick_\d\d/, "RangeError"],
36-
// // An array of strings or regexps that'll be used to ignore specific errors based on their origin url
37-
blacklistUrls: ["external-lib.js"],
38-
// // An array of strings or regexps that'll be used to allow specific errors based on their origin url
39-
whitelistUrls: ["http://localhost:5000", "https://browser.sentry-cdn"],
40-
// // Debug mode with valuable initialization/lifecycle informations.
38+
// ignoreErrors: [/PickleRick_\d\d/, "RangeError"],
39+
// // // An array of strings or regexps that'll be used to ignore specific errors based on their origin url
40+
// blacklistUrls: ["external-lib.js"],
41+
// // // An array of strings or regexps that'll be used to allow specific errors based on their origin url
42+
// whitelistUrls: ["http://localhost:5000", "https://browser.sentry-cdn"],
43+
// // // Debug mode with valuable initialization/lifecycle informations.
4144
debug: true,
4245
// Whether SDK should be enabled or not.
4346
enabled: true,
4447
// Custom integrations callback
45-
integrations(integrations) {
46-
return [new HappyIntegration(), ...integrations];
47-
},
48+
// integrations(integrations) {
49+
// return [new HappyIntegration(), ...integrations];
50+
// },
4851
// A release identifier.
49-
release: "1537345109360",
52+
release: '1537345109360',
5053
// An environment identifier.
51-
environment: "staging",
54+
environment: 'staging',
5255
// Custom event transport that will be used to send things to Sentry
53-
transport: HappyTransport,
56+
// transport: HappyTransport,
5457
// Method called for every captured event
55-
async beforeSend(event, hint) {
56-
// Because beforeSend and beforeBreadcrumb are async, user can fetch some data
57-
// return a promise, or whatever he wants
58-
// Our CustomError defined in errors.js has `someMethodAttachedToOurCustomError`
59-
// which can mimick something like a network request to grab more detailed error info or something.
60-
// hint is original exception that was triggered, so we check for our CustomError name
61-
if (hint.originalException.name === "CustomError") {
62-
const serverData = await hint.originalException.someMethodAttachedToOurCustomError();
63-
event.extra = {
64-
...event.extra,
65-
serverData
66-
};
67-
}
68-
console.log(event);
69-
return event;
70-
},
58+
// async beforeSend(event, hint) {
59+
// // Because beforeSend and beforeBreadcrumb are async, user can fetch some data
60+
// // return a promise, or whatever he wants
61+
// // Our CustomError defined in errors.js has `someMethodAttachedToOurCustomError`
62+
// // which can mimick something like a network request to grab more detailed error info or something.
63+
// // hint is original exception that was triggered, so we check for our CustomError name
64+
// if (hint.originalException.name === 'CustomError') {
65+
// const serverData = await hint.originalException.someMethodAttachedToOurCustomError();
66+
// event.extra = {
67+
// ...event.extra,
68+
// serverData,
69+
// };
70+
// }
71+
// console.log(event);
72+
// return event;
73+
// },
7174
// Method called for every captured breadcrumb
7275
beforeBreadcrumb(breadcrumb, hint) {
7376
// We ignore our own logger and rest of the buttons just for presentation purposes
74-
if (breadcrumb.message.startsWith("Sentry Logger")) return null;
75-
if (breadcrumb.category !== "ui.click" || hint.event.target.id !== "breadcrumb-hint") return null;
77+
if (breadcrumb.message.startsWith('Sentry Logger')) return null;
78+
if (breadcrumb.category !== 'ui.click' || hint.event.target.id !== 'breadcrumb-hint') return null;
7679

7780
// If we have a `ui.click` type of breadcrumb, eg. clicking on a button we defined in index.html
7881
// We will extract a `data-label` attribute from it and use it as a part of the message
79-
if (breadcrumb.category === "ui.click") {
82+
if (breadcrumb.category === 'ui.click') {
8083
const label = hint.event.target.dataset.label;
8184
if (label) {
8285
breadcrumb.message = `User clicked on a button with label "${label}"`;
8386
}
8487
}
8588
console.log(breadcrumb);
8689
return breadcrumb;
87-
}
90+
},
8891
});
8992

9093
// Testing code, irrelevant vvvvv
9194

92-
document.addEventListener("DOMContentLoaded", () => {
93-
document.querySelector("#blacklist-url").addEventListener("click", () => {
94-
const script = document.createElement("script");
95-
script.crossOrigin = "anonymous";
95+
document.addEventListener('DOMContentLoaded', () => {
96+
document.querySelector('#blacklist-url').addEventListener('click', () => {
97+
const script = document.createElement('script');
98+
script.crossOrigin = 'anonymous';
9699
script.src =
97-
"https://rawgit.com/kamilogorek/cfbe9f92196c6c61053b28b2d42e2f5d/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/external-lib.js";
100+
'https://rawgit.com/kamilogorek/cfbe9f92196c6c61053b28b2d42e2f5d/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/external-lib.js';
98101
document.body.appendChild(script);
99102
});
100103

101-
document.querySelector("#whitelist-url").addEventListener("click", () => {
102-
const script = document.createElement("script");
103-
script.crossOrigin = "anonymous";
104+
document.querySelector('#whitelist-url').addEventListener('click', () => {
105+
const script = document.createElement('script');
106+
script.crossOrigin = 'anonymous';
104107
script.src =
105-
"https://rawgit.com/kamilogorek/cb67dafbd0e12b782bdcc1fbcaed2b87/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/lib.js";
108+
'https://rawgit.com/kamilogorek/cb67dafbd0e12b782bdcc1fbcaed2b87/raw/3aef6ff5e2fd2ad4a84205cd71e2496a445ebe1d/lib.js';
106109
document.body.appendChild(script);
107110
});
108111

109-
document.querySelector("#ignore-message").addEventListener("click", () => {
110-
throw new Error("Exception that will be ignored because of this keyword => PickleRick_42 <=");
112+
document.querySelector('#ignore-message').addEventListener('click', () => {
113+
throw new Error('Exception that will be ignored because of this keyword => PickleRick_42 <=');
111114
});
112115

113-
document.querySelector("#ignore-type").addEventListener("click", () => {
116+
document.querySelector('#ignore-type').addEventListener('click', () => {
114117
throw new RangeError("Exception that will be ignored because of it's type");
115118
});
116119

117-
document.querySelector("#regular-exception").addEventListener("click", () => {
120+
document.querySelector('#regular-exception').addEventListener('click', () => {
118121
throw new Error(`Regular exception no. ${Date.now()}`);
119122
});
120123

121-
document.querySelector("#capture-exception").addEventListener("click", () => {
124+
document.querySelector('#capture-exception').addEventListener('click', () => {
122125
Sentry.captureException(new Error(`captureException call no. ${Date.now()}`));
123126
});
124127

125-
document.querySelector("#capture-message").addEventListener("click", () => {
128+
document.querySelector('#capture-message').addEventListener('click', () => {
126129
Sentry.captureMessage(`captureMessage call no. ${Date.now()}`);
127130
});
128131

129-
document.querySelector("#duplicate-exception").addEventListener("click", () => {
130-
Sentry.captureException(new Error("duplicated exception"));
132+
document.querySelector('#duplicate-exception').addEventListener('click', () => {
133+
Sentry.captureException(new Error('duplicated exception'));
131134
});
132135

133-
document.querySelector("#duplicate-message").addEventListener("click", () => {
134-
Sentry.captureMessage("duplicate captureMessage");
136+
document.querySelector('#duplicate-message').addEventListener('click', () => {
137+
Sentry.captureMessage('duplicate captureMessage');
135138
});
136139

137-
document.querySelector("#integration-example").addEventListener("click", () => {
138-
Sentry.captureMessage("Happy Message");
140+
document.querySelector('#integration-example').addEventListener('click', () => {
141+
Sentry.captureMessage('Happy Message');
139142
});
140143

141-
document.querySelector("#exception-hint").addEventListener("click", () => {
144+
document.querySelector('#exception-hint').addEventListener('click', () => {
142145
class CustomError extends Error {
143146
constructor(...args) {
144147
super(...args);
145-
this.name = "CustomError";
148+
this.name = 'CustomError';
146149
}
147150
someMethodAttachedToOurCustomError() {
148151
return new Promise(resolve => {
149-
resolve("some data, who knows what exactly");
152+
resolve('some data, who knows what exactly');
150153
});
151154
}
152155
}
153156

154-
throw new CustomError("Hey there");
157+
throw new CustomError('Hey there');
155158
});
156159

157-
document.querySelector("#breadcrumb-hint").addEventListener("click", () => {});
160+
document.querySelector('#breadcrumb-hint').addEventListener('click', () => {});
158161
});

packages/browser/examples/index.html

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
4+
<meta charset="utf-8" />
55
<title>@sentry/browser SDK examples</title>
66
<script src="bundle.js"></script>
7-
<script src="app.js"></script>
8-
<style>
9-
button {
10-
display: block;
11-
margin: 0.5em 0;
12-
font-size: 1em;
13-
cursor: pointer;
14-
padding: 0.5em;
15-
}
7+
<!-- <script src="https://browser.sentry-cdn.com/4.6.4/bundle.min.js" crossorigin="anonymous"></script> -->
8+
<!-- <script src="https://cdn.ravenjs.com/3.26.4/raven.min.js" crossorigin="anonymous"></script> -->
169

17-
button:hover {
18-
background: #ddd;
19-
}
20-
</style>
10+
<!-- <script src="app.js"></script> -->
11+
<script type="text/javascript">
12+
Sentry.init({ dsn: 'https://2838816694c54bf3973d9b08eeb429c1@dgriesser-7b0957b1732f38a5e205.eu.ngrok.io/11' });
13+
// Raven.config('https://2838816694c54bf3973d9b08eeb429c1@dgriesser-7b0957b1732f38a5e205.eu.ngrok.io/11').install();
14+
// Raven.captureException('this is a raven test');
15+
Sentry.captureException('this is a test');
16+
</script>
2117
</head>
22-
<body>
23-
<button id="blacklist-url">blacklistUrl example</button>
24-
<button id="whitelist-url">whitelistUrl example</button>
25-
<button id="ignore-message">ignoreError message example</button>
26-
<button id="ignore-type">ignoreError type example</button>
27-
<button id="regular-exception">regularException example</button>
28-
<button id="capture-exception">captureException example</button>
29-
<button id="capture-message">captureMessage example</button>
30-
<button id="duplicate-exception">duplicated exception example</button>
31-
<button id="duplicate-message">duplicated message example</button>
32-
<button id="integration-example">integration example</button>
33-
<button id="exception-hint">event hints example</button>
34-
<button data-label="User Defined Label" id="breadcrumb-hint">breadcrumb hints example</button>
35-
</body>
36-
</html>
18+
<body></body>
19+
</html>

packages/browser/src/backend.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { BaseBackend } from '@sentry/core';
22
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
33
import { isDOMError, isDOMException, isError, isErrorEvent, isPlainObject } from '@sentry/utils/is';
44
import { addExceptionTypeValue } from '@sentry/utils/misc';
5-
import { supportsBeacon, supportsFetch } from '@sentry/utils/supports';
5+
import { supportsFetch } from '@sentry/utils/supports';
66
import { SyncPromise } from '@sentry/utils/syncpromise';
77

88
import { eventFromPlainObject, eventFromStacktrace, prepareFramesForEvent } from './parsers';
99
import { computeStackTrace } from './tracekit';
10-
import { BeaconTransport, FetchTransport, XHRTransport } from './transports';
10+
import { FetchTransport, XHRTransport } from './transports';
1111

1212
/**
1313
* Configuration options for the Sentry Browser SDK.
@@ -50,9 +50,6 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
5050
if (this._options.transport) {
5151
return new this._options.transport(transportOptions);
5252
}
53-
if (supportsBeacon()) {
54-
return new BeaconTransport(transportOptions);
55-
}
5653
if (supportsFetch()) {
5754
return new FetchTransport(transportOptions);
5855
}

0 commit comments

Comments
 (0)