-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: custom tracing in production builds (#27124)
Update trace utilities to use Sentry functions via `globalThis`. Add trace E2E tests.
- Loading branch information
1 parent
0c3e391
commit 9c77f61
Showing
7 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { MockttpServer } from 'mockttp'; | ||
import FixtureBuilder from '../../fixture-builder'; | ||
import { | ||
defaultGanacheOptions, | ||
unlockWallet, | ||
withFixtures, | ||
} from '../../helpers'; | ||
import { | ||
expectMockRequest, | ||
expectNoMockRequest, | ||
} from '../../helpers/mock-server'; | ||
|
||
async function mockSentryCustomTrace(mockServer: MockttpServer) { | ||
return [ | ||
await mockServer | ||
.forPost(/sentry/u) | ||
.withBodyIncluding('"transaction":"UI Startup"') | ||
.thenCallback(() => { | ||
return { | ||
statusCode: 200, | ||
json: {}, | ||
}; | ||
}), | ||
]; | ||
} | ||
|
||
async function mockSentryAutomatedTrace(mockServer: MockttpServer) { | ||
return [ | ||
await mockServer | ||
.forPost(/sentry/u) | ||
.withBodyIncluding('"transaction":"/home.html"') | ||
.thenCallback(() => { | ||
return { | ||
statusCode: 200, | ||
json: {}, | ||
}; | ||
}), | ||
]; | ||
} | ||
|
||
describe('Traces', function () { | ||
it('sends custom trace when opening UI if metrics enabled', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder() | ||
.withMetaMetricsController({ | ||
participateInMetaMetrics: true, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
testSpecificMock: mockSentryCustomTrace, | ||
manifestFlags: { | ||
doNotForceSentryForThisTest: true, | ||
}, | ||
}, | ||
async ({ driver, mockedEndpoint }) => { | ||
await unlockWallet(driver); | ||
await expectMockRequest(driver, mockedEndpoint[0], { timeout: 3000 }); | ||
}, | ||
); | ||
}); | ||
|
||
it('does not send custom trace when opening UI if metrics disabled @no-mmi', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder() | ||
.withMetaMetricsController({ | ||
participateInMetaMetrics: false, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
testSpecificMock: mockSentryCustomTrace, | ||
manifestFlags: { | ||
doNotForceSentryForThisTest: true, | ||
}, | ||
}, | ||
async ({ driver, mockedEndpoint }) => { | ||
await unlockWallet(driver); | ||
await expectNoMockRequest(driver, mockedEndpoint[0], { timeout: 3000 }); | ||
}, | ||
); | ||
}); | ||
|
||
it('sends automated trace when opening UI if metrics enabled', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder() | ||
.withMetaMetricsController({ | ||
participateInMetaMetrics: true, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
testSpecificMock: mockSentryAutomatedTrace, | ||
manifestFlags: { | ||
doNotForceSentryForThisTest: true, | ||
}, | ||
}, | ||
async ({ driver, mockedEndpoint }) => { | ||
await unlockWallet(driver); | ||
await expectMockRequest(driver, mockedEndpoint[0], { timeout: 3000 }); | ||
}, | ||
); | ||
}); | ||
|
||
it('does not send automated trace when opening UI if metrics disabled @no-mmi', async function () { | ||
await withFixtures( | ||
{ | ||
fixtures: new FixtureBuilder() | ||
.withMetaMetricsController({ | ||
participateInMetaMetrics: false, | ||
}) | ||
.build(), | ||
ganacheOptions: defaultGanacheOptions, | ||
title: this.test?.fullTitle(), | ||
testSpecificMock: mockSentryAutomatedTrace, | ||
manifestFlags: { | ||
doNotForceSentryForThisTest: true, | ||
}, | ||
}, | ||
async ({ driver, mockedEndpoint }) => { | ||
await unlockWallet(driver); | ||
await expectNoMockRequest(driver, mockedEndpoint[0], { timeout: 3000 }); | ||
}, | ||
); | ||
}); | ||
}); |