-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Refactor telemetry usage flow #7522
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 |
---|---|---|
|
@@ -32,7 +32,6 @@ export function createDevelopmentEnvironment( | |
site: settings.config.site, | ||
ssr: isServerLikeOutput(settings.config), | ||
streaming: true, | ||
telemetry: Boolean(settings.forceDisableTelemetry), | ||
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. Note: There's a bug here before. This should be |
||
}); | ||
|
||
return { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ polyfill(globalThis, { | |
exclude: 'window document', | ||
}); | ||
|
||
// Disable telemetry when running tests | ||
process.env.ASTRO_TELEMETRY_DISABLED = true; | ||
Comment on lines
+25
to
+26
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. This is where I disable the telemetry. It should affect other integration tests as they import this file too. |
||
|
||
/** | ||
* @typedef {import('undici').Response} Response | ||
* @typedef {import('../src/core/dev/dev').DedvServer} DevServer | ||
|
@@ -146,13 +149,6 @@ export async function loadFixture(inlineConfig) { | |
return settings; | ||
}; | ||
|
||
/** @type {import('@astrojs/telemetry').AstroTelemetry} */ | ||
const telemetry = { | ||
record() { | ||
return Promise.resolve(); | ||
}, | ||
}; | ||
|
||
const resolveUrl = (url) => | ||
`http://${config.server.host || 'localhost'}:${config.server.port}${url.replace(/^\/?/, '/')}`; | ||
|
||
|
@@ -184,15 +180,15 @@ export async function loadFixture(inlineConfig) { | |
return { | ||
build: async (opts = {}) => { | ||
process.env.NODE_ENV = 'production'; | ||
return build(await getSettings(), { logging, telemetry, ...opts }); | ||
return build(await getSettings(), { logging, ...opts }); | ||
}, | ||
sync: async (opts) => sync(await getSettings(), { logging, fs, ...opts }), | ||
check: async (opts) => { | ||
return await check(await getSettings(), { logging, ...opts }); | ||
}, | ||
startDevServer: async (opts = {}) => { | ||
process.env.NODE_ENV = 'development'; | ||
devServer = await dev(await getSettings(), { logging, telemetry, ...opts }); | ||
devServer = await dev(await getSettings(), { logging, ...opts }); | ||
config.server.host = parseAddressToHost(devServer.address.address); // update host | ||
config.server.port = devServer.address.port; // update port | ||
return devServer; | ||
|
@@ -214,11 +210,7 @@ export async function loadFixture(inlineConfig) { | |
}, | ||
preview: async (opts = {}) => { | ||
process.env.NODE_ENV = 'production'; | ||
const previewServer = await preview(await getSettings(), { | ||
logging, | ||
telemetry, | ||
...opts, | ||
}); | ||
const previewServer = await preview(await getSettings(), { logging, ...opts }); | ||
config.server.host = parseAddressToHost(previewServer.host); // update host | ||
config.server.port = previewServer.port; // update port | ||
return previewServer; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ describe('<Code />', () => { | |
let container; | ||
let mod; | ||
before(async () => { | ||
container = await createContainer({ root, disableTelemetry: true }); | ||
container = await createContainer({ root }); | ||
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. For unit tests, I didn't disable telemetry because the only way is to set it through the npm script command, which is a bit ugly. But:
So I think it's fine 😬 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. How do we discover if the unit tests will start triggering telemetry events? 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. I don't know 😄 Currently I do a global search for I wouldn't mind adding a flag to the npm script to disable it completely if you prefer too. |
||
const loader = createViteLoader(container.viteServer); | ||
mod = await loader.import('astro/components/Shiki.js'); | ||
}); | ||
|
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.
For the code review, you may notice
disableTelemetry
,forceDisableTelemtry
, etc gets removed. I found these options only exists for tests to pass a value.I removed it to simplify the code and rely on
process.env.ASTRO_TELEMETRY_DISABLED = true
instead.