@adstage/web-sdk 3.0.9 → 3.0.11
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.cjs.js +1 -1
- package/dist/index.d.ts +144 -21
- package/dist/index.esm.js +1 -1
- package/dist/index.standalone.js +2 -2
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/src/constants/endpoints.ts +8 -7
- package/src/core/adstage.ts +187 -7
- package/src/events/global-events.ts +5 -35
- package/src/index.ts +3 -1
- package/src/modules/events/events-module.ts +185 -39
- package/src/modules/tracking/tracking-params.ts +318 -0
- package/src/types/events.ts +0 -2
- package/src/managers/events/event-session-manager.ts +0 -183
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,44 @@ 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
|
+
* 우선순위: sessionStorage (현재 세션) > localStorage (영속 저장)
|
|
505
|
+
*/
|
|
506
|
+
getAttributionId(): string | null;
|
|
507
|
+
/**
|
|
508
|
+
* Attribution ID로 이벤트 전송 (별칭 메서드)
|
|
509
|
+
* track() 메서드가 자동으로 Attribution ID를 사용하므로 동일하게 동작
|
|
510
|
+
* @param eventName 이벤트 이름
|
|
511
|
+
* @param properties 이벤트 속성
|
|
512
|
+
*/
|
|
513
|
+
trackWithAttributionId(eventName: string, properties?: EventProperties): Promise<void>;
|
|
492
514
|
/**
|
|
493
515
|
* 서버에 이벤트 전송
|
|
494
516
|
*/
|
|
495
517
|
private sendEventToServer;
|
|
518
|
+
/**
|
|
519
|
+
* 서버에 Attribution 등록
|
|
520
|
+
*/
|
|
521
|
+
private sendAttributionToServer;
|
|
496
522
|
}
|
|
497
523
|
|
|
498
524
|
/**
|
|
@@ -534,6 +560,11 @@ declare class AdStage {
|
|
|
534
560
|
* SDK 리셋 (테스트용)
|
|
535
561
|
*/
|
|
536
562
|
static reset(): void;
|
|
563
|
+
/**
|
|
564
|
+
* Device ID 생성 (브라우저 fingerprint 기반)
|
|
565
|
+
* localStorage에 저장하여 재사용
|
|
566
|
+
*/
|
|
567
|
+
private generateDeviceId;
|
|
537
568
|
/**
|
|
538
569
|
* 디버그용 메서드들
|
|
539
570
|
*/
|
|
@@ -566,18 +597,6 @@ declare class AdStage {
|
|
|
566
597
|
* });
|
|
567
598
|
*/
|
|
568
599
|
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
600
|
/**
|
|
582
601
|
* 사용자 속성 설정
|
|
583
602
|
* @param properties 사용자 속성 객체
|
|
@@ -622,6 +641,110 @@ declare function useAdStageContext(): AdStageContextType;
|
|
|
622
641
|
*/
|
|
623
642
|
declare function useAdStageInstance(): typeof AdStage | null;
|
|
624
643
|
|
|
644
|
+
/**
|
|
645
|
+
* AdStage SDK - Tracking Parameters Module
|
|
646
|
+
* URL에서 광고 추적 파라미터를 자동으로 추출하여 저장
|
|
647
|
+
*
|
|
648
|
+
* 지원 파라미터:
|
|
649
|
+
* - 클릭 ID: gclid, fbclid, ttclid, nclid (플랫폼별)
|
|
650
|
+
* - 캠페인 정보: campaign, campaign_id, ad_group, ad_creative, term
|
|
651
|
+
* - UTM 파라미터: utm_source, utm_medium, utm_campaign, utm_content, utm_term
|
|
652
|
+
*
|
|
653
|
+
* 동작 방식:
|
|
654
|
+
* 1. SDK 초기화 시 URL에서 파라미터 자동 추출
|
|
655
|
+
* 2. sessionStorage에 저장 (SPA 페이지 전환 시에도 유지)
|
|
656
|
+
* 3. EventsModule에서 track() 호출 시 자동으로 attribution 정보 주입
|
|
657
|
+
*/
|
|
658
|
+
interface TrackingParams {
|
|
659
|
+
gclid?: string;
|
|
660
|
+
fbclid?: string;
|
|
661
|
+
ttclid?: string;
|
|
662
|
+
nclid?: string;
|
|
663
|
+
liclid?: string;
|
|
664
|
+
msclkid?: string;
|
|
665
|
+
twclid?: string;
|
|
666
|
+
channel?: string;
|
|
667
|
+
campaign?: string;
|
|
668
|
+
campaign_id?: string;
|
|
669
|
+
ad_group?: string;
|
|
670
|
+
ad_group_id?: string;
|
|
671
|
+
ad_creative?: string;
|
|
672
|
+
creative_id?: string;
|
|
673
|
+
term?: string;
|
|
674
|
+
utm_source?: string;
|
|
675
|
+
utm_medium?: string;
|
|
676
|
+
utm_campaign?: string;
|
|
677
|
+
utm_content?: string;
|
|
678
|
+
utm_term?: string;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* TrackingParams 모듈
|
|
682
|
+
* URL 파라미터 추출 및 저장 관리
|
|
683
|
+
*/
|
|
684
|
+
declare class TrackingParamsModule {
|
|
685
|
+
private static readonly STORAGE_KEY;
|
|
686
|
+
private static readonly CLICK_ID_KEYS;
|
|
687
|
+
private static readonly CAMPAIGN_KEYS;
|
|
688
|
+
private static readonly UTM_KEYS;
|
|
689
|
+
private static readonly ALL_KEYS;
|
|
690
|
+
/**
|
|
691
|
+
* 현재 URL에서 추적 파라미터 추출 및 저장
|
|
692
|
+
* SDK 초기화 시 자동 호출됨
|
|
693
|
+
*
|
|
694
|
+
* 지원 형식:
|
|
695
|
+
* 1. 일반 URL 파라미터: ?gclid=abc123&campaign=summer
|
|
696
|
+
* 2. adstage_referrer 인코딩 파라미터: ?adstage_referrer=channel%3Dgoogle.ads%26gclid%3Dabc123
|
|
697
|
+
*/
|
|
698
|
+
static captureFromUrl(): TrackingParams | null;
|
|
699
|
+
/**
|
|
700
|
+
* 추적 파라미터를 sessionStorage + localStorage에 저장
|
|
701
|
+
* (SPA 페이지 전환 + 브라우저 재시작 시에도 유지)
|
|
702
|
+
*/
|
|
703
|
+
static store(params: TrackingParams): void;
|
|
704
|
+
/**
|
|
705
|
+
* 저장된 추적 파라미터 반환
|
|
706
|
+
* 우선순위: sessionStorage (현재 세션) > localStorage (영속 저장)
|
|
707
|
+
* EventsModule에서 track() 호출 시 사용됨
|
|
708
|
+
*/
|
|
709
|
+
static get(): TrackingParams | null;
|
|
710
|
+
/**
|
|
711
|
+
* 저장된 추적 파라미터 삭제
|
|
712
|
+
*/
|
|
713
|
+
static clear(): void;
|
|
714
|
+
/**
|
|
715
|
+
* 현재 추적 파라미터 보유 여부 확인
|
|
716
|
+
*/
|
|
717
|
+
static hasParams(): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* 특정 클릭 ID 보유 여부 확인
|
|
720
|
+
* 어트리뷰션이 가능한 상태인지 체크
|
|
721
|
+
*/
|
|
722
|
+
static hasClickId(): boolean;
|
|
723
|
+
/**
|
|
724
|
+
* Click 이벤트 자동 전송 여부 확인
|
|
725
|
+
* 새로운 클릭 ID가 발견되면 true 반환
|
|
726
|
+
*/
|
|
727
|
+
static shouldSendClickEvent(): boolean;
|
|
728
|
+
/**
|
|
729
|
+
* Click 이벤트 전송 완료 마킹
|
|
730
|
+
*/
|
|
731
|
+
static markClickEventSent(): void;
|
|
732
|
+
/**
|
|
733
|
+
* Click 이벤트 전송 여부 확인
|
|
734
|
+
*/
|
|
735
|
+
static isClickEventSent(): boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Event 스키마의 attribution 객체로 변환
|
|
738
|
+
* EventsModule에서 사용
|
|
739
|
+
*
|
|
740
|
+
* 변환 규칙:
|
|
741
|
+
* - 클릭 ID, channel: 그대로 전달
|
|
742
|
+
* - 광고 플랫폼 파라미터: snake_case → camelCase 변환 (웹 호환)
|
|
743
|
+
* - UTM 파라미터: snake_case 그대로 유지 (앱/웹 공통 표준)
|
|
744
|
+
*/
|
|
745
|
+
static toAttributionObject(): Record<string, any> | null;
|
|
746
|
+
}
|
|
747
|
+
|
|
625
748
|
/**
|
|
626
749
|
* AdStage Web SDK
|
|
627
750
|
* 네임스페이스 아키텍처 기반 SDK
|
|
@@ -630,4 +753,4 @@ declare function useAdStageInstance(): typeof AdStage | null;
|
|
|
630
753
|
declare const SDK_VERSION = "2.0.0";
|
|
631
754
|
declare const SUPPORTED_MODULES: readonly ["ads", "events", "config"];
|
|
632
755
|
|
|
633
|
-
export { AdEventType, AdOptions, AdSlot, AdStage, AdStageConfig, AdStageProvider, AdType, Advertisement, ApiResponse, BaseModule, EventProperties, ModuleName, OrganizationInfo, SDK_VERSION, SUPPORTED_MODULES,
|
|
756
|
+
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 };
|