• 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株式会社。

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