Angular CLI - ng analytics Command



This chapter will discuss the Angular CLI ng analytics command. It includes its syntax, arguments, options, and suitable examples to help you understand the real-time usage of this command in your Angular project.

The 'ng analytics' Command

The ng analytics command in the Angular CLI is used to manage the collection and usage of Angular usage analytics data. By default, Angular collects anonymous usage data to help the Angular team understand how developers are using the framework and tools. This data helps improve the framework and tools.

Syntax

Following is the syntax of the Angular CLI ng analytics command −

ng analytics [options]

Here,

  • options: An optional flags (options) or arguments that control the behavior of the command.
Important! If you do not use the --help flag after this command, it might throw an error, so you are recommended to use the ng analytics --help command.

The --help option will display all the related commands that you can use for various tasks.

Arguments

The arguments for ng analytics command is as follows −

Sr.No. Argument & Description
1 <settingOrProject>=on|off|ci|project|prompt

Directly enables or disables all usage analytics for the user, or prompts the user to set the status interactively, or sets the default status for the project. Following are the details of options.

  • on − Enables analytics gathering and reporting for the user.

  • off − Disables analytics gathering and reporting for the user.

  • ci − Enables analytics and configures reporting for use with Continuous Integration, which uses a common CI user.

  • prompt − Prompts the user to set the status interactively.

  • project − Sets the default status for the project to the projectSetting value, which can be any of the other values. The projectSetting argument is ignored for all other values of settingOrProject.

2 <projectSetting>=on|off|prompt

Sets the default analytics enablement status for the project.

Options

Options are optional parameters. A few commonly used options are listed below:

Sr.No. Option & Description
1 --help=true|false|json|JSON

Shows a help message for this command in the console.

Default: false

Example

Below is an example of using the ng analytics command in an Angular project. Run the following command in your code editor terminal to see the output −

ng analytics --help

Once the above command runs successfully, the following output will be displayed in the terminal:

ng analytics

Configures the gathering of Angular CLI usage metrics.

Commands:
  ng analytics disable  Disables analytics gathering and reporting for the user. [aliases: off]
  ng analytics enable   Enables analytics gathering and reporting for the user.  [aliases: on]
  ng analytics info     Prints analytics gathering and reporting configuration in the console.
  ng analytics prompt   Prompts the user to set the analytics gathering status interactively.

Options:
  --help  Shows a help message for this command in the console. 

As you can see in the above output, you can use any of the commands to manage the collection of analytics data. The commands are:

  • ng analytics disable
  • ng analytics enable
  • ng analytics info
  • ng analytics prompt
Advertisements