( context: CommandContext, global: boolean, force = false, )
| 64 | * @return Whether or not the user was shown a prompt. |
| 65 | */ |
| 66 | export async function promptAnalytics( |
| 67 | context: CommandContext, |
| 68 | global: boolean, |
| 69 | force = false, |
| 70 | ): Promise<boolean> { |
| 71 | const level = global ? 'global' : 'local'; |
| 72 | const workspace = await getWorkspace(level); |
| 73 | if (!workspace) { |
| 74 | throw new Error(`Could not find a ${level} workspace. Are you in a project?`); |
| 75 | } |
| 76 | |
| 77 | if (force || isTTY()) { |
| 78 | const answer = await askConfirmation( |
| 79 | ` |
| 80 | Would you like to share pseudonymous usage data about this project with the Angular Team |
| 81 | at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more |
| 82 | details and how to change this setting, see https://angular.dev/cli/analytics. |
| 83 | |
| 84 | `, |
| 85 | false, |
| 86 | ); |
| 87 | |
| 88 | await setAnalyticsConfig(global, answer); |
| 89 | |
| 90 | if (answer) { |
| 91 | console.log(''); |
| 92 | console.log( |
| 93 | tags.stripIndent` |
| 94 | Thank you for sharing pseudonymous usage data. Should you change your mind, the following |
| 95 | command will disable this feature entirely: |
| 96 | |
| 97 | ${colors.yellow(`ng analytics disable${global ? ' --global' : ''}`)} |
| 98 | `, |
| 99 | ); |
| 100 | console.log(''); |
| 101 | } |
| 102 | |
| 103 | process.stderr.write(await getAnalyticsInfoString(context)); |
| 104 | |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Get the analytics user id. |
no test coverage detected