Simplify telemetry Vite version detection (#7414)
This commit is contained in:
parent
8f4a04d46b
commit
bb644834ef
2 changed files with 7 additions and 11 deletions
5
.changeset/brave-candles-invent.md
Normal file
5
.changeset/brave-candles-invent.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Simplify telemetry Vite version detection
|
|
@ -1,19 +1,10 @@
|
||||||
import { AstroTelemetry } from '@astrojs/telemetry';
|
import { AstroTelemetry } from '@astrojs/telemetry';
|
||||||
import { createRequire } from 'module';
|
import { version as viteVersion } from 'vite';
|
||||||
import { ASTRO_VERSION } from '../core/constants.js';
|
import { ASTRO_VERSION } from '../core/constants.js';
|
||||||
const require = createRequire(import.meta.url);
|
|
||||||
|
|
||||||
function getViteVersion() {
|
|
||||||
try {
|
|
||||||
const { version } = require('vite/package.json');
|
|
||||||
return version;
|
|
||||||
} catch (e) {}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const telemetry = new AstroTelemetry({
|
export const telemetry = new AstroTelemetry({
|
||||||
astroVersion: ASTRO_VERSION,
|
astroVersion: ASTRO_VERSION,
|
||||||
viteVersion: getViteVersion(),
|
viteVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
export * from './error.js';
|
export * from './error.js';
|
||||||
|
|
Loading…
Add table
Reference in a new issue