-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(tracing): Make tracing integrations tree shakeable (#4204)
Cuts ~2kb for nextjs client gzip + minified bundle. Previously we expected users to import tracing integrations like ```js import { Integrations } from '@sentry/tracing'; const instance = new Integrations.BrowserTracing(); ``` This makes the integrations unable to be treeshaken though. To address this, we now have this individual export. We now expect users to consume BrowserTracing like so: ```js import { BrowserTracing } from '@sentry/tracing'; const instance = new BrowserTracing(); ``` This works because we avoid the object spread in the index, we instead just take advantage of js exporting the object correctly.
- Loading branch information
1 parent
d17f049
commit aeedac2
Showing
5 changed files
with
51 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import { Integrations } from '../src/index.bundle'; | ||
import { testOnlyIfNodeVersionAtLeast } from './testutils'; | ||
|
||
describe('Integrations export', () => { | ||
// TODO `Object.values` doesn't work on Node < 8 | ||
testOnlyIfNodeVersionAtLeast(8)('is exported correctly', () => { | ||
Object.values(Integrations).forEach(integration => { | ||
expect(integration.id).toStrictEqual(expect.any(String)); | ||
it('is exported correctly', () => { | ||
Object.keys(Integrations).forEach(key => { | ||
expect(Integrations[key as keyof typeof Integrations].id).toStrictEqual(expect.any(String)); | ||
}); | ||
}); | ||
}); |
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,23 @@ | ||
import { getCurrentHub } from '@sentry/hub'; | ||
|
||
import { BrowserTracing, Integrations } from '../src'; | ||
|
||
describe('index', () => { | ||
it('patches the global hub to add an implementation for `Hub.startTransaction` as a side effect', () => { | ||
const hub = getCurrentHub(); | ||
const transaction = hub.startTransaction({ name: 'test', endTimestamp: 123 }); | ||
expect(transaction).toBeDefined(); | ||
}); | ||
|
||
describe('Integrations', () => { | ||
it('is exported correctly', () => { | ||
Object.keys(Integrations).forEach(key => { | ||
expect(Integrations[key as keyof typeof Integrations].id).toStrictEqual(expect.any(String)); | ||
}); | ||
}); | ||
|
||
it('contains BrowserTracing', () => { | ||
expect(Integrations.BrowserTracing).toEqual(BrowserTracing); | ||
}); | ||
}); | ||
}); |