-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
update telemetry to support more anonymized project id #3713
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"astro": patch | ||
"@astrojs/telemetry": minor | ||
--- | ||
|
||
Update telemetry to support a more anonymized project id. `anonymousProjectId` is now hashed based on anonymous git data instead of your git remote URL. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './build.js'; | ||
export * from './session.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
import { createRequire } from 'node:module'; | ||
|
||
import type { AstroUserConfig } from '../@types/astro'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const EVENT_SESSION = 'ASTRO_CLI_SESSION_STARTED'; | ||
|
||
// :( We can't import the type because of TurboRepo circular dep limitation | ||
type AstroUserConfig = Record<string, any>; | ||
|
||
interface EventCliSession { | ||
astroVersion: string; | ||
cliCommand: string; | ||
} | ||
|
||
|
@@ -25,7 +21,7 @@ interface ConfigInfo { | |
markdown: | ||
| undefined | ||
| { | ||
mode: undefined | 'md' | 'mdx'; | ||
drafts: undefined | boolean; | ||
syntaxHighlight: undefined | 'shiki' | 'prism' | false; | ||
}; | ||
} | ||
|
@@ -91,15 +87,18 @@ export function eventCliSession( | |
flags?: Record<string, any> | ||
): { eventName: string; payload: EventCliSessionInternal }[] { | ||
// Filter out falsy integrations | ||
const integrations = userConfig?.integrations?.filter?.(Boolean) ?? []; | ||
const configValues = userConfig | ||
? { | ||
markdownPlugins: [ | ||
userConfig?.markdown?.remarkPlugins ?? [], | ||
userConfig?.markdown?.rehypePlugins ?? [], | ||
].flat(1), | ||
...(userConfig?.markdown?.remarkPlugins?.map((p) => | ||
typeof p === 'string' ? p : typeof p | ||
) ?? []), | ||
...(userConfig?.markdown?.rehypePlugins?.map((p) => | ||
typeof p === 'string' ? p : typeof p | ||
) ?? []), | ||
] as string[], | ||
adapter: userConfig?.adapter?.name ?? null, | ||
integrations: integrations?.map?.((i: any) => i?.name) ?? [], | ||
integrations: (userConfig?.integrations ?? []).filter(Boolean).map((i: any) => i?.name), | ||
trailingSlash: userConfig?.trailingSlash, | ||
build: userConfig?.build | ||
? { | ||
|
@@ -108,7 +107,7 @@ export function eventCliSession( | |
: undefined, | ||
markdown: userConfig?.markdown | ||
? { | ||
mode: userConfig?.markdown?.mode, | ||
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. mode is no longer supported but the types were out of date, so this wasn't caught. Removed this and added |
||
drafts: userConfig.markdown?.drafts, | ||
syntaxHighlight: userConfig.markdown?.syntaxHighlight, | ||
} | ||
: undefined, | ||
|
@@ -121,15 +120,12 @@ export function eventCliSession( | |
const payload: EventCliSessionInternal = { | ||
cliCommand: event.cliCommand, | ||
// Versions | ||
astroVersion: event.astroVersion, | ||
viteVersion: getViteVersion(), | ||
nodeVersion: process.version.replace(/^v?/, ''), | ||
configKeys: userConfig ? configKeys(userConfig, '') : undefined, | ||
// Config Values | ||
config: configValues, | ||
flags: cliFlags, | ||
// Optional integrations | ||
optionalIntegrations: userConfig?.integrations?.length - integrations?.length, | ||
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 was added as a "nice-to-have" in a PR that was fixing a different bug, but I don't think this is actually valuable to us so I removed it. |
||
}; | ||
return [{ eventName: EVENT_SESSION, payload }]; | ||
} |
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.
this isn't needed, since
astroVersion
is passed to theAstroTelemetry
constructor above.