@adstage/web-sdk 2.4.10 → 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 CHANGED
@@ -911,7 +911,7 @@ class EndpointBuilder {
911
911
  batch: () => `${this.baseUrl}${API_PATHS.events.batch}`
912
912
  };
913
913
  // 기본값은 베타 환경 사용
914
- this.baseUrl = baseUrl || API_ENDPOINTS.beta;
914
+ this.baseUrl = baseUrl || API_ENDPOINTS.production;
915
915
  }
916
916
  /**
917
917
  * 기본 URL 변경
@@ -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 element = document.getElementById(slot.id);
2947
- if (!element)
2948
- return;
2949
- // 기본 fraud 검사
2950
- const fraudDetector = new BasicFraudDetector();
2951
- // viewability 추적
2952
- const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
2953
- await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
2954
- });
2955
- // 정리를 위해 저장
2956
- slot.viewabilityTracker = tracker;
2957
- slot.fraudDetector = fraudDetector;
2958
- if (this._config?.debug) {
2959
- console.log(`🎯 Viewability tracking started for slot: ${slot.id}`);
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 이벤트 처리
@@ -3324,6 +3344,13 @@ class AdStage {
3324
3344
  productionMode: false,
3325
3345
  ...config
3326
3346
  };
3347
+ // 🔧 baseUrl이 설정된 경우 전역 endpoints 객체 업데이트
3348
+ if (instance._config.baseUrl) {
3349
+ endpoints.setBaseUrl(instance._config.baseUrl);
3350
+ if (config.debug) {
3351
+ console.log('🌐 API endpoint configured:', instance._config.baseUrl);
3352
+ }
3353
+ }
3327
3354
  // 모듈 동기 초기화
3328
3355
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3329
3356
  for (const moduleName of enabledModules) {
package/dist/index.d.ts CHANGED
@@ -300,7 +300,7 @@ declare class AdsModule implements BaseModule {
300
300
  * 배너 광고를 위한 컨테이너 최적화
301
301
  */
302
302
  /**
303
- * 기본 viewability 추적 시작
303
+ * 기본 viewability 추적 시작 (재시도 로직 포함)
304
304
  */
305
305
  private startBasicViewabilityTracking;
306
306
  /**
package/dist/index.esm.js CHANGED
@@ -909,7 +909,7 @@ class EndpointBuilder {
909
909
  batch: () => `${this.baseUrl}${API_PATHS.events.batch}`
910
910
  };
911
911
  // 기본값은 베타 환경 사용
912
- this.baseUrl = baseUrl || API_ENDPOINTS.beta;
912
+ this.baseUrl = baseUrl || API_ENDPOINTS.production;
913
913
  }
914
914
  /**
915
915
  * 기본 URL 변경
@@ -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 element = document.getElementById(slot.id);
2945
- if (!element)
2946
- return;
2947
- // 기본 fraud 검사
2948
- const fraudDetector = new BasicFraudDetector();
2949
- // viewability 추적
2950
- const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
2951
- await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
2952
- });
2953
- // 정리를 위해 저장
2954
- slot.viewabilityTracker = tracker;
2955
- slot.fraudDetector = fraudDetector;
2956
- if (this._config?.debug) {
2957
- console.log(`🎯 Viewability tracking started for slot: ${slot.id}`);
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 이벤트 처리
@@ -3322,6 +3342,13 @@ class AdStage {
3322
3342
  productionMode: false,
3323
3343
  ...config
3324
3344
  };
3345
+ // 🔧 baseUrl이 설정된 경우 전역 endpoints 객체 업데이트
3346
+ if (instance._config.baseUrl) {
3347
+ endpoints.setBaseUrl(instance._config.baseUrl);
3348
+ if (config.debug) {
3349
+ console.log('🌐 API endpoint configured:', instance._config.baseUrl);
3350
+ }
3351
+ }
3325
3352
  // 모듈 동기 초기화
3326
3353
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3327
3354
  for (const moduleName of enabledModules) {
@@ -906,7 +906,7 @@ class EndpointBuilder {
906
906
  batch: () => `${this.baseUrl}${API_PATHS.events.batch}`
907
907
  };
908
908
  // 기본값은 베타 환경 사용
909
- this.baseUrl = baseUrl || API_ENDPOINTS.beta;
909
+ this.baseUrl = baseUrl || API_ENDPOINTS.production;
910
910
  }
911
911
  /**
912
912
  * 기본 URL 변경
@@ -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 element = document.getElementById(slot.id);
2942
- if (!element)
2943
- return;
2944
- // 기본 fraud 검사
2945
- const fraudDetector = new BasicFraudDetector();
2946
- // viewability 추적
2947
- const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
2948
- await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
2949
- });
2950
- // 정리를 위해 저장
2951
- slot.viewabilityTracker = tracker;
2952
- slot.fraudDetector = fraudDetector;
2953
- if (this._config?.debug) {
2954
- console.log(`🎯 Viewability tracking started for slot: ${slot.id}`);
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 이벤트 처리
@@ -3319,6 +3339,13 @@ class AdStage {
3319
3339
  productionMode: false,
3320
3340
  ...config
3321
3341
  };
3342
+ // 🔧 baseUrl이 설정된 경우 전역 endpoints 객체 업데이트
3343
+ if (instance._config.baseUrl) {
3344
+ endpoints.setBaseUrl(instance._config.baseUrl);
3345
+ if (config.debug) {
3346
+ console.log('🌐 API endpoint configured:', instance._config.baseUrl);
3347
+ }
3348
+ }
3322
3349
  // 모듈 동기 초기화
3323
3350
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3324
3351
  for (const moduleName of enabledModules) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "2.4.10",
3
+ "version": "2.4.12",
4
4
  "description": "AdStage Web SDK - Production-ready marketing platform SDK with React Provider support for seamless integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
@@ -15,9 +15,9 @@ export const API_ENDPOINTS = {
15
15
  } as const;
16
16
 
17
17
  /**
18
- * 기본 엔드포인트 (베타 환경)
18
+ * 기본 엔드포인트 (프로덕션 환경)
19
19
  */
