Skip to content

Commit 8ec79f1

Browse files
authored
Additional migration notes from raven-js (getsentry#2629)
A few important keys were renamed (such as `shouldSendCallback`) without any notice in the docs. Additionally, this commit adds links to the appropriate documentation pages so the user can learn more about how to use new features, such as `withScope`.
1 parent 2c35736 commit 8ec79f1

File tree

1 file changed

+97
-2
lines changed

1 file changed

+97
-2
lines changed

MIGRATION.md

+97-2
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ Here are some examples of how the new SDKs work. Please note that the API for al
138138

139139
#### Installation
140140

141+
> [Docs](https://docs.sentry.io/platforms/javascript/#connecting-the-sdk-to-sentry)
142+
141143
_Old_:
142144

143145
```js
@@ -157,6 +159,8 @@ Sentry.init({
157159

158160
#### Set a global tag
159161

162+
> [Docs](https://docs.sentry.io/platforms/javascript/#tagging-events)
163+
160164
_Old_:
161165

162166
```js
@@ -171,6 +175,8 @@ Sentry.setTag('key', 'value');
171175

172176
#### Capture custom exception
173177

178+
> A scope must now be sent around a capture to add extra information. [Docs](https://docs.sentry.io/platforms/javascript/#unsetting-context)
179+
174180
_Old_:
175181

176182
```js
@@ -196,23 +202,29 @@ try {
196202

197203
#### Capture a message
198204

205+
> A scope must now be sent around a capture to add extra information. [Docs](https://docs.sentry.io/platforms/javascript/#unsetting-context)
206+
199207
_Old_:
200208

201209
```js
202-
Raven.captureMessage('test', 'info', { extra: { debug: false } });
210+
Raven.captureMessage('test1', 'info');
211+
Raven.captureMessage('test2', 'info', { extra: { debug: false } });
203212
```
204213

205214
_New_:
206215

207216
```js
217+
Raven.captureMessage('test1', 'info');
208218
Sentry.withScope(scope => {
209219
scope.setExtra('debug', false);
210-
Sentry.captureMessage('test', 'info');
220+
Sentry.captureMessage('test2', 'info');
211221
});
212222
```
213223

214224
#### Breadcrumbs
215225

226+
> [Docs](https://docs.sentry.io/platforms/javascript/#breadcrumbs)
227+
216228
_Old_:
217229

218230
```js
@@ -239,3 +251,86 @@ Sentry.addBreadcrumb({
239251
});
240252
```
241253

254+
### Ignoring Urls
255+
256+
> 'ignoreUrls' was renamed to 'blacklistUrls'. 'ignoreErrors', which has a similar name was not renamed. [Docs](https://docs.sentry.io/error-reporting/configuration/?platform=browser#blacklist-urls) and [Decluttering Sentry](https://docs.sentry.io/platforms/javascript/#decluttering-sentry)
257+
258+
_Old_:
259+
260+
```js
261+
Sentry.init({
262+
ignoreUrls: [
263+
'https://www.baddomain.com',
264+
/graph\.facebook\.com/i,
265+
],
266+
});
267+
```
268+
269+
_New_:
270+
271+
```js
272+
Sentry.init({
273+
blacklistUrls: [
274+
'https://www.baddomain.com',
275+
/graph\.facebook\.com/i,
276+
],
277+
});
278+
```
279+
280+
### Ignoring Events (`shouldSendCallback`)
281+
282+
> `shouldSendCallback` was renamed to `beforeSend` ([#2253](https://github.com/getsentry/sentry-javascript/issues/2253)). Instead of returning `false`, you must return `null` to omit sending the event. [Docs](https://docs.sentry.io/error-reporting/configuration/filtering/?platform=browser#before-send)
283+
284+
_Old_:
285+
286+
```js
287+
Sentry.init({
288+
shouldSendCallback(event) {
289+
// Modify the event here
290+
if(event.user){
291+
// Don't send user's email address
292+
delete event.user.email;
293+
} else {
294+
return false; // don't send this event
295+
}
296+
return event;
297+
}
298+
});
299+
```
300+
301+
_New_:
302+
303+
```js
304+
Sentry.init({
305+
beforeSend(event) {
306+
// Modify the event here
307+
if(event.user){
308+
// Don't send user's email address
309+
delete event.user.email;
310+
} else {
311+
return null; // don't send this event
312+
}
313+
return event;
314+
}
315+
});
316+
```
317+
318+
### Attaching Stacktraces
319+
320+
> 'stacktrace' was renamed to 'attackStacktrace'. [Docs](https://docs.sentry.io/error-reporting/configuration/?platform=browser#attach-stacktrace)
321+
322+
_Old_:
323+
324+
```js
325+
Sentry.init({
326+
stacktrace: true,
327+
});
328+
```
329+
330+
_New_:
331+
332+
```js
333+
Sentry.init({
334+
attachStacktrace: true,
335+
});
336+
```

0 commit comments

Comments
 (0)