• /
  • ログイン
  • 無料アカウント

onEnd (browser SPA API)

Syntax

onEnd(function $callback)

Change the values associated with a SPA interaction before the interaction is saved .

Requirements

Agent version nr-963 or higher.

Description

This call provides the same object as getContext(). When this is called, you can make final adjustments to the interaction before it's recorded. For example, you could add additional attributes based on the context values.

Other methods for modifying the interaction include:

Parameters

Parameter

Description

$callback

function

Required. This function is called when the interaction ends. It is called with one parameter, which is the interaction context.

Return values

This method returns the same API object created by interaction().

Examples

// 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 © 2020 New Relic Inc.