@adstage/web-sdk 3.0.2 → 3.0.3
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
|
@@ -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,33 @@ 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(),
|
|
56
|
+
appVersion: ConfigUtils.getAppVersion(),
|
|
30
57
|
osVersion: 'SSR'
|
|
31
58
|
};
|
|
32
59
|
}
|
|
@@ -49,21 +76,58 @@ export class EventDeviceCollector {
|
|
|
49
76
|
category,
|
|
50
77
|
platform: platformString,
|
|
51
78
|
model: navigator.platform,
|
|
52
|
-
appVersion: ConfigUtils.getAppVersion(),
|
|
79
|
+
appVersion: ConfigUtils.getAppVersion(),
|
|
53
80
|
osVersion: navigator.platform
|
|
54
81
|
};
|
|
55
82
|
}
|
|
56
83
|
|
|
84
|
+
/**
|
|
85
|
+
* 디바이스 정보 설정 (런타임 업데이트)
|
|
86
|
+
*/
|
|
87
|
+
static setDeviceInfo(deviceInfo: Partial<{
|
|
88
|
+
category: 'mobile' | 'desktop' | 'tablet' | 'other';
|
|
89
|
+
platform: string;
|
|
90
|
+
model: string;
|
|
91
|
+
appVersion: string;
|
|
92
|
+
osVersion: string;
|
|
93
|
+
}>): void {
|
|
94
|
+
EventDeviceCollector._userProvidedDeviceInfo = {
|
|
95
|
+
...EventDeviceCollector._userProvidedDeviceInfo,
|
|
96
|
+
...deviceInfo
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 개별 디바이스 속성 설정
|
|
102
|
+
*/
|
|
103
|
+
static setDeviceProperty(key: 'category' | 'platform' | 'model' | 'appVersion' | 'osVersion', value: string): void {
|
|
104
|
+
EventDeviceCollector._userProvidedDeviceInfo[key] = value as any;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 사용자 제공 디바이스 정보 초기화
|
|
109
|
+
*/
|
|
110
|
+
static clearUserProvidedDeviceInfo(): void {
|
|
111
|
+
EventDeviceCollector._userProvidedDeviceInfo = {};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 현재 사용자가 설정한 디바이스 정보 반환
|
|
116
|
+
*/
|
|
117
|
+
static getUserProvidedDeviceInfo(): typeof EventDeviceCollector._userProvidedDeviceInfo {
|
|
118
|
+
return { ...EventDeviceCollector._userProvidedDeviceInfo };
|
|
119
|
+
}
|
|
120
|
+
|
|
57
121
|
/**
|
|
58
122
|
* 플랫폼 타입을 Events API용 문자열로 매핑
|
|
59
123
|
*/
|
|
60
124
|
private static mapPlatformForEvents(platformType: 'ios' | 'android' | 'web' | 'desktop'): string {
|
|
61
125
|
switch (platformType) {
|
|
62
|
-
case 'ios': return '
|
|
63
|
-
case 'android': return '
|
|
64
|
-
case 'web': return '
|
|
65
|
-
case 'desktop': return '
|
|
66
|
-
default: return '
|
|
126
|
+
case 'ios': return 'iOS';
|
|
127
|
+
case 'android': return 'Android';
|
|
128
|
+
case 'web': return 'Mobile Web';
|
|
129
|
+
case 'desktop': return 'Desktop Web';
|
|
130
|
+
default: return 'Unknown';
|
|
67
131
|
}
|
|
68
132
|
}
|
|
69
133
|
|