Skip to content

Commit ee30754

Browse files
committed
feat(perf): Update onPostBuild step to generate performance on-boarding docs
1 parent 822327f commit ee30754

File tree

4 files changed

+103
-4
lines changed

4 files changed

+103
-4
lines changed

src/gatsby/onPostBuild.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@ export default async ({ graphql }) => {
6767
await writeJson(output, nodes, platformRegistry);
6868
};
6969

70+
const parsePathSlug = (slug: string) => {
71+
if (slug.includes("performance-onboarding")) {
72+
const pathMatch = slug.match(
73+
/^\/(?<platform>[^/]+)\/performance-onboarding\/(?<sub_platform>[^/]+)\/(?<step>[^/]+)\/$/
74+
);
75+
const { platform, sub_platform } = pathMatch.groups;
76+
let step = pathMatch.groups.step;
77+
step = String(step).replace(/\./g, "-");
78+
let sub = `performance-onboarding-${sub_platform}-${step}`;
79+
80+
if (platform === pathMatch.groups.sub_platform) {
81+
sub = `performance-onboarding-${step}`;
82+
}
83+
84+
return {
85+
platform,
86+
sub,
87+
};
88+
}
89+
90+
const pathMatch = slug.match(/^\/([^/]+)(?:\/([^/]+))?\/$/);
91+
if (!pathMatch) throw new Error("cant identify language");
92+
93+
const [, main, sub] = pathMatch;
94+
95+
return {
96+
platform: main,
97+
sub: sub,
98+
};
99+
};
100+
70101
const writeJson = async (
71102
path: string,
72103
nodes,
@@ -75,10 +106,8 @@ const writeJson = async (
75106
const platforms = [];
76107
const indexJson = {};
77108
nodes.forEach(node => {
78-
const pathMatch = node.fields.slug.match(/^\/([^/]+)(?:\/([^/]+))?\/$/);
79-
if (!pathMatch) throw new Error("cant identify language");
80-
// eslint-disable-next-line no-unused-vars
81-
const [, main, sub] = pathMatch;
109+
const { platform: main, sub } = parsePathSlug(node.fields.slug);
110+
82111
if (!indexJson[main]) indexJson[main] = {};
83112
if (!node.frontmatter.doc_link) {
84113
throw new Error(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: JavaScript
3+
doc_link: https://docs.sentry.io/platforms/javascript/performance/
4+
support_level: production
5+
type: language
6+
---
7+
8+
#### Install
9+
10+
Install our JavaScript browser SDK using either `yarn` or `npm`:
11+
12+
```bash {tabTitle: ESM}
13+
# Using yarn
14+
yarn add @sentry/browser @sentry/tracing
15+
# Using npm
16+
npm install --save @sentry/browser @sentry/tracing
17+
```
18+
19+
We also support alternate [installation methods](/platforms/javascript/install/).
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: JavaScript
3+
doc_link: https://docs.sentry.io/platforms/javascript/performance/
4+
support_level: production
5+
type: language
6+
---
7+
8+
#### Configure
9+
10+
Configuration should happen as early as possible in your application's lifecycle.
11+
12+
Once this is done, Sentry's JavaScript SDK captures all unhandled exceptions and transactions.
13+
14+
```javascript
15+
import * as Sentry from "@sentry/browser";
16+
import { BrowserTracing } from "@sentry/tracing";
17+
18+
Sentry.init({
19+
dsn: "___PUBLIC_DSN___",
20+
integrations: [new BrowserTracing()],
21+
22+
// Set tracesSampleRate to 1.0 to capture 100%
23+
// of transactions for performance monitoring.
24+
// We recommend adjusting this value in production
25+
tracesSampleRate: 1.0,
26+
});
27+
```
28+
29+
We recommend adjusting the value of `tracesSampleRate` in production. Learn more about configuring sampling in our [full documentation](/platforms/javascript/configuration/sampling/).
30+
31+
Learn more about manually capturing an error or message in our [Usage documentation](/usage/).
32+
33+
To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: JavaScript
3+
doc_link: https://docs.sentry.io/platforms/javascript/performance/
4+
support_level: production
5+
type: language
6+
---
7+
8+
#### Verify
9+
10+
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up:
11+
12+
```javascript
13+
myUndefinedFunction();
14+
```
15+
16+
If you're new to Sentry, use the email alert to access your account and complete a product tour.
17+
18+
If you're an existing user and have disabled alerts, you won't receive this email.

0 commit comments

Comments
 (0)