@adstage/web-sdk 2.4.11 → 2.4.12
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 +36 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +36 -16
- package/dist/index.standalone.js +36 -16
- package/package.json +1 -1
- package/src/modules/ads/AdsModule.ts +41 -18
package/dist/index.cjs.js
CHANGED
|
@@ -2917,6 +2917,12 @@ class AdsModule {
|
|
|
2917
2917
|
// 광고가 여러 개이거나 autoSlide 옵션이 있으면 슬라이더로 렌더링
|
|
2918
2918
|
if (adstageData.length > 1 || slot.config?.autoSlide) {
|
|
2919
2919
|
await this.adRenderer?.renderAdSlider(slot, adstageData);
|
|
2920
|
+
// 🔧 슬라이더의 첫 번째 광고도 자동 viewability 추적 시작
|
|
2921
|
+
if (adstageData.length > 0) {
|
|
2922
|
+
setTimeout(() => {
|
|
2923
|
+
this.startBasicViewabilityTracking(slot, adstageData[0]);
|
|
2924
|
+
}, 100); // 슬라이더 렌더링 완료 후 추적 시작
|
|
2925
|
+
}
|
|
2920
2926
|
}
|
|
2921
2927
|
else {
|
|
2922
2928
|
// 광고가 1개면 일반 렌더링
|
|
@@ -2940,24 +2946,38 @@ class AdsModule {
|
|
|
2940
2946
|
*/
|
|
2941
2947
|
// optimizeContainerForBannerAds 제거: AdRenderer.optimizeContainerForBannerAds 사용
|
|
2942
2948
|
/**
|
|
2943
|
-
* 기본 viewability 추적 시작
|
|
2949
|
+
* 기본 viewability 추적 시작 (재시도 로직 포함)
|
|
2944
2950
|
*/
|
|
2945
2951
|
startBasicViewabilityTracking(slot, ad) {
|
|
2946
|
-
const
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2952
|
+
const tryStartTracking = (retryCount = 0) => {
|
|
2953
|
+
const element = document.getElementById(slot.id);
|
|
2954
|
+
if (!element) {
|
|
2955
|
+
if (retryCount < 5) {
|
|
2956
|
+
// 최대 5번 재시도 (총 1.5초)
|
|
2957
|
+
setTimeout(() => tryStartTracking(retryCount + 1), 300);
|
|
2958
|
+
if (this._config?.debug) {
|
|
2959
|
+
console.log(`🔄 Retrying viewability tracking for slot: ${slot.id} (attempt ${retryCount + 1})`);
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
else {
|
|
2963
|
+
console.warn(`❌ Failed to find element for viewability tracking: ${slot.id}`);
|
|
2964
|
+
}
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
// 기본 fraud 검사
|
|
2968
|
+
const fraudDetector = new BasicFraudDetector();
|
|
2969
|
+
// viewability 추적
|
|
2970
|
+
const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
|
|
2971
|
+
await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
|
|
2972
|
+
});
|
|
2973
|
+
// 정리를 위해 저장
|
|
2974
|
+
slot.viewabilityTracker = tracker;
|
|
2975
|
+
slot.fraudDetector = fraudDetector;
|
|
2976
|
+
if (this._config?.debug) {
|
|
2977
|
+
console.log(`🎯 Viewability tracking started for slot: ${slot.id} (element found)`);
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
tryStartTracking();
|
|
2961
2981
|
}
|
|
2962
2982
|
/**
|
|
2963
2983
|
* Viewable 이벤트 처리
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -2915,6 +2915,12 @@ class AdsModule {
|
|
|
2915
2915
|
// 광고가 여러 개이거나 autoSlide 옵션이 있으면 슬라이더로 렌더링
|
|
2916
2916
|
if (adstageData.length > 1 || slot.config?.autoSlide) {
|
|
2917
2917
|
await this.adRenderer?.renderAdSlider(slot, adstageData);
|
|
2918
|
+
// 🔧 슬라이더의 첫 번째 광고도 자동 viewability 추적 시작
|
|
2919
|
+
if (adstageData.length > 0) {
|
|
2920
|
+
setTimeout(() => {
|
|
2921
|
+
this.startBasicViewabilityTracking(slot, adstageData[0]);
|
|
2922
|
+
}, 100); // 슬라이더 렌더링 완료 후 추적 시작
|
|
2923
|
+
}
|
|
2918
2924
|
}
|
|
2919
2925
|
else {
|
|
2920
2926
|
// 광고가 1개면 일반 렌더링
|
|
@@ -2938,24 +2944,38 @@ class AdsModule {
|
|
|
2938
2944
|
*/
|
|
2939
2945
|
// optimizeContainerForBannerAds 제거: AdRenderer.optimizeContainerForBannerAds 사용
|
|
2940
2946
|
/**
|
|
2941
|
-
* 기본 viewability 추적 시작
|
|
2947
|
+
* 기본 viewability 추적 시작 (재시도 로직 포함)
|
|
2942
2948
|
*/
|
|
2943
2949
|
startBasicViewabilityTracking(slot, ad) {
|
|
2944
|
-
const
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2950
|
+
const tryStartTracking = (retryCount = 0) => {
|
|
2951
|
+
const element = document.getElementById(slot.id);
|
|
2952
|
+
if (!element) {
|
|
2953
|
+
if (retryCount < 5) {
|
|
2954
|
+
// 최대 5번 재시도 (총 1.5초)
|
|
2955
|
+
setTimeout(() => tryStartTracking(retryCount + 1), 300);
|
|
2956
|
+
if (this._config?.debug) {
|
|
2957
|
+
console.log(`🔄 Retrying viewability tracking for slot: ${slot.id} (attempt ${retryCount + 1})`);
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
else {
|
|
2961
|
+
console.warn(`❌ Failed to find element for viewability tracking: ${slot.id}`);
|
|
2962
|
+
}
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
// 기본 fraud 검사
|
|
2966
|
+
const fraudDetector = new BasicFraudDetector();
|
|
2967
|
+
// viewability 추적
|
|
2968
|
+
const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
|
|
2969
|
+
await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
|
|
2970
|
+
});
|
|
2971
|
+
// 정리를 위해 저장
|
|
2972
|
+
slot.viewabilityTracker = tracker;
|
|
2973
|
+
slot.fraudDetector = fraudDetector;
|
|
2974
|
+
if (this._config?.debug) {
|
|
2975
|
+
console.log(`🎯 Viewability tracking started for slot: ${slot.id} (element found)`);
|
|
2976
|
+
}
|
|
2977
|
+
};
|
|
2978
|
+
tryStartTracking();
|
|
2959
2979
|
}
|
|
2960
2980
|
/**
|
|
2961
2981
|
* Viewable 이벤트 처리
|
package/dist/index.standalone.js
CHANGED
|
@@ -2912,6 +2912,12 @@ class AdsModule {
|
|
|
2912
2912
|
// 광고가 여러 개이거나 autoSlide 옵션이 있으면 슬라이더로 렌더링
|
|
2913
2913
|
if (adstageData.length > 1 || slot.config?.autoSlide) {
|
|
2914
2914
|
await this.adRenderer?.renderAdSlider(slot, adstageData);
|
|
2915
|
+
// 🔧 슬라이더의 첫 번째 광고도 자동 viewability 추적 시작
|
|
2916
|
+
if (adstageData.length > 0) {
|
|
2917
|
+
setTimeout(() => {
|
|
2918
|
+
this.startBasicViewabilityTracking(slot, adstageData[0]);
|
|
2919
|
+
}, 100); // 슬라이더 렌더링 완료 후 추적 시작
|
|
2920
|
+
}
|
|
2915
2921
|
}
|
|
2916
2922
|
else {
|
|
2917
2923
|
// 광고가 1개면 일반 렌더링
|
|
@@ -2935,24 +2941,38 @@ class AdsModule {
|
|
|
2935
2941
|
*/
|
|
2936
2942
|
// optimizeContainerForBannerAds 제거: AdRenderer.optimizeContainerForBannerAds 사용
|
|
2937
2943
|
/**
|
|
2938
|
-
* 기본 viewability 추적 시작
|
|
2944
|
+
* 기본 viewability 추적 시작 (재시도 로직 포함)
|
|
2939
2945
|
*/
|
|
2940
2946
|
startBasicViewabilityTracking(slot, ad) {
|
|
2941
|
-
const
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2947
|
+
const tryStartTracking = (retryCount = 0) => {
|
|
2948
|
+
const element = document.getElementById(slot.id);
|
|
2949
|
+
if (!element) {
|
|
2950
|
+
if (retryCount < 5) {
|
|
2951
|
+
// 최대 5번 재시도 (총 1.5초)
|
|
2952
|
+
setTimeout(() => tryStartTracking(retryCount + 1), 300);
|
|
2953
|
+
if (this._config?.debug) {
|
|
2954
|
+
console.log(`🔄 Retrying viewability tracking for slot: ${slot.id} (attempt ${retryCount + 1})`);
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
else {
|
|
2958
|
+
console.warn(`❌ Failed to find element for viewability tracking: ${slot.id}`);
|
|
2959
|
+
}
|
|
2960
|
+
return;
|
|
2961
|
+
}
|
|
2962
|
+
// 기본 fraud 검사
|
|
2963
|
+
const fraudDetector = new BasicFraudDetector();
|
|
2964
|
+
// viewability 추적
|
|
2965
|
+
const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
|
|
2966
|
+
await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
|
|
2967
|
+
});
|
|
2968
|
+
// 정리를 위해 저장
|
|
2969
|
+
slot.viewabilityTracker = tracker;
|
|
2970
|
+
slot.fraudDetector = fraudDetector;
|
|
2971
|
+
if (this._config?.debug) {
|
|
2972
|
+
console.log(`🎯 Viewability tracking started for slot: ${slot.id} (element found)`);
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
tryStartTracking();
|
|
2956
2976
|
}
|
|
2957
2977
|
/**
|
|
2958
2978
|
* Viewable 이벤트 처리
|
package/package.json
CHANGED
|
@@ -321,6 +321,13 @@ export class AdsModule implements BaseModule {
|
|
|
321
321
|
// 광고가 여러 개이거나 autoSlide 옵션이 있으면 슬라이더로 렌더링
|
|
322
322
|
if (adstageData.length > 1 || (slot.config as any)?.autoSlide) {
|
|
323
323
|
await this.adRenderer?.renderAdSlider(slot, adstageData);
|
|
324
|
+
|
|
325
|
+
// 🔧 슬라이더의 첫 번째 광고도 자동 viewability 추적 시작
|
|
326
|
+
if (adstageData.length > 0) {
|
|
327
|
+
setTimeout(() => {
|
|
328
|
+
this.startBasicViewabilityTracking(slot, adstageData[0]);
|
|
329
|
+
}, 100); // 슬라이더 렌더링 완료 후 추적 시작
|
|
330
|
+
}
|
|
324
331
|
} else {
|
|
325
332
|
// 광고가 1개면 일반 렌더링
|
|
326
333
|
slot.advertisement = adstageData[0];
|
|
@@ -347,27 +354,43 @@ export class AdsModule implements BaseModule {
|
|
|
347
354
|
// optimizeContainerForBannerAds 제거: AdRenderer.optimizeContainerForBannerAds 사용
|
|
348
355
|
|
|
349
356
|
/**
|
|
350
|
-
* 기본 viewability 추적 시작
|
|
357
|
+
* 기본 viewability 추적 시작 (재시도 로직 포함)
|
|
351
358
|
*/
|
|
352
359
|
private startBasicViewabilityTracking(slot: AdSlot, ad: Advertisement): void {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
360
|
+
const tryStartTracking = (retryCount = 0) => {
|
|
361
|
+
const element = document.getElementById(slot.id);
|
|
362
|
+
|
|
363
|
+
if (!element) {
|
|
364
|
+
if (retryCount < 5) {
|
|
365
|
+
// 최대 5번 재시도 (총 1.5초)
|
|
366
|
+
setTimeout(() => tryStartTracking(retryCount + 1), 300);
|
|
367
|
+
if (this._config?.debug) {
|
|
368
|
+
console.log(`🔄 Retrying viewability tracking for slot: ${slot.id} (attempt ${retryCount + 1})`);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
console.warn(`❌ Failed to find element for viewability tracking: ${slot.id}`);
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// 기본 fraud 검사
|
|
377
|
+
const fraudDetector = new BasicFraudDetector();
|
|
378
|
+
|
|
379
|
+
// viewability 추적
|
|
380
|
+
const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
|
|
381
|
+
await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// 정리를 위해 저장
|
|
385
|
+
(slot as any).viewabilityTracker = tracker;
|
|
386
|
+
(slot as any).fraudDetector = fraudDetector;
|
|
367
387
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
388
|
+
if (this._config?.debug) {
|
|
389
|
+
console.log(`🎯 Viewability tracking started for slot: ${slot.id} (element found)`);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
tryStartTracking();
|
|
371
394
|
}
|
|
372
395
|
|
|
373
396
|
/**
|