11import * as SentryCore from '@sentry/core' ;
2- import {
3- captureSpan ,
4- debug ,
5- hasSpanStreamingEnabled ,
6- isStreamedBeforeSendSpanCallback ,
7- spanIsSampled ,
8- } from '@sentry/core' ;
9- import type { Span } from '@sentry/core' ;
2+ import { debug } from '@sentry/core' ;
103import { beforeEach , describe , expect , it , vi } from 'vitest' ;
114import { BrowserClient , spanStreamingIntegration } from '../../src' ;
125import { getDefaultBrowserClientOptions } from '../helper/browser-client-options' ;
@@ -27,35 +20,6 @@ vi.mock('@sentry/core', async () => {
2720 return {
2821 ...original ,
2922 SpanBuffer : MockSpanBuffer ,
30- setupSpanStreaming : vi . fn ( ( client : any ) => {
31- const initialMessage = 'SpanStreaming integration requires' ;
32- const fallbackMsg = 'Falling back to static trace lifecycle.' ;
33-
34- if ( ! ( original as any ) . hasSpanStreamingEnabled ( client ) ) {
35- ( original as any ) . debug . warn ( `${ initialMessage } \`traceLifecycle\` to be set to "stream"! ${ fallbackMsg } ` ) ;
36- return undefined ;
37- }
38-
39- const beforeSendSpan = client . getOptions ( ) . beforeSendSpan ;
40- if ( beforeSendSpan && ! ( original as any ) . isStreamedBeforeSendSpanCallback ( beforeSendSpan ) ) {
41- client . getOptions ( ) . traceLifecycle = 'static' ;
42- ( original as any ) . debug . warn (
43- `${ initialMessage } a beforeSendSpan callback using \`withStreamedSpan\`! ${ fallbackMsg } ` ,
44- ) ;
45- return undefined ;
46- }
47-
48- const buffer = new MockSpanBuffer ( client ) ;
49-
50- client . on ( 'afterSpanEnd' , ( span : Readonly < Span > ) => {
51- if ( ! ( original as any ) . spanIsSampled ( span ) ) {
52- return ;
53- }
54- buffer . add ( ( original as any ) . captureSpan ( span , client ) ) ;
55- } ) ;
56-
57- return buffer ;
58- } ) ,
5923 } ;
6024} ) ;
6125
@@ -113,7 +77,7 @@ describe('spanStreamingIntegration', () => {
11377 dsn : 'https://username@domain/123' ,
11478 integrations : [ spanStreamingIntegration ( ) ] ,
11579 traceLifecycle : 'stream' ,
116- beforeSendSpan : ( span : Span ) => span ,
80+ beforeSendSpan : ( span : SentryCore . SpanJSON ) => span ,
11781 } ) ;
11882
11983 SentryCore . setCurrentClient ( client ) ;
0 commit comments