99import * as fs from 'node:fs/promises'
1010import { createFileRoute } from '@tanstack/react-router'
1111import { 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" ;
1413import { useState , useEffect , useRef } from 'react'
1514
1615export const Route = createFileRoute ( '/demo/sentry/testing' ) ( {
@@ -21,7 +20,7 @@ export const Route = createFileRoute('/demo/sentry/testing')({
2120const badServerFunc = createServerFn ( {
2221 method : 'GET' ,
2322} ) . handler ( async ( ) => {
24- return await SentryServer . startSpan (
23+ return await Sentry . startSpan (
2524 {
2625 name : 'Reading non-existent file' ,
2726 op : 'file.read'
@@ -31,7 +30,7 @@ const badServerFunc = createServerFn({
3130 await fs . readFile ( './doesnt-exist' , 'utf-8' )
3231 return true
3332 } catch ( error ) {
34- SentryServer . captureException ( error )
33+ Sentry . captureException ( error )
3534 throw error
3635 }
3736 }
@@ -42,7 +41,7 @@ const badServerFunc = createServerFn({
4241const goodServerFunc = createServerFn ( {
4342 method : 'GET' ,
4443} ) . handler ( async ( ) => {
45- return await SentryServer . startSpan (
44+ return await Sentry . startSpan (
4645 {
4746 name : 'Successful server operation' ,
4847 op : 'demo.success'
@@ -244,6 +243,7 @@ function RouteComponent() {
244243 < div className = "space-y-6" >
245244 < div >
246245 < button
246+ type = "button"
247247 onClick = { ( ) => {
248248 setDemoStep ( prev => prev + 1 )
249249 handleClientError ( )
@@ -267,22 +267,24 @@ function RouteComponent() {
267267 < div className = "bg-red-900/20 border border-red-500/50 rounded-lg p-2" >
268268 < div className = "flex items-center text-red-400 text-sm" >
269269 < 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" />
271272 </ svg >
272273 Client-side error captured and traced
273274 </ div >
274275 </ div >
275276 < div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
276277 < div className = "flex items-center justify-between" >
277278 < div className = "relative" >
278- < div
279+ < button
280+ type = "button"
279281 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' : '' } ` }
280282 onClick = { ( ) => handleCopy ( spanOps . clientError ) }
281283 title = "Click to copy operation name"
282284 >
283285 < span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
284286 < code className = "text-purple-400 text-sm font-mono" > { spanOps . clientError } </ code >
285- </ div >
287+ </ button >
286288 { copiedSpan === spanOps . clientError && (
287289 < 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" >
288290 Copied!
@@ -297,6 +299,7 @@ function RouteComponent() {
297299
298300 < div >
299301 < button
302+ type = "button"
300303 onClick = { ( ) => {
301304 setDemoStep ( prev => prev + 1 )
302305 handleClientTrace ( )
@@ -332,14 +335,15 @@ function RouteComponent() {
332335 < div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
333336 < div className = "flex items-center justify-between" >
334337 < div className = "relative" >
335- < div
338+ < button
339+ type = "button"
336340 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' : '' } ` }
337341 onClick = { ( ) => handleCopy ( spanOps . client ) }
338342 title = "Click to copy operation name"
339343 >
340344 < span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
341345 < code className = "text-purple-400 text-sm font-mono" > { spanOps . client } </ code >
342- </ div >
346+ </ button >
343347 { copiedSpan === spanOps . client && (
344348 < 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" >
345349 Copied!
@@ -361,6 +365,7 @@ function RouteComponent() {
361365 < div className = "space-y-6" >
362366 < div >
363367 < button
368+ type = "button"
364369 onClick = { ( ) => {
365370 setDemoStep ( prev => prev + 1 )
366371 handleServerError ( )
@@ -384,6 +389,7 @@ function RouteComponent() {
384389 < div className = "bg-red-900/20 border border-red-500/50 rounded-lg p-3" >
385390 < div className = "flex items-center text-red-400 text-sm" >
386391 < 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 >
387393 < 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" />
388394 </ svg >
389395 Server-side error captured and traced
@@ -392,14 +398,15 @@ function RouteComponent() {
392398 < div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
393399 < div className = "flex items-center justify-between" >
394400 < div className = "relative" >
395- < div
401+ < button
402+ type = "button"
396403 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' : '' } ` }
397404 onClick = { ( ) => handleCopy ( spanOps . serverError ) }
398405 title = "Click to copy operation name"
399406 >
400407 < span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
401408 < code className = "text-purple-400 text-sm font-mono" > { spanOps . serverError } </ code >
402- </ div >
409+ </ button >
403410 { copiedSpan === spanOps . serverError && (
404411 < 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" >
405412 Copied!
@@ -414,6 +421,7 @@ function RouteComponent() {
414421
415422 < div >
416423 < button
424+ type = "button"
417425 onClick = { ( ) => {
418426 setDemoStep ( prev => prev + 1 )
419427 handleServerTrace ( )
@@ -449,14 +457,15 @@ function RouteComponent() {
449457 < div className = "bg-purple-900/20 border border-purple-500/50 rounded-lg p-3" >
450458 < div className = "flex items-center justify-between" >
451459 < div className = "relative" >
452- < div
460+ < button
461+ type = "button"
453462 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' : '' } ` }
454463 onClick = { ( ) => handleCopy ( spanOps . server ) }
455464 title = "Click to copy operation name"
456465 >
457466 < span className = "text-purple-300 text-sm font-medium mr-2" > span.op</ span >
458467 < code className = "text-purple-400 text-sm font-mono" > { spanOps . server } </ code >
459- </ div >
468+ </ button >
460469 { copiedSpan === spanOps . server && (
461470 < 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" >
462471 Copied!
0 commit comments