-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
{WIP} Focus getting started content #2274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c7f8b5a
minimize getting started
PeloWriter f6cdf34
move test into its own snippet
PeloWriter b40de31
Update src/includes/test-verify/javascript.mdx
PeloWriter 8686c9d
Update src/platforms/javascript/index.mdx
PeloWriter b5b2d99
Update src/includes/test-verify/javascript.mdx
PeloWriter 64c4d61
Update src/platforms/javascript/index.mdx
PeloWriter cbb72e0
Create Angular includes
PeloWriter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
This snippet includes our [performance monitoring](/product/performance/) package, which register and configures the Tracing integration, including custom Angular routing instrumentation: | ||
|
||
```javascript | ||
import { enableProdMode } from "@angular/core"; | ||
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; | ||
import * as Sentry from "@sentry/angular"; | ||
import { Integrations } from "@sentry/tracing"; | ||
|
||
import { AppModule } from "./app/app.module"; | ||
|
||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___" , | ||
integrations: [ | ||
new Integrations.BrowserTracing({ | ||
tracingOrigins: ["localhost", "https://yourserver.io/api"], | ||
routingInstrumentation: Sentry.routingInstrumentation, | ||
}), | ||
], | ||
tracesSampleRate: 1.0, // Be sure to lower this in production | ||
|
||
enableProdMode(); | ||
platformBrowserDynamic() | ||
.bootstrapModule(AppModule) | ||
.then(success => console.log(`Bootstrap success`)) | ||
.catch(err => console.error(err)); | ||
``` | ||
|
||
You can also configure `@sentry/angular` to catch any Angular-specific exceptions reported through the [@angular/core/ErrorHandler](https://angular.io/api/core/ErrorHandler) provider. | ||
|
||
`@sentry/angular` exports a Trace Service, Directive, and Decorators that leverages the `@sentry/tracing`, Sentry's Tracing integration, to add Angular-related spans to transactions. The service itself tracks route changes and durations, where directive and decorators are tracking component initializations. | ||
|
||
### Automatically Send Errors with `ErrorHandler` | ||
|
||
`@sentry/angular` exports a function to instantiate an `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler. | ||
|
||
```javascript | ||
import { NgModule, ErrorHandler } from "@angular/core"; | ||
import * as Sentry from "@sentry/angular"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: ErrorHandler, | ||
useValue: Sentry.createErrorHandler({ | ||
showDialog: true, | ||
}), | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
You can configure the behavior of `createErrorHandler`. For more details see the `ErrorHandlerOptions` interface in [our repository](https://github.com/getsentry/sentry-javascript/blob/master/packages/angular/src/errorhandler.ts). | ||
|
||
### Register `TraceService` | ||
|
||
In Angular's DI system, register `TraceService` as a provider with a `Router` as its dependency: | ||
|
||
```javascript | ||
import { NgModule } from "@angular/core"; | ||
import { Router } from "@angular/router"; | ||
import * as Sentry from "@sentry/angular"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: Sentry.TraceService, | ||
deps: [Router], | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
Then, either require the `TraceService` from inside `AppModule` or use `APP_INITIALIZER` to force instantiate Tracing. | ||
|
||
```javascript | ||
@NgModule({ | ||
// ... | ||
}) | ||
export class AppModule { | ||
constructor(trace: Sentry.TraceService) {} | ||
} | ||
``` | ||
|
||
or | ||
|
||
```javascript | ||
import { APP_INITIALIZER } from "@angular/core"; | ||
|
||
@NgModule({ | ||
// ... | ||
providers: [ | ||
{ | ||
provide: APP_INITIALIZER, | ||
useFactory: () => () => {}, | ||
deps: [Sentry.TraceService], | ||
multi: true, | ||
}, | ||
], | ||
// ... | ||
}) | ||
export class AppModule {} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
```javascript {tabTitle: ESM} | ||
import * as Sentry from "@sentry/browser"; | ||
import { Integrations } from "@sentry/tracing"; | ||
Sentry.init({ | ||
dsn: "___PUBLIC_DSN___", | ||
release: "my-project-name@" + process.env.npm_package_version, // To set your release version | ||
integrations: [new Integrations.BrowserTracing()], | ||
tracesSampleRate: 1.0, // Remember to lower this in production | ||
}); | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```bash {tabTitle:npm} | ||
npm install --save @sentry/angular | ||
``` | ||
|
||
```bash {tabTitle:Yarn} | ||
yarn add @sentry/angular | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```bash {tabTitle: ESM} | ||
# Using yarn | ||
$ yarn add @sentry/browser @sentry/tracing | ||
|
||
# Using npm | ||
$ npm install --save @sentry/browser @sentry/tracing | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```JavaScript {tabTitle: ESM} | ||
myUndefinedFunction(); // To test your setup | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link should probably point to
/platforms/javascript/configuration/filtering/#sampling
That being said, does sampleRate supersede tracesSampleRate?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a better link, thanks. I don't know the answer to your questions, @HazAT - which sample rate takes precedence?