Skip to content

Onboarding wizard for errors + replay + performance #6633

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

Merged
merged 23 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/gatsby/onPostBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ export default async function onPostBuild({graphql}) {
frontmatter {
name
doc_link
wizard_setup {
childMarkdownRemark {
html
}
}
support_level
type
}
Expand Down Expand Up @@ -108,13 +103,13 @@ const parsePathSlug = (slug: string) => {
};
}

if (slug.includes('/react/') && slug !== '/javascript/react/') {
if (slug.match('^/javascript/([A-Za-z]+)/(.*?)/$')) {
const pathMatch = slug.match(
/^\/(?<platform>[^/]+)\/(?<sub_platform>[^/]+)\/(?<product>index|with-error-monitoring|with-error-monitoring-and-performance|with-error-monitoring-and-replay|with-error-monitoring-performance-and-replay)\/$/
);

if (!pathMatch) {
throw new Error(`Unable to parse react doc paths from slug: ${slug}`);
throw new Error(`Unable to parse javascript doc paths from slug: ${slug}`);
}

const {platform, product, sub_platform} = pathMatch.groups;
Expand All @@ -126,6 +121,7 @@ const parsePathSlug = (slug: string) => {
}

const pathMatch = slug.match(/^\/([^/]+)(?:\/([^/]+))?\/$/);

if (!pathMatch) {
throw new Error('cant identify language');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Sentry.init({
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
}),
],
// Set tracesSampleRate to 1.0 to capture 100%
Expand Down Expand Up @@ -56,7 +55,6 @@ Sentry.init({
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
}),
],
// Set tracesSampleRate to 1.0 to capture 100%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import * as Sentry from "@sentry/electron/renderer";
Sentry.init({
dsn: "___PUBLIC_DSN___",

integrations: [
new Sentry.BrowserTracing({
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
// ... other options
}),
],
integrations: [new Sentry.BrowserTracing()],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ After configuration, you will see both `pageload` and `navigation` transactions
```javascript
// If you're using one of our framework SDK packages, like `@sentry/angular`,
// substitute its name for `@sentry/browser` here
import * as Sentry from "@sentry/browser";
import * as Sentry from '@sentry/browser';

Sentry.init({
dsn: "___PUBLIC_DSN___",
dsn: '___PUBLIC_DSN___',

integrations: [
new Sentry.BrowserTracing({
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
// ... other options
}),
],
integrations: [new Sentry.BrowserTracing()],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ Sentry.init({

integrations: [
new Sentry.BrowserTracing({
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],

// Can also use reactRouterV3Instrumentation or reactRouterV4Instrumentation
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),

// ... other options
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "___PUBLIC_DSN___",

integrations: [
new Sentry.ReactNativeTracing({
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
// ... other options
}),
],
integrations: [new Sentry.ReactNativeTracing()],
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,7 @@ import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "___PUBLIC_DSN___",

integrations: [
new Sentry.ReactNativeTracing({
tracePropagationTargets: ["localhost", "my-site-url.com", /^\//],
// ... other options
}),
],
integrations: [new Sentry.ReactNativeTracing()],
});
```

Expand Down
108 changes: 108 additions & 0 deletions src/wizard/javascript/angular/with-error-monitoring-and-performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
name: Angular
doc_link: https://docs.sentry.io/platforms/javascript/guides/angular/
support_level: production
type: framework
---

## Install

To use Sentry with your Angular application, you'll need `@sentry/angular-ivy` or `@sentry/angular`, Sentry’s Browser Angular SDKs:

- If you're using Angular 12 or newer, use `@sentry/angular-ivy`
- If you're using Angular 10 or 11, use `@sentry/angular`

Add the Sentry SDK as a dependency using `yarn` or `npm`:

```bash
# Using yarn (Angular 12+)
yarn add @sentry/angular-ivy
# Using yarn (Angular 10 and 11)
yarn add @sentry/angular

# Using npm (Angular 12+)
npm install --save @sentry/angular-ivy
# Using npm (Angular 10 and 11)
npm install --save @sentry/angular
```

## Configure

You should `init` the Sentry browser SDK in your `main.ts` file as soon as possible during application load up, before initializing Angular:

```javascript
import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead
import * as Sentry from '@sentry/angular-ivy';

import {AppModule} from './app/app.module';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.routingInstrumentation,
}),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions, reduce in production!
});

enableProdMode();
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(success => console.log(`Bootstrap success`))
.catch(err => console.error(err));
```

### ErrorHandler and Tracer

The Sentry Angular SDK exports a function to instantiate `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler.

```javascript
import {APP_INITIALIZER, ErrorHandler, NgModule} from '@angular/core';
import {Router} from '@angular/router';
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead
import * as Sentry from '@sentry/angular-ivy';

@NgModule({
// ...
providers: [
{
provide: ErrorHandler,
useValue: Sentry.createErrorHandler({
showDialog: true,
}),
},
{
provide: Sentry.TraceService,
deps: [Router],
},
{
provide: APP_INITIALIZER,
useFactory: () => () => {},
deps: [Sentry.TraceService],
multi: true,
},
],
// ...
})
export class AppModule {}
```

## Verify

This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected.

```javascript
myUndefinedFunction();
```

---

## Next Steps

- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors.
- [Angular Features](https://docs.sentry.io/platforms/javascript/guides/angular/features/): Learn about our first class integration with the Angular framework.
- [Session Replay](https://docs.sentry.io/platforms/javascript/guides/angular/session-replay/): Get to the root cause of an error or latency issue faster by seeing all the technical details related to that issue in one visual replay on your web application.
95 changes: 95 additions & 0 deletions src/wizard/javascript/angular/with-error-monitoring-and-replay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: Angular
doc_link: https://docs.sentry.io/platforms/javascript/guides/angular/
support_level: production
type: framework
---

## Install

To use Sentry with your Angular application, you'll need `@sentry/angular-ivy` or `@sentry/angular`, Sentry’s Browser Angular SDKs:

- If you're using Angular 12 or newer, use `@sentry/angular-ivy`
- If you're using Angular 10 or 11, use `@sentry/angular`

Add the Sentry SDK as a dependency using `yarn` or `npm`:

```bash
# Using yarn (Angular 12+)
yarn add @sentry/angular-ivy
# Using yarn (Angular 10 and 11)
yarn add @sentry/angular

# Using npm (Angular 12+)
npm install --save @sentry/angular-ivy
# Using npm (Angular 10 and 11)
npm install --save @sentry/angular
```

## Configure

You should `init` the Sentry browser SDK in your `main.ts` file as soon as possible during application load up, before initializing Angular:

```javascript
import {enableProdMode} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead
import * as Sentry from '@sentry/angular-ivy';

import {AppModule} from './app/app.module';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [new Sentry.Replay()],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});

enableProdMode();
platformBrowserDynamic()
.bootstrapModule(AppModule)
.then(success => console.log(`Bootstrap success`))
.catch(err => console.error(err));
```

### ErrorHandler

The Sentry Angular SDK exports a function to instantiate `ErrorHandler` provider that will automatically send JavaScript errors captured by the Angular's error handler.

```javascript
import {APP_INITIALIZER, ErrorHandler, NgModule} from '@angular/core';
import {Router} from '@angular/router';
// import * as Sentry from "@sentry/angular" // for Angular 10/11 instead
import * as Sentry from '@sentry/angular-ivy';

@NgModule({
// ...
providers: [
{
provide: ErrorHandler,
useValue: Sentry.createErrorHandler({
showDialog: true,
}),
},
],
// ...
})
export class AppModule {}
```

## Verify

This snippet contains an intentional error and can be used as a test to make sure that everything's working as expected.

```javascript
myUndefinedFunction();
```

---

## Next Steps

- [Source Maps](https://docs.sentry.io/platforms/javascript/guides/angular/sourcemaps/): Learn how to enable readable stack traces in your Sentry errors.
- [Angular Features](https://docs.sentry.io/platforms/javascript/guides/angular/features/): Learn about our first class integration with the Angular framework.
- [Performance Monitoring](https://docs.sentry.io/platforms/javascript/guides/angular/performance/): Track down transactions to connect the dots between 10-second page loads and poor-performing API calls or slow database queries.
Loading