1
1
/* eslint-disable max-lines */
2
- import type { SentrySpan } from '@sentry/core' ;
3
2
import { getActiveSpan , startInactiveSpan } from '@sentry/core' ;
4
3
import { setMeasurement } from '@sentry/core' ;
5
4
import type { Measurements , Span , StartSpanOptions } from '@sentry/types' ;
@@ -445,15 +444,11 @@ function _trackNavigator(span: Span): void {
445
444
const connection = navigator . connection ;
446
445
if ( connection ) {
447
446
if ( connection . effectiveType ) {
448
- // TODO: Can we rewrite this to an attribute?
449
- // eslint-disable-next-line deprecation/deprecation
450
- ( span as SentrySpan ) . setTag ( 'effectiveConnectionType' , connection . effectiveType ) ;
447
+ span . setAttribute ( 'effectiveConnectionType' , connection . effectiveType ) ;
451
448
}
452
449
453
450
if ( connection . type ) {
454
- // TODO: Can we rewrite this to an attribute?
455
- // eslint-disable-next-line deprecation/deprecation
456
- ( span as SentrySpan ) . setTag ( 'connectionType' , connection . type ) ;
451
+ span . setAttribute ( 'connectionType' , connection . type ) ;
457
452
}
458
453
459
454
if ( isMeasurementValue ( connection . rtt ) ) {
@@ -462,15 +457,11 @@ function _trackNavigator(span: Span): void {
462
457
}
463
458
464
459
if ( isMeasurementValue ( navigator . deviceMemory ) ) {
465
- // TODO: Can we rewrite this to an attribute?
466
- // eslint-disable-next-line deprecation/deprecation
467
- ( span as SentrySpan ) . setTag ( 'deviceMemory' , `${ navigator . deviceMemory } GB` ) ;
460
+ span . setAttribute ( 'deviceMemory' , `${ navigator . deviceMemory } GB` ) ;
468
461
}
469
462
470
463
if ( isMeasurementValue ( navigator . hardwareConcurrency ) ) {
471
- // TODO: Can we rewrite this to an attribute?
472
- // eslint-disable-next-line deprecation/deprecation
473
- ( span as SentrySpan ) . setTag ( 'hardwareConcurrency' , String ( navigator . hardwareConcurrency ) ) ;
464
+ span . setAttribute ( 'hardwareConcurrency' , String ( navigator . hardwareConcurrency ) ) ;
474
465
}
475
466
}
476
467
@@ -482,36 +473,26 @@ function _tagMetricInfo(span: Span): void {
482
473
// Capture Properties of the LCP element that contributes to the LCP.
483
474
484
475
if ( _lcpEntry . element ) {
485
- // TODO: Can we rewrite this to an attribute?
486
- // eslint-disable-next-line deprecation/deprecation
487
- ( span as SentrySpan ) . setTag ( 'lcp.element' , htmlTreeAsString ( _lcpEntry . element ) ) ;
476
+ span . setAttribute ( 'lcp.element' , htmlTreeAsString ( _lcpEntry . element ) ) ;
488
477
}
489
478
490
479
if ( _lcpEntry . id ) {
491
- // TODO: Can we rewrite this to an attribute?
492
- // eslint-disable-next-line deprecation/deprecation
493
- ( span as SentrySpan ) . setTag ( 'lcp.id' , _lcpEntry . id ) ;
480
+ span . setAttribute ( 'lcp.id' , _lcpEntry . id ) ;
494
481
}
495
482
496
483
if ( _lcpEntry . url ) {
497
484
// Trim URL to the first 200 characters.
498
- // TODO: Can we rewrite this to an attribute?
499
- // eslint-disable-next-line deprecation/deprecation
500
- ( span as SentrySpan ) . setTag ( 'lcp.url' , _lcpEntry . url . trim ( ) . slice ( 0 , 200 ) ) ;
485
+ span . setAttribute ( 'lcp.url' , _lcpEntry . url . trim ( ) . slice ( 0 , 200 ) ) ;
501
486
}
502
487
503
- // TODO: Can we rewrite this to an attribute?
504
- // eslint-disable-next-line deprecation/deprecation
505
- ( span as SentrySpan ) . setTag ( 'lcp.size' , _lcpEntry . size ) ;
488
+ span . setAttribute ( 'lcp.size' , _lcpEntry . size ) ;
506
489
}
507
490
508
491
// See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift
509
492
if ( _clsEntry && _clsEntry . sources ) {
510
493
DEBUG_BUILD && logger . log ( '[Measurements] Adding CLS Data' ) ;
511
494
_clsEntry . sources . forEach ( ( source , index ) =>
512
- // TODO: Can we rewrite this to an attribute?
513
- // eslint-disable-next-line deprecation/deprecation
514
- ( span as SentrySpan ) . setTag ( `cls.source.${ index + 1 } ` , htmlTreeAsString ( source . node ) ) ,
495
+ span . setAttribute ( `cls.source.${ index + 1 } ` , htmlTreeAsString ( source . node ) ) ,
515
496
) ;
516
497
}
517
498
}
0 commit comments