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

Function setAnalyticsConfig

packages/angular/cli/src/analytics/analytics.ts:45–59  ·  view source on GitHub ↗
(global: boolean, value: string | boolean)

Source from the content-addressed store, hash-verified

43 * @param value Either a user ID, true to generate a new User ID, or false to disable analytics.
44 */
45export async function setAnalyticsConfig(global: boolean, value: string | boolean): Promise<void> {
46 const level = global ? 'global' : 'local';
47 const workspace = await getWorkspace(level);
48 if (!workspace) {
49 throw new Error(`Could not find ${level} workspace.`);
50 }
51
52 const cli = (workspace.extensions['cli'] ??= {});
53 if (!workspace || !json.isJsonObject(cli)) {
54 throw new Error(`Invalid config found at ${workspace.filePath}. CLI should be an object.`);
55 }
56
57 cli.analytics = value === true ? randomUUID() : value;
58 await workspace.save();
59}
60
61/**
62 * Prompt the user for usage gathering permission.

Callers 3

runMethod · 0.90
runMethod · 0.90
promptAnalyticsFunction · 0.85

Calls 2

getWorkspaceFunction · 0.90
saveMethod · 0.45

Tested by

no test coverage detected