Skip to content

TouchLinerDomainLogger

도메인 세션 추적을 위한 로거 클래스입니다. 세션당 한 번만 이벤트를 로깅합니다.

Import

ts
import { TouchLinerDomainLogger } from '@liner-engineering/orbit-app/analytics';

초기화

ts
const domainLogger = new TouchLinerDomainLogger({
  logEvent: ampLogEvent,
  defaultEventName: 'touch_liner_domain',
});

생성자 파라미터

파라미터타입설명
logEvent(eventName: string, properties: object) => void이벤트 로깅 함수
defaultEventNamestring기본 이벤트 이름

Methods

setSessionCookie

세션 쿠키를 설정합니다 (브라우저 세션 동안 유효).

ts
domainLogger.setSessionCookie();

hasSessionCookie

세션 쿠키 존재 여부를 확인합니다.

ts
const hasSession = domainLogger.hasSessionCookie();
// true | false

removeSessionCookie

세션 쿠키를 삭제합니다.

ts
domainLogger.removeSessionCookie();

logAndSetSessionCookie

이벤트를 로깅하고 세션 쿠키를 설정합니다.

ts
// 기본 이벤트 이름 사용
domainLogger.logAndSetSessionCookie();

// 커스텀 이벤트 이름과 속성 사용
domainLogger.logAndSetSessionCookie({
  eventName: 'custom_domain_touch',
  properties: {
    page: 'home',
    source: 'direct',
  },
});

logAndSetSessionCookie 옵션

옵션타입설명
eventNamestring커스텀 이벤트 이름 (선택)
propertiesRecord<string, unknown>추가 속성 (선택)

사용 예시

tsx
import { TouchLinerDomainLogger } from '@liner-engineering/orbit-app/analytics';

const domainLogger = new TouchLinerDomainLogger({
  logEvent: ampLogEvent,
  defaultEventName: 'touch_liner_domain',
});

function App() {
  useEffect(() => {
    // 세션당 한 번만 로깅
    if (!domainLogger.hasSessionCookie()) {
      domainLogger.logAndSetSessionCookie();
    }
  }, []);

  return <YourApp />;
}

쿠키 이름

쿠키 이름은 TOUCH_LINER_DOMAIN_SESSION이며, 브라우저 세션 동안 유효합니다.

Released under the MIT License.