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

Function getAnalyticsUserId

packages/angular/cli/src/analytics/analytics.ts:145–184  ·  view source on GitHub ↗
(
  context: CommandContext,
  skipPrompt = false,
)

Source from the content-addressed store, hash-verified

143}
144
145export async function getAnalyticsUserId(
146 context: CommandContext,
147 skipPrompt = false,
148): Promise<string | undefined> {
149 const { workspace } = context;
150 // Global config takes precedence over local config only for the disabled check.
151 // IE:
152 // global: disabled & local: enabled = disabled
153 // global: id: 123 & local: id: 456 = 456
154
155 // check global
156 const globalConfig = await getAnalyticsUserIdForLevel('global');
157 if (globalConfig === false) {
158 return undefined;
159 }
160
161 // Not disabled globally, check locally or not set globally and command is run outside of workspace example: `ng new`
162 if (workspace || globalConfig === undefined) {
163 const level = workspace ? 'local' : 'global';
164 let localOrGlobalConfig = await getAnalyticsUserIdForLevel(level);
165 if (localOrGlobalConfig === undefined) {
166 if (!skipPrompt) {
167 // config is unset, prompt user.
168 // TODO: This should honor the `no-interactive` option.
169 // It is currently not an `ng` option but rather only an option for specific commands.
170 // The concept of `ng`-wide options are needed to cleanly handle this.
171 await promptAnalytics(context, !workspace /** global */);
172 localOrGlobalConfig = await getAnalyticsUserIdForLevel(level);
173 }
174 }
175
176 if (localOrGlobalConfig === false) {
177 return undefined;
178 } else if (typeof localOrGlobalConfig === 'string') {
179 return localOrGlobalConfig;
180 }
181 }
182
183 return globalConfig;
184}
185
186function analyticsConfigValueToHumanFormat(value: unknown): 'enabled' | 'disabled' | 'not set' {
187 if (value === false) {

Callers 2

getAnalyticsFunction · 0.90
getAnalyticsInfoStringFunction · 0.85

Calls 2

promptAnalyticsFunction · 0.85

Tested by

no test coverage detected