20
- export const DEFAULT_API_ENDPOINT = API_ENDPOINTS.beta;
20
+ export const DEFAULT_API_ENDPOINT = API_ENDPOINTS.production;
21
21
 
22
22
  /**
23
23
  * API 경로 상수
@@ -45,7 +45,7 @@ export class EndpointBuilder {
45
45
 
46
46
  constructor(baseUrl?: string) {
47
47
  // 기본값은 베타 환경 사용
48
- this.baseUrl = baseUrl || API_ENDPOINTS.beta;
48
+ this.baseUrl = baseUrl || API_ENDPOINTS.production;
49
49
  }
50
50
 
51
51
  /**
@@ -7,6 +7,7 @@ import { AdStageConfig, ModuleName } from '../types/config';
7
7
  import { AdsModule } from '../modules/ads/AdsModule';
8
8
  import { ConfigModule } from '../modules/config/ConfigModule';
9
9
  import { EventsModule } from '../modules/events/EventsModule';
10
+ import { endpoints } from '../constants/endpoints';
10
11
 
11
12
  export class AdStage {
12
13
  private static instance: AdStage;
@@ -52,6 +53,14 @@ export class AdStage {
52
53
  ...config
53
54
  };
54
55
 
56
+ // 🔧 baseUrl이 설정된 경우 전역 endpoints 객체 업데이트
57
+ if (instance._config.baseUrl) {
58
+ endpoints.setBaseUrl(instance._config.baseUrl);
59
+ if (config.debug) {
60
+ console.log('🌐 API endpoint configured:', instance._config.baseUrl);
61
+ }
62
+ }
63
+
55
64
  // 모듈 동기 초기화
56
65
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
57
66
 
@@ -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 element = document.getElementById(slot.id);
354
- if (!element) return;
355
-
356
- // 기본 fraud 검사
357
- const fraudDetector = new BasicFraudDetector();
358
-
359
- // viewability 추적
360
- const tracker = new ViewabilityTracker(element, slot.adType, async (metrics) => {
361
- await this.handleViewableEvent(ad, slot, metrics, fraudDetector);
362
- });
363
-
364
- // 정리를 위해 저장
365
- (slot as any).viewabilityTracker = tracker;
366
- (slot as any).fraudDetector = fraudDetector;
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
- if (this._config?.debug) {
369
- console.log(`🎯 Viewability tracking started for slot: ${slot.id}`);
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
  /**