Skip to content

Commit 1f23ebe

Browse files
committed
add test
1 parent fbb8722 commit 1f23ebe

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

packages/core/src/utils/applyScopeDataToEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function applyDataToEvent(event: Event, data: ScopeData): void {
142142
event.level = level;
143143
}
144144

145-
// transaction events get their `transaction` from the root span name
145+
// transaction events get their `transaction` from the root span name
146146
if (transactionName && event.type !== 'transaction') {
147147
event.transaction = transactionName;
148148
}

packages/core/test/lib/utils/applyScopeDataToEvent.test.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,38 @@ describe('applyScopeDataToEvent', () => {
187187
expect(event.transaction).toBe('/users/:id');
188188
});
189189

190-
it("doesn't the root span name to non-transaction events", () => {
190+
it('applies the root span name to transaction events', () => {
191+
const data: ScopeData = {
192+
eventProcessors: [],
193+
breadcrumbs: [],
194+
user: {},
195+
tags: {},
196+
extra: {},
197+
contexts: {},
198+
attachments: [],
199+
propagationContext: { spanId: '1', traceId: '1' },
200+
sdkProcessingMetadata: {},
201+
fingerprint: [],
202+
transactionName: 'foo',
203+
span: {
204+
attributes: {},
205+
startTime: 1,
206+
endTime: 2,
207+
status: 'ok',
208+
name: 'bar',
209+
// @ts-expect-error - we don't need to provide all span context fields
210+
spanContext: () => ({}),
211+
},
212+
};
213+
214+
const event: Event = { type: 'transaction' };
215+
216+
applyScopeDataToEvent(event, data);
217+
218+
expect(event.transaction).toBe('bar');
219+
});
220+
221+
it("doesn't apply the root span name to non-transaction events", () => {
191222
const data: ScopeData = {
192223
eventProcessors: [],
193224
breadcrumbs: [],

0 commit comments

Comments
 (0)