Browser agent
Prerequisites
- For prerequisite checks for agent installation, see Prerequisite checks for agent installation.
- URL/IP of the SixthSense collector (your tenant URL which will be provided by Customer Support)
- Access token from the SixthSense portal. For accessing the token, see Accessing your Access Token.
- PACKAGE_TOKEN provided by Customer Support.
Downloading the agent
Download the SixthSense agent into your project dependencies "@sixthsense/sixthsense-javascript-agent": "^3.7.3" (Add this dependency to the package.json file of your application).
Example:
Configuring the agent
Agent configurations will be added to the entry point of your application.
ClientMonitor.register | ClientMonitor.setPerformance | About |
---|---|---|
service: | service: | Name of the application (must be same for both) |
collector: | collector: | (tenant URL which will be provided by the onboarding team) |
authorization: | authorization: | Get the access token from the SixthSense portal |
- Upgrade the following in mains.ts file.
For OneCloud Platform, use the following command:
- Update the app.component.ts
For OneCloud Platform, use the following command:
- Update the app.module.ts
Add only if you are using global error handler.
For OneCloud Platform, use the following command:
note
Rakuten does not recommended hardcoding the authorization token in the codebase. In order to make it dynamic, you can use the following method.
- Add the token to .env file as SS_AUTH_TOKEN or any other way so that your Webpack picks it from the environment variable while generating the bundle.
- In your code base use it as
process.env.SS_AUTH_TOKEN
instead of hardcoding the actual token in your code. - Ensure that you add to .env while building your bundle and not after building UI bundle.
- Get Access token. For accessing the token, see Accessing your Access Token.
- Add access token to the token_from_ui.
Run your application
- Run the following commands before the npm install command.
- PACKAGE_TOKEN which will be provided by Customer Support.
- Run npm install command to download all the dependencies (npm i @sixthsense/sixthsense-javascript-agent).
- Run the start command to run your application.
Installing on a Docker
For agent integration in Docker, follow the procedure in Agent Configuration.
Adding the dependency download configuration in Docker file
- The SixthSense agent is hosted in Rakuten self-hosted private Package manager. To download the package, an additional step is required for authentication.
- Add the following code snippet in your docker file before the npm install command.
- This will set the configuration to identify the SixthSense package registry. It also tells the dependency to download from the URL which you defined with the same name in the package.json file.
- SixthSense package manager URL - https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/9/packages/npm/
- _authToken' "PACKAGE_TOKEN"– Since the package is hosted in a private package manager, it requires some authentication to identify the user. This auth token will be defined during onboarding.
- For ease, the auth token is placed in the docker file. However, if you don’t wish to add in the docker file and push it to your version control repository, you can pass this auth token based on your credential management by setting the environment variable, passing the secrets from Jenkins CI/CD, and so on.
- Build your application with Docker build and run the Docker image/container. The agent is integrated with your application and you will start seeing the metrics in the SixthSense dashboard.
Pass the PACKAGE_TOKEN as build arguments.
Example: Docker Configuration
Using Bundle for jQuery and HTML:
- Download bundle.js to resources/ static folder.
- Add the bundle to HTML page script tag.
- Add the SixthSense code.
For OneCloud Platform, use the following command: