• EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

Te ofrecemos esta traducción automática para facilitar la lectura.

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

Crea una propuesta

onEnd (API SPA)

Sintaxis

onEnd(function $callback)

Cambie los valores asociados con una interacción SPA antes de guardar la interacción.

Requisitos

Descripción

Esta llamada proporciona el mismo objeto que getContext(). Cuando se llama a esto, puede realizar ajustes finales a la interacción antes de que se grabe. Por ejemplo, podría agregar atributos adicionales según los valores del contexto.

Otros métodos para modificar la interacción incluyen:

Parámetros

Parámetro

Descripción

$callback

función

Requerido. Esta función se llama cuando finaliza la interacción. Se llama con un parámetro, que es el contexto de interacción.

Valores de retorno

Este método devuelve el mismo objeto API creado por interaction().

Ejemplos

// 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 Inc.

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