• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は参考用に提供されます。

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページ を参照してください。

問題を作成する

onEnd (SPA API)

構文

onEnd(function $callback)

インタラクションを保存する前に、SPA インタラクションに関連付けられた値を変更します。

要件

説明

この呼び出しは、 getContext()と同じオブジェクトを提供します。これが呼び出されると、インタラクションを記録する前に最終的な調整を行うことができます。たとえば、コンテキスト値に基づいて追加の属性を追加できます。

他にも、相互作用を修正する方法があります。

パラメーター

パラメータ

説明

$callback

機能

必要です。この関数は、インタラクションの終了時に呼び出されます。この関数は、1つのパラメータ(インタラクションコンテキスト)を指定して呼び出されます。

戻り値

このメソッドは、 interaction()によって作成されたものと同じAPIオブジェクトを返します。

// router.js
router.addRoute('/dashboard', () => {
const interaction = newrelic.interaction().onEnd(ctx => {
interaction.setAttribute(
'averageChartLoadTime',
ctx.totalChartLoadTime / ctx.chartLoadCount
);
});
getCharts().forEach(loadChart);
});
// chart-loader.js
function loadChart(chart) {
const start = Date.now();
chart.load().then(() => {
const loadTime = Date.now() - start;
interaction.getContext(ctx => {
ctx.totalChartLoadTime = (ctx.totalChartLoadTime || 0) + loadTime;
ctx.chartLoadCount += (ctx.chartLoadCount || 0) + 1;
});
})
}
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.