Installing Digital Experience agent

Prerequisites

  • URL/IP of the SixthSense collector (your tenant URL, which will be provided by the onboarding team).
  • Access token from the SixthSense portal (See Get Access token from SixthSense portal section).
  • PACKAGE_TOKEN (will be provided by the onboarding team).

Downloading the agent

Download the SixthSense agent into your project dependencies "@sixthsense/sixthsense-de-agent": "^1.0.3" (Add this dependency to the package.json file of your application).

Example:

"dependencies": {
"async": "^1.5.2",
"body-parser": "^1.15.1",
"cookie-parser": "^1.4.3",
"express": "^4.13.4",
"express-session": "^1.13.0",
"finalhandler": "^0.4.1",
"request": "^2.72.0",
"serve-static": "^1.10.2",
"prom-client": "^6.3.0",
"morgan": "^1.7.0",
"connect-redis": "^3.2.0",
"@sixthsense/sixthsense-de-agent": "^3.4.0"
}

Configuring the agent

Agent configurations will be added to the entry point of your application.

React JS

sixthsenseDEDescription
service_nameName of the application
api_hosttenant URL which will be provided by the Customer Support team
authorizationGet the access token from the SixthSense portal
// Index.js file
import sixthsenseDE from '@sixthsense/sixthsense-de-agent'
sixthsenseDE.init('#authorization','#service_name',{api_host:'#api_host', disable_session_recording: false, autocapture: false, capture_pageview: false})
// App.js
import { SixthsenseDE } from 'sixthsense-de-agent';
import {useLocation} from "react-router-dom";
const location = useLocation();
useEffect(() => {
SixthsenseDE.capture('$pageview');
}, [location]);

Vue JS

Add sixthsense-de.js plugin

import sixthsenseDE from '@sixthsense/sixthsense-de-agent';
export default {
install(Vue, options) {
Vue.prototype.$posthog = sixthsenseDE.init('#authorization','#service_name',{api_host:'#api_host', disable_session_recording: false, autocapture: false, capture_pageview: false})
},
};
// App.vue
import sixthsenseDE from '@sixthsense/sixthsense-de-agent';
watch: {
$route(to, from) {
sixthsenseDE.capture('$pageview');
},
},
//main.ts
import sixthsenseDe from './plugins/sixthsense-de';
Vue.use(sixthsenseDe);

Geting Access token from the SixthSense portal

  1. Login to the SixthSense portal.
  2. Navigate to Settings on the left pane.
  3. Navigate to Access token.
  4. Click Show access token.
  5. Click Copy to copy the access token and add it to the token_from_ui.

Running your application

Run the following commands before the npm install command one by one.

npm config set "@sixthsense:registry" https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/
npm config set -- '//artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/:_authToken' "${PACKAGE_TOKEN}"`
  • PACKAGE_TOKEN (will be provided by the onboarding team.)
  • Run npm install command to download all the dependencies (npm i @sixthsense/sixthsense-de-agent)
  • Run the start command to run your application.

Agent Integrations in a Docker

See Configuring the Agent.

Adding the Dependency Download configuration in a Docker file

  • The SixthSense agent is hosted on the Rakuten self-hosted private Package manager. To download the package, an additional step is required for authentication.
  • Add the below code snippet in your docker file before the NPM install command as follows:
npm config set "@sixthsense:registry" https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/ && \
npm config set -- '//artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/:_authToken' "${PACKAGE_TOKEN}"
  • This will set the configuration to identify the SixthSense package registry and also tells the dependency to download from the URL that you defined with the same name in the package.json file.
  • https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/9/packages/npm/. This is the SixthSense package manager URL
  • _authToken' "PACKAGE_TOKEN"– Since the package is hosted in a private package manager it requires authentication to identify the user. This auth token will be defined during your onboarding.
  • For simplicity, the auth token is placed in the docker file. However, if you don’t wish to add it 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 and passing the secrets from Jenkins CI/CD, and so on.
  • Now 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.

docker build --build-arg PACKAGE_TOKEN=${PACKAGE_TOKEN_VALUE} -t service:tag .

Example: Docker Configuration

FROM node:10-alpine
ENV NODE_ENV "production"
ENV PORT 8079
EXPOSE 8079
RUN addgroup mygroup && adduser -D -G mygroup myuser && mkdir -p /usr/src/app && chown -R myuser /usr/src/app
# Prepare app directory
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
COPY yarn.lock /usr/src/app/
RUN chown myuser /usr/src/app/yarn.lock
USER myuser
RUN mkdir sixthsense-logs
ARG PAT
RUN npm config set "@sixthsense:registry" https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/ && \
npm config set -- '//artifacts-observability.sixthsense.rakuten.com/api/v4/projects/46/packages/npm/:_authToken' "${PAT}"
# RUN yarn add @sixthsense/sixthsense-de-agent
RUN yarn install
COPY . /usr/src/app
# Start the app
CMD ["/usr/local/bin/npm", "start"]