@@ -130,3 +130,112 @@ using `@sentry/node` on a serverless infrastructure.
130130
131131Now ` close ` and ` flush ` work similar, with the difference that if you call ` close ` in addition to returing a ` Promise `
132132that you can await it also ** disables** the client so it will not send any future events.
133+
134+ # Migrating from ` raven-js ` to ` @sentry/browser `
135+
136+ ` @sentry/browser ` needs polyfills to work in IE 11 or older, see: https://docs.sentry.io/platforms/javascript/#browser-table
137+ Here are some examples of how the new SDKs work. Please note that the API for all JavaScript SDKs is the same.
138+
139+ #### Installation
140+
141+ _ Old_ :
142+
143+ ``` js
144+ Raven .config (' ___PUBLIC_DSN___' , {
145+ release: ' 1.3.0' ,
146+ }).install ();
147+ ```
148+
149+ _ New_ :
150+
151+ ``` js
152+ Sentry .init ({
153+ dsn: ' ___PUBLIC_DSN___' ,
154+ release: ' 1.3.0' ,
155+ });
156+ ```
157+
158+ #### Set a global tag
159+
160+ _ Old_ :
161+
162+ ``` js
163+ Raven .setTagsContext ({ key: ' value' });
164+ ```
165+
166+ _ New_ :
167+
168+ ``` js
169+ Sentry .setTag (' key' , ' value' );
170+ ```
171+
172+ #### Capture custom exception
173+
174+ _ Old_ :
175+
176+ ``` js
177+ try {
178+ throwingFunction ();
179+ } catch (e) {
180+ Raven .captureException (e, { extra: { debug: false } });
181+ }
182+ ```
183+
184+ _ New_ :
185+
186+ ``` js
187+ try {
188+ throwingFunction ();
189+ } catch (e) {
190+ Sentry .withScope (scope => {
191+ scope .setExtra (' debug' , false );
192+ Sentry .captureException (e);
193+ });
194+ }
195+ ```
196+
197+ #### Capture a message
198+
199+ _ Old_ :
200+
201+ ``` js
202+ Raven .captureMessage (' test' , ' info' , { extra: { debug: false } });
203+ ```
204+
205+ _ New_ :
206+
207+ ``` js
208+ Sentry .withScope (scope => {
209+ scope .setExtra (' debug' , false );
210+ Sentry .captureMessage (' test' , ' info' );
211+ });
212+ ```
213+
214+ #### Breadcrumbs
215+
216+ _ Old_ :
217+
218+ ``` js
219+ Raven .captureBreadcrumb ({
220+ message: ' Item added to shopping cart' ,
221+ category: ' action' ,
222+ data: {
223+ isbn: ' 978-1617290541' ,
224+ cartSize: ' 3' ,
225+ },
226+ });
227+ ```
228+
229+ _ New_ :
230+
231+ ``` js
232+ Sentry .addBreadcrumb ({
233+ message: ' Item added to shopping cart' ,
234+ category: ' action' ,
235+ data: {
236+ isbn: ' 978-1617290541' ,
237+ cartSize: ' 3' ,
238+ },
239+ });
240+ ```
241+
0 commit comments