Skip to content

TouchProductGatewayLogger

Cross-domain 이동 시 touch_product_gateway 이벤트를 위한 데이터를 쿠키에 저장하고 로깅을 관리하는 클래스입니다.

Import

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

초기화

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

생성자 파라미터

파라미터타입설명
cookieDomainstring쿠키 도메인 (예: '.liner.com')
logEvent(eventName: string, properties: object) => void이벤트 로깅 함수

Methods

setCookie

게이트웨이 데이터를 쿠키에 저장합니다 (30분 유효).

ts
gatewayLogger.setCookie({
  fromLinerProduct: 'ai_search',
  fromLinerProductDetail: null,
  toLinerProduct: 'scholar',
  toLinerProductDetail: null,
  entryType: 'sidebar',
  entryTypeDetail: null,
  componentType: 'menu_button',
  uxWriting: 'Scholar로 이동',
});

getCookie

저장된 쿠키 데이터를 반환합니다.

ts
const data = gatewayLogger.getCookie();
// TouchProductGatewayLogParams | undefined

removeCookie

쿠키를 삭제합니다.

ts
gatewayLogger.removeCookie();

logAndRemoveCookie

쿠키 데이터로 이벤트를 로깅하고 쿠키를 삭제합니다.

ts
const logged = gatewayLogger.logAndRemoveCookie();
// true: 로깅 성공, false: 쿠키 없음

TouchProductGatewayLogParams

ts
interface TouchProductGatewayLogParams {
  fromLinerProduct: 'ai_search' | 'scholar';
  fromLinerProductDetail: string | null;
  toLinerProduct: 'ai_search' | 'scholar';
  toLinerProductDetail: string | null;
  entryType: string;
  entryTypeDetail: string | null;
  componentType: 'button' | 'menu_button' | 'popup_button' | 'banner';
  uxWriting: string;
}

사용 예시

TenantRouter와 함께 사용

ts
const tenantRouter = new TenantRouter({
  appHostname: 'https://app.liner.com',
  scholarHostname: 'https://scholar.liner.com',
  gatewayLogger, // TouchProductGatewayLogger 인스턴스
});

// 테넌트 이동 시 자동으로 setCookie 호출
tenantRouter.push(Tenant.Scholar, {
  path: '/search',
  gatewayLogParams: {
    fromLinerProduct: 'ai_search',
    // ...
  },
});

도착 페이지에서 로깅

tsx
// Scholar 앱의 _app.tsx
function MyApp() {
  useEffect(() => {
    // 쿠키가 있으면 이벤트 로깅 후 삭제
    gatewayLogger.logAndRemoveCookie();
  }, []);

  return <App />;
}

쿠키 이름

쿠키 이름은 TOUCH_PRODUCT_GATEWAY_DATA이며, 30분간 유효합니다.

Released under the MIT License.