| 99 | |
| 100 | /** Exported only for tests */ |
| 101 | export 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 |