1- import { notifyEventProcessors } from '@sentry/core' ;
21import { OpenTelemetryScope } from '@sentry/opentelemetry' ;
3- import type {
4- Attachment ,
5- Breadcrumb ,
6- Client ,
7- Event ,
8- EventHint ,
9- EventProcessor ,
10- Severity ,
11- SeverityLevel ,
12- } from '@sentry/types' ;
2+ import type { Attachment , Breadcrumb , Client , Event , EventHint , Severity , SeverityLevel } from '@sentry/types' ;
133import { uuid4 } from '@sentry/utils' ;
144
155import { getGlobalCarrier } from './globals' ;
@@ -116,13 +106,7 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
116106
117107 /** @inheritdoc */
118108 public getAttachments ( ) : Attachment [ ] {
119- const data = getGlobalScope ( ) . getScopeData ( ) ;
120- const isolationScopeData = this . _getIsolationScope ( ) . getScopeData ( ) ;
121- const scopeData = this . getScopeData ( ) ;
122-
123- // Merge data together, in order
124- mergeData ( data , isolationScopeData ) ;
125- mergeData ( data , scopeData ) ;
109+ const data = this . getScopeData ( ) ;
126110
127111 return data . attachments ;
128112 }
@@ -200,7 +184,7 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
200184 }
201185
202186 /** Get all relevant data for this scope. */
203- public getScopeData ( ) : ScopeData {
187+ public getPerScopeData ( ) : ScopeData {
204188 const {
205189 _breadcrumbs,
206190 _attachments,
@@ -230,63 +214,17 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
230214 } ;
231215 }
232216
233- /**
234- * Applies data from the scope to the event and runs all event processors on it.
235- *
236- * @param event Event
237- * @param hint Object containing additional information about the original exception, for use by the event processors.
238- * @hidden
239- */
240- public applyToEvent (
241- event : Event ,
242- hint : EventHint = { } ,
243- additionalEventProcessors : EventProcessor [ ] = [ ] ,
244- ) : PromiseLike < Event | null > {
245- const data = getGlobalScope ( ) . getScopeData ( ) ;
246- const isolationScopeData = this . _getIsolationScope ( ) . getScopeData ( ) ;
247- const scopeData = this . getScopeData ( ) ;
217+ /** @inheritdoc */
218+ public getScopeData ( ) : ScopeData {
219+ const data = getGlobalScope ( ) . getPerScopeData ( ) ;
220+ const isolationScopeData = this . _getIsolationScope ( ) . getPerScopeData ( ) ;
221+ const scopeData = this . getPerScopeData ( ) ;
248222
249223 // Merge data together, in order
250224 mergeData ( data , isolationScopeData ) ;
251225 mergeData ( data , scopeData ) ;
252226
253- // Apply the data
254- const { extra, tags, user, contexts, level, sdkProcessingMetadata, breadcrumbs, fingerprint, eventProcessors } =
255- data ;
256-
257- mergePropKeep ( event , 'extra' , extra ) ;
258- mergePropKeep ( event , 'tags' , tags ) ;
259- mergePropKeep ( event , 'user' , user ) ;
260- mergePropKeep ( event , 'contexts' , contexts ) ;
261- mergePropKeep ( event , 'sdkProcessingMetadata' , sdkProcessingMetadata ) ;
262- event . sdkProcessingMetadata = {
263- ...event . sdkProcessingMetadata ,
264- propagationContext : this . _propagationContext ,
265- } ;
266-
267- mergeArray ( event , 'breadcrumbs' , breadcrumbs ) ;
268- mergeArray ( event , 'fingerprint' , fingerprint ) ;
269-
270- if ( level ) {
271- event . level = level ;
272- }
273-
274- const allEventProcessors = [ ...additionalEventProcessors , ...eventProcessors ] ;
275-
276- // Apply additional things to the event
277- if ( this . _transactionName ) {
278- event . transaction = this . _transactionName ;
279- }
280-
281- return notifyEventProcessors ( allEventProcessors , event , hint ) ;
282- }
283-
284- /**
285- * Get all breadcrumbs attached to this scope.
286- * @internal
287- */
288- public getBreadcrumbs ( ) : Breadcrumb [ ] {
289- return this . _breadcrumbs ;
227+ return data ;
290228 }
291229
292230 /** Get the isolation scope for this scope. */
@@ -308,6 +246,7 @@ export function mergeData(data: ScopeData, mergeData: ScopeData): void {
308246 fingerprint,
309247 eventProcessors,
310248 attachments,
249+ propagationContext,
311250 } = mergeData ;
312251
313252 mergePropOverwrite ( data , 'extra' , extra ) ;
@@ -335,6 +274,8 @@ export function mergeData(data: ScopeData, mergeData: ScopeData): void {
335274 if ( attachments . length ) {
336275 data . attachments = [ ...data . attachments , ...attachments ] ;
337276 }
277+
278+ data . propagationContext = { ...data . propagationContext , ...propagationContext } ;
338279}
339280
340281/**
0 commit comments