MCPcopy Index your code
hub / github.com/angular/angular-cli / promptAnalytics

Function promptAnalytics

packages/angular/cli/src/analytics/analytics.ts:66–109  ·  view source on GitHub ↗
(
  context: CommandContext,
  global: boolean,
  force = false,
)

Source from the content-addressed store, hash-verified

64 * @return Whether or not the user was shown a prompt.
65 */
66export 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 `
80Would you like to share pseudonymous usage data about this project with the Angular Team
81at Google under Google's Privacy Policy at https://policies.google.com/privacy. For more
82details 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.

Callers 2

runMethod · 0.90
getAnalyticsUserIdFunction · 0.85

Calls 7

getWorkspaceFunction · 0.90
isTTYFunction · 0.90
askConfirmationFunction · 0.90
setAnalyticsConfigFunction · 0.85
getAnalyticsInfoStringFunction · 0.85
logMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected