-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rum-core): add network info for all transactions #752
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import resourceEntries from '../fixtures/resource-entries' | |
import Span from '../../src/performance-monitoring/span' | ||
import Transaction from '../../src/performance-monitoring/transaction' | ||
import { PAGE_LOAD } from '../../src/common/constants' | ||
import { toEqualOrUndefined } from '../../../../dev-utils/jasmine' | ||
import { mockGetEntriesByType } from '../utils/globals-mock' | ||
|
||
describe('Context', () => { | ||
|
@@ -166,6 +167,7 @@ describe('Context', () => { | |
}) | ||
|
||
it('should enrich transaction with context info based on type', () => { | ||
jasmine.addMatchers({ toEqualOrUndefined }) | ||
const transaction = new Transaction('test', 'custom') | ||
const trContext = { tags: { tag1: 'tag1' } } | ||
transaction.addContext(trContext) | ||
|
@@ -182,12 +184,16 @@ describe('Context', () => { | |
message: 'test' | ||
} | ||
} | ||
addTransactionContext(transaction, configContext) | ||
expect(transaction.context).toEqual({ | ||
page: { | ||
const pageContext = { | ||
page: jasmine.objectContaining({ | ||
referer: jasmine.any(String), | ||
url: jasmine.any(String) | ||
}, | ||
}) | ||
} | ||
|
||
addTransactionContext(transaction, configContext) | ||
expect(transaction.context).toEqual({ | ||
...pageContext, | ||
...userContext, | ||
...trContext | ||
}) | ||
|
@@ -197,10 +203,7 @@ describe('Context', () => { | |
pageloadTr.end() | ||
addTransactionContext(pageloadTr, configContext) | ||
expect(pageloadTr.context).toEqual({ | ||
page: { | ||
referer: jasmine.any(String), | ||
url: jasmine.any(String) | ||
}, | ||
...pageContext, | ||
response: { | ||
transfer_size: 26941, | ||
encoded_body_size: 105297, | ||
|
@@ -211,7 +214,12 @@ describe('Context', () => { | |
}, | ||
...userContext | ||
}) | ||
|
||
expect(pageloadTr.context.page.netinfo).toEqualOrUndefined({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If i get it right, do you want to test it only for supported browsers? Like we do explicit check like if (connection) {
expect(measuredInfo).toBe(actualInfo)?
} I was trying to express this using the matcher, May be i missed something. We can also do explicit checks in tests if its confusing.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct! also check the else condition, i.e: if (connection) {
expect(measuredInfo).toBe(actualInfo)
} else {
expect(measuredInfo).toBe(undefined)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sounds good 👍 |
||
downlink: jasmine.any(Number), | ||
effective_type: jasmine.any(String), | ||
rtt: jasmine.any(Number), | ||
save_data: jasmine.any(Boolean) | ||
}) | ||
unmock() | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to not negate the condition and just wrap the following return inside if.