MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / update

Method update

packages/core/src/scope.ts:495–547  ·  view source on GitHub ↗

* Updates the scope with provided data. Can work in three variations: * - plain object containing updatable attributes * - Scope instance that'll extract the attributes from * - callback function that'll receive the current scope as an argument and allow for modifications

(captureContext?: CaptureContext)

Source from the content-addressed store, hash-verified

493 * - callback function that'll receive the current scope as an argument and allow for modifications
494 */
495 public update(captureContext?: CaptureContext): this {
496 if (!captureContext) {
497 return this;
498 }
499
500 const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;
501
502 const scopeInstance =
503 scopeToMerge instanceof Scope
504 ? scopeToMerge.getScopeData()
505 : isPlainObject(scopeToMerge)
506 ? (captureContext as ScopeContext)
507 : undefined;
508
509 const {
510 tags,
511 attributes,
512 extra,
513 user,
514 contexts,
515 level,
516 fingerprint = [],
517 propagationContext,
518 conversationId,
519 } = scopeInstance || {};
520
521 this._tags = { ...this._tags, ...tags };
522 this._attributes = { ...this._attributes, ...attributes };
523 this._extra = { ...this._extra, ...extra };
524 this._contexts = { ...this._contexts, ...contexts };
525
526 if (user && Object.keys(user).length) {
527 this._user = user;
528 }
529
530 if (level) {
531 this._level = level;
532 }
533
534 if (fingerprint.length) {
535 this._fingerprint = fingerprint;
536 }
537
538 if (propagationContext) {
539 this._propagationContext = propagationContext;
540 }
541
542 if (conversationId) {
543 this._conversationId = conversationId;
544 }
545
546 return this;
547 }
548
549 /**
550 * Clears the current scope and resets its properties.

Callers 15

initAndBindFunction · 0.45
getFinalScopeFunction · 0.45
_initFunction · 0.45
_initFunction · 0.45
initFunction · 0.45
stringToUUIDFunction · 0.45
hashSha256base64Function · 0.45
metrics.test.tsFile · 0.45
sendBlockEventFunction · 0.45
outputDependencyCacheKeyFunction · 0.45
toggleFunction · 0.45
index.tsFile · 0.45

Calls 3

isPlainObjectFunction · 0.90
getScopeDataMethod · 0.80
keysMethod · 0.65

Tested by

no test coverage detected