Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 2.39 KB

File metadata and controls

67 lines (52 loc) · 2.39 KB
title type shortDescription tags metaDescription redirects freshnessValidatedDate
save (SPA API)
apiDoc
Ensures a SPA browser interaction will be saved when it ends.
Browser
Browser monitoring
Browser agent and SPA API
SPA API call with browser monitoring to ensures an interaction will be saved when it ends.
/docs/browser/new-relic-browser/browser-agent-apis/browser-spa-api-newrelicinteractionsave
/docs/browser/new-relic-browser/browser-agent-spa-api/browser-spa-api-newrelicinteractionsave
/docs/browser/new-relic-browser/browser-agent-spa-api/newrelicinteractionsave-browser-spa-agent-api
/docs/browser/new-relic-browser/browser-agent-spa-api/spa-save
/docs/browser/new-relic-browser/browser-agent-spa-api/save-browser-spa-api
never

Syntax

newrelic.interaction().save()

Ensures a SPA browser interaction will be saved when it ends.

Requirements

  • Browser Pro+SPA agent (v963 or higher)

  • If you're using npm to install the browser agent, you must enable the spa feature when instantiating the BrowserAgent class. In the features array, add the following:

    import { Spa } from '@newrelic/browser-agent/features/spa';
    
    const options = {
      info: { ... },
      loader_config: { ... },
      init: { ... },
      features: [
        Spa
      ]
    }

    For more information, see the npm browser installation documentation.

Description

This SPA method ensures a browser interaction will be saved when it ends. Normally an interaction is only saved and sent to New Relic if it is an initial page load or if it results in a URL or hash change. You must call this method to override this behavior and guarantee the interaction will be recorded.

Return values

This method returns the same API object created by interaction(), which is associated with a BrowserInteraction event.

Examples

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.
    loadNextPage(); // Start loading the next page.
  }
});