Alan Agius a497d12a6b refactor(@angular/cli): remove hasAnalyticsConfig analytics logic
With this change we clean up further the analytics code and re-use the `getAnalytics` to determine if the config is set or not.

Also, this change inclused a refactor to the `createAnalytics` method to make it more readable.
2022-03-16 11:36:10 -07:00

28 lines
615 B
JavaScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
'use strict';
// This file is ES5 because it needs to be executed as is.
if ('NG_CLI_ANALYTICS' in process.env) {
return;
}
try {
var analytics = require('../../src/analytics/analytics');
analytics
.getAnalytics('global')
.then((hasGlobalConfig) => {
if (!hasGlobalConfig) {
return analytics.promptAnalytics(true /** global */);
}
})
.catch(() => {});
} catch (_) {}