Skip to content

Commit a42f6db

Browse files
committed
fix: revert changes to examples in browser
1 parent b4226c6 commit a42f6db

File tree

2 files changed

+66
-49
lines changed

2 files changed

+66
-49
lines changed

packages/browser/examples/app.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,59 @@ class HappyIntegration {
1818
}
1919
}
2020

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-
// );
27-
28-
// return {
29-
// status: 'success',
30-
// };
31-
// }
32-
// }
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+
);
27+
28+
return {
29+
status: 'success',
30+
};
31+
}
32+
}
3333

3434
Sentry.init({
3535
// Client's DSN.
36-
dsn: 'https://2838816694c54bf3973d9b08eeb429c1@dgriesser-7b0957b1732f38a5e205.eu.ngrok.io/11',
36+
dsn: 'https://363a337c11a64611be4845ad6e24f3ac@sentry.io/297378',
3737
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message
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.
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.
4444
debug: true,
4545
// Whether SDK should be enabled or not.
4646
enabled: true,
4747
// Custom integrations callback
48-
// integrations(integrations) {
49-
// return [new HappyIntegration(), ...integrations];
50-
// },
48+
integrations(integrations) {
49+
return [new HappyIntegration(), ...integrations];
50+
},
5151
// A release identifier.
5252
release: '1537345109360',
5353
// An environment identifier.
5454
environment: 'staging',
5555
// Custom event transport that will be used to send things to Sentry
56-
// transport: HappyTransport,
56+
transport: HappyTransport,
5757
// Method called for every captured event
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-
// },
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+
},
7474
// Method called for every captured breadcrumb
7575
beforeBreadcrumb(breadcrumb, hint) {
7676
// We ignore our own logger and rest of the buttons just for presentation purposes

packages/browser/examples/index.html

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,33 @@
44
<meta charset="utf-8" />
55
<title>@sentry/browser SDK examples</title>
66
<script src="bundle.js"></script>
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> -->
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+
}
916

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>
17+
button:hover {
18+
background: #ddd;
19+
}
20+
</style>
1721
</head>
18-
<body></body>
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>
1936
</html>

0 commit comments

Comments
 (0)