Skip to content

Commit 01a9dbc

Browse files
authored
refactor: migrate js sdks onboarding to inline product options syntax (#13418)
* refactor: migrate js sdks onboarding inline product options syntax * migrate again * port platform includes * migrate express v7
1 parent dff51d4 commit 01a9dbc

File tree

33 files changed

+418
-67
lines changed

33 files changed

+418
-67
lines changed

docs/platforms/javascript/guides/astro/index.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export default defineConfig({
9494

9595
### Client-Side Setup
9696

97-
```javascript {filename:sentry.client.config.js} {"onboardingOptions": {"performance": "11,14-17", "session-replay": "12,18-25"}}
97+
```javascript {filename:sentry.client.config.js}
9898
import * as Sentry from "@sentry/astro";
9999

100100
Sentry.init({
@@ -105,13 +105,20 @@ Sentry.init({
105105
sendDefaultPii: true,
106106

107107
integrations: [
108+
// ___PRODUCT_OPTION_START___ performance
108109
Sentry.browserTracingIntegration(),
110+
// ___PRODUCT_OPTION_END___ performance
111+
// ___PRODUCT_OPTION_START___ session-replay
109112
Sentry.replayIntegration(),
113+
// ___PRODUCT_OPTION_END___ session-replay
110114
],
115+
// ___PRODUCT_OPTION_START___ performance
111116

112117
// Define how likely traces are sampled. Adjust this value in production,
113118
// or use tracesSampler for greater control.
114119
tracesSampleRate: 1.0,
120+
// ___PRODUCT_OPTION_END___ performance
121+
// ___PRODUCT_OPTION_START___ session-replay
115122

116123
// This sets the sample rate to be 10%. You may want this to be 100% while
117124
// in development and sample at a lower rate in production
@@ -120,34 +127,43 @@ Sentry.init({
120127
// If the entire session is not sampled, use the below sample rate to sample
121128
// sessions when an error occurs.
122129
replaysOnErrorSampleRate: 1.0,
130+
// ___PRODUCT_OPTION_END___ session-replay
123131
});
124132
```
125133

126134
### Server-Side Setup
127135

128-
```javascript {filename:sentry.server.config.js} {"onboardingOptions": {"performance": "15-18", "profiling": "2,10-14,19-22"}}
136+
```javascript {filename:sentry.server.config.js}
129137
import * as Sentry from "@sentry/astro";
138+
// ___PRODUCT_OPTION_START___ profiling
130139
import { nodeProfilingIntegration } from '@sentry/profiling-node';
140+
// ___PRODUCT_OPTION_END___ profiling
131141

132142
Sentry.init({
133143
dsn: "___PUBLIC_DSN___",
134144

135145
// Adds request headers and IP for users, for more info visit: for more info visit:
136146
// https://docs.sentry.io/platforms/javascript/guides/astro/configuration/options/#sendDefaultPii
137147
sendDefaultPii: true,
148+
// ___PRODUCT_OPTION_START___ profiling
138149

139150
integrations: [
140151
// Add our Profiling integration
141152
nodeProfilingIntegration(),
142153
],
154+
// ___PRODUCT_OPTION_END___ profiling
155+
// ___PRODUCT_OPTION_START___ performance
143156

144157
// Define how likely traces are sampled. Adjust this value in production,
145158
// or use tracesSampler for greater control.
146159
tracesSampleRate: 1.0,
160+
// ___PRODUCT_OPTION_END___ performance
161+
// ___PRODUCT_OPTION_START___ profiling
147162

148163
// Set sampling rate for profiling
149164
// This is relative to tracesSampleRate
150165
profilesSampleRate: 1.0
166+
// ___PRODUCT_OPTION_END___ profiling
151167
});
152168
```
153169

docs/platforms/javascript/guides/aws-lambda/install/cjs-layer.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ Select which Sentry features you'd like to install in addition to Error Monitori
4949

5050
Set the following environment variables in your Lambda function configuration:
5151

52-
```bash {"onboardingOptions": {"performance": "3"}}
52+
```bash
5353
NODE_OPTIONS="-r @sentry/aws-serverless/awslambda-auto"
5454
SENTRY_DSN="___PUBLIC_DSN___"
55+
# ___PRODUCT_OPTION_START___ performance
5556
SENTRY_TRACES_SAMPLE_RATE="1.0"
57+
# ___PRODUCT_OPTION_END___ performance
5658
```
5759

5860
To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**:
@@ -67,7 +69,7 @@ Note that you don't have to actually install an NPM package for this to work, as
6769

6870
Make sure you completed [step 1](#1-prerequisites) and [step 2](#2-add-the-sentry-lambda-layer) before proceeding.
6971

70-
```javascript {filename:index.js} {"onboardingOptions": {"performance": "9-15"}}
72+
```javascript {filename:index.js}
7173
const Sentry = require("@sentry/aws-serverless");
7274

7375
Sentry.init({
@@ -76,13 +78,15 @@ Sentry.init({
7678
// Adds request headers and IP for users, for more info visit:
7779
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
7880
sendDefaultPii: true,
81+
// ___PRODUCT_OPTION_START___ performance
7982

8083
// Add Tracing by setting tracesSampleRate and adding integration
8184
// Set tracesSampleRate to 1.0 to capture 100% of transactions
8285
// We recommend adjusting this value in production
8386
// Learn more at
8487
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
8588
tracesSampleRate: 1.0,
89+
// ___PRODUCT_OPTION_END___ performance
8690
});
8791

8892
exports.handler = Sentry.wrapHandler(async (event, context) => {

docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v7.x.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ Select which Sentry features you'd like to install in addition to Error Monitori
5252

5353
Set the following environment variables in your Lambda function configuration:
5454

55-
```bash {"onboardingOptions": {"performance": "3"}}
55+
```bash
5656
NODE_OPTIONS="-r @sentry/serverless/dist/awslambda-auto"
5757
SENTRY_DSN="___PUBLIC_DSN___"
58+
# ___PRODUCT_OPTION_START___ performance
5859
SENTRY_TRACES_SAMPLE_RATE="1.0"
60+
# ___PRODUCT_OPTION_END___ performance
5961
```
6062

6163
To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**.
@@ -68,17 +70,19 @@ Note that you don't have to actually install an NPM package for this to work, as
6870

6971
Make sure you completed [step 1](#1-prerequisites) and [step 2](#2-add-the-sentry-lambda-layer) before proceeding.
7072

71-
```javascript {filename:index.js} {"onboardingOptions": {"performance": "5-8"}}
73+
```javascript {filename:index.js}
7274
const Sentry = require("@sentry/serverless");
7375

7476
Sentry.init({
7577
dsn: "___PUBLIC_DSN___",
78+
// ___PRODUCT_OPTION_START___ performance
7679
// Add Tracing by setting tracesSampleRate and adding integration
7780
// Set tracesSampleRate to 1.0 to capture 100% of transactions
7881
// We recommend adjusting this value in production
7982
// Learn more at
8083
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
8184
tracesSampleRate: 1.0,
85+
// ___PRODUCT_OPTION_END___ performance
8286
});
8387

8488
exports.handler = Sentry.wrapHandler(async (event, context) => {

docs/platforms/javascript/guides/aws-lambda/install/cjs-layer__v8.x.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ Select which Sentry features you'd like to install in addition to Error Monitori
6161

6262
Set the following environment variables in your Lambda function configuration:
6363

64-
```bash {"onboardingOptions": {"performance": "3"}}
64+
```bash
6565
NODE_OPTIONS="-r @sentry/aws-serverless/awslambda-auto"
6666
SENTRY_DSN="___PUBLIC_DSN___"
67+
# ___PRODUCT_OPTION_START___ performance
6768
SENTRY_TRACES_SAMPLE_RATE="1.0"
69+
# ___PRODUCT_OPTION_END___ performance
6870
```
6971

7072
To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**:
@@ -79,17 +81,19 @@ Note that you don't have to actually install an NPM package for this to work, as
7981

8082
Make sure you completed [step 1](#1-prerequisites) and [step 2](#2-add-the-sentry-lambda-layer) before proceeding.
8183

82-
```javascript {filename:index.js} {"onboardingOptions": {"performance": "5-8"}}
84+
```javascript {filename:index.js}
8385
const Sentry = require("@sentry/aws-serverless");
8486

8587
Sentry.init({
8688
dsn: "___PUBLIC_DSN___",
89+
// ___PRODUCT_OPTION_START___ performance
8790
// Add Tracing by setting tracesSampleRate and adding integration
8891
// Set tracesSampleRate to 1.0 to capture 100% of transactions
8992
// We recommend adjusting this value in production
9093
// Learn more at
9194
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
9295
tracesSampleRate: 1.0,
96+
// ___PRODUCT_OPTION_END___ performance
9397
});
9498

9599
exports.handler = Sentry.wrapHandler(async (event, context) => {

docs/platforms/javascript/guides/aws-lambda/install/cjs-npm.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,36 @@ pnpm add @sentry/aws-serverless @sentry/profiling-node
6262

6363
Initialize and configure the SDK in your Lambda function Code. Call `Sentry.init` _outside_ of the handler function to avoid re-initializing the SDK on every invocation. Also, add the `Sentry.wrapHandler` wrapper around your function to automatically catch errors and performance data:
6464

65-
```javascript {filename:index.js} {"onboardingOptions": {"performance": "12-18", "profiling": "2,10-11,17-21"}}
65+
```javascript {filename:index.js}
6666
const Sentry = require("@sentry/aws-serverless");
67+
// ___PRODUCT_OPTION_START___ profiling
6768
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
6869

70+
// ___PRODUCT_OPTION_END___ profiling
6971
Sentry.init({
7072
dsn: "___PUBLIC_DSN___",
7173

7274
// Adds request headers and IP for users, for more info visit:
7375
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
7476
sendDefaultPii: true,
7577

78+
// ___PRODUCT_OPTION_START___ profiling
7679
integrations: [nodeProfilingIntegration()],
80+
// ___PRODUCT_OPTION_END___ profiling
7781

82+
// ___PRODUCT_OPTION_START___ performance
7883
// Add Tracing by setting tracesSampleRate and adding integration
7984
// Set tracesSampleRate to 1.0 to capture 100% of transactions
8085
// We recommend adjusting this value in production
8186
// Learn more at
8287
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
8388
tracesSampleRate: 1.0,
89+
// ___PRODUCT_OPTION_END___ performance
90+
// ___PRODUCT_OPTION_START___ profiling
8491

8592
// Set sampling rate for profiling - this is relative to tracesSampleRate
8693
profilesSampleRate: 1.0,
94+
// ___PRODUCT_OPTION_END___ profiling
8795
});
8896

8997
exports.handler = Sentry.wrapHandler(async (event, context) => {

docs/platforms/javascript/guides/aws-lambda/install/esm-npm.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ export const handler = Sentry.wrapHandler(async (event, context) => {
8282

8383
To initialize and configure the SDK, you need to set the following environment variables in your AWS Lambda function configuration:
8484

85-
```bash {"onboardingOptions": {"performance": "3"}}
85+
```bash
8686
NODE_OPTIONS="--import @sentry/aws-serverless/awslambda-auto"
8787
SENTRY_DSN="___PUBLIC_DSN___"
88+
# ___PRODUCT_OPTION_START___ performance
8889
SENTRY_TRACES_SAMPLE_RATE="1.0"
90+
# ___PRODUCT_OPTION_END___ performance
8991
```
9092

9193
To set environment variables, navigate to your Lambda function, select **Configuration**, then **Environment variables**:
@@ -107,28 +109,36 @@ Follow steps 1 and 2 above to [install the SDK NPM package](#2-install) in your
107109

108110
Create a new file, for example `instrument.mjs` to initialize the SDK:
109111

110-
```javascript {filename:instrument.mjs} {"onboardingOptions": {"performance": "12-18", "profiling": "2,10-11,17-21"}}
112+
```javascript {filename:instrument.mjs}
111113
import * as Sentry from "@sentry/aws-serverless";
114+
// ___PRODUCT_OPTION_START___ profiling
112115
import { nodeProfilingIntegration } from "@sentry/profiling-node";
113116

117+
// ___PRODUCT_OPTION_END___ profiling
114118
Sentry.init({
115119
dsn: "___PUBLIC_DSN___",
116120

117121
// Adds request headers and IP for users, for more info visit:
118122
// https://docs.sentry.io/platforms/javascript/guides/aws-lambda/configuration/options/#sendDefaultPii
119123
sendDefaultPii: true,
124+
// ___PRODUCT_OPTION_START___ profiling
120125

121126
integrations: [nodeProfilingIntegration()],
127+
// ___PRODUCT_OPTION_END___ profiling
128+
// ___PRODUCT_OPTION_START___ performance
122129

123130
// Add Tracing by setting tracesSampleRate and adding integration
124131
// Set tracesSampleRate to 1.0 to capture 100% of transactions
125132
// We recommend adjusting this value in production
126133
// Learn more at
127134
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
128135
tracesSampleRate: 1.0,
136+
// ___PRODUCT_OPTION_END___ performance
129137

138+
// ___PRODUCT_OPTION_START___ profiling
130139
// Set sampling rate for profiling - this is relative to tracesSampleRate
131140
profilesSampleRate: 1.0,
141+
// ___PRODUCT_OPTION_END___ profiling
132142
});
133143
```
134144

docs/platforms/javascript/guides/azure-functions/index.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,38 @@ Sentry captures data by using an SDK within your application’s runtime. This m
2727

2828
To set up Sentry error logging for an Azure Function:
2929

30-
```javascript {tabTitle:async} {"onboardingOptions": {"performance": "14-20", "profiling": "2, 10-13, 21-23"}}
30+
```javascript {tabTitle:async}
3131
const Sentry = require("@sentry/node");
32+
// ___PRODUCT_OPTION_START___ profiling
3233
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
3334

35+
// ___PRODUCT_OPTION_END___ profiling
3436
Sentry.init({
3537
dsn: "___PUBLIC_DSN___",
3638

3739
// Adds request headers and IP for users, for more info visit:
3840
// https://docs.sentry.io/platforms/javascript/guides/azure-functions/configuration/options/#sendDefaultPii
3941
sendDefaultPii: true,
42+
// ___PRODUCT_OPTION_START___ profiling
4043

4144
integrations: [
4245
nodeProfilingIntegration(),
4346
],
47+
// ___PRODUCT_OPTION_END___ profiling
4448

49+
// ___PRODUCT_OPTION_START___ performance
4550
// Add Performance Monitoring by setting tracesSampleRate
4651
// Set tracesSampleRate to 1.0 to capture 100% of transactions
4752
// We recommend adjusting this value in production
4853
// Learn more at
4954
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
5055
tracesSampleRate: 1.0,
56+
// ___PRODUCT_OPTION_END___ performance
5157

58+
// ___PRODUCT_OPTION_START___ profiling
5259
// Set sampling rate for profiling - this is relative to tracesSampleRate
5360
profilesSampleRate: 1.0,
61+
// ___PRODUCT_OPTION_END___ profiling
5462
});
5563

5664
module.exports = async function (context, req) {

docs/platforms/javascript/guides/bun/index.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Once this is done, Sentry's Bun SDK captures unhandled exceptions as well as tra
3434

3535
You need to create a file named `instrument.js` that imports and initializes Sentry:
3636

37-
```javascript {filename: instrument.js} {"onboardingOptions": {"performance": "10-16"}}
37+
```javascript {filename: instrument.js}
3838
import * as Sentry from "@sentry/bun";
3939

4040
// Ensure to call this before importing any other modules!
@@ -44,13 +44,15 @@ Sentry.init({
4444
// Adds request headers and IP for users, for more info visit:
4545
// https://docs.sentry.io/platforms/javascript/guides/bun/configuration/options/#sendDefaultPii
4646
sendDefaultPii: true,
47+
// ___PRODUCT_OPTION_START___ performance
4748

4849
// Add Performance Monitoring by setting tracesSampleRate
4950
// Set tracesSampleRate to 1.0 to capture 100% of transactions
5051
// We recommend adjusting this value in production
5152
// Learn more at
5253
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
5354
tracesSampleRate: 1.0,
55+
// ___PRODUCT_OPTION_END___ performance
5456
});
5557
```
5658

@@ -78,10 +80,12 @@ import http from "http";
7880

7981
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
8082

81-
```javascript {"onboardingOptions": {"performance": "1-4, 12"}}
83+
```javascript
84+
// ___PRODUCT_OPTION_START___ performance
8285
Sentry.startSpan({
8386
op: "test",
8487
name: "My First Test Transaction",
88+
// ___PRODUCT_OPTION_END___ performance
8589
}, () => {
8690
setTimeout(() => {
8791
try {
@@ -90,7 +94,9 @@ Sentry.startSpan({
9094
Sentry.captureException(e);
9195
}
9296
}, 99);
97+
// ___PRODUCT_OPTION_START___ performance
9398
});
99+
// ___PRODUCT_OPTION_END___ performance
94100
```
95101

96102
<Alert>

0 commit comments

Comments
 (0)