From d0e19bcfcef95304566ff3a15f65d5aba2e062cc Mon Sep 17 00:00:00 2001 From: cjr125 Date: Wed, 4 Dec 2024 15:13:58 -0500 Subject: [PATCH] added unit test --- .../transaction-service.spec.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/rum-core/test/performance-monitoring/transaction-service.spec.js b/packages/rum-core/test/performance-monitoring/transaction-service.spec.js index ce511c99f..bada10914 100644 --- a/packages/rum-core/test/performance-monitoring/transaction-service.spec.js +++ b/packages/rum-core/test/performance-monitoring/transaction-service.spec.js @@ -619,6 +619,35 @@ describe('TransactionService', function () { transaction.end(pageLoadTime + 1000) }) + + it('should capture tags from dispatch context', done => { + // todo: can't test hard navigation metrics since karma runs tests inside an iframe + config.setConfig({ + transactionContextCallback: () => { + let stack + try { + throw new Error('') + } + catch (error) { + stack = error.stack || '' + } + stack = stack.split('\n').map(function (line) { return line.trim(); }) + return { stack }; + } + }) + const transactionService = new TransactionService(logger, config) + + const tr1 = transactionService.startTransaction( + 'transaction1', + 'transaction' + ) + + tr1.onEnd = () => { + expect(tr1.options.tags.stack).toBeTruthy() + done() + } + tr1.end() + }) }) it('should truncate active spans after transaction ends', () => {