• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

사용자의 편의를 위해 제공되는 기계 번역입니다.

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.

문제 신고

getContext(SPA API)

통사론

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

현재 SPA 상호 작용에 대한 값을 브라우저에 비동기적으로 저장합니다.

요구 사항

설명

이 API 메서드는 현재 상호 작용과 연결된 컨텍스트 개체와 비동기적으로 호출되는 콜백을 사용합니다. 현재 상호 작용과 관련된 데이터를 집계하는 데 사용합니다. 이 값은 코드의 다른 부분에서 사용할 수 있습니다.

이 컨텍스트는 onEnd 호출에서도 제공됩니다.

매개변수

매개변수

설명

$callback

기능

필수의. 상호작용 컨텍스트 객체를 유일한 인수로 받아들이는 함수.

반환 값

이 메서드는 interaction() 에서 생성한 것과 동일한 API 객체를 반환합니다.

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.