@adstage/web-sdk 3.0.8 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -433,14 +433,6 @@ declare class EventsModule implements BaseModule {
433
433
  * 모듈 설정 반환
434
434
  */
435
435
  getConfig(): AdStageConfig | null;
436
- /**
437
- * 사용자 ID 설정
438
- */
439
- setUserId(userId: string): void;
440
- /**
441
- * 현재 사용자 ID 반환
442
- */
443
- getUserId(): string | undefined;
444
436
  /**
445
437
  * 사용자 속성 설정
446
438
  */
@@ -489,10 +481,43 @@ declare class EventsModule implements BaseModule {
489
481
  * @param properties 이벤트 속성
490
482
  */
491
483
  track(eventName: string, properties?: EventProperties): Promise<void>;
484
+ /**
485
+ * Attribution 등록 (서버 기반 Attribution ID 패턴)
486
+ *
487
+ * 사용 사례:
488
+ * 1. 앱 설치 시 Install Referrer 전송
489
+ * 2. 웹 첫 방문 시 URL 파라미터 전송
490
+ *
491
+ * @param deviceId 디바이스 고유 ID
492
+ * @returns Attribution ID 및 파싱된 정보
493
+ */
494
+ registerAttribution(deviceId: string): Promise<{
495
+ attributionId: string;
496
+ channel: string;
497
+ campaign?: string;
498
+ attribution: Record<string, any>;
499
+ installedAt: Date;
500
+ expiresAt: Date;
501
+ } | null>;
502
+ /**
503
+ * 저장된 Attribution ID 반환
504
+ */
505
+ getAttributionId(): string | null;
506
+ /**
507
+ * Attribution ID로 이벤트 전송 (별칭 메서드)
508
+ * track() 메서드가 자동으로 Attribution ID를 사용하므로 동일하게 동작
509
+ * @param eventName 이벤트 이름
510
+ * @param properties 이벤트 속성
511
+ */
512
+ trackWithAttributionId(eventName: string, properties?: EventProperties): Promise<void>;
492
513
  /**
493
514
  * 서버에 이벤트 전송
494
515
  */
495
516
  private sendEventToServer;
517
+ /**
518
+ * 서버에 Attribution 등록
519
+ */
520
+ private sendAttributionToServer;
496
521
  }
497
522
 
498
523
  /**
@@ -525,7 +550,7 @@ declare class AdStage {
525
550
  */
526
551
  static getInstance(): AdStage;
527
552
  /**
528
- * 편의성을 위한 정적 모듈 접근자들
553
+ * 편의성을 위한 정적 모듈 접근자들 (안전장치 포함)
529
554
  */
530
555
  static get ads(): AdsModule;
531
556
  static get events(): EventsModule;
@@ -534,6 +559,11 @@ declare class AdStage {
534
559
  * SDK 리셋 (테스트용)
535
560
  */
536
561
  static reset(): void;
562
+ /**
563
+ * Device ID 생성 (브라우저 fingerprint 기반)
564
+ * localStorage에 저장하여 재사용
565
+ */
566
+ private generateDeviceId;
537
567
  /**
538
568
  * 디버그용 메서드들
539
569
  */
@@ -566,18 +596,6 @@ declare class AdStage {
566
596
  * });
567
597
  */
568
598
  declare function track(eventName: string, properties?: EventProperties): Promise<void>;
569
- /**
570
- * 사용자 ID 설정
571
- * @param userId 사용자 ID
572
- *
573
- * @example
574
- * setUserId('user123');
575
- */
576
- declare function setUserId(userId: string): void;
577
- /**
578
- * 현재 사용자 ID 반환
579
- */
580
- declare function getUserId(): string | undefined;
581
599
  /**
582
600
  * 사용자 속성 설정
583
601
  * @param properties 사용자 속성 객체
@@ -622,6 +640,109 @@ declare function useAdStageContext(): AdStageContextType;
622
640
  */
623
641
  declare function useAdStageInstance(): typeof AdStage | null;
624
642
 
643
+ /**
644
+ * AdStage SDK - Tracking Parameters Module
645
+ * URL에서 광고 추적 파라미터를 자동으로 추출하여 저장
646
+ *
647
+ * 지원 파라미터:
648
+ * - 클릭 ID: gclid, fbclid, ttclid, nclid (플랫폼별)
649
+ * - 캠페인 정보: campaign, campaign_id, ad_group, ad_creative, term
650
+ * - UTM 파라미터: utm_source, utm_medium, utm_campaign, utm_content, utm_term
651
+ *
652
+ * 동작 방식:
653
+ * 1. SDK 초기화 시 URL에서 파라미터 자동 추출
654
+ * 2. sessionStorage에 저장 (SPA 페이지 전환 시에도 유지)
655
+ * 3. EventsModule에서 track() 호출 시 자동으로 attribution 정보 주입
656
+ */
657
+ interface TrackingParams {
658
+ gclid?: string;
659
+ fbclid?: string;
660
+ ttclid?: string;
661
+ nclid?: string;
662
+ liclid?: string;
663
+ msclkid?: string;
664
+ twclid?: string;
665
+ channel?: string;
666
+ campaign?: string;
667
+ campaign_id?: string;
668
+ ad_group?: string;
669
+ ad_group_id?: string;
670
+ ad_creative?: string;
671
+ creative_id?: string;
672
+ term?: string;
673
+ utm_source?: string;
674
+ utm_medium?: string;
675
+ utm_campaign?: string;
676
+ utm_content?: string;
677
+ utm_term?: string;
678
+ }
679
+ /**
680
+ * TrackingParams 모듈
681
+ * URL 파라미터 추출 및 저장 관리
682
+ */
683
+ declare class TrackingParamsModule {
684
+ private static readonly STORAGE_KEY;
685
+ private static readonly CLICK_ID_KEYS;
686
+ private static readonly CAMPAIGN_KEYS;
687
+ private static readonly UTM_KEYS;
688
+ private static readonly ALL_KEYS;
689
+ /**
690
+ * 현재 URL에서 추적 파라미터 추출 및 저장
691
+ * SDK 초기화 시 자동 호출됨
692
+ *
693
+ * 지원 형식:
694
+ * 1. 일반 URL 파라미터: ?gclid=abc123&campaign=summer
695
+ * 2. adstage_referrer 인코딩 파라미터: ?adstage_referrer=channel%3Dgoogle.ads%26gclid%3Dabc123
696
+ */
697
+ static captureFromUrl(): TrackingParams | null;
698
+ /**
699
+ * 추적 파라미터를 sessionStorage에 저장
700
+ * (SPA 페이지 전환 시에도 유지)
701
+ */
702
+ static store(params: TrackingParams): void;
703
+ /**
704
+ * 저장된 추적 파라미터 반환
705
+ * EventsModule에서 track() 호출 시 사용됨
706
+ */
707
+ static get(): TrackingParams | null;
708
+ /**
709
+ * 저장된 추적 파라미터 삭제
710
+ */
711
+ static clear(): void;
712
+ /**
713
+ * 현재 추적 파라미터 보유 여부 확인
714
+ */
715
+ static hasParams(): boolean;
716
+ /**
717
+ * 특정 클릭 ID 보유 여부 확인
718
+ * 어트리뷰션이 가능한 상태인지 체크
719
+ */
720
+ static hasClickId(): boolean;
721
+ /**
722
+ * Click 이벤트 자동 전송 여부 확인
723
+ * 새로운 클릭 ID가 발견되면 true 반환
724
+ */
725
+ static shouldSendClickEvent(): boolean;
726
+ /**
727
+ * Click 이벤트 전송 완료 마킹
728
+ */
729
+ static markClickEventSent(): void;
730
+ /**
731
+ * Click 이벤트 전송 여부 확인
732
+ */
733
+ static isClickEventSent(): boolean;
734
+ /**
735
+ * Event 스키마의 attribution 객체로 변환
736
+ * EventsModule에서 사용
737
+ *
738
+ * 변환 규칙:
739
+ * - 클릭 ID, channel: 그대로 전달
740
+ * - 광고 플랫폼 파라미터: snake_case → camelCase 변환 (웹 호환)
741
+ * - UTM 파라미터: snake_case 그대로 유지 (앱/웹 공통 표준)
742
+ */
743
+ static toAttributionObject(): Record<string, any> | null;
744
+ }
745
+
625
746
  /**
626
747
  * AdStage Web SDK
627
748
  * 네임스페이스 아키텍처 기반 SDK
@@ -630,4 +751,4 @@ declare function useAdStageInstance(): typeof AdStage | null;
630
751
  declare const SDK_VERSION = "2.0.0";
631
752
  declare const SUPPORTED_MODULES: readonly ["ads", "events", "config"];
632
753
 
633
- export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdStageProvider, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, SDK_VERSION, SUPPORTED_MODULES, UserProperties, getUserId, getUserProperties, setUserId, setUserProperties, track, useAdStageContext, useAdStageInstance };
754
+ export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdStageProvider, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, SDK_VERSION, SUPPORTED_MODULES, TrackingParams, TrackingParamsModule, UserProperties, getUserProperties, setUserProperties, track, useAdStageContext, useAdStageInstance };