Sintaxis
newrelic.interaction().save()
Garantiza que una interacción browser SPA se guardará cuando finalice.
Requisitos
Browser Pro+SPA agente (v963 o superior)
Si está utilizando npm para instalar el agente del navegador, debe habilitar la característica
spa
al crear una instancia de la claseBrowserAgent
. En la matrizfeatures
, agregue lo siguiente:import { Spa } from '@newrelic/browser-agent/features/spa';const options = {info: { ... },loader_config: { ... },init: { ... },features: [Spa]}Para obtener más información, consulte la documentación de instalación del navegador npm.
Descripción
Este método SPA garantiza que la interacción del navegador se almacenará cuando finalice. Normalmente, una interacción solo se almacena y se envía a New Relic si se trata de la carga de página inicial o si se trata de un cambio de ruta sujeto a la heurística predeterminada. Debe llamar a este método para anular este comportamiento y garantizar que se registrará la interacción.
Valores de retorno
Este método devuelve el mismo objeto API creado por interaction()
, que está asociado con un eventoBrowserInteraction
.
Ejemplos
window.addEventListener('scroll', () => { if (atBottomOfPage()) { newrelic.interaction() // Start monitoring this interaction. .setName('loadNextPage') // Set name of interaction. .save(); // Ensure that this interaction will be saved as a BrowserInteraction event when it ends, even if URL change and DOM modification did not occur. loadNextPage(); // Start loading the next page. }});