@adstage/web-sdk 2.3.5 → 2.3.7

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
@@ -1602,12 +1602,7 @@ class AdvertisementEventTracker {
1602
1602
  */
1603
1603
  async trackAdvertisementEvent(adId, slotId, eventType, additionalData) {
1604
1604
  try {
1605
- // VIEWABLE 이벤트의 경우 중복 확인
1606
- if (eventType === AdEventType.VIEWABLE) {
1607
- if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this.debug)) {
1608
- return; // 중복 viewable 이벤트이므로 추적하지 않음
1609
- }
1610
- }
1605
+ // 중복 확인은 AdsModule에서 이미 수행됨 - 여기서는 제거
1611
1606
  // 현재 슬롯 정보 가져오기
1612
1607
  const slot = this.slots.get(slotId);
1613
1608
  // 디바이스 정보 수집
@@ -2845,6 +2840,22 @@ class AdsModule {
2845
2840
  }
2846
2841
  }
2847
2842
  }
2843
+ // 🆕 슬라이더에서 VIEWABLE 이벤트 발생 시 해당 광고로 ViewabilityTracker 교체
2844
+ if (eventType === AdEventType.VIEWABLE && advertisements.length > 1) {
2845
+ const currentAd = advertisements.find(ad => ad._id === adId);
2846
+ if (currentAd) {
2847
+ // 기존 ViewabilityTracker 정리
2848
+ if (slot.viewabilityTracker) {
2849
+ slot.viewabilityTracker.destroy();
2850
+ slot.viewabilityTracker = null;
2851
+ }
2852
+ // 현재 광고에 대해 새로운 ViewabilityTracker 시작
2853
+ this.startBasicViewabilityTracking(slot, currentAd);
2854
+ if (this._config?.debug) {
2855
+ console.log(`🔄 ViewabilityTracker switched to ad ${adId} in slider: ${slot.id}`);
2856
+ }
2857
+ }
2858
+ }
2848
2859
  };
2849
2860
  let sliderElement;
2850
2861
  // 최적화된 슬라이더 옵션 준비
@@ -2871,6 +2882,13 @@ class AdsModule {
2871
2882
  // 기존 내용 제거하고 슬라이더 추가
2872
2883
  container.innerHTML = '';
2873
2884
  container.appendChild(sliderElement);
2885
+ // ✅ 신규: 슬라이더에서도 첫 번째 광고에 대해 ViewabilityTracker 시작
2886
+ if (advertisements.length > 0) {
2887
+ this.startBasicViewabilityTracking(slot, advertisements[0]);
2888
+ if (this._config?.debug) {
2889
+ console.log(`🎯 Viewability tracking started for first ad in slider: ${slot.id}`);
2890
+ }
2891
+ }
2874
2892
  }
2875
2893
  /**
2876
2894
  * 광고 렌더링 (단일 광고용)
package/dist/index.esm.js CHANGED
@@ -1600,12 +1600,7 @@ class AdvertisementEventTracker {
1600
1600
  */
1601
1601
  async trackAdvertisementEvent(adId, slotId, eventType, additionalData) {
1602
1602
  try {
1603
- // VIEWABLE 이벤트의 경우 중복 확인
1604
- if (eventType === AdEventType.VIEWABLE) {
1605
- if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this.debug)) {
1606
- return; // 중복 viewable 이벤트이므로 추적하지 않음
1607
- }
1608
- }
1603
+ // 중복 확인은 AdsModule에서 이미 수행됨 - 여기서는 제거
1609
1604
  // 현재 슬롯 정보 가져오기
1610
1605
  const slot = this.slots.get(slotId);
1611
1606
  // 디바이스 정보 수집
@@ -2843,6 +2838,22 @@ class AdsModule {
2843
2838
  }
2844
2839
  }
2845
2840
  }
2841
+ // 🆕 슬라이더에서 VIEWABLE 이벤트 발생 시 해당 광고로 ViewabilityTracker 교체
2842
+ if (eventType === AdEventType.VIEWABLE && advertisements.length > 1) {
2843
+ const currentAd = advertisements.find(ad => ad._id === adId);
2844
+ if (currentAd) {
2845
+ // 기존 ViewabilityTracker 정리
2846
+ if (slot.viewabilityTracker) {
2847
+ slot.viewabilityTracker.destroy();
2848
+ slot.viewabilityTracker = null;
2849
+ }
2850
+ // 현재 광고에 대해 새로운 ViewabilityTracker 시작
2851
+ this.startBasicViewabilityTracking(slot, currentAd);
2852
+ if (this._config?.debug) {
2853
+ console.log(`🔄 ViewabilityTracker switched to ad ${adId} in slider: ${slot.id}`);
2854
+ }
2855
+ }
2856
+ }
2846
2857
  };
2847
2858
  let sliderElement;
2848
2859
  // 최적화된 슬라이더 옵션 준비
@@ -2869,6 +2880,13 @@ class AdsModule {
2869
2880
  // 기존 내용 제거하고 슬라이더 추가
2870
2881
  container.innerHTML = '';
2871
2882
  container.appendChild(sliderElement);
2883
+ // ✅ 신규: 슬라이더에서도 첫 번째 광고에 대해 ViewabilityTracker 시작
2884
+ if (advertisements.length > 0) {
2885
+ this.startBasicViewabilityTracking(slot, advertisements[0]);
2886
+ if (this._config?.debug) {
2887
+ console.log(`🎯 Viewability tracking started for first ad in slider: ${slot.id}`);
2888
+ }
2889
+ }
2872
2890
  }
