• 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

getContext (SPA API)

Sintaxis

newrelic.interaction().getContext(function $callback)

Almacena valores para la interacción SPA actual de forma asincrónica en browser.

Requisitos

Descripción

Este método API recibe una devolución de llamada que se invocará de forma asincrónica con el objeto de contexto asociado con la interacción actual. Utilícelo para agregar datos asociados con la interacción actual. Estos valores se pueden utilizar en otras partes de su código.

Este contexto también lo proporciona la llamada onEnd .

Parámetros

Parámetro

Descripción

$callback

función

Requerido. Una función que acepta el objeto de contexto de interacción como único argumento.

Valores de retorno

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

Ejemplos

router.addRoute('/products/{productId}', params => {
newrelic.interaction().getContext(ctx => ctx.productId = params.productId);
renderProduct(params.productId);
updateHash();
});
window.addEventListener('hashchange', (ev) => {
const interaction = newrelic.interaction();
interaction.getContext(ctx => {
if (ctx.productId) {
interaction.setAttribute('productId', ctx.productId);
}
});
});
Copyright © 2024 New Relic Inc.

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