9
9
import * as fs from 'node:fs/promises'
10
10
import { createFileRoute } from '@tanstack/react-router'
11
11
import { createServerFn } from '@tanstack/react-start'
12
- import * as Sentry from '@sentry/react'
13
- import * as SentryServer from '@sentry/node'
12
+ import * as Sentry from "@sentry/tanstackstart-react" ;
14
13
import { useState , useEffect , useRef } from 'react'
15
14
16
15
export const Route = createFileRoute ( '/demo/sentry/testing' ) ( {
@@ -21,7 +20,7 @@ export const Route = createFileRoute('/demo/sentry/testing')({
21
20
const badServerFunc = createServerFn ( {
22
21
method : 'GET' ,
23
22
} ) . handler ( async ( ) => {
24
- return await SentryServer . startSpan (
23
+ return await Sentry . startSpan (
25
24
{
26
25
name : 'Reading non-existent file' ,
27
26
op : 'file.read'
@@ -31,7 +30,7 @@ const badServerFunc = createServerFn({
31
30
await fs . readFile ( './doesnt-exist' , 'utf-8' )
32
31
return true
33
32
} catch ( error ) {
34
- SentryServer . captureException ( error )
33
+ Sentry . captureException ( error )
35
34
throw error
36
35
}
37
36
}
@@ -42,7 +41,7 @@ const badServerFunc = createServerFn({
42
41
const goodServerFunc = createServerFn ( {
43
42
method : 'GET' ,
44
43
} ) . handler ( async ( ) => {
45
- return await SentryServer . startSpan (
44
+ return await Sentry . startSpan (
46
45
{
47
46
name : 'Successful server operation' ,
48
47
op : 'demo.success'
@@ -244,6 +243,7 @@ function RouteComponent() {
244
243
< div className = "space-y-6" >
245
244
< div >
246
245
< button
246
+ type = "button"
247
247
onClick = { ( ) => {
248
248
setDemoStep ( prev => prev + 1 )
249
249
handleClientError ( )
@@ -267,22 +267,24 @@ function RouteComponent() {
267
267
< div className = "bg-red-900/20 border border-red-500/50 rounded-lg p-2" >
268
268
< div className = "flex items-center text-red-400 text-sm" >
269
269
< svg className = "w-4 h-4 mr-2" fill = "none" strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" viewBox = "0 0 24 24" stroke = "currentColor" >
270
- < path d = "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
270
+ < title > Red Warning Sign</ title >
271
+ < path d = "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
271
272
</ svg >
272
273
Client-side error captured and traced
273
274
</ div >
274
275
</ div >
275
276
< div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
276
277
< div className = "flex items-center justify-between" >
277
278
< div className = "relative" >
278
- < div
279
+ < button
280
+ type = "button"
279
281
className = { `inline-flex items-center bg-purple-900/40 px-3 py-1.5 rounded-lg border border-purple-500/50 cursor-pointer hover:bg-purple-900/60 transition-all ${ copiedSpan === spanOps . clientError ? 'scale-95' : '' } ` }
280
282
onClick = { ( ) => handleCopy ( spanOps . clientError ) }
281
283
title = "Click to copy operation name"
282
284
>
283
285
< span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
284
286
< code className = "text-purple-400 text-sm font-mono" > { spanOps . clientError } </ code >
285
- </ div >
287
+ </ button >
286
288
{ copiedSpan === spanOps . clientError && (
287
289
< div className = "absolute -top-8 left-1/2 -translate-x-1/2 bg-green-500/90 text-white text-xs px-2 py-1 rounded animate-fade-out" >
288
290
Copied!
@@ -297,6 +299,7 @@ function RouteComponent() {
297
299
298
300
< div >
299
301
< button
302
+ type = "button"
300
303
onClick = { ( ) => {
301
304
setDemoStep ( prev => prev + 1 )
302
305
handleClientTrace ( )
@@ -332,14 +335,15 @@ function RouteComponent() {
332
335
< div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
333
336
< div className = "flex items-center justify-between" >
334
337
< div className = "relative" >
335
- < div
338
+ < button
339
+ type = "button"
336
340
className = { `inline-flex items-center bg-purple-900/40 px-3 py-1.5 rounded-lg border border-purple-500/50 cursor-pointer hover:bg-purple-900/60 transition-all ${ copiedSpan === spanOps . client ? 'scale-95' : '' } ` }
337
341
onClick = { ( ) => handleCopy ( spanOps . client ) }
338
342
title = "Click to copy operation name"
339
343
>
340
344
< span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
341
345
< code className = "text-purple-400 text-sm font-mono" > { spanOps . client } </ code >
342
- </ div >
346
+ </ button >
343
347
{ copiedSpan === spanOps . client && (
344
348
< div className = "absolute -top-8 left-1/2 -translate-x-1/2 bg-green-500/90 text-white text-xs px-2 py-1 rounded animate-fade-out" >
345
349
Copied!
@@ -361,6 +365,7 @@ function RouteComponent() {
361
365
< div className = "space-y-6" >
362
366
< div >
363
367
< button
368
+ type = "button"
364
369
onClick = { ( ) => {
365
370
setDemoStep ( prev => prev + 1 )
366
371
handleServerError ( )
@@ -384,6 +389,7 @@ function RouteComponent() {
384
389
< div className = "bg-red-900/20 border border-red-500/50 rounded-lg p-3" >
385
390
< div className = "flex items-center text-red-400 text-sm" >
386
391
< svg className = "w-4 h-4 mr-2" fill = "none" strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" viewBox = "0 0 24 24" stroke = "currentColor" >
392
+ < title > Red Warning Sign</ title >
387
393
< path d = "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
388
394
</ svg >
389
395
Server-side error captured and traced
@@ -392,14 +398,15 @@ function RouteComponent() {
392
398
< div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
393
399
< div className = "flex items-center justify-between" >
394
400
< div className = "relative" >
395
- < div
401
+ < button
402
+ type = "button"
396
403
className = { `inline-flex items-center bg-purple-900/40 px-3 py-1.5 rounded-lg border border-purple-500/50 cursor-pointer hover:bg-purple-900/60 transition-all ${ copiedSpan === spanOps . serverError ? 'scale-95' : '' } ` }
397
404
onClick = { ( ) => handleCopy ( spanOps . serverError ) }
398
405
title = "Click to copy operation name"
399
406
>
400
407
< span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
401
408
< code className = "text-purple-400 text-sm font-mono" > { spanOps . serverError } </ code >
402
- </ div >
409
+ </ button >
403
410
{ copiedSpan === spanOps . serverError && (
404
411
< div className = "absolute -top-8 left-1/2 -translate-x-1/2 bg-green-500/90 text-white text-xs px-2 py-1 rounded animate-fade-out" >
405
412
Copied!
@@ -414,6 +421,7 @@ function RouteComponent() {
414
421
415
422
< div >
416
423
< button
424
+ type = "button"
417
425
onClick = { ( ) => {
418
426
setDemoStep ( prev => prev + 1 )
419
427
handleServerTrace ( )
@@ -449,14 +457,15 @@ function RouteComponent() {
449
457
< div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
450
458
< div className = "flex items-center justify-between" >
451
459
< div className = "relative" >
452
- < div
460
+ < button
461
+ type = "button"
453
462
className = { `inline-flex items-center bg-purple-900/40 px-3 py-1.5 rounded-lg border border-purple-500/50 cursor-pointer hover:bg-purple-900/60 transition-all ${ copiedSpan === spanOps . server ? 'scale-95' : '' } ` }
454
463
onClick = { ( ) => handleCopy ( spanOps . server ) }
455
464
title = "Click to copy operation name"
456
465
>
457
466
< span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
458
467
< code className = "text-purple-400 text-sm font-mono" > { spanOps . server } </ code >
459
- </ div >
468
+ </ button >
460
469
{ copiedSpan === spanOps . server && (
461
470
< div className = "absolute -top-8 left-1/2 -translate-x-1/2 bg-green-500/90 text-white text-xs px-2 py-1 rounded animate-fade-out" >
462
471
Copied!
0 commit comments