2873
2891
  /**
2874
2892
  * 광고 렌더링 (단일 광고용)
@@ -1597,12 +1597,7 @@ class AdvertisementEventTracker {
1597
1597
  */
1598
1598
  async trackAdvertisementEvent(adId, slotId, eventType, additionalData) {
1599
1599
  try {
1600
- // VIEWABLE 이벤트의 경우 중복 확인
1601
- if (eventType === AdEventType.VIEWABLE) {
1602
- if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this.debug)) {
1603
- return; // 중복 viewable 이벤트이므로 추적하지 않음
1604
- }
1605
- }
1600
+ // 중복 확인은 AdsModule에서 이미 수행됨 - 여기서는 제거
1606
1601
  // 현재 슬롯 정보 가져오기
1607
1602
  const slot = this.slots.get(slotId);
1608
1603
  // 디바이스 정보 수집
@@ -2840,6 +2835,22 @@ class AdsModule {
2840
2835
  }
2841
2836
  }
2842
2837
  }
2838
+ // 🆕 슬라이더에서 VIEWABLE 이벤트 발생 시 해당 광고로 ViewabilityTracker 교체
2839
+ if (eventType === AdEventType.VIEWABLE && advertisements.length > 1) {
2840
+ const currentAd = advertisements.find(ad => ad._id === adId);
2841
+ if (currentAd) {
2842
+ // 기존 ViewabilityTracker 정리
2843
+ if (slot.viewabilityTracker) {
2844
+ slot.viewabilityTracker.destroy();
2845
+ slot.viewabilityTracker = null;
2846
+ }
2847
+ // 현재 광고에 대해 새로운 ViewabilityTracker 시작
2848
+ this.startBasicViewabilityTracking(slot, currentAd);
2849
+ if (this._config?.debug) {
2850
+ console.log(`🔄 ViewabilityTracker switched to ad ${adId} in slider: ${slot.id}`);
2851
+ }
2852
+ }
2853
+ }
2843
2854
  };
2844
2855
  let sliderElement;
2845
2856
  // 최적화된 슬라이더 옵션 준비
@@ -2866,6 +2877,13 @@ class AdsModule {
2866
2877
  // 기존 내용 제거하고 슬라이더 추가
2867
2878
  container.innerHTML = '';
2868
2879
  container.appendChild(sliderElement);
2880
+ // ✅ 신규: 슬라이더에서도 첫 번째 광고에 대해 ViewabilityTracker 시작
2881
+ if (advertisements.length > 0) {
2882
+ this.startBasicViewabilityTracking(slot, advertisements[0]);
2883
+ if (this._config?.debug) {
2884
+ console.log(`🎯 Viewability tracking started for first ad in slider: ${slot.id}`);
2885
+ }
2886
+ }
2869
2887
  }
2870
2888
  /**
2871
2889
  * 광고 렌더링 (단일 광고용)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
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",
@@ -40,12 +40,7 @@ export class AdvertisementEventTracker {
40
40
  }
41
41
  ): Promise<void> {
42
42
  try {
43
- // VIEWABLE 이벤트의 경우 중복 확인
44
- if (eventType === AdEventType.VIEWABLE) {
45
- if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this.debug)) {
46
- return; // 중복 viewable 이벤트이므로 추적하지 않음
47
- }
48
- }
43
+ // 중복 확인은 AdsModule에서 이미 수행됨 - 여기서는 제거
49
44
 
50
45
  // 현재 슬롯 정보 가져오기
51
46
  const slot = this.slots.get(slotId);
@@ -963,6 +963,25 @@ export class AdsModule implements BaseModule {
963
963
  }
964
964
  }
965
965
  }
966
+
967
+ // 🆕 슬라이더에서 VIEWABLE 이벤트 발생 시 해당 광고로 ViewabilityTracker 교체
968
+ if (eventType === AdEventType.VIEWABLE && advertisements.length > 1) {
969
+ const currentAd = advertisements.find(ad => ad._id === adId);
970
+ if (currentAd) {
971
+ // 기존 ViewabilityTracker 정리
972
+ if ((slot as any).viewabilityTracker) {
973
+ (slot as any).viewabilityTracker.destroy();
974
+ (slot as any).viewabilityTracker = null;
975
+ }
976
+
977
+ // 현재 광고에 대해 새로운 ViewabilityTracker 시작
978
+ this.startBasicViewabilityTracking(slot, currentAd);
979
+
980
+ if (this._config?.debug) {
981
+ console.log(`🔄 ViewabilityTracker switched to ad ${adId} in slider: ${slot.id}`);
982
+ }
983
+ }
984
+ }
966
985
  };
967
986
 
968
987
  let sliderElement: HTMLElement;
@@ -1004,6 +1023,15 @@ export class AdsModule implements BaseModule {
1004
1023
  // 기존 내용 제거하고 슬라이더 추가
1005
1024
  container.innerHTML = '';
1006
1025
  container.appendChild(sliderElement);
1026
+
1027
+ // ✅ 신규: 슬라이더에서도 첫 번째 광고에 대해 ViewabilityTracker 시작
1028
+ if (advertisements.length > 0) {
1029
+ this.startBasicViewabilityTracking(slot, advertisements[0]);
1030
+
1031
+ if (this._config?.debug) {
1032
+ console.log(`🎯 Viewability tracking started for first ad in slider: ${slot.id}`);
1033
+ }
1034
+ }
1007
1035
  }
1008
1036
 
1009
1037
  /**