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

Function mergeArray

packages/core/src/utils/scopeData.ts:101–115  ·  view source on GitHub ↗
(
  event: Event,
  prop: Prop,
  mergeVal: ScopeData[Prop],
)

Source from the content-addressed store, hash-verified

99
100/** Exported only for tests */
101export function mergeArray<Prop extends 'breadcrumbs' | 'fingerprint'>(
102 event: Event,
103 prop: Prop,
104 mergeVal: ScopeData[Prop],
105): void {
106 const prevVal = event[prop];
107 // If we are not merging any new values,
108 // we only need to proceed if there was an empty array before (as we want to replace it with undefined)
109 if (!mergeVal.length && (!prevVal || prevVal.length)) {
110 return;
111 }
112
113 const merged = [...(prevVal || []), ...mergeVal] as ScopeData[Prop];
114 event[prop] = merged.length ? merged : undefined;
115}
116
117/**
118 * Get the scope data for the current scope after merging with the

Callers 1

scopeData.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected