11Then forward the ` init ` method from the sibling Sentry SDK for the framework you use, such as Angular in this example:
22
33
4- ``` typescript {tabTitle: Angular} {filename: app.module.ts} {"onboardingOptions": {"performance": "13-16, 21-28, 46-55", "session-replay": "17-19, 29-33"}}
4+ ``` typescript {tabTitle: Angular 14 Or higher} {filename: app.module.ts} {"onboardingOptions": {"performance": "13-16, 21-28, 46-55", "session-replay": "17-19, 29-33"}}
5+ import * as Sentry from " @sentry/capacitor" ;
6+ import * as SentryAngular from " @sentry/angular" ;
7+
8+ Sentry .init (
9+ {
10+ dsn: " ___PUBLIC_DSN___" ,
11+
12+ // Set your release version, such as "[email protected] " 13+ release: " my-project-name@<release-name>" ,
14+ // Set your dist version, such as "1"
15+ dist: " <dist>" ,
16+ integrations: [
17+ // Registers and configures the Tracing integration,
18+ // which automatically instruments your application to monitor its
19+ // performance, including custom Angular routing instrumentation
20+ Sentry .browserTracingIntegration (),
21+ // Registers the Replay integration,
22+ // which automatically captures Session Replays
23+ Sentry .replayIntegration (),
24+ ],
25+
26+ // Set tracesSampleRate to 1.0 to capture 100%
27+ // of transactions for tracing.
28+ // We recommend adjusting this value in production
29+ tracesSampleRate: 1.0 ,
30+
31+ // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
32+ tracePropagationTargets: [" localhost" , / ^ https:\/\/ yourserver\. io\/ api/ ],
33+
34+ // Capture Replay for 10% of all sessions,
35+ // plus for 100% of sessions with an error
36+ replaysSessionSampleRate: 0.1 ,
37+ replaysOnErrorSampleRate: 1.0 ,
38+ },
39+ // Forward the init method from @sentry/angular
40+ SentryAngular .init
41+ );
42+
43+ @NgModule ({
44+ providers: [
45+ {
46+ provide: ErrorHandler ,
47+ // Attach the Sentry ErrorHandler
48+ useValue: SentryAngular .createErrorHandler (),
49+ },
50+ {
51+ provide: SentryAngular .TraceService ,
52+ deps: [Router ],
53+ },
54+ {
55+ provide: APP_INITIALIZER ,
56+ useFactory : () => () => {},
57+ deps: [SentryAngular .TraceService ],
58+ multi: true ,
59+ },
60+ ],
61+ })
62+ ```
63+
64+ ``` typescript {tabTitle: Angular 12, 13} {filename: app.module.ts} {"onboardingOptions": {"performance": "14-17, 22-29, 47-56", "session-replay": "18-20, 30-34"}}
65+ // Requires @sentry/capacitor V0.
566import * as Sentry from " @sentry/capacitor" ;
667import * as SentryAngular from " @sentry/angular-ivy" ;
768
@@ -17,10 +78,10 @@ Sentry.init(
1778 // Registers and configures the Tracing integration,
1879 // which automatically instruments your application to monitor its
1980 // performance, including custom Angular routing instrumentation
20- SentryAngular . browserTracingIntegration (),
81+ new Sentry . BrowserTracing (),
2182 // Registers the Replay integration,
2283 // which automatically captures Session Replays
23- SentryAngular . replayIntegration (),
84+ new Sentry . Replay (),
2485 ],
2586
2687 // Set tracesSampleRate to 1.0 to capture 100%
@@ -61,17 +122,88 @@ Sentry.init(
61122})
62123```
63124
64- ``` javascript {tabTitle: Other Frameworks}
125+ ``` typescript {tabTitle: React} {filename: index.tsx} {"onboardingOptions": {"performance": "13-16, 21-28, 46-55", "session-replay": "17-19, 29-33"}}
126+ import * as Sentry from " @sentry/capacitor" ;
127+ import * as SentryReact from " @sentry/react" ;
128+
129+ Sentry .init (
130+ {
131+ dsn: " ___PUBLIC_DSN___" ,
132+
133+ // Set your release version, such as "[email protected] " 134+ release: " my-project-name@<release-name>" ,
135+ // Set your dist version, such as "1"
136+ dist: " <dist>" ,
137+ integrations: [
138+ // Registers and configures the Tracing integration,
139+ // which automatically instruments your application to monitor its
140+ // performance, including custom Angular routing instrumentation
141+ Sentry .browserTracingIntegration (),
142+ // Registers the Replay integration,
143+ // which automatically captures Session Replays
144+ Sentry .replayIntegration (),
145+ ],
146+
147+ // Set tracesSampleRate to 1.0 to capture 100%
148+ // of transactions for tracing.
149+ // We recommend adjusting this value in production
150+ tracesSampleRate: 1.0 ,
151+
152+ // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
153+ tracePropagationTargets: [" localhost" , / ^ https:\/\/ yourserver\. io\/ api/ ],
154+
155+ // Capture Replay for 10% of all sessions,
156+ // plus for 100% of sessions with an error
157+ replaysSessionSampleRate: 0.1 ,
158+ replaysOnErrorSampleRate: 1.0 ,
159+ },
160+ // Forward the init method from @sentry/angular
161+ SentryReact .init
162+ );
163+ ```
164+
165+ ``` typescript {tabTitle: Vue} {filename: main.ts} {"onboardingOptions": {"performance": "17-20, 25-32, 50-59", "session-replay": "21-23, 33-37 "}}
65166import * as Sentry from " @sentry/capacitor" ;
167+ import * as SentryVue from " @sentry/vue" ;
168+ import { createApp } from ' vue'
66169
67- Sentry .init ({
68- dsn: " ___PUBLIC_DSN___" ,
170+ const app = createApp (App )
69171
70- // Set your release version, such as "[email protected] " 71- release: " my-project-name@<release-name>" ,
72- // Set your dist version, such as "1"
73- dist: " <dist>" ,
74- });
172+ Sentry .init (
173+ {
174+ app ,
175+ dsn: " ___PUBLIC_DSN___" ,
176+
177+ // Set your release version, such as "[email protected] " 178+ release: " my-project-name@<release-name>" ,
179+ // Set your dist version, such as "1"
180+ dist: " <dist>" ,
181+ integrations: [
182+ // Registers and configures the Tracing integration,
183+ // which automatically instruments your application to monitor its
184+ // performance, including custom Angular routing instrumentation
185+ Sentry .browserTracingIntegration (),
186+ // Registers the Replay integration,
187+ // which automatically captures Session Replays
188+ Sentry .replayIntegration (),
189+ ],
190+
191+ // Set tracesSampleRate to 1.0 to capture 100%
192+ // of transactions for tracing.
193+ // We recommend adjusting this value in production
194+ tracesSampleRate: 1.0 ,
195+
196+ // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
197+ tracePropagationTargets: [" localhost" , / ^ https:\/\/ yourserver\. io\/ api/ ],
198+
199+ // Capture Replay for 10% of all sessions,
200+ // plus for 100% of sessions with an error
201+ replaysSessionSampleRate: 0.1 ,
202+ replaysOnErrorSampleRate: 1.0 ,
203+ },
204+ // Forward the init method from @sentry/angular
205+ SentryVue .init
206+ );
75207```
76208
77209You can also use the features available with the Sentry SDK for the framework you use, such as [ Angular] ( /platforms/javascript/guides/angular/ ) .
0 commit comments