Not a customer? Click the 'Start a free trial' link to begin a 30-day SaaS trial of our product and to join our community.
Existing Cisco AppDynamics customers should click the 'Sign In' button to authenticate to access the community
01-25-2024 08:46 AM - edited 04-05-2024 04:57 AM
When setting up for a multiple environment adrum injection in an Angular application, it is best to follow a few patterns to keep things clean and easy to debug. This approach will reduce any unnecessary complexity and make any issues easier to debug and track down.
In the following instructions, you can expect to find the brief steps needed to create Adrum scripts for different environments to help you manage your Angular applications effectively across various environments.
We want to create any adrum scripts, tailored for respective environments, within the /assets/scripts
directory. This will enable Angular to permit the local injection of these scripts into a separate file.
This script is quite simple to begin with, and you can add to it for added app complexity and tracking needs. The screenshot below shows an example of this AppDConfig.js
file that will be used for each environment that needs tracking with a different logic or appkey.
We will next want to create an index.html
file for each environment for which we have a different injection script, as seen in this screenshot, below. We have three index files:
index.html
that has no special logic, no adrum script, and will be used unless we tell the angular.json file to swap the index file with a different one. This is typically used for local development, so we don't report local development to the AppDynamics Controller.index.prod.html
and index.uat.html
(you can have as many as you need for specific logic in respective environments).
In the same screenshot to the left, we can see there are three scripts, AppDConfig.js
, AppDConfig.prod.js
, and AppDConfig.uat.js
, that will be imported into the respective index files to dynamically inject the correct script at build time into the correct environment.
In the screenshot below, we can see the index.prod.html
file which is using the AppDConfig.prod.js
script. This index file will be dynamically replaced on the build when the builder for production is run.
ng build -c production |
Likewise below is the screenshot of the index.uat.html
that will pull in the AppDConfig.uat.js
file when UAT is built.
ng build -c uat |
angular.json
in anticipation of the environment build Next, we will want to apply configurations in the angular.json file so that when we build the respective environments, these new index files are swapped out with the default and replaced with the environment-specific index.html file.
You can see that, in the production configuration, we have added:
"index": { |
And likewise, in the UAT configuration we have added:
"index": { |
This will tell Angular to swap these out at build time only for these environments/configurations. All other configurations, without this special setup, will just use the default index.html
file, which has no AppDynamics injection script.
Thank you! Your submission has been received!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form