@adstage/web-sdk 3.0.2 → 3.0.4

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
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",
@@ -6,12 +6,19 @@
6
6
 
7
7
  import { DOMUtils } from '../../utils/dom-utils';
8
8
  import { DeviceInfoCollector } from '../device-info-collector';
9
- import { getSDKVersion } from '../../utils/version';
10
9
  import { ConfigUtils } from '../../utils/config-utils';
11
10
 
12
11
  export class EventDeviceCollector {
12
+ private static _userProvidedDeviceInfo: Partial<{
13
+ category: 'mobile' | 'desktop' | 'tablet' | 'other';
14
+ platform: string;
15
+ model: string;
16
+ appVersion: string;
17
+ osVersion: string;
18
+ }> = {};
13
19
  /**
14
- * Events API용 디바이스 정보 반환
20
+ * Events API용 디바이스 정보 반환 (하이브리드 방식)
21
+ * 사용자 제공 정보 + 자동 수집 정보 병합
15
22
  * TrackEventDto.DeviceInfoInput 형태에 맞춤
16
23
  */
17
24
  static getDeviceInfo(): {
@@ -20,13 +27,32 @@ export class EventDeviceCollector {
20
27
  model?: string;
21
28
  appVersion?: string;
22
29
  osVersion?: string;
30
+ } {
31
+ // 자동 수집된 기본 정보 가져오기
32
+ const autoDetectedInfo = EventDeviceCollector.getAutoDetectedDeviceInfo();
33
+
34
+ // 사용자 제공 정보와 병합 (사용자 정보가 우선)
35
+ return {
36
+ ...autoDetectedInfo,
37
+ ...EventDeviceCollector._userProvidedDeviceInfo
38
+ };
39
+ }
40
+
41
+ /**
42
+ * 자동 감지된 디바이스 정보만 반환
43
+ */
44
+ private static getAutoDetectedDeviceInfo(): {
45
+ category: 'mobile' | 'desktop' | 'tablet' | 'other';
46
+ platform?: string;
47
+ model?: string;
48
+ appVersion?: string;
49
+ osVersion?: string;
23
50
  } {
24
51
  if (!DOMUtils.isBrowser()) {
25
52
  return {
26
53
  category: 'other',
27
54
  platform: 'SSR',
28
55
  model: 'SSR',
29
- appVersion: ConfigUtils.getAppVersion(), // AdStage.init()에서 설정 또는 기본값 '1.0.0'
30
56
  osVersion: 'SSR'
31
57
  };
32
58
  }
@@ -49,21 +75,57 @@ export class EventDeviceCollector {
49
75
  category,
50
76
  platform: platformString,
51
77
  model: navigator.platform,
52
- appVersion: ConfigUtils.getAppVersion(), // AdStage.init()에서 설정 또는 기본값 '1.0.0'
53
78
  osVersion: navigator.platform
54
79
  };
55
80
  }
56
81
 
82
+ /**
83
+ * 디바이스 정보 설정 (런타임 업데이트)
84
+ */
85
+ static setDeviceInfo(deviceInfo: Partial<{
86
+ category: 'mobile' | 'desktop' | 'tablet' | 'other';
87
+ platform: string;
88
+ model: string;
89
+ appVersion: string;
90
+ osVersion: string;
91
+ }>): void {
92
+ EventDeviceCollector._userProvidedDeviceInfo = {
93
+ ...EventDeviceCollector._userProvidedDeviceInfo,
94
+ ...deviceInfo
95
+ };
96
+ }
97
+
98
+ /**
99
+ * 개별 디바이스 속성 설정
100
+ */
101
+ static setDeviceProperty(key: 'category' | 'platform' | 'model' | 'appVersion' | 'osVersion', value: string): void {
102
+ EventDeviceCollector._userProvidedDeviceInfo[key] = value as any;
103
+ }
104
+
105
+ /**
106
+ * 사용자 제공 디바이스 정보 초기화
107
+ */
108
+ static clearDeviceInfo(): void {
109
+ EventDeviceCollector._userProvidedDeviceInfo = {};
110
+ }
111
+
112
+ /**
113
+ * 현재 사용자가 설정한 디바이스 정보 반환
114
+ */
115
+ static getUserDeviceInfo(): typeof EventDeviceCollector._userProvidedDeviceInfo {
116
+ return { ...EventDeviceCollector._userProvidedDeviceInfo };
117
+ }
118
+
57
119
  /**
58
120
  * 플랫폼 타입을 Events API용 문자열로 매핑
59
121
  */
60
122
  private static mapPlatformForEvents(platformType: 'ios' | 'android' | 'web' | 'desktop'): string {
61
123
  switch (platformType) {
62
- case 'ios': return 'ios';
63
- case 'android': return 'android';
64
- case 'web': return 'mobile-web';
65
- case 'desktop': return 'desktop-web';
66
- default: return 'unknown';
124
+ case 'ios': return 'iOS';
125
+ case 'android': return 'Android';
126
+ case 'web': return 'Mobile Web';
127
+ case 'desktop': return 'Desktop Web';
128
+ default: return 'Unknown';
67
129
  }
68
130
  }
69
131
 
@@ -80,6 +80,73 @@ export class EventsModule implements BaseModule {
80
80
  return EventUserCollector.getCurrentUserProperties();
81
81
  }
82
82
 
83
+ /**
84
+ * 디바이스 정보 설정
85
+ */
86
+ setDeviceInfo(deviceInfo: Partial<{
87
+ category: 'mobile' | 'desktop' | 'tablet' | 'other';
88
+ platform: string;
89
+ model: string;
90
+ appVersion: string;
91
+ osVersion: string;
92
+ }>): void {
93
+ EventDeviceCollector.setDeviceInfo(deviceInfo);
94
+
95
+ if (this._config?.debug) {
96
+ console.log('📱 Device info set:', deviceInfo);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * 개별 디바이스 속성 설정
102
+ */
103
+ setDeviceProperty(key: 'category' | 'platform' | 'model' | 'appVersion' | 'osVersion', value: string): void {
104
+ EventDeviceCollector.setDeviceProperty(key, value);
105
+
106
+ if (this._config?.debug) {
107
+ console.log('📱 Device property set:', key, value);
108
+ }
109
+ }
110
+
111
+ /**
112
+ * 사용자 제공 디바이스 정보 초기화
113
+ */
114
+ clearDeviceInfo(): void {
115
+ EventDeviceCollector.clearDeviceInfo();
116
+
117
+ if (this._config?.debug) {
118
+ console.log('📱 User provided device info cleared');
119
+ }
120
+ }
121
+
122
+ /**
123
+ * 현재 사용자가 설정한 디바이스 정보 반환
124
+ */
125
+ getUserDeviceInfo(): any {
126
+ return EventDeviceCollector.getUserDeviceInfo();
127
+ }
128
+
129
+ /**
130
+ * 현재 디바이스 정보 반환
131
+ */
132
+ getDeviceInfo(): any {
133
+ return EventDeviceCollector.getDeviceInfo();
134
+ }
135
+
136
+ /**
137
+ * 현재 사용자 정보 반환
138
+ */
139
+ getUserInfo(): any {
140
+ return EventUserCollector.getUserInfo();
141
+ }
142
+
143
+ /**
144
+ * 현재 사용자 속성 반환 (별칭)
145
+ */
146
+ getCurrentUserProperties(): any {
147
+ return EventUserCollector.getCurrentUserProperties();
148
+ }
149
+
83
150
  /**
84
151
  * 이벤트 추적
85
152
  * @param eventName 이벤트 이름