=== @ensono-stacks/azure-node:app-insights

.Installs and configures a ReactJS Library with App Insights.
[%collapsible]
=====
[discrete]
== @ensono-stacks/azure-node:app-insights

Installs and configures App Insights in your NodeJS app.

This generator will add and configure https://www.npmjs.com/package/applicationinsights[applicationinsights] npm package for you.

[discrete]
=== Prerequisites

- Requires a NodeJs server for application insights to hook into.

TIP: Use the https://nx.dev/packages/next/generators/custom-server[@nx/next:custom-server] generator which will have been added to your workspace by link:/docs/getting_started/workspace/ensono-stacks-workspace[@ensono-stacks/workspace] to generate your NodeJS server!

- Requires the APPLICATIONINSIGHTS_CONNECTION_STRING environment variable to be set.

WARNING: There is a known issue with the https://nx.dev/packages/next/generators/custom-server[@nx/next:custom-server] impacting _customServerTarget_ when typescript libraries are present in the monorepo. Please check the following https://github.com/nrwl/nx/issues/12032[Github Issue] for the status of this issue.

[discrete]
=== Usage

[source, bash]
nx generate @ensono-stacks/azure-node:app-insights

[discrete]
=== Command line arguments

The following command line arguments are available:

[cols="1,1,1"]
|===
|Option |Description | Type

|--project
|Target project name.
|string

|--applicationinsightsConnectionString
|The env variable that stores the app insights connection string.
|string


|--server
|Path to custom server file inside the project.
|string

|===

[discrete]
=== Generator Output

* Adds `applicationinsights` dependency in `package.json`.
* Extends `main()` function in the server file to initialise and configure app insights.
=====