Skip to content

Analytics

분석 이벤트 로깅을 위한 모듈입니다. Cross-domain 이동 시 쿠키 기반 이벤트 추적을 제공합니다.

Import

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

로거 클래스

클래스용도
TouchProductGatewayLogger제품 간 이동 추적
TouchLinerDomainLogger도메인 세션 추적
TouchWebLinerLandingLogger웹 랜딩 추적 (UTM)

useLinerTouchLog Hook

모든 로거를 통합하여 터치 이벤트를 자동으로 로깅하는 React Hook입니다.

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

function App() {
  useLinerTouchLog({
    gatewayLogger,
    landingLogger,
    domainLogger,
  });

  return <YourApp />;
}

동작 순서

  1. gatewayLogger에 쿠키가 있으면 touch_product_gateway 이벤트 로깅 후 쿠키 삭제
  2. 쿠키가 없고, 비로그인 사용자이며 새 세션이면 touch_web_liner_landing 이벤트 로깅
  3. domainLogger에 세션 쿠키가 없으면 도메인 터치 이벤트 로깅

파라미터

파라미터타입설명
gatewayLoggerTouchProductGatewayLogger제품 게이트웨이 로거
landingLoggerTouchWebLinerLandingLogger웹 랜딩 로거
domainLoggerTouchLinerDomainLogger도메인 로거

일반적인 설정

tsx
// loggers.ts
import {
  TouchProductGatewayLogger,
  TouchWebLinerLandingLogger,
  TouchLinerDomainLogger,
} from '@liner-engineering/orbit-app/analytics';

export const gatewayLogger = new TouchProductGatewayLogger({
  cookieDomain: '.liner.com',
  logEvent: ampLogEvent,
});

export const landingLogger = new TouchWebLinerLandingLogger({
  cookieDomain: '.liner.com',
  logEvent: ampLogEvent,
  checkIsLoginUser: async () => {
    // 로그인 여부 확인 로직
    return false;
  },
});

export const domainLogger = new TouchLinerDomainLogger({
  logEvent: ampLogEvent,
  defaultEventName: 'touch_liner_domain',
});
tsx
// App.tsx
import { useLinerTouchLog } from '@liner-engineering/orbit-app/analytics';
import { gatewayLogger, landingLogger, domainLogger } from './loggers';

function App() {
  useLinerTouchLog({
    gatewayLogger,
    landingLogger,
    domainLogger,
  });

  return <YourApp />;
}

Released under the MIT License.