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
Add telemetry for @next/font #42579
Merged
Merged
Add telemetry for @next/font #42579
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fa51d97
Add telemetry for @next/font
f9daf8f
Fix path
835e4da
Add telemetry tests
fb95db1
Merge branch 'canary' into next-font-telemetry
c3f95fd
test descr
2fd8ad0
Merge branch 'canary' into next-font-telemetry
1805c89
Move telemetry tests to test/production
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { createNext, FileRef } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import { findAllTelemetryEvents } from 'next-test-utils' | ||
import { join } from 'path' | ||
|
||
const mockedGoogleFontResponses = require.resolve( | ||
'./google-font-mocked-responses.js' | ||
) | ||
|
||
describe('@next/font used telemetry', () => { | ||
const isNextStart = (global as any).isNextStart | ||
let next: NextInstance | ||
|
||
if (!isNextStart) { | ||
it('should only run when isNextStart', () => {}) | ||
return | ||
} | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
pages: new FileRef(join(__dirname, 'telemetry/pages')), | ||
'next.config.js': new FileRef( | ||
join(__dirname, 'basepath/next.config.js') | ||
), | ||
}, | ||
dependencies: { | ||
'@next/font': 'canary', | ||
}, | ||
env: { | ||
NEXT_FONT_GOOGLE_MOCKED_RESPONSES: mockedGoogleFontResponses, | ||
NEXT_TELEMETRY_DEBUG: '1', | ||
}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should send @next/font/google and @next/font/local usage event', async () => { | ||
const events = findAllTelemetryEvents( | ||
next.cliOutput, | ||
'NEXT_BUILD_FEATURE_USAGE' | ||
) | ||
expect(events).toContainEqual({ | ||
featureName: '@next/font/google', | ||
invocationCount: 1, | ||
}) | ||
expect(events).toContainEqual({ | ||
featureName: '@next/font/local', | ||
invocationCount: 1, | ||
}) | ||
}) | ||
}) | ||
|
||
describe('@next/font unused telemetry', () => { | ||
const isNextStart = (global as any).isNextStart | ||
let next: NextInstance | ||
|
||
if (!isNextStart) { | ||
it('should only run when isNextStart', () => {}) | ||
return | ||
} | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
pages: new FileRef(join(__dirname, 'telemetry/pages-unused')), | ||
'next.config.js': new FileRef( | ||
join(__dirname, 'basepath/next.config.js') | ||
), | ||
}, | ||
dependencies: { | ||
'@next/font': 'canary', | ||
}, | ||
env: { | ||
NEXT_FONT_GOOGLE_MOCKED_RESPONSES: mockedGoogleFontResponses, | ||
NEXT_TELEMETRY_DEBUG: '1', | ||
}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should send @next/font/google and @next/font/local usage event', async () => { | ||
const events = findAllTelemetryEvents( | ||
next.cliOutput, | ||
'NEXT_BUILD_FEATURE_USAGE' | ||
) | ||
expect(events).toContainEqual({ | ||
featureName: '@next/font/google', | ||
invocationCount: 0, | ||
}) | ||
expect(events).toContainEqual({ | ||
featureName: '@next/font/local', | ||
invocationCount: 0, | ||
}) | ||
}) | ||
}) |
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,13 @@ | ||
module.exports = { | ||
experimental: { | ||
fontLoaders: [ | ||
{ | ||
loader: '@next/font/google', | ||
options: { subsets: ['latin'] }, | ||
}, | ||
{ | ||
loader: '@next/font/local', | ||
}, | ||
], | ||
}, | ||
} |
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,3 @@ | ||
export default function Page() { | ||
return <p>Hello world</p> | ||
} |
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,13 @@ | ||
import localFont from '@next/font/local' | ||
|
||
const myFont = localFont({ src: './my-font.woff2' }) | ||
|
||
function MyApp({ Component, pageProps }) { | ||
return ( | ||
<div className={myFont.className}> | ||
<Component {...pageProps} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default MyApp |
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,11 @@ | ||
import { Open_Sans } from '@next/font/google' | ||
const openSans = Open_Sans({ subsets: ['latin'] }) | ||
|
||
export default function Page() { | ||
return ( | ||
<> | ||
<p>Hello world 1</p> | ||
<p className={openSans.className}>Hello world 2</p> | ||
</> | ||
) | ||
} |
Binary file not shown.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If the suite is only testing production behavior it can go in
test/production
instead.