@adstage/web-sdk 3.0.6 → 3.0.8
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/package.json
CHANGED
|
@@ -41,13 +41,31 @@ export class AdvertisementEventTracker {
|
|
|
41
41
|
// 현재 슬롯 정보 가져오기
|
|
42
42
|
const slot = this.slots.get(slotId);
|
|
43
43
|
|
|
44
|
+
// 슬롯이 없으면 추적하지 않음 (잘못된 adType으로 저장되는 것 방지)
|
|
45
|
+
if (!slot) {
|
|
46
|
+
if (this.debug) {
|
|
47
|
+
console.warn(`⚠️ Slot not found for slotId: ${slotId}. Skipping event tracking to prevent incorrect adType.`);
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// DOM 요소가 실제로 존재하는지 확인 (이미 제거된 요소에 대한 추적 방지)
|
|
53
|
+
const element = document.getElementById(slot.containerId) ||
|
|
54
|
+
document.querySelector(`[data-adstage-slot-id="${slotId}"]`);
|
|
55
|
+
if (!element) {
|
|
56
|
+
if (this.debug) {
|
|
57
|
+
console.warn(`⚠️ DOM element not found for slotId: ${slotId} (containerId: ${slot.containerId}). Skipping event tracking.`);
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
// 디바이스 정보 수집
|
|
45
63
|
const deviceInfo = DeviceInfoCollector.collectDeviceInfo();
|
|
46
64
|
|
|
47
65
|
// 광고 이벤트 데이터 구성 (단순화됨)
|
|
48
66
|
const eventData = {
|
|
49
|
-
// 필수 필드들 (DTO 검증용)
|
|
50
|
-
adType: slot
|
|
67
|
+
// 필수 필드들 (DTO 검증용) - 이제 slot이 확실히 존재함
|
|
68
|
+
adType: slot.adType,
|
|
51
69
|
platform: deviceInfo.platform,
|
|
52
70
|
deviceId: deviceInfo.deviceId,
|
|
53
71
|
|
|
@@ -59,9 +77,9 @@ export class AdvertisementEventTracker {
|
|
|
59
77
|
pageTitle: DOMUtils.getPageInfo().title,
|
|
60
78
|
referrer: DOMUtils.getPageInfo().referrer,
|
|
61
79
|
slotId,
|
|
62
|
-
slotPosition: DeviceInfoCollector.getSlotPosition(slot
|
|
63
|
-
slotWidth: AdvertisementEventTracker.parseNumericValue(slot
|
|
64
|
-
slotHeight: AdvertisementEventTracker.parseNumericValue(slot
|
|
80
|
+
slotPosition: DeviceInfoCollector.getSlotPosition(slot.containerId),
|
|
81
|
+
slotWidth: AdvertisementEventTracker.parseNumericValue(slot.width),
|
|
82
|
+
slotHeight: AdvertisementEventTracker.parseNumericValue(slot.height),
|
|
65
83
|
sessionId: deviceInfo.sessionId,
|
|
66
84
|
|
|
67
85
|
// 성능 메트릭
|
|
@@ -119,9 +119,26 @@ export class DeviceInfoCollector {
|
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* 슬롯 위치 정보 가져오기 (SSR 안전)
|
|
122
|
+
* 슬라이더 내부 광고 요소도 지원
|
|
122
123
|
*/
|
|
123
124
|
static getSlotPosition(containerId: string): string {
|
|
124
|
-
|
|
125
|
+
// 1. 기본 컨테이너 ID로 먼저 찾기
|
|
126
|
+
let element = DOMUtils.safeGetElementById(containerId);
|
|
127
|
+
|
|
128
|
+
// 2. 컨테이너를 찾지 못한 경우, 슬라이더 래퍼 찾기
|
|
129
|
+
if (!element) {
|
|
130
|
+
// 슬라이더 래퍼는 일반적으로 원본 컨테이너 내부에 있음
|
|
131
|
+
const sliderWrapper = DOMUtils.safeQuerySelector(`#${containerId} .adstage-slider-wrapper`);
|
|
132
|
+
if (sliderWrapper) {
|
|
133
|
+
element = sliderWrapper as HTMLElement;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 3. 여전히 찾지 못한 경우, data-adstage-slot-id 속성으로 찾기
|
|
138
|
+
if (!element) {
|
|
139
|
+
element = DOMUtils.safeQuerySelector(`[data-adstage-slot-id="${containerId}"]`);
|
|
140
|
+
}
|
|
141
|
+
|
|
125
142
|
if (!element) return 'unknown';
|
|
126
143
|
|
|
127
144
|
const rect = element.getBoundingClientRect();
|