Skip to content

Commit d1a7088

Browse files
committed
fix: formatting
1 parent 5ff3c9b commit d1a7088

File tree

5 files changed

+71
-44
lines changed

5 files changed

+71
-44
lines changed

examples/with-sentry/app/api/sentry-example-api/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class SentryExampleAPIError extends Error {
99
}
1010
// A faulty API route to test Sentry's error monitoring
1111
export function GET() {
12-
throw new SentryExampleAPIError("This error is raised on the backend called by the example page.");
12+
throw new SentryExampleAPIError(
13+
"This error is raised on the backend called by the example page.",
14+
);
1315
return NextResponse.json({ data: "Testing Sentry Error..." });
1416
}

examples/with-sentry/app/page.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,17 @@ export default function Home() {
6565
className="flex h-12 w-full gap-2 items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a]"
6666
href="/sentry-example-page"
6767
>
68-
<svg height="20" width="20" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
69-
<path d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z" fill="currentcolor"/>
68+
<svg
69+
height="20"
70+
width="20"
71+
viewBox="0 0 40 40"
72+
fill="none"
73+
xmlns="http://www.w3.org/2000/svg"
74+
>
75+
<path
76+
d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z"
77+
fill="currentcolor"
78+
/>
7079
</svg>
7180
Sentry Example Page
7281
</Link>

examples/with-sentry/app/sentry-example-page/page.tsx

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class SentryExampleFrontendError extends Error {
1414
export default function Page() {
1515
const [hasSentError, setHasSentError] = useState(false);
1616
const [isConnected, setIsConnected] = useState(true);
17-
17+
1818
useEffect(() => {
1919
async function checkConnectivity() {
2020
const result = await Sentry.diagnoseSdkConnectivity();
21-
setIsConnected(result !== 'sentry-unreachable');
21+
setIsConnected(result !== "sentry-unreachable");
2222
}
2323
checkConnectivity();
2424
}, []);
@@ -32,54 +32,76 @@ export default function Page() {
3232

3333
<main>
3434
<div className="flex-spacer" />
35-
<svg height="40" width="40" fill="none" xmlns="http://www.w3.org/2000/svg">
36-
<path d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z" fill="currentcolor"/>
35+
<svg
36+
height="40"
37+
width="40"
38+
fill="none"
39+
xmlns="http://www.w3.org/2000/svg"
40+
>
41+
<path
42+
d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z"
43+
fill="currentcolor"
44+
/>
3745
</svg>
38-
<h1>
39-
sentry-example-page
40-
</h1>
46+
<h1>sentry-example-page</h1>
4147

4248
<p className="description">
43-
Click the button below, and view the sample error on the Sentry <a target="_blank" href="https://sentry-sdks.sentry.io/issues/?project=4510187201757184">Issues Page</a>.
44-
For more details about setting up Sentry, <a target="_blank"
45-
href="https://docs.sentry.io/platforms/javascript/guides/nextjs/">read our docs</a>.
49+
Click the button below, and view the sample error on the Sentry{" "}
50+
<a
51+
target="_blank"
52+
href="https://sentry-sdks.sentry.io/issues/?project=4510187201757184" rel="noreferrer"
53+
>
54+
Issues Page
55+
</a>
56+
. For more details about setting up Sentry,{" "}
57+
<a
58+
target="_blank"
59+
href="https://docs.sentry.io/platforms/javascript/guides/nextjs/" rel="noreferrer"
60+
>
61+
read our docs
62+
</a>
63+
.
4664
</p>
4765

4866
<button
4967
type="button"
5068
onClick={async () => {
51-
await Sentry.startSpan({
52-
name: 'Example Frontend/Backend Span',
53-
op: 'test'
54-
}, async () => {
55-
const res = await fetch("/api/sentry-example-api");
56-
if (!res.ok) {
57-
setHasSentError(true);
58-
}
59-
});
60-
throw new SentryExampleFrontendError("This error is raised on the frontend of the example page.");
69+
await Sentry.startSpan(
70+
{
71+
name: "Example Frontend/Backend Span",
72+
op: "test",
73+
},
74+
async () => {
75+
const res = await fetch("/api/sentry-example-api");
76+
if (!res.ok) {
77+
setHasSentError(true);
78+
}
79+
},
80+
);
81+
throw new SentryExampleFrontendError(
82+
"This error is raised on the frontend of the example page.",
83+
);
6184
}}
6285
disabled={!isConnected}
6386
>
64-
<span>
65-
Throw Sample Error
66-
</span>
87+
<span>Throw Sample Error</span>
6788
</button>
6889

6990
{hasSentError ? (
70-
<p className="success">
71-
Error sent to Sentry.
72-
</p>
91+
<p className="success">Error sent to Sentry.</p>
7392
) : !isConnected ? (
7493
<div className="connectivity-error">
75-
<p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>
94+
<p>
95+
It looks like network requests to Sentry are being blocked, which
96+
will prevent errors from being captured. Try disabling your
97+
ad-blocker to complete the test.
98+
</p>
7699
</div>
77100
) : (
78101
<div className="success_placeholder" />
79102
)}
80103

81104
<div className="flex-spacer" />
82-
83105
</main>
84106

85107
<style>{`

examples/with-sentry/instrumentation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as Sentry from '@sentry/nextjs';
1+
import * as Sentry from "@sentry/nextjs";
22

33
export async function register() {
4-
if (process.env.NEXT_RUNTIME === 'nodejs') {
5-
await import('./sentry.server.config');
4+
if (process.env.NEXT_RUNTIME === "nodejs") {
5+
await import("./sentry.server.config");
66
}
77

8-
if (process.env.NEXT_RUNTIME === 'edge') {
9-
await import('./sentry.edge.config');
8+
if (process.env.NEXT_RUNTIME === "edge") {
9+
await import("./sentry.edge.config");
1010
}
1111
}
1212

examples/with-sentry/tsconfig.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
4+
"lib": ["dom", "dom.iterable", "esnext"],
95
"allowJs": true,
106
"skipLibCheck": true,
117
"strict": false,
@@ -31,7 +27,5 @@
3127
".next/types/**/*.ts",
3228
".next/dev/types/**/*.ts"
3329
],
34-
"exclude": [
35-
"node_modules"
36-
]
30+
"exclude": ["node_modules"]
3731
}

0 commit comments

Comments
 (0)