์ค์
์ด API๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๋ธ๋ผ์ฐ์ ์์ด์ ํธ์ Browser Pro+SPA ๋ฒ์ ์ด ํ์ํฉ๋๋ค.
ํต์ฌ๋ก
newrelic.interaction().getContext(function $callback)
ํ์ฌ SPA ์ํธ ์์ฉ์ ๋ํ ๊ฐ์ ๋ธ๋ผ์ฐ์ ์ ๋น๋๊ธฐ์ ์ผ๋ก ์ ์ฅํฉ๋๋ค.
์๊ตฌ ์ฌํญ
์์ด์ ํธ ๋ฒ์ nr-963 ์ด์์ ๋๋ค.
์ค๋ช
์ด API ๋ฉ์๋๋ ํ์ฌ ์ํธ ์์ฉ๊ณผ ์ฐ๊ฒฐ๋ ์ปจํ ์คํธ ๊ฐ์ฒด์ ๋น๋๊ธฐ์ ์ผ๋ก ํธ์ถ๋๋ ์ฝ๋ฐฑ์ ์ฌ์ฉํฉ๋๋ค. ํ์ฌ ์ํธ ์์ฉ๊ณผ ๊ด๋ จ๋ ๋ฐ์ดํฐ๋ฅผ ์ง๊ณํ๋ ๋ฐ ์ฌ์ฉํฉ๋๋ค. ์ด ๊ฐ์ ์ฝ๋์ ๋ค๋ฅธ ๋ถ๋ถ์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ด ์ปจํ
์คํธ๋ onEnd
ํธ์ถ์์๋ ์ ๊ณต๋ฉ๋๋ค.
๋งค๊ฐ๋ณ์
๋งค๊ฐ๋ณ์ | ์ค๋ช |
---|---|
๊ธฐ๋ฅ | ํ์์. ์ํธ์์ฉ ์ปจํ ์คํธ ๊ฐ์ฒด๋ฅผ ์ ์ผํ ์ธ์๋ก ๋ฐ์๋ค์ด๋ ํจ์. |
๋ฐํ ๊ฐ
์ด ๋ฉ์๋๋ 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); } });});