@adstage/web-sdk 2.3.0 → 2.3.2

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
@@ -2802,7 +2802,7 @@ class AdsModule {
2802
2802
  throw new Error(`Container not found: ${slot.containerId}`);
2803
2803
  }
2804
2804
  // 이벤트 추적 콜백 함수 (중복 노출 방지 포함)
2805
- const trackEventCallback = (adId, slotId, eventType) => {
2805
+ const trackEventCallback = async (adId, slotId, eventType) => {
2806
2806
  // 노출 이벤트인 경우 중복 확인
2807
2807
  if (eventType === AdEventType.VIEWABLE) {
2808
2808
  if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this._config?.debug)) {
@@ -2815,8 +2815,20 @@ class AdsModule {
2815
2815
  console.log(`✅ New viewable recorded for ad ${adId} in slot ${slotId}`);
2816
2816
  }
2817
2817
  }
2818
- if (this.advertisementEventTracker && this._config?.debug) {
2819
- console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2818
+ // 실제 API 호출로 이벤트 전송
2819
+ if (this.advertisementEventTracker) {
2820
+ try {
2821
+ await this.advertisementEventTracker.trackAdvertisementEvent(adId, slotId, eventType, {} // 기본 메타데이터
2822
+ );
2823
+ if (this._config?.debug) {
2824
+ console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2825
+ }
2826
+ }
2827
+ catch (error) {
2828
+ if (this._config?.debug) {
2829
+ console.error(`❌ Failed to track ${eventType} event for ad ${adId}:`, error);
2830
+ }
2831
+ }
2820
2832
  }
2821
2833
  };
2822
2834
  let sliderElement;
@@ -3239,6 +3251,13 @@ class AdStage {
3239
3251
  productionMode: false,
3240
3252
  ...config
3241
3253
  };
3254
+ // baseUrl이 설정되었으면 endpoints에 적용
3255
+ if (config.baseUrl) {
3256
+ endpoints.setBaseUrl(config.baseUrl);
3257
+ if (config.debug) {
3258
+ console.log('🔄 API base URL set to:', config.baseUrl);
3259
+ }
3260
+ }
3242
3261
  // 모듈 동기 초기화
3243
3262
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3244
3263
  for (const moduleName of enabledModules) {
package/dist/index.esm.js CHANGED
@@ -2800,7 +2800,7 @@ class AdsModule {
2800
2800
  throw new Error(`Container not found: ${slot.containerId}`);
2801
2801
  }
2802
2802
  // 이벤트 추적 콜백 함수 (중복 노출 방지 포함)
2803
- const trackEventCallback = (adId, slotId, eventType) => {
2803
+ const trackEventCallback = async (adId, slotId, eventType) => {
2804
2804
  // 노출 이벤트인 경우 중복 확인
2805
2805
  if (eventType === AdEventType.VIEWABLE) {
2806
2806
  if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this._config?.debug)) {
@@ -2813,8 +2813,20 @@ class AdsModule {
2813
2813
  console.log(`✅ New viewable recorded for ad ${adId} in slot ${slotId}`);
2814
2814
  }
2815
2815
  }
2816
- if (this.advertisementEventTracker && this._config?.debug) {
2817
- console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2816
+ // 실제 API 호출로 이벤트 전송
2817
+ if (this.advertisementEventTracker) {
2818
+ try {
2819
+ await this.advertisementEventTracker.trackAdvertisementEvent(adId, slotId, eventType, {} // 기본 메타데이터
2820
+ );
2821
+ if (this._config?.debug) {
2822
+ console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2823
+ }
2824
+ }
2825
+ catch (error) {
2826
+ if (this._config?.debug) {
2827
+ console.error(`❌ Failed to track ${eventType} event for ad ${adId}:`, error);
2828
+ }
2829
+ }
2818
2830
  }
2819
2831
  };
2820
2832
  let sliderElement;
@@ -3237,6 +3249,13 @@ class AdStage {
3237
3249
  productionMode: false,
3238
3250
  ...config
3239
3251
  };
3252
+ // baseUrl이 설정되었으면 endpoints에 적용
3253
+ if (config.baseUrl) {
3254
+ endpoints.setBaseUrl(config.baseUrl);
3255
+ if (config.debug) {
3256
+ console.log('🔄 API base URL set to:', config.baseUrl);
3257
+ }
3258
+ }
3240
3259
  // 모듈 동기 초기화
3241
3260
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3242
3261
  for (const moduleName of enabledModules) {
@@ -2797,7 +2797,7 @@ class AdsModule {
2797
2797
  throw new Error(`Container not found: ${slot.containerId}`);
2798
2798
  }
2799
2799
  // 이벤트 추적 콜백 함수 (중복 노출 방지 포함)
2800
- const trackEventCallback = (adId, slotId, eventType) => {
2800
+ const trackEventCallback = async (adId, slotId, eventType) => {
2801
2801
  // 노출 이벤트인 경우 중복 확인
2802
2802
  if (eventType === AdEventType.VIEWABLE) {
2803
2803
  if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this._config?.debug)) {
@@ -2810,8 +2810,20 @@ class AdsModule {
2810
2810
  console.log(`✅ New viewable recorded for ad ${adId} in slot ${slotId}`);
2811
2811
  }
2812
2812
  }
2813
- if (this.advertisementEventTracker && this._config?.debug) {
2814
- console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2813
+ // 실제 API 호출로 이벤트 전송
2814
+ if (this.advertisementEventTracker) {
2815
+ try {
2816
+ await this.advertisementEventTracker.trackAdvertisementEvent(adId, slotId, eventType, {} // 기본 메타데이터
2817
+ );
2818
+ if (this._config?.debug) {
2819
+ console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
2820
+ }
2821
+ }
2822
+ catch (error) {
2823
+ if (this._config?.debug) {
2824
+ console.error(`❌ Failed to track ${eventType} event for ad ${adId}:`, error);
2825
+ }
2826
+ }
2815
2827
  }
2816
2828
  };
2817
2829
  let sliderElement;
@@ -3234,6 +3246,13 @@ class AdStage {
3234
3246
  productionMode: false,
3235
3247
  ...config
3236
3248
  };
3249
+ // baseUrl이 설정되었으면 endpoints에 적용
3250
+ if (config.baseUrl) {
3251
+ endpoints.setBaseUrl(config.baseUrl);
3252
+ if (config.debug) {
3253
+ console.log('🔄 API base URL set to:', config.baseUrl);
3254
+ }
3255
+ }
3237
3256
  // 모듈 동기 초기화
3238
3257
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
3239
3258
  for (const moduleName of enabledModules) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
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",
@@ -39,7 +39,7 @@
39
39
  "ads",
40
40
  "banner",
41
41
  "text",
42
- "video",
42
+ "video",
43
43
  "native",
44
44
  "interstitial",
45
45
  "sdk",
@@ -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 (config.baseUrl) {
58
+ endpoints.setBaseUrl(config.baseUrl);
59
+ if (config.debug) {
60
+ console.log('🔄 API base URL set to:', config.baseUrl);
61
+ }
62
+ }
63
+
55
64
  // 모듈 동기 초기화
56
65
  const enabledModules = instance._config.modules || ['ads', 'events', 'config'];
57
66
 
@@ -106,6 +106,7 @@ export class AdvertisementEventTracker {
106
106
  }),
107
107
  };
108
108
 
109
+
109
110
  await fetch(
110
111
  `${this.baseUrl}/advertisements/events/${adId}/${eventType}`,
111
112
  {
@@ -929,7 +929,7 @@ export class AdsModule implements BaseModule {
929
929
  }
930
930
 
931
931
  // 이벤트 추적 콜백 함수 (중복 노출 방지 포함)
932
- const trackEventCallback = (adId: string, slotId: string, eventType: AdEventType) => {
932
+ const trackEventCallback = async (adId: string, slotId: string, eventType: AdEventType) => {
933
933
  // 노출 이벤트인 경우 중복 확인
934
934
  if (eventType === AdEventType.VIEWABLE) {
935
935
  if (ViewableEventTracker.isDuplicateViewable(adId, slotId, this._config?.debug)) {
@@ -944,8 +944,24 @@ export class AdsModule implements BaseModule {
944
944
  }
945
945
  }
946
946
 
947
- if (this.advertisementEventTracker && this._config?.debug) {
948
- console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
947
+ // 실제 API 호출로 이벤트 전송
948
+ if (this.advertisementEventTracker) {
949
+ try {
950
+ await this.advertisementEventTracker.trackAdvertisementEvent(
951
+ adId,
952
+ slotId,
953
+ eventType,
954
+ {} // 기본 메타데이터
955
+ );
956
+
957
+ if (this._config?.debug) {
958
+ console.log(`📊 Advertisement event tracked: ${eventType} for ad ${adId} in slot ${slotId}`);
959
+ }
960
+ } catch (error) {
961
+ if (this._config?.debug) {
962
+ console.error(`❌ Failed to track ${eventType} event for ad ${adId}:`, error);
963
+ }
964
+ }
949
965
  }
950
966
  };
951
967