이 이벤트는 세션이 닫힐 때 클라이언트에 의해 호출됩니다. 이 이벤트는 세션 종료에 대한 응답으로 정리 작업을 수행하거나 애플리케이션 상태를 업데이트할 수 있는 기회를 제공합니다. ON_SESSION_CLOSED 이벤트는 다음 eventData를 사용합니다.
| 이벤트 데이터 | Description |
|---|---|
| 세션 ID | 닫힌 세션의 세션 ID입니다. |
Example
// Define a handler function that's triggered when a session is closed
let sessionClosedHandlerFunction = function(eventInput) {
// Log the ID of the closed session to the console
console.log("Session closed: " + eventInput.data.sessionId);
};
// Retrieve the event topic specific to session closing from the API
let sessionCloseTopic = Microsoft.Apm.getEventPublisherTopic("ON_SESSION_CLOSED");
// Create a new broadcast channel to subscribe to session close events
let sessionCloseSubscriber = new BroadcastChannel(sessionCloseTopic);
// Attach the session closed handler function to the message event of the subscriber
sessionCloseSubscriber.onmessage = sessionClosedHandlerFunction;
비고
코드 샘플은 브로드캐스트 채널 API - 웹 API를 사용하여 원본이 동일한 페이지 또는 iframe과 같은 서로 다른 문서 간에 통신합니다. 이 API에 대한 지원은 다를 수 있으므로 사용자 정의와 호환되는지 확인하세요.