-
Notifications
You must be signed in to change notification settings - Fork 63
Separate telemetry handling between CLI and the app #2780
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
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
87ff9fe
Configure CLI build pipeline for npm publishing
ivan-ottinger 81d1bcd
Address Copilot review feedback
ivan-ottinger 773f2ee
Remove redundant web WASM pruning (removed upstream in wordpress-play…
ivan-ottinger 2cf25ef
Remove node_modules pruning from postinstall script
ivan-ottinger 7707212
Extract shared Vite config into vite.config.base.ts
ivan-ottinger fb7be26
Remove @studio/common deps from dependencies (bundled by Vite)
ivan-ottinger 57bfb0e
Rename package from @automattic/studio-cli to @automattic/wp-studio
ivan-ottinger 535a343
Simplify externalDeps filter (no-op @studio/common exception removed)
ivan-ottinger 760b4b2
Fail loudly when patch-package fails during postinstall
ivan-ottinger 0786acf
Use Rollup banner for shebang to preserve sourcemap accuracy
ivan-ottinger 2ba7ede
Deduplicate Node builtin externals in npm Vite config
ivan-ottinger 81c92d1
Sync CLI package version with Studio app version
ivan-ottinger 07ae336
Remove source maps from npm package
ivan-ottinger bccdb50
Simplify postinstall to inline patch-package command
ivan-ottinger bdce54e
Remove yargs locale copying (no longer needed since yargs is external…
ivan-ottinger e55cc43
Use defineConfig() in base Vite config for consistency
ivan-ottinger d39b8b4
Clarify why @php-wasm/@wp-playground regex externalization is needed
ivan-ottinger 2da2890
Move __STUDIO_CLI_VERSION__ define to shared base config
ivan-ottinger 8455b4d
Update dependencies: remove unused @wp-playground/common, add zod and…
ivan-ottinger 6eacd2d
Update package-lock.json to match package.json
ivan-ottinger e060e40
Merge remote-tracking branch 'origin/trunk' into stu-1362-cli-npm-bui…
ivan-ottinger 45c5bb1
Restore postinstall script for npm consumers
ivan-ottinger b677102
Fix postinstall workspace detection by checking for patched packages
ivan-ottinger bcb1fa4
Add directly imported @php-wasm and @wp-playground packages to depend…
ivan-ottinger 8301ec6
Merge remote-tracking branch 'origin/trunk' into stu-1362-cli-npm-bui…
ivan-ottinger 6b756c5
Separate bump stat handling between CLI and app
fredrikekelund 9bbd8bb
Only enable CLI telemetry in production builds
fredrikekelund 1d02ed6
Type-safe wrappers in `apps/cli`
fredrikekelund fd74c4d
Fix bad imports
fredrikekelund dbcb0ee
Cleanup
fredrikekelund 8c11f7f
Fix tests
fredrikekelund d902e60
Naming
fredrikekelund 0b3b46a
Fix locking regression
fredrikekelund 81e1f66
Only copy node_modules when building CLI for prod
fredrikekelund 508ef54
Fix package-lock diff
fredrikekelund b140592
Upgrade Playground packages
fredrikekelund 479e8b9
Merge branch 'trunk' into stu-1362-cli-npm-build-pipeline
fredrikekelund 0328355
Fixup
fredrikekelund 2684826
Even more fixups
fredrikekelund be9c5e7
Added README and LICENSE
fredrikekelund cfb3213
Update version
fredrikekelund 7e77f61
`npm pkg fix` and remove `publishConfig`
fredrikekelund 1396884
Add a warning in the README
fredrikekelund 2515bf2
Install atomically, fix tree-shaking, upgrade version
fredrikekelund 66eab06
Move ora dependency
fredrikekelund ddb03c8
Version
fredrikekelund 3193be8
Define external modules the same way in every build
fredrikekelund 6908bec
Dynamic command imports to avoid barrel file issue
fredrikekelund 03e99d0
Merge branch 'stu-1362-cli-npm-build-pipeline' into stu-1365-standalo…
fredrikekelund 2edd6dd
Fix circular dependency issue
fredrikekelund 197a919
Fix
fredrikekelund d097274
Merge branch 'trunk' into stu-1365-standalone-cli-telemetry
fredrikekelund 888ae05
More permissive `lastBumpStats` zod schema
fredrikekelund 7b0a05a
Review suggestion
fredrikekelund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,3 +1,5 @@ | ||
| declare const __ENABLE_STUDIO_AI__: boolean; | ||
| declare const __ENABLE_AGENT_SUITE__: boolean; | ||
| declare const __ENABLE_CLI_TELEMETRY__: boolean; | ||
| declare const __ENABLE_STUDIO_AI__: boolean; | ||
| declare const __IS_PACKAGED_FOR_NPM__: boolean; | ||
| declare const __STUDIO_CLI_VERSION__: string; |
This file contains hidden or 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 hidden or 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 hidden or 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,50 @@ | ||
| import { | ||
| __bumpAggregatedUniqueStat, | ||
| __bumpStat, | ||
| AggregateInterval, | ||
| LastBumpStatsProvider, | ||
| } from '@studio/common/lib/bump-stat'; | ||
| import { lockAppdata, readAppdata, saveAppdata, unlockAppdata } from 'cli/lib/appdata'; | ||
| import { StatsGroup, StatsMetric } from 'cli/lib/types/bump-stats'; | ||
|
|
||
| const lastBumpStatsProvider: LastBumpStatsProvider = { | ||
| load: async () => { | ||
| const { lastBumpStats } = await readAppdata(); | ||
| return lastBumpStats ?? {}; | ||
| }, | ||
| lock: lockAppdata, | ||
| unlock: unlockAppdata, | ||
| save: async ( lastBumpStats ) => { | ||
| const appdata = await readAppdata(); | ||
| appdata.lastBumpStats = lastBumpStats; | ||
| // Locking is handled in `@studio/common/lib/bump-stat` | ||
| // eslint-disable-next-line studio/require-lock-before-save | ||
| await saveAppdata( appdata ); | ||
| }, | ||
| }; | ||
|
|
||
| export function bumpStat( group: StatsGroup, stat: StatsMetric, bumpInDev = false ) { | ||
| return __bumpStat( group, stat, bumpInDev ); | ||
| } | ||
|
|
||
| export async function bumpAggregatedUniqueStat( | ||
| group: StatsGroup, | ||
| stat: StatsMetric, | ||
| aggregateBy: AggregateInterval, | ||
| bumpInDev = false | ||
| ) { | ||
| return __bumpAggregatedUniqueStat( group, stat, aggregateBy, lastBumpStatsProvider, bumpInDev ); | ||
| } | ||
|
|
||
| export function getPlatformMetric(): StatsMetric { | ||
| switch ( process.platform ) { | ||
| case 'darwin': | ||
| return StatsMetric.DARWIN; | ||
| case 'linux': | ||
| return StatsMetric.LINUX; | ||
| case 'win32': | ||
| return StatsMetric.WINDOWS; | ||
| default: | ||
| return StatsMetric.UNKNOWN_PLATFORM; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,15 @@ | ||
| export enum StatsGroup { | ||
| STUDIO_CLI_USAGE_UNIQUE = 'studio-cli-usage-unique', | ||
| STUDIO_CLI_WEEKLY_UNIQUE_NPM = 'studio-cli-weekly-unq-npm', | ||
| STUDIO_CLI_WEEKLY_UNIQUE_APP = 'studio-cli-weekly-unq-app', | ||
| } | ||
|
|
||
| export enum StatsMetric { | ||
| SUCCESS = 'success', | ||
| FAILURE = 'failure', | ||
| // Platforms | ||
| DARWIN = 'darwin', | ||
| LINUX = 'linux', | ||
| WINDOWS = 'win32', | ||
| UNKNOWN_PLATFORM = 'unknown-platform', | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| import { defineConfig, mergeConfig } from 'vite'; | ||
| import { baseConfig } from './vite.config.base'; | ||
|
|
||
| export default mergeConfig( | ||
| baseConfig, | ||
| defineConfig( { | ||
| define: { | ||
| __IS_PACKAGED_FOR_NPM__: false, | ||
| __ENABLE_CLI_TELEMETRY__: false, | ||
| }, | ||
| } ) | ||
| ); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
I previously advocated for the stricter schema here (#2394 (review)), but it actually causes more trouble than it fixes, given the other changes in this PR. Strictness in runtime types makes sense (i.e., for the function arguments to `bumpStat), but strictness in the appdata schema introduces the risk of runtime exceptions if the config file contains unknown bump stats. That isn't really needed, since we only use this object to check when we last bumped a particular stat.
Anyway, with this change, it's safe to land this PR to trunk even before the config file PR train (#2807 etc) has landed.