@adstage/web-sdk 2.6.3 → 3.0.1

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
@@ -323,7 +323,7 @@ class DOMUtils {
323
323
  * AdStage SDK - 버전 정보 유틸리티
324
324
  */
325
325
  // package.json에서 버전 정보 가져오기 (빌드 시 자동으로 교체됨)
326
- const SDK_VERSION$1 = '"2.6.3"';
326
+ const SDK_VERSION$1 = '"3.0.1"';
327
327
  /**
328
328
  * SDK 버전 정보 반환
329
329
  */
@@ -4356,6 +4356,7 @@ class EventsModule {
4356
4356
  eventName,
4357
4357
  userId: EventSessionManager.getUserId(),
4358
4358
  sessionId: EventSessionManager.getSessionId(),
4359
+ sdkVersion: getSDKVersion(),
4359
4360
  device: EventDeviceCollector.getDeviceInfo(),
4360
4361
  user: EventUserCollector.getUserInfo(),
4361
4362
  params: properties || {}
package/dist/index.esm.js CHANGED
@@ -321,7 +321,7 @@ class DOMUtils {
321
321
  * AdStage SDK - 버전 정보 유틸리티
322
322
  */
323
323
  // package.json에서 버전 정보 가져오기 (빌드 시 자동으로 교체됨)
324
- const SDK_VERSION$1 = '"2.6.3"';
324
+ const SDK_VERSION$1 = '"3.0.1"';
325
325
  /**
326
326
  * SDK 버전 정보 반환
327
327
  */
@@ -4354,6 +4354,7 @@ class EventsModule {
4354
4354
  eventName,
4355
4355
  userId: EventSessionManager.getUserId(),
4356
4356
  sessionId: EventSessionManager.getSessionId(),
4357
+ sdkVersion: getSDKVersion(),
4357
4358
  device: EventDeviceCollector.getDeviceInfo(),
4358
4359
  user: EventUserCollector.getUserInfo(),
4359
4360
  params: properties || {}
@@ -318,7 +318,7 @@ class DOMUtils {
318
318
  * AdStage SDK - 버전 정보 유틸리티
319
319
  */
320
320
  // package.json에서 버전 정보 가져오기 (빌드 시 자동으로 교체됨)
321
- const SDK_VERSION$1 = '"2.6.3"';
321
+ const SDK_VERSION$1 = '"3.0.1"';
322
322
  /**
323
323
  * SDK 버전 정보 반환
324
324
  */
@@ -4351,6 +4351,7 @@ class EventsModule {
4351
4351
  eventName,
4352
4352
  userId: EventSessionManager.getUserId(),
4353
4353
  sessionId: EventSessionManager.getSessionId(),
4354
+ sdkVersion: getSDKVersion(),
4354
4355
  device: EventDeviceCollector.getDeviceInfo(),
4355
4356
  user: EventUserCollector.getUserInfo(),
4356
4357
  params: properties || {}
package/dist/index.umd.js CHANGED
@@ -324,7 +324,7 @@
324
324
  * AdStage SDK - 버전 정보 유틸리티
325
325
  */
326
326
  // package.json에서 버전 정보 가져오기 (빌드 시 자동으로 교체됨)
327
- const SDK_VERSION$1 = '"2.6.3"';
327
+ const SDK_VERSION$1 = '"3.0.1"';
328
328
  /**
329
329
  * SDK 버전 정보 반환
330
330
  */
@@ -4357,6 +4357,7 @@
4357
4357
  eventName,
4358
4358
  userId: EventSessionManager.getUserId(),
4359
4359
  sessionId: EventSessionManager.getSessionId(),
4360
+ sdkVersion: getSDKVersion(),
4360
4361
  device: EventDeviceCollector.getDeviceInfo(),
4361
4362
  user: EventUserCollector.getUserInfo(),
4362
4363
  params: properties || {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adstage/web-sdk",
3
- "version": "2.6.3",
3
+ "version": "3.0.1",
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",
@@ -18,6 +18,8 @@
18
18
  "files": [
19
19
  "dist",
20
20
  "src",
21
+ "!src/example/",
22
+ "!**/*.example.*",
21
23
  "README.md",
22
24
  "LICENSE"
23
25
  ],
@@ -6,6 +6,7 @@
6
6
  import { AdStageConfig, BaseModule } from '../../types/config';
7
7
  import { endpoints } from '../../constants/endpoints';
8
8
  import { ApiHeaders } from '../../utils/api-headers';
9
+ import { getSDKVersion } from '../../utils/version';
9
10
  import { EventDeviceCollector } from '../../managers/events/event-device-collector';
10
11
  import { EventUserCollector } from '../../managers/events/event-user-collector';
11
12
  import { EventSessionManager } from '../../managers/events/event-session-manager';
@@ -115,6 +116,7 @@ export class EventsModule implements BaseModule {
115
116
  eventName,
116
117
  userId: EventSessionManager.getUserId(),
117
118
  sessionId: EventSessionManager.getSessionId(),
119
+ sdkVersion: getSDKVersion(),
118
120
  device: EventDeviceCollector.getDeviceInfo(),
119
121
  user: EventUserCollector.getUserInfo(),
120
122
  params: properties || {}
@@ -1,125 +0,0 @@
1
- # AdStage SDK - 이벤트 추적 예시
2
-
3
- EventLogGenerator의 파라미터를 참고하여 만든 간단한 이벤트 추적 예시들입니다.
4
-
5
- ## 📁 폴더 구조
6
-
7
- ```
8
- events/
9
- ├── javascript/ # Vanilla JS 예시
10
- ├── react/ # React 예시
11
- └── nextjs/ # Next.js 예시
12
- ```
13
-
14
- ## 🚀 실행 방법
15
-
16
- ### JavaScript (Vanilla JS)
17
- ```bash
18
- # 브라우저에서 직접 열기 (NPM CDN 사용)
19
- open javascript/index.html
20
- ```
21
-
22
- ### React
23
- ```bash
24
- cd react
25
- npm install # @adstage/web-sdk@^2.6.1 설치됨
26
- npm start
27
- # http://localhost:3000
28
- ```
29
-
30
- ### Next.js
31
- ```bash
32
- cd nextjs
33
- npm install # @adstage/web-sdk@^2.6.1 설치됨
34
- npm run dev
35
- # http://localhost:3000
36
- ```
37
-
38
- ## 📊 구현된 이벤트 타입
39
-
40
- ### JavaScript 예시
41
- - `purchase` - 구매 이벤트
42
- - `signup_complete` - 회원가입 이벤트
43
- - `page_view` - 페이지뷰 이벤트
44
-
45
- ### React 예시
46
- - `purchase` - 구매 이벤트
47
- - `signup_complete` - 회원가입 이벤트
48
- - `view_item` - 상품조회 이벤트
49
-
50
- ### Next.js 예시
51
- - `add_to_cart` - 장바구니 추가 이벤트
52
- - `first_open` - 앱 설치 이벤트
53
- - `search` - 검색 이벤트
54
-
55
- ## 🎯 공통 특징
56
-
57
- - **흰 바탕에 간단한 버튼 3개**
58
- - **각 버튼마다 다른 이벤트 전송**
59
- - **EventLogGenerator 파라미터 구조 참고**
60
- - **실시간 결과 표시**
61
- - **자동 페이지뷰 추적**
62
-
63
- ## 📋 이벤트 파라미터 예시
64
-
65
- 모든 예시는 EventLogGenerator에서 사용하는 실제 파라미터 구조를 따릅니다:
66
-
67
- ```javascript
68
- // 구매 이벤트
69
- {
70
- transaction_id: "tx_1725123456789",
71
- value: 99000,
72
- currency: "KRW",
73
- payment_method: "card",
74
- items: 2,
75
- category: "electronics",
76
- brand: "Samsung"
77
- }
78
-
79
- // 회원가입 이벤트
80
- {
81
- user_id: "user_1725123456789",
82
- signup_method: "email",
83
- email_verified: true,
84
- time_to_complete: 120,
85
- form_version: "v2",
86
- utm_source: "google_ads",
87
- utm_medium: "cpc"
88
- }
89
-
90
- // 페이지뷰 이벤트
91
- {
92
- page: "/",
93
- title: "Home Page",
94
- referrer: "direct",
95
- utm_source: "organic"
96
- }
97
- ```
98
-
99
- ## 🔧 SDK 설정
100
-
101
- 모든 예시에서 동일한 SDK 설정을 사용합니다:
102
-
103
- ```javascript
104
- AdStage.init({
105
- apiKey: '7dfddcfda637fbb73225bac3731688b80b90675942fe9f2057a88e2379aba2a4',
106
- debug: true,
107
- appVersion: '1.2.3' // 각 플랫폼별로 다른 버전
108
- });
109
- ```
110
-
111
- ## 📦 SDK 로드 방법
112
-
113
- ### JavaScript (CDN)
114
- ```html
115
- <script src="https://unpkg.com/@adstage/web-sdk@latest/dist/index.standalone.js"></script>
116
- ```
117
-
118
- ### React/Next.js (NPM)
119
- ```json
120
- {
121
- "dependencies": {
122
- "@adstage/web-sdk": "^2.6.1"
123
- }
124
- }
125
- ```
@@ -1,159 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>AdStage SDK - 이벤트 추적 예시 (ESM)</title>
5
- <style>
6
- body {
7
- font-family: Arial, sans-serif;
8
- padding: 20px;
9
- background-color: white;
10
- }
11
-
12
- button {
13
- padding: 12px 24px;
14
- margin: 10px;
15
- font-size: 16px;
16
- border: 1px solid #ccc;
17
- border-radius: 4px;
18
- background-color: #f8f9fa;
19
- cursor: pointer;
20
- }
21
-
22
- button:hover {
23
- background-color: #e9ecef;
24
- }
25
-
26
- button:active {
27
- background-color: #dee2e6;
28
- }
29
-
30
- .result {
31
- margin-top: 20px;
32
- padding: 15px;
33
- border: 1px solid #ddd;
34
- border-radius: 4px;
35
- background-color: #f8f9fa;
36
- white-space: pre-wrap;
37
- font-family: monospace;
38
- }
39
-
40
- .note {
41
- background: #e3f2fd;
42
- padding: 15px;
43
- border-left: 4px solid #2196f3;
44
- margin: 20px 0;
45
- }
46
- </style>
47
- </head>
48
- <body>
49
- <h1>AdStage SDK - 이벤트 추적 예시 (ESM 방식)</h1>
50
-
51
- <div class="note">
52
- <strong>📋 ESM 방식:</strong><br>
53
- • ES Module을 지원하는 모던 브라우저에서 사용<br>
54
- • 번들러 없이 직접 import 가능<br>
55
- • Tree-shaking 최적화 지원
56
- </div>
57
-
58
- <div>
59
- <button id="purchaseBtn">구매 이벤트 전송</button>
60
- <button id="signupBtn">회원가입 이벤트 전송</button>
61
- <button id="pageViewBtn">페이지뷰 이벤트 전송</button>
62
- </div>
63
-
64
- <div id="result" class="result">이벤트 결과가 여기에 표시됩니다.</div>
65
-
66
- <!-- ESM 방식: ES Module import -->
67
- <script type="module">
68
- // ESM 방식으로 SDK import
69
- import { AdStage, track } from 'https://unpkg.com/@adstage/web-sdk@2.6.2/dist/index.standalone.js';
70
-
71
- // SDK 초기화
72
- AdStage.init({
73
- apiKey: 'c06e2bc7c7244e111d90e530227274898de66ac9f3b5dbeae10e7615c1c616de',
74
- debug: true,
75
- baseUrl: 'https://beta-api.adstage.app',
76
- appVersion: '1.2.3',
77
- });
78
-
79
- // 결과 표시 함수
80
- function showResult(message) {
81
- document.getElementById('result').textContent = message;
82
- }
83
-
84
- // 구매 이벤트
85
- async function trackPurchase() {
86
- try {
87
- showResult('구매 이벤트 전송 중...');
88
-
89
- await track('purchase', {
90
- currency: 'KRW',
91
- value: 29900,
92
- item_id: 'premium_plan_001',
93
- item_name: '프리미엄 플랜',
94
- item_category: 'subscription',
95
- quantity: 1,
96
- payment_type: 'credit_card',
97
- transaction_id: 'txn_' + Date.now()
98
- });
99
-
100
- showResult('✅ 구매 이벤트가 성공적으로 전송되었습니다!');
101
- } catch (error) {
102
- showResult('❌ 구매 이벤트 전송 실패: ' + error.message);
103
- }
104
- }
105
-
106
- // 회원가입 이벤트
107
- async function trackSignup() {
108
- try {
109
- showResult('회원가입 이벤트 전송 중...');
110
-
111
- await track('sign_up', {
112
- method: 'email',
113
- user_type: 'advertiser',
114
- signup_source: 'landing_page',
115
- utm_source: 'google',
116
- utm_medium: 'cpc',
117
- utm_campaign: 'brand_keywords'
118
- });
119
-
120
- showResult('✅ 회원가입 이벤트가 성공적으로 전송되었습니다!');
121
- } catch (error) {
122
- showResult('❌ 회원가입 이벤트 전송 실패: ' + error.message);
123
- }
124
- }
125
-
126
- // 페이지뷰 이벤트
127
- async function trackPageView() {
128
- try {
129
- showResult('페이지뷰 이벤트 전송 중...');
130
-
131
- await track('page_view', {
132
- page_title: document.title,
133
- page_location: window.location.href,
134
- page_referrer: document.referrer || '직접 접속',
135
- content_group1: 'example',
136
- content_group2: 'events',
137
- session_id: 'sess_' + Date.now()
138
- });
139
-
140
- showResult('✅ 페이지뷰 이벤트가 성공적으로 전송되었습니다!');
141
- } catch (error) {
142
- showResult('❌ 페이지뷰 이벤트 전송 실패: ' + error.message);
143
- }
144
- }
145
-
146
- // 이벤트 리스너 등록
147
- document.getElementById('purchaseBtn').addEventListener('click', trackPurchase);
148
- document.getElementById('signupBtn').addEventListener('click', trackSignup);
149
- document.getElementById('pageViewBtn').addEventListener('click', trackPageView);
150
-
151
- // 페이지 로드 시 자동으로 페이지뷰 이벤트 전송
152
- window.addEventListener('load', () => {
153
- setTimeout(() => {
154
- trackPageView();
155
- }, 1000);
156
- });
157
- </script>
158
- </body>
159
- </html>
@@ -1,151 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>AdStage SDK - 이벤트 추적 예시</title>
5
- <style>
6
- body {
7
- font-family: Arial, sans-serif;
8
- padding: 20px;
9
- background-color: white;
10
- }
11
-
12
- button {
13
- padding: 12px 24px;
14
- margin: 10px;
15
- font-size: 16px;
16
- border: 1px solid #ccc;
17
- border-radius: 4px;
18
- background-color: #f8f9fa;
19
- cursor: pointer;
20
- }
21
-
22
- button:hover {
23
- background-color: #e9ecef;
24
- }
25
-
26
- button:active {
27
- background-color: #dee2e6;
28
- }
29
-
30
- .result {
31
- margin-top: 20px;
32
- padding: 15px;
33
- border: 1px solid #ddd;
34
- border-radius: 4px;
35
- background-color: #f8f9fa;
36
- white-space: pre-wrap;
37
- font-family: monospace;
38
- }
39
- </style>
40
- </head>
41
- <body>
42
- <h1>AdStage SDK - 이벤트 추적 예시</h1>
43
-
44
- <div>
45
- <button onclick="trackPurchase()">구매 이벤트 전송</button>
46
- <button onclick="trackSignup()">회원가입 이벤트 전송</button>
47
- <button onclick="trackPageView()">페이지뷰 이벤트 전송</button>
48
- </div>
49
-
50
- <div id="result" class="result">이벤트 결과가 여기에 표시됩니다.</div>
51
-
52
- <!-- AdStage SDK - UMD 방식 (브라우저 호환성을 위한 UMD 포맷) -->
53
- <script src="https://unpkg.com/@adstage/web-sdk@2.6.2/dist/index.umd.js"></script>
54
- <script>
55
- // SDK 초기화
56
- AdStage.init({
57
- apiKey: 'c06e2bc7c7244e111d90e530227274898de66ac9f3b5dbeae10e7615c1c616de',
58
- debug: true,
59
- baseUrl: 'https://beta-api.adstage.app',
60
- appVersion: '1.2.3',
61
- });
62
-
63
- // 사용자 ID 설정
64
- AdStage.events.setUserId('gunny1234');
65
-
66
- // 사용자 속성 설정
67
- AdStage.events.setUserProperties({
68
- age: '28',
69
- city: 'Seoul',
70
- gender: 'male',
71
- country: 'KR',
72
- occupation: 'developer',
73
- interests: ['technology', 'gaming', 'travel']
74
- });
75
-
76
- function showResult(eventName, params, success = true) {
77
- const result = document.getElementById('result');
78
- const timestamp = new Date().toLocaleString();
79
- result.textContent = `[${timestamp}] ${eventName} 이벤트 ${success ? '전송됨' : '실패'}\n\n파라미터:\n${JSON.stringify(params, null, 2)}`;
80
- }
81
-
82
- // 구매 이벤트
83
- function trackPurchase() {
84
- const params = {
85
- transaction_id: `tx_${Date.now()}`,
86
- value: 99000,
87
- currency: 'KRW',
88
- payment_method: 'card',
89
- items: 2,
90
- category: 'electronics',
91
- brand: 'Samsung'
92
- };
93
-
94
- try {
95
- AdStage.events.track('purchase', params);
96
- showResult('purchase', params);
97
- } catch (error) {
98
- showResult('purchase', params, false);
99
- console.error('Purchase event failed:', error);
100
- }
101
- }
102
-
103
- // 회원가입 이벤트
104
- function trackSignup() {
105
- const params = {
106
- user_id: `user_${Date.now()}`,
107
- signup_method: 'email',
108
- email_verified: true,
109
- time_to_complete: 120,
110
- form_version: 'v2',
111
- utm_source: 'google_ads',
112
- utm_medium: 'cpc'
113
- };
114
-
115
- try {
116
- AdStage.events.track('signup_complete', params);
117
- showResult('signup_complete', params);
118
- } catch (error) {
119
- showResult('signup_complete', params, false);
120
- console.error('Signup event failed:', error);
121
- }
122
- }
123
-
124
- // 페이지뷰 이벤트
125
- function trackPageView() {
126
- const params = {
127
- page: window.location.pathname,
128
- title: document.title,
129
- referrer: document.referrer || 'direct',
130
- utm_source: 'organic',
131
- user_engagement: Math.floor(Math.random() * 300) + 30
132
- };
133
-
134
- try {
135
- AdStage.events.pageView(params);
136
- showResult('page_view', params);
137
- } catch (error) {
138
- showResult('page_view', params, false);
139
- console.error('PageView event failed:', error);
140
- }
141
- }
142
-
143
- // 페이지 로드 시 자동 페이지뷰 추적
144
- window.addEventListener('load', () => {
145
- setTimeout(() => {
146
- trackPageView();
147
- }, 1000);
148
- });
149
- </script>
150
- </body>
151
- </html>
@@ -1,54 +0,0 @@
1
- # AdStage SDK - Next.js 이벤트 추적 예시
2
-
3
- ## 설치 및 실행
4
-
5
- ```bash
6
- cd /Users/gunny/Documents/workspace/adstage/sdk/src/example/events/nextjs
7
- npm install # @adstage/web-sdk@^2.6.1 설치됨
8
- npm run dev
9
- ```
10
-
11
- 서버: http://localhost:3000
12
-
13
- ## 기능
14
-
15
- - 장바구니 추가 이벤트
16
- - 앱 설치 이벤트
17
- - 검색 이벤트
18
- - 자동 페이지뷰 추적
19
-
20
- ## 이벤트 파라미터 예시
21
-
22
- ### 장바구니 추가 (add_to_cart)
23
- ```javascript
24
- {
25
- item_id: "prod_1234",
26
- quantity: 2,
27
- cart_value: 125000,
28
- category: "home",
29
- brand: "IKEA",
30
- source: "product_page"
31
- }
32
- ```
33
-
34
- ### 앱 설치 (first_open)
35
- ```javascript
36
- {
37
- install_source: "google_play",
38
- campaign: "summer_2024",
39
- days_since_click: 3,
40
- organic: false,
41
- referrer: "google_ads"
42
- }
43
- ```
44
-
45
- ### 검색 (search)
46
- ```javascript
47
- {
48
- search_term: "iPhone",
49
- results_count: 42,
50
- category: "electronics",
51
- filters_applied: true,
52
- sort_by: "price"
53
- }
54
- ```
@@ -1,8 +0,0 @@
1
- /** @type {import('next').NextConfig} */
2
- const nextConfig = {
3
- experimental: {
4
- appDir: false
5
- }
6
- }
7
-
8
- module.exports = nextConfig
@@ -1,16 +0,0 @@
1
- {
2
- "name": "adstage-events-nextjs-example",
3
- "version": "1.0.0",
4
- "private": true,
5
- "scripts": {
6
- "dev": "next dev",
7
- "build": "next build",
8
- "start": "next start"
9
- },
10
- "dependencies": {
11
- "@adstage/web-sdk": "^2.6.1",
12
- "next": "14.0.0",
13
- "react": "^18.2.0",
14
- "react-dom": "^18.2.0"
15
- }
16
- }
@@ -1,15 +0,0 @@
1
- import { AdStageProvider } from '@adstage/web-sdk';
2
-
3
- export default function App({ Component, pageProps }) {
4
- return (
5
- <AdStageProvider
6
- config={{
7
- apiKey: '7dfddcfda637fbb73225bac3731688b80b90675942fe9f2057a88e2379aba2a4',
8
- debug: true,
9
- appVersion: '3.0.1'
10
- }}
11
- >
12
- <Component {...pageProps} />
13
- </AdStageProvider>
14
- );
15
- }
@@ -1,139 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { track, pageView } from '@adstage/web-sdk';
3
-
4
- export default function Home() {
5
- const [result, setResult] = useState('이벤트 결과가 여기에 표시됩니다.');
6
-
7
- const showResult = (eventName, params, success = true) => {
8
- const timestamp = new Date().toLocaleString();
9
- setResult(`[${timestamp}] ${eventName} 이벤트 ${success ? '전송됨' : '실패'}\n\n파라미터:\n${JSON.stringify(params, null, 2)}`);
10
- };
11
-
12
- // 장바구니 추가 이벤트
13
- const handleAddToCart = () => {
14
- const params = {
15
- item_id: `prod_${Math.floor(Math.random() * 9999) + 1000}`,
16
- quantity: Math.floor(Math.random() * 3) + 1,
17
- cart_value: Math.floor(Math.random() * 200000) + 50000,
18
- category: 'home',
19
- brand: 'IKEA',
20
- source: 'product_page'
21
- };
22
-
23
- try {
24
- track('add_to_cart', params);
25
- showResult('add_to_cart', params);
26
- } catch (error) {
27
- showResult('add_to_cart', params, false);
28
- console.error('AddToCart event failed:', error);
29
- }
30
- };
31
-
32
- // 앱 설치 이벤트
33
- const handleAppInstall = () => {
34
- const params = {
35
- install_source: 'google_play',
36
- campaign: 'summer_2024',
37
- days_since_click: Math.floor(Math.random() * 7),
38
- organic: false,
39
- referrer: 'google_ads'
40
- };
41
-
42
- try {
43
- track('first_open', params);
44
- showResult('first_open', params);
45
- } catch (error) {
46
- showResult('first_open', params, false);
47
- console.error('FirstOpen event failed:', error);
48
- }
49
- };
50
-
51
- // 검색 이벤트
52
- const handleSearch = () => {
53
- const searchTerms = ['iPhone', 'Samsung Galaxy', 'MacBook', 'AirPods', 'iPad'];
54
- const params = {
55
- search_term: searchTerms[Math.floor(Math.random() * searchTerms.length)],
56
- results_count: Math.floor(Math.random() * 50) + 10,
57
- category: 'electronics',
58
- filters_applied: Math.random() > 0.5,
59
- sort_by: ['price', 'popularity', 'rating', 'newest'][Math.floor(Math.random() * 4)]
60
- };
61
-
62
- try {
63
- track('search', params);
64
- showResult('search', params);
65
- } catch (error) {
66
- showResult('search', params, false);
67
- console.error('Search event failed:', error);
68
- }
69
- };
70
-
71
- // 페이지 로드 시 자동 페이지뷰
72
- useEffect(() => {
73
- const timer = setTimeout(() => {
74
- const params = {
75
- page: '/',
76
- title: 'AdStage Next.js Example',
77
- referrer: typeof window !== 'undefined' ? document.referrer || 'direct' : 'ssr',
78
- utm_source: 'direct'
79
- };
80
- pageView(params);
81
- showResult('page_view', params);
82
- }, 1000);
83
-
84
- return () => clearTimeout(timer);
85
- }, []);
86
-
87
- return (
88
- <div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
89
- <h1>AdStage SDK - Next.js 이벤트 추적 예시</h1>
90
-
91
- <div>
92
- <button
93
- onClick={handleAddToCart}
94
- style={buttonStyle}
95
- >
96
- 장바구니 추가 이벤트
97
- </button>
98
-
99
- <button
100
- onClick={handleAppInstall}
101
- style={buttonStyle}
102
- >
103
- 앱 설치 이벤트
104
- </button>
105
-
106
- <button
107
- onClick={handleSearch}
108
- style={buttonStyle}
109
- >
110
- 검색 이벤트
111
- </button>
112
- </div>
113
-
114
- <div style={resultStyle}>
115
- {result}
116
- </div>
117
- </div>
118
- );
119
- }
120
-
121
- const buttonStyle = {
122
- padding: '12px 24px',
123
- margin: '10px',
124
- fontSize: '16px',
125
- border: '1px solid #ccc',
126
- borderRadius: '4px',
127
- backgroundColor: '#f8f9fa',
128
- cursor: 'pointer'
129
- };
130
-
131
- const resultStyle = {
132
- marginTop: '20px',
133
- padding: '15px',
134
- border: '1px solid #ddd',
135
- borderRadius: '4px',
136
- backgroundColor: '#f8f9fa',
137
- whiteSpace: 'pre-wrap',
138
- fontFamily: 'monospace'
139
- };
File without changes
@@ -1,57 +0,0 @@
1
- # AdStage SDK - React 이벤트 추적 예시
2
-
3
- ## 설치 및 실행
4
-
5
- ```bash
6
- cd /Users/gunny/Documents/workspace/adstage/sdk/src/example/events/react
7
- npm install # @adstage/web-sdk@^2.6.1 설치됨
8
- npm start
9
- ```
10
-
11
- ## 기능
12
-
13
- - 구매 이벤트 전송
14
- - 회원가입 이벤트 전송
15
- - 상품조회 이벤트 전송
16
- - 자동 페이지뷰 추적
17
-
18
- ## 이벤트 파라미터 예시
19
-
20
- ### 구매 이벤트 (purchase)
21
- ```javascript
22
- {
23
- transaction_id: "tx_1725123456789",
24
- value: 158000,
25
- currency: "KRW",
26
- payment_method: "card",
27
- items: 3,
28
- category: "fashion",
29
- brand: "Nike"
30
- }
31
- ```
32
-
33
- ### 회원가입 이벤트 (signup_complete)
34
- ```javascript
35
- {
36
- user_id: "user_1725123456789",
37
- signup_method: "google",
38
- email_verified: false,
39
- time_to_complete: 85,
40
- form_version: "v3",
41
- utm_source: "facebook_ads",
42
- utm_medium: "social"
43
- }
44
- ```
45
-
46
- ### 상품조회 이벤트 (view_item)
47
- ```javascript
48
- {
49
- item_id: "prod_1234",
50
- category: "electronics",
51
- brand: "Apple",
52
- price: 1290000,
53
- currency: "KRW",
54
- referrer: "search",
55
- search_term: "iPhone 15 Pro"
56
- }
57
- ```
@@ -1,27 +0,0 @@
1
- {
2
- "name": "adstage-events-react-example",
3
- "version": "1.0.0",
4
- "private": true,
5
- "dependencies": {
6
- "@adstage/web-sdk": "^2.6.1",
7
- "react": "^18.2.0",
8
- "react-dom": "^18.2.0",
9
- "react-scripts": "5.0.1"
10
- },
11
- "scripts": {
12
- "start": "react-scripts start",
13
- "build": "react-scripts build"
14
- },
15
- "browserslist": {
16
- "production": [
17
- ">0.2%",
18
- "not dead",
19
- "not op_mini all"
20
- ],
21
- "development": [
22
- "last 1 chrome version",
23
- "last 1 firefox version",
24
- "last 1 safari version"
25
- ]
26
- }
27
- }
@@ -1,11 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>AdStage Events React Example</title>
7
- </head>
8
- <body>
9
- <div id="root"></div>
10
- </body>
11
- </html>
@@ -1,162 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { AdStageProvider, useAdStageInstance, track, pageView } from '@adstage/web-sdk';
3
-
4
- // 이벤트 컴포넌트
5
- function EventButtons() {
6
- const adstage = useAdStageInstance();
7
- const [result, setResult] = useState('이벤트 결과가 여기에 표시됩니다.');
8
-
9
- const showResult = (eventName, params, success = true) => {
10
- const timestamp = new Date().toLocaleString();
11
- setResult(`[${timestamp}] ${eventName} 이벤트 ${success ? '전송됨' : '실패'}\n\n파라미터:\n${JSON.stringify(params, null, 2)}`);
12
- };
13
-
14
- // 구매 이벤트
15
- const handlePurchase = () => {
16
- const params = {
17
- transaction_id: `tx_${Date.now()}`,
18
- value: 158000,
19
- currency: 'KRW',
20
- payment_method: 'card',
21
- items: 3,
22
- category: 'fashion',
23
- brand: 'Nike'
24
- };
25
-
26
- try {
27
- track('purchase', params);
28
- showResult('purchase', params);
29
- } catch (error) {
30
- showResult('purchase', params, false);
31
- console.error('Purchase event failed:', error);
32
- }
33
- };
34
-
35
- // 회원가입 이벤트
36
- const handleSignup = () => {
37
- const params = {
38
- user_id: `user_${Date.now()}`,
39
- signup_method: 'google',
40
- email_verified: false,
41
- time_to_complete: 85,
42
- form_version: 'v3',
43
- utm_source: 'facebook_ads',
44
- utm_medium: 'social'
45
- };
46
-
47
- try {
48
- track('signup_complete', params);
49
- showResult('signup_complete', params);
50
- } catch (error) {
51
- showResult('signup_complete', params, false);
52
- console.error('Signup event failed:', error);
53
- }
54
- };
55
-
56
- // 아이템 조회 이벤트
57
- const handleViewItem = () => {
58
- const params = {
59
- item_id: `prod_${Math.floor(Math.random() * 9999) + 1000}`,
60
- category: 'electronics',
61
- brand: 'Apple',
62
- price: 1290000,
63
- currency: 'KRW',
64
- referrer: 'search',
65
- search_term: 'iPhone 15 Pro'
66
- };
67
-
68
- try {
69
- track('view_item', params);
70
- showResult('view_item', params);
71
- } catch (error) {
72
- showResult('view_item', params, false);
73
- console.error('ViewItem event failed:', error);
74
- }
75
- };
76
-
77
- // 페이지 로드 시 자동 페이지뷰
78
- useEffect(() => {
79
- const timer = setTimeout(() => {
80
- const params = {
81
- page: '/',
82
- title: 'AdStage React Example',
83
- referrer: 'direct',
84
- utm_source: 'direct'
85
- };
86
- pageView(params);
87
- showResult('page_view', params);
88
- }, 1000);
89
-
90
- return () => clearTimeout(timer);
91
- }, []);
92
-
93
- return (
94
- <div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
95
- <h1>AdStage SDK - React 이벤트 추적 예시</h1>
96
-
97
- <div>
98
- <button
99
- onClick={handlePurchase}
100
- style={buttonStyle}
101
- >
102
- 구매 이벤트 전송
103
- </button>
104
-
105
- <button
106
- onClick={handleSignup}
107
- style={buttonStyle}
108
- >
109
- 회원가입 이벤트 전송
110
- </button>
111
-
112
- <button
113
- onClick={handleViewItem}
114
- style={buttonStyle}
115
- >
116
- 상품조회 이벤트 전송
117
- </button>
118
- </div>
119
-
120
- <div style={resultStyle}>
121
- {result}
122
- </div>
123
- </div>
124
- );
125
- }
126
-
127
- const buttonStyle = {
128
- padding: '12px 24px',
129
- margin: '10px',
130
- fontSize: '16px',
131
- border: '1px solid #ccc',
132
- borderRadius: '4px',
133
- backgroundColor: '#f8f9fa',
134
- cursor: 'pointer'
135
- };
136
-
137
- const resultStyle = {
138
- marginTop: '20px',
139
- padding: '15px',
140
- border: '1px solid #ddd',
141
- borderRadius: '4px',
142
- backgroundColor: '#f8f9fa',
143
- whiteSpace: 'pre-wrap',
144
- fontFamily: 'monospace'
145
- };
146
-
147
- // 메인 앱 컴포넌트
148
- function App() {
149
- return (
150
- <AdStageProvider
151
- config={{
152
- apiKey: '7dfddcfda637fbb73225bac3731688b80b90675942fe9f2057a88e2379aba2a4',
153
- debug: true,
154
- appVersion: '2.1.0'
155
- }}
156
- >
157
- <EventButtons />
158
- </AdStageProvider>
159
- );
160
- }
161
-
162
- export default App;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import ReactDOM from 'react-dom/client';
3
- import App from './App';
4
-
5
- const root = ReactDOM.createRoot(document.getElementById('root'));
6
- root.render(<App />);