@adstage/react-native-sdk 1.0.0

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +327 -0
  3. package/adstage-react-native.podspec +24 -0
  4. package/android/build.gradle +66 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/io/nbase/adstage/reactnative/AdStageModule.kt +701 -0
  7. package/android/src/main/java/io/nbase/adstage/reactnative/AdStagePackage.kt +24 -0
  8. package/ios/AdStageModule.m +70 -0
  9. package/ios/AdStageModule.swift +457 -0
  10. package/lib/commonjs/AdStage.js +213 -0
  11. package/lib/commonjs/AdStage.js.map +1 -0
  12. package/lib/commonjs/deeplink/AdStageDeepLink.js +235 -0
  13. package/lib/commonjs/deeplink/AdStageDeepLink.js.map +1 -0
  14. package/lib/commonjs/event/AdStageEvent.js +689 -0
  15. package/lib/commonjs/event/AdStageEvent.js.map +1 -0
  16. package/lib/commonjs/index.js +34 -0
  17. package/lib/commonjs/index.js.map +1 -0
  18. package/lib/commonjs/promotion/AdStagePromotion.js +158 -0
  19. package/lib/commonjs/promotion/AdStagePromotion.js.map +1 -0
  20. package/lib/commonjs/types.js +2 -0
  21. package/lib/commonjs/types.js.map +1 -0
  22. package/lib/module/AdStage.js +206 -0
  23. package/lib/module/AdStage.js.map +1 -0
  24. package/lib/module/deeplink/AdStageDeepLink.js +228 -0
  25. package/lib/module/deeplink/AdStageDeepLink.js.map +1 -0
  26. package/lib/module/event/AdStageEvent.js +682 -0
  27. package/lib/module/event/AdStageEvent.js.map +1 -0
  28. package/lib/module/index.js +15 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/promotion/AdStagePromotion.js +151 -0
  31. package/lib/module/promotion/AdStagePromotion.js.map +1 -0
  32. package/lib/module/types.js +2 -0
  33. package/lib/module/types.js.map +1 -0
  34. package/lib/typescript/src/AdStage.d.ts +124 -0
  35. package/lib/typescript/src/AdStage.d.ts.map +1 -0
  36. package/lib/typescript/src/deeplink/AdStageDeepLink.d.ts +154 -0
  37. package/lib/typescript/src/deeplink/AdStageDeepLink.d.ts.map +1 -0
  38. package/lib/typescript/src/event/AdStageEvent.d.ts +426 -0
  39. package/lib/typescript/src/event/AdStageEvent.d.ts.map +1 -0
  40. package/lib/typescript/src/index.d.ts +13 -0
  41. package/lib/typescript/src/index.d.ts.map +1 -0
  42. package/lib/typescript/src/promotion/AdStagePromotion.d.ts +98 -0
  43. package/lib/typescript/src/promotion/AdStagePromotion.d.ts.map +1 -0
  44. package/lib/typescript/src/types.d.ts +305 -0
  45. package/lib/typescript/src/types.d.ts.map +1 -0
  46. package/package.json +105 -0
  47. package/src/AdStage.ts +212 -0
  48. package/src/deeplink/AdStageDeepLink.ts +246 -0
  49. package/src/event/AdStageEvent.ts +844 -0
  50. package/src/index.ts +48 -0
  51. package/src/promotion/AdStagePromotion.ts +162 -0
  52. package/src/types.ts +392 -0
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * AdStage React Native SDK
3
+ *
4
+ * 광고 어트리뷰션, 딥링크, 프로모션을 위한 통합 SDK
5
+ *
6
+ * @since 3.0.0
7
+ */
8
+
9
+ export { AdStage } from './AdStage';
10
+ export { AdStageDeepLink } from './deeplink/AdStageDeepLink';
11
+ export { AdStagePromotion } from './promotion/AdStagePromotion';
12
+ export { AdStageEvent } from './event/AdStageEvent';
13
+
14
+ // Types
15
+ export type {
16
+ // Core
17
+ AdStageConfig,
18
+ // DeepLink
19
+ DeepLinkData,
20
+ DeepLinkSource,
21
+ DeepLinkListener,
22
+ CreateDeepLinkRequest,
23
+ CreateDeepLinkResponse,
24
+ RedirectConfig,
25
+ PlatformConfig,
26
+ // Promotion
27
+ PromotionListParams,
28
+ PromotionListResponse,
29
+ Promotion,
30
+ PromotionDeepLink,
31
+ PromotionClickResult,
32
+ // Event
33
+ TrackEventParams,
34
+ TrackEventResult,
35
+ UserAttributes,
36
+ // Event - Standard Types
37
+ SignUpMethod,
38
+ PaymentMethod,
39
+ EcommerceItem,
40
+ // Event - Unity Parity Types
41
+ AdPlatform,
42
+ AdFormat,
43
+ GameServerInfo,
44
+ PatchInfo,
45
+ StockTransactionInfo,
46
+ AccountOpenInfo,
47
+ CardApplicationInfo,
48
+ } from './types';
@@ -0,0 +1,162 @@
1
+ /**
2
+ * AdStage Promotion 모듈
3
+ *
4
+ * 프로모션 조회, 표시, 클릭 처리를 담당합니다.
5
+ * Android/iOS PromotionHandler, PromotionManager와 동일한 API를 제공합니다.
6
+ *
7
+ * @since 3.0.0
8
+ */
9
+
10
+ import { NativeModules } from 'react-native';
11
+ import type {
12
+ PromotionListParams,
13
+ PromotionListResponse,
14
+ Promotion,
15
+ PromotionClickResult,
16
+ } from '../types';
17
+
18
+ const { AdStageModule } = NativeModules;
19
+
20
+ /**
21
+ * AdStage Promotion 클래스
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // 프로모션 목록 조회
26
+ * const response = await AdStage.promotion.getList({
27
+ * bannerType: 'NATIVE',
28
+ * region: 'KR',
29
+ * limit: 10
30
+ * });
31
+ *
32
+ * // 프로모션 클릭 처리
33
+ * const result = await AdStage.promotion.handleClick(response.promotions[0]);
34
+ * ```
35
+ */
36
+ export class AdStagePromotion {
37
+ // ============================================
38
+ // Promotion List
39
+ // ============================================
40
+
41
+ /**
42
+ * 프로모션 목록 조회
43
+ *
44
+ * @param params - 조회 파라미터
45
+ * @returns 프로모션 목록 응답
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const response = await AdStage.promotion.getList({
50
+ * bannerType: 'NATIVE', // NATIVE, INTERSTITIAL, REWARDED_VIDEO, POPUP
51
+ * region: 'KR', // KR, JP, US, SEA, EU, GLOBAL
52
+ * deviceType: 'HIGH_END', // LOW_END, MID_END, HIGH_END
53
+ * limit: 10,
54
+ * status: 'ACTIVE',
55
+ * partner: 'game_company',
56
+ * primaryInterest: 'GAMES',
57
+ * primaryAgeGroup: '18-24',
58
+ * gameGenrePreference: 'RPG',
59
+ * playerSpendingTier: 'DOLPHIN', // F2P, DOLPHIN, WHALE
60
+ * playTimePattern: 'EVENING'
61
+ * });
62
+ *
63
+ * console.log('Total:', response.totalItems);
64
+ * response.promotions.forEach(promo => {
65
+ * console.log(`${promo.appName}: ${promo.bannerUrl}`);
66
+ * });
67
+ * ```
68
+ */
69
+ static async getList(
70
+ params: PromotionListParams = {}
71
+ ): Promise<PromotionListResponse> {
72
+ if (!AdStageModule) {
73
+ throw new Error('AdStage: Native module is not available');
74
+ }
75
+
76
+ const result = await AdStageModule.getPromotionList(params);
77
+
78
+ return {
79
+ totalItems: result.totalItems ?? 0,
80
+ promotions: result.promotions ?? [],
81
+ };
82
+ }
83
+
84
+ // ============================================
85
+ // Promotion Click Handling
86
+ // ============================================
87
+
88
+ /**
89
+ * 프로모션 클릭 처리
90
+ *
91
+ * 클릭 이벤트를 서버에 전송하고 스토어를 엽니다.
92
+ *
93
+ * @param promotion - 클릭할 프로모션
94
+ * @returns 클릭 처리 결과
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const result = await AdStage.promotion.handleClick(promotion);
99
+ *
100
+ * if (result.success) {
101
+ * console.log('스토어로 이동:', result.storeUrl);
102
+ * } else {
103
+ * console.error('클릭 처리 실패:', result.error);
104
+ * }
105
+ * ```
106
+ */
107
+ static async handleClick(promotion: Promotion): Promise<PromotionClickResult> {
108
+ if (!AdStageModule) {
109
+ throw new Error('AdStage: Native module is not available');
110
+ }
111
+
112
+ try {
113
+ const result = await AdStageModule.handlePromotionClick(promotion);
114
+ return {
115
+ success: true,
116
+ storeUrl: result.storeUrl,
117
+ };
118
+ } catch (error) {
119
+ return {
120
+ success: false,
121
+ error:
122
+ error instanceof Error ? error.message : 'Unknown error occurred',
123
+ };
124
+ }
125
+ }
126
+
127
+ /**
128
+ * 프로모션 노출 이벤트 전송
129
+ *
130
+ * 프로모션이 화면에 표시될 때 호출합니다.
131
+ *
132
+ * @param promotion - 노출된 프로모션
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * // 프로모션 배너가 화면에 보일 때
137
+ * AdStage.promotion.trackImpression(promotion);
138
+ * ```
139
+ */
140
+ static async trackImpression(promotion: Promotion): Promise<void> {
141
+ if (!AdStageModule) {
142
+ return;
143
+ }
144
+ await AdStageModule.trackPromotionImpression?.(promotion);
145
+ }
146
+
147
+ // ============================================
148
+ // Utility
149
+ // ============================================
150
+
151
+ /**
152
+ * 플랫폼에 맞는 스토어 URL 추출
153
+ *
154
+ * @param promotion - 프로모션
155
+ * @returns 스토어 URL 또는 null
156
+ */
157
+ static getStoreUrl(promotion: Promotion): string | null {
158
+ const platform =
159
+ require('react-native').Platform.OS === 'ios' ? 'ios' : 'android';
160
+ return promotion.storeUrls?.[platform] ?? null;
161
+ }
162
+ }
package/src/types.ts ADDED
@@ -0,0 +1,392 @@
1
+ /**
2
+ * AdStage SDK 타입 정의
3
+ *
4
+ * Android/iOS 네이티브 SDK와 동일한 타입 구조를 제공합니다.
5
+ *
6
+ * @since 3.0.0
7
+ */
8
+
9
+ // ============================================
10
+ // Core Types
11
+ // ============================================
12
+
13
+ /**
14
+ * AdStage SDK 초기화 설정
15
+ */
16
+ export interface AdStageConfig {
17
+ /** API 인증 키 (필수) */
18
+ apiKey: string;
19
+ /** 서버 URL (선택, 기본값: https://api.adstage.app) */
20
+ serverUrl?: string;
21
+ }
22
+
23
+ // ============================================
24
+ // DeepLink Types
25
+ // ============================================
26
+
27
+ /**
28
+ * 딥링크 소스 타입
29
+ */
30
+ export type DeepLinkSource = 'realtime' | 'install' | 'unknown';
31
+
32
+ /**
33
+ * 딥링크 데이터
34
+ */
35
+ export interface DeepLinkData {
36
+ /** 딥링크 ID (서버 발급) */
37
+ linkId: string;
38
+ /** Short Path (예: "SDGWNBB") */
39
+ shortPath: string;
40
+ /** 딥링크 파라미터 */
41
+ parameters: Record<string, string>;
42
+ /** 딥링크 소스 */
43
+ source: DeepLinkSource;
44
+ /** 이벤트 타입 (OPEN, INSTALL) */
45
+ eventType: string;
46
+ /** 타임스탬프 (Unity 호환) */
47
+ timestamp?: string;
48
+ }
49
+
50
+ /**
51
+ * 딥링크 리스너
52
+ */
53
+ export type DeepLinkListener = (data: DeepLinkData) => void;
54
+
55
+ /**
56
+ * 플랫폼별 리다이렉트 설정
57
+ */
58
+ export interface PlatformConfig {
59
+ /** 앱 스토어 URL */
60
+ storeUrl?: string;
61
+ /** 앱 커스텀 스킴 */
62
+ appScheme?: string;
63
+ /** 웹 폴백 URL */
64
+ webUrl?: string;
65
+ /** 패키지명 (Android) / 번들 ID (iOS) */
66
+ packageName?: string;
67
+ /** App Store ID (iOS) */
68
+ appStoreId?: string;
69
+ }
70
+
71
+ /**
72
+ * 리다이렉트 설정
73
+ */
74
+ export interface RedirectConfig {
75
+ /** 리다이렉트 타입: STORE, APP, WEB */
76
+ type: 'STORE' | 'APP' | 'WEB';
77
+ /** Android 플랫폼 설정 */
78
+ android?: PlatformConfig;
79
+ /** iOS 플랫폼 설정 */
80
+ ios?: PlatformConfig;
81
+ /** 데스크톱 설정 */
82
+ desktop?: { webUrl?: string };
83
+ }
84
+
85
+ /**
86
+ * 딥링크 생성 요청
87
+ */
88
+ export interface CreateDeepLinkRequest {
89
+ /** 딥링크 이름 (필수) */
90
+ name: string;
91
+ /** 딥링크 설명 */
92
+ description?: string;
93
+ /** Short Path 커스텀 */
94
+ shortPath?: string;
95
+ /** 채널 */
96
+ channel?: string;
97
+ /** 서브 채널 */
98
+ subChannel?: string;
99
+ /** 캠페인 */
100
+ campaign?: string;
101
+ /** 광고 그룹 */
102
+ adGroup?: string;
103
+ /** 광고 크리에이티브 */
104
+ creative?: string;
105
+ /** 콘텐츠 (Unity 호환) */
106
+ content?: string;
107
+ /** 키워드 */
108
+ keyword?: string;
109
+ /** 리다이렉트 설정 */
110
+ redirectConfig?: RedirectConfig;
111
+ /** 커스텀 파라미터 */
112
+ parameters?: Record<string, string>;
113
+ }
114
+
115
+ /**
116
+ * 딥링크 생성 응답
117
+ */
118
+ export interface CreateDeepLinkResponse {
119
+ /** 생성된 Short URL */
120
+ shortUrl: string;
121
+ /** Short Path */
122
+ shortPath: string;
123
+ /** 딥링크 ID */
124
+ linkId: string;
125
+ }
126
+
127
+ // ============================================
128
+ // Promotion Types
129
+ // ============================================
130
+
131
+ /**
132
+ * 프로모션 조회 파라미터
133
+ */
134
+ export interface PromotionListParams {
135
+ /** 배너 타입: NATIVE, INTERSTITIAL, REWARDED_VIDEO, POPUP */
136
+ bannerType?: string;
137
+ /** 타겟 사용자 필터 */
138
+ targetAudience?: string;
139
+ /** 디바이스 타입: LOW_END, MID_END, HIGH_END */
140
+ deviceType?: string;
141
+ /** 지역: KR, JP, US, SEA, EU, GLOBAL */
142
+ region?: string;
143
+ /** 조회 개수 제한 */
144
+ limit?: number;
145
+ /** 상태: ACTIVE, PENDING, PAUSED, ENDED */
146
+ status?: string;
147
+ /** 파트너(광고주) 필터 */
148
+ partner?: string;
149
+ /** 주요 관심사 */
150
+ primaryInterest?: string;
151
+ /** 주요 연령대: 13-17, 18-24, 25-34, 35-44, 45+ */
152
+ primaryAgeGroup?: string;
153
+ /** 게임 장르 선호도 */
154
+ gameGenrePreference?: string;
155
+ /** 플레이어 지출 티어: F2P, DOLPHIN, WHALE */
156
+ playerSpendingTier?: string;
157
+ /** 플레이 시간 패턴 */
158
+ playTimePattern?: string;
159
+ }
160
+
161
+ /**
162
+ * 프로모션 딥링크 정보
163
+ */
164
+ export interface PromotionDeepLink {
165
+ id: string;
166
+ name: string;
167
+ description: string;
168
+ shortPath: string;
169
+ linkType: string;
170
+ channel: string;
171
+ subChannel: string;
172
+ campaign: string;
173
+ content: string;
174
+ keyword: string;
175
+ status: string;
176
+ }
177
+
178
+ /**
179
+ * 프로모션 데이터
180
+ */
181
+ export interface Promotion {
182
+ /** 프로모션 ID */
183
+ id: string;
184
+ /** 파트너(광고주) 이름 */
185
+ partner: string;
186
+ /** 앱 이름 */
187
+ appName: string;
188
+ /** 배너 이미지 URL */
189
+ bannerUrl: string;
190
+ /** 배너 타입 */
191
+ bannerType: string;
192
+ /** 앱 설명 */
193
+ appDescription: string;
194
+ /** 딥링크 정보 */
195
+ deeplink: PromotionDeepLink;
196
+ /** 스토어 URL */
197
+ storeUrls?: {
198
+ android?: string;
199
+ ios?: string;
200
+ };
201
+ }
202
+
203
+ /**
204
+ * 프로모션 리스트 응답
205
+ */
206
+ export interface PromotionListResponse {
207
+ /** 전체 개수 */
208
+ totalItems: number;
209
+ /** 프로모션 목록 */
210
+ promotions: Promotion[];
211
+ }
212
+
213
+ /**
214
+ * 프로모션 클릭 결과
215
+ */
216
+ export interface PromotionClickResult {
217
+ /** 성공 여부 */
218
+ success: boolean;
219
+ /** 이동한 스토어 URL */
220
+ storeUrl?: string;
221
+ /** 에러 메시지 */
222
+ error?: string;
223
+ }
224
+
225
+ // ============================================
226
+ // Event Tracking Types
227
+ // ============================================
228
+
229
+ /**
230
+ * 사용자 속성
231
+ */
232
+ export interface UserAttributes {
233
+ /** 성별: male, female, other */
234
+ gender?: string;
235
+ /** 국가 코드: KR, US, JP 등 */
236
+ country?: string;
237
+ /** 도시 */
238
+ city?: string;
239
+ /** 나이 */
240
+ age?: string;
241
+ /** 언어: ko-KR, en-US 등 */
242
+ language?: string;
243
+ }
244
+
245
+ /**
246
+ * 이벤트 파라미터 (자유 형식)
247
+ */
248
+ export type TrackEventParams = Record<string, unknown>;
249
+
250
+ /**
251
+ * 이벤트 전송 결과
252
+ */
253
+ export interface TrackEventResult {
254
+ /** 성공 여부 */
255
+ success: boolean;
256
+ /** 이벤트 ID */
257
+ eventId?: string;
258
+ /** 에러 메시지 */
259
+ error?: string;
260
+ }
261
+
262
+ // ============================================
263
+ // Standard Event Types
264
+ // ============================================
265
+
266
+ /**
267
+ * 회원가입 방법
268
+ */
269
+ export type SignUpMethod =
270
+ | 'email'
271
+ | 'google'
272
+ | 'apple'
273
+ | 'facebook'
274
+ | 'kakao'
275
+ | 'naver'
276
+ | 'twitter'
277
+ | 'line'
278
+ | 'guest';
279
+
280
+ /**
281
+ * 결제 방법
282
+ */
283
+ export type PaymentMethod =
284
+ | 'credit_card'
285
+ | 'debit_card'
286
+ | 'paypal'
287
+ | 'google_pay'
288
+ | 'apple_pay'
289
+ | 'samsung_pay'
290
+ | 'kakao_pay'
291
+ | 'naver_pay'
292
+ | 'toss'
293
+ | 'bank_transfer'
294
+ | 'virtual_account'
295
+ | 'carrier_billing'
296
+ | 'gift_card'
297
+ | 'cryptocurrency'
298
+ | 'other';
299
+
300
+ /**
301
+ * 이커머스 아이템
302
+ */
303
+ export interface EcommerceItem {
304
+ itemId: string;
305
+ itemName: string;
306
+ price?: number;
307
+ quantity?: number;
308
+ itemCategory?: string;
309
+ itemBrand?: string;
310
+ }
311
+
312
+ // ============================================
313
+ // Additional Event Types (Unity Parity)
314
+ // ============================================
315
+
316
+ /**
317
+ * 광고 플랫폼 타입
318
+ */
319
+ export type AdPlatform =
320
+ | 'admob'
321
+ | 'applovin'
322
+ | 'ironsource'
323
+ | 'unity_ads'
324
+ | 'facebook'
325
+ | 'vungle'
326
+ | 'chartboost'
327
+ | 'mopub'
328
+ | 'other';
329
+
330
+ /**
331
+ * 광고 포맷 타입
332
+ */
333
+ export type AdFormat =
334
+ | 'banner'
335
+ | 'interstitial'
336
+ | 'rewarded'
337
+ | 'rewarded_interstitial'
338
+ | 'native'
339
+ | 'app_open'
340
+ | 'other';
341
+
342
+ /**
343
+ * 게임 서버 정보 (Unity 문서 기준)
344
+ */
345
+ export interface GameServerInfo {
346
+ /** 서버 ID (Unity: contentId) */
347
+ contentId?: string;
348
+ /** 서버 타입 (Unity: contentType) - 예: 'pvp', 'pve' */
349
+ contentType?: string;
350
+ /** 서버 이름 (Unity: itemName) */
351
+ itemName?: string;
352
+ }
353
+
354
+ /**
355
+ * 패치 정보 (Unity 문서 기준)
356
+ */
357
+ export interface PatchInfo {
358
+ /** 패치 ID (Unity: contentId) - 예: 'PATCH_2.1.0' */
359
+ contentId?: string;
360
+ /** 패치 타입 (Unity: contentType) - 예: 'update', 'hotfix' */
361
+ contentType?: string;
362
+ }
363
+
364
+ /**
365
+ * 금융 거래 정보
366
+ */
367
+ export interface StockTransactionInfo {
368
+ itemId?: string;
369
+ itemName?: string;
370
+ quantity?: number;
371
+ price?: number;
372
+ value?: number;
373
+ currency?: string;
374
+ }
375
+
376
+ /**
377
+ * 계좌 개설 정보
378
+ */
379
+ export interface AccountOpenInfo {
380
+ contentType?: string;
381
+ contentId?: string;
382
+ method?: string;
383
+ }
384
+
385
+ /**
386
+ * 카드 신청 정보
387
+ */
388
+ export interface CardApplicationInfo {
389
+ contentType?: string;
390
+ itemName?: string;
391
+ itemId?: string;
392
+ }