Agent for Next.js application

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 under Getting started with the Observability Portal.
  • PACKAGE_TOKEN provided by Customer Support.

Downloading the agent

Download the SixthSense agent into your project dependencies "@sixthsense/sixthsense-javascript-agent": "^3.7.2" (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-javascript-agent": "^3.7.2"
}

Configuring the agent

  • Next.js renders on the server-side. Hence, you must add the following code in one of the application index files.
  • Initialization must occur in the useEffect hook in the application index file.
useEffect(() => {
const Init = async () => {
const ssJS = await import("@sixthsense/sixthsense-javascript-agent");
console.log(ssJS)
ssJS.default.register({
service: "next-js", // Name the app
collector: 'https://http-collector-observability.sixthsense.rakuten.com/oap/',
pagePath: "index.html",
serviceVersion: "1.2.1",
enableSPA: true,
useFmp: true,
autoTracePerf: true,
enableDirectFetchPatching: false,
detailMode: true,
environment: "testing",
authorization: "Access Token", // Get the Access Token from SixthSense UI
});
ssJS.default.setPerformance({
service: "next-js",
collector: 'https://http-collector-observability.sixthsense.rakuten.com/oap/',
serviceVersion: "1.2.1",
perfInterval: 1000,
useFmp: true,
authorization: "Access Token", // Get the Access Token from SixthSense UI
});
};
// Call the function to trigger the agent
Init();
}, []);

For OneCloud Platform, use the following command:

useEffect(() => {
const Init = async () => {
const ssJS = await import("@sixthsense/sixthsense-javascript-agent");
console.log(ssJS)
ssJS.default.register({
service: "next-js", // Name the app
collector: 'https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/oap',
pagePath: "index.html",
serviceVersion: "1.2.1",
enableSPA: true,
useFmp: true,
autoTracePerf: true,
enableDirectFetchPatching: false,
detailMode: true,
environment: "testing",
authorization: "Access Token", // Get the Access Token from SixthSense UI
});
ssJS.default.setPerformance({
service: "next-js",
collector: 'https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/oap',
serviceVersion: "1.2.1",
perfInterval: 1000,
useFmp: true,
authorization: "Access Token", // Get the Access Token from SixthSense UI
});
};
// Call the function to trigger the agent
Init();
}, []);