Next.js アプリケーション用エージェント
前提条件
エージェントのインストールに必要な前提条件の確認については エージェントのインストールに必要な前提条件の確認 を参照してください。
SixthSense コレクターの URL/IP(カスタマーサポートから提供されるお客様のテナントURL)
アクセストークンは SixthSense ポータルから取得します。トークンの取得方法については、[SixSense ポータルを始める] にある アクセストークンの取得 を参照してください。
カスタマーサポートから提供された PACKAGE_TOKEN
エージェントのダウンロード
SixthSense エージェントをプロジェクトの依存関係としてダウンロードしてください。 "@sixthsense/sixthsense-javascript-agent": "^3.7.2" (この依存関係をアプリケーションのpackage.jsonファイルに追加してください)。
例:
"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"
}
エージェントの設定
- Next.js はサーバーサイドでレンダリングされます。そのため、アプリケーションのインデックスファイルのいずれかに次のコードを追加する必要があります。
- 初期化は、アプリケーションのインデックスファイルの useEffect フック内で行う必要があります。
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();
}, []);
OneCloud Platform の場合は、次のコマンドを使用します:
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();
}, []);