@ai-ad-network/frontend-sdk 1.0.7 → 1.0.8
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/README.md +242 -282
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/docs/QUICK_START.md +232 -384
- package/package.json +1 -1
- package/INTEGRATION_CHECKLIST.md +0 -175
- package/docs/CLIENT_INFO_COLLECTION.md +0 -880
- package/docs/COMPONENT_DOCUMENTATION.md +0 -671
- package/docs/README.md +0 -348
package/README.md
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
> 🚀 **Zero-config** SDK for AI-powered native ads with automatic client info collection
|
|
4
4
|
>
|
|
5
|
-
>
|
|
5
|
+
> **📦 Dual Support**: React SDK + Universal Framework-Agnostic SDK
|
|
6
|
+
>
|
|
7
|
+
> **Version**: 1.0.7
|
|
8
|
+
|
|
9
|
+
---
|
|
6
10
|
|
|
7
|
-
## 🎯 Choose Your
|
|
11
|
+
## 🎯 Choose Your SDK
|
|
8
12
|
|
|
9
|
-
### React Projects
|
|
13
|
+
### React Projects
|
|
10
14
|
```bash
|
|
11
15
|
npm install @ai-ad-network/frontend-sdk
|
|
12
16
|
```
|
|
13
17
|
```tsx
|
|
14
|
-
import { AdProvider, useAiAds } from '@ai-ad-network/frontend-sdk';
|
|
18
|
+
import { AdProvider, useAiAds, ActionCardAd } from '@ai-ad-network/frontend-sdk';
|
|
15
19
|
```
|
|
16
20
|
|
|
17
|
-
###
|
|
21
|
+
### Other Frameworks (Vue, Angular, Vanilla JS, etc.)
|
|
18
22
|
```bash
|
|
19
23
|
npm install @ai-ad-network/frontend-sdk
|
|
20
24
|
```
|
|
@@ -22,119 +26,154 @@ npm install @ai-ad-network/frontend-sdk
|
|
|
22
26
|
import { AdManager, DOMRenderer } from '@ai-ad-network/frontend-sdk/universal';
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
**Universal SDK Works With
|
|
26
|
-
- ✅ Vanilla JavaScript
|
|
27
|
-
- ✅ Vue 2 & 3
|
|
28
|
-
- ✅ Angular
|
|
29
|
-
- ✅ Svelte
|
|
30
|
-
- ✅ SolidJS
|
|
31
|
-
- ✅ Any other framework
|
|
29
|
+
**Universal SDK Works With**: Vue 2/3, Angular, Svelte, SolidJS, Vanilla JS, or any other framework
|
|
32
30
|
|
|
33
|
-
|
|
31
|
+
---
|
|
34
32
|
|
|
35
33
|
## ✨ Key Features
|
|
36
34
|
|
|
37
35
|
- 🎯 **Intent-based Ad Delivery** - Ads matched to user intent
|
|
38
|
-
- 🎨 **Native Ad Formats** - Action Cards, Suffix, Follow-up, Sponsored Sources
|
|
36
|
+
- 🎨 **Native Ad Formats** - Action Cards, Suffix, Follow-up, Sponsored Sources, Lead Gen
|
|
39
37
|
- 📊 **Built-in Analytics** - Impression and click tracking
|
|
40
38
|
- ⚡ **Optimized Performance** - SWR caching, Intersection Observer
|
|
41
39
|
- 🎭 **Headless Design** - Full customization with CSS variables
|
|
42
40
|
- 📱 **Responsive** - Works on all screen sizes
|
|
43
|
-
- 🔐 **Built-in Authentication** - API key support
|
|
44
|
-
- 🌐 **OpenRTB Compliant** -
|
|
41
|
+
- 🔐 **Built-in Authentication** - API key support
|
|
42
|
+
- 🌐 **OpenRTB Compliant** - **Zero-config** auto-collection of device/app/user/geo info
|
|
43
|
+
- 🌐 **Framework-Agnostic** - Works with ANY frontend framework
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 🚀 Quick Start
|
|
45
48
|
|
|
46
|
-
|
|
49
|
+
### React (3 Steps)
|
|
47
50
|
|
|
48
|
-
**
|
|
51
|
+
**Step 1: Install**
|
|
52
|
+
```bash
|
|
53
|
+
npm install @ai-ad-network/frontend-sdk
|
|
54
|
+
```
|
|
49
55
|
|
|
56
|
+
**Step 2: Wrap App**
|
|
50
57
|
```tsx
|
|
51
|
-
import {
|
|
58
|
+
import { AdProvider } from '@ai-ad-network/frontend-sdk';
|
|
52
59
|
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
apiBaseUrl: '/api/v1',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
function App() {
|
|
61
|
+
return (
|
|
62
|
+
<AdProvider config={{ apiBaseUrl: '/api/v1', apiKey: 'ak_your_key' }}>
|
|
63
|
+
<ChatApp />
|
|
64
|
+
</AdProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
**Step 3: Use Ads**
|
|
70
|
+
```tsx
|
|
71
|
+
import { useAiAds, ActionCardAd } from '@ai-ad-network/frontend-sdk';
|
|
72
|
+
|
|
73
|
+
function ChatApp() {
|
|
74
|
+
const { ads } = useAiAds(query, response, isFinished, {
|
|
75
|
+
formats: ['action_card', 'suffix'],
|
|
64
76
|
});
|
|
65
77
|
|
|
66
|
-
|
|
67
|
-
// {
|
|
68
|
-
// conversationContext: {...},
|
|
69
|
-
// userContext: {...},
|
|
70
|
-
// clientInfo: { // ← Zero-config! Auto-collected!
|
|
71
|
-
// device: { os, model, screen... },
|
|
72
|
-
// app: { bundle, name, version... },
|
|
73
|
-
// user: { id, consent... },
|
|
74
|
-
// geo: { country, language... }
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
78
|
+
return ads.map(ad => <ActionCardAd key={ad.id} ad={ad} />);
|
|
77
79
|
}
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
- 🖥️ **Device Info**: OS, model, screen size, language
|
|
82
|
-
- 📱 **App Info**: Bundle ID, name, version (inferred from page)
|
|
83
|
-
- 👤 **User Info**: Unique ID (auto-generated & persistent)
|
|
84
|
-
- 🌍 **Geo Info**: Country, language (from timezone/locale)
|
|
82
|
+
### Universal / Other Frameworks (3 Steps)
|
|
85
83
|
|
|
86
|
-
|
|
84
|
+
**Step 1: Install**
|
|
85
|
+
```bash
|
|
86
|
+
npm install @ai-ad-network/frontend-sdk
|
|
87
|
+
```
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
**Step 2: Import**
|
|
90
|
+
```javascript
|
|
91
|
+
import { AdManager, DOMRenderer } from '@ai-ad-network/frontend-sdk/universal';
|
|
92
|
+
// or CDN: <script src="universal.iife.js"></script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Step 3: Use**
|
|
96
|
+
```javascript
|
|
97
|
+
const adManager = new AdManager({
|
|
98
|
+
apiBaseUrl: '/api/v1',
|
|
99
|
+
slots: [{ slotId: 'banner', position: 'top', adTypes: ['action-card'] }]
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const result = await adManager.requestAds({
|
|
103
|
+
conversationContext: { topic: 'tech', messages: [] }
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
DOMRenderer.renderActionCard(result.slots[0].ad, container);
|
|
107
|
+
```
|
|
89
108
|
|
|
90
|
-
|
|
109
|
+
---
|
|
91
110
|
|
|
92
|
-
|
|
111
|
+
## 🆕 ClientInfo API
|
|
93
112
|
|
|
94
|
-
|
|
113
|
+
**Direct access to client information for analytics, personalization, A/B testing, and more!**
|
|
95
114
|
|
|
96
115
|
```typescript
|
|
97
116
|
// React SDK
|
|
98
117
|
import { getUserId, getDeviceInfo, getClientInfo } from '@ai-ad-network/frontend-sdk';
|
|
99
118
|
|
|
100
|
-
// Universal SDK
|
|
119
|
+
// Universal SDK
|
|
101
120
|
import { getUserId, getDeviceInfo, getClientInfo } from '@ai-ad-network/frontend-sdk/universal';
|
|
102
121
|
|
|
103
|
-
//
|
|
104
|
-
const userId = getUserId();
|
|
105
|
-
analytics.identify(userId);
|
|
106
|
-
|
|
107
|
-
// Get device info for conditional features
|
|
108
|
-
const device = getDeviceInfo();
|
|
109
|
-
if (device.devicetype === 1) {
|
|
110
|
-
// Mobile - enable mobile optimizations
|
|
111
|
-
} else {
|
|
112
|
-
// Desktop - enable desktop features
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Get complete info for personalization
|
|
116
|
-
const info = getClientInfo();
|
|
117
|
-
if (info.geo?.country === 'CN') {
|
|
118
|
-
loadChinesePaymentMethods();
|
|
119
|
-
}
|
|
122
|
+
// CDN
|
|
123
|
+
const userId = window.AiAdNetwork.getUserId();
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
**Available Functions:**
|
|
123
|
-
- `getClientInfo()` -
|
|
124
|
-
- `getUserId()` -
|
|
125
|
-
- `getDeviceInfo()` -
|
|
126
|
-
- `getUserInfo()` -
|
|
127
|
-
- `getAppInfo()` -
|
|
128
|
-
- `getGeoInfo()` -
|
|
129
|
-
- `getClientInfoJSON()` -
|
|
130
|
-
- `getClientInfoSummary()` -
|
|
127
|
+
- `getClientInfo()` - Complete client information
|
|
128
|
+
- `getUserId()` - Persistent user ID
|
|
129
|
+
- `getDeviceInfo()` - Device info only
|
|
130
|
+
- `getUserInfo()` - User info only
|
|
131
|
+
- `getAppInfo()` - App info only
|
|
132
|
+
- `getGeoInfo()` - Geo info only
|
|
133
|
+
- `getClientInfoJSON()` - As JSON string
|
|
134
|
+
- `getClientInfoSummary()` - Human-readable summary
|
|
131
135
|
- `clearClientInfoCache()` - Force re-collection
|
|
132
136
|
|
|
133
|
-
|
|
137
|
+
**Use Cases:**
|
|
138
|
+
- 📊 **Analytics**: `analytics.identify(getUserId())`
|
|
139
|
+
- 🌍 **Localization**: `if (getGeoInfo()?.country === 'CN') { ... }`
|
|
140
|
+
- 🧪 **A/B Testing**: `const variant = getUserId() % 2 === 0 ? 'A' : 'B'`
|
|
141
|
+
- 📱 **Conditional**: `if (getDeviceInfo().devicetype === 1) { /* mobile */ }`
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 🔑 Zero-Config ClientInfo Collection
|
|
146
|
+
|
|
147
|
+
**No manual setup required!** The SDK automatically collects and injects:
|
|
148
|
+
|
|
149
|
+
- 🖥️ **Device Info**: OS, model, screen size, language
|
|
150
|
+
- 📱 **App Info**: Bundle ID, name, version (inferred from page)
|
|
151
|
+
- 👤 **User Info**: Unique persistent ID (auto-generated)
|
|
152
|
+
- 🌍 **Geo Info**: Country, language (from timezone/locale)
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// ClientInfo is AUTOMATICALLY collected and injected!
|
|
156
|
+
await requestAds({
|
|
157
|
+
conversationContext: { query, response },
|
|
158
|
+
userContext: { sessionId },
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Request payload includes:
|
|
162
|
+
// {
|
|
163
|
+
// conversationContext: {...},
|
|
164
|
+
// userContext: {...},
|
|
165
|
+
// clientInfo: { // ← Auto-collected!
|
|
166
|
+
// device: { os, model, screen... },
|
|
167
|
+
// app: { bundle, name, version... },
|
|
168
|
+
// user: { id, consent... },
|
|
169
|
+
// geo: { country, language... }
|
|
170
|
+
// }
|
|
171
|
+
// }
|
|
172
|
+
```
|
|
134
173
|
|
|
135
|
-
|
|
174
|
+
---
|
|
136
175
|
|
|
137
|
-
## Installation
|
|
176
|
+
## 📦 Installation
|
|
138
177
|
|
|
139
178
|
```bash
|
|
140
179
|
npm install @ai-ad-network/frontend-sdk
|
|
@@ -144,251 +183,172 @@ yarn add @ai-ad-network/frontend-sdk
|
|
|
144
183
|
pnpm add @ai-ad-network/frontend-sdk
|
|
145
184
|
```
|
|
146
185
|
|
|
147
|
-
|
|
186
|
+
**Build Outputs:**
|
|
187
|
+
- React SDK: `dist/index.js`, `dist/index.esm.js`
|
|
188
|
+
- Universal SDK: `dist/universal/universal.*.js` (ES, CJS, UMD, IIFE)
|
|
148
189
|
|
|
149
|
-
|
|
150
|
-
import { AdProvider, useAiAds, ActionCardAd } from '@ai-ad-network/frontend-sdk';
|
|
151
|
-
|
|
152
|
-
function App() {
|
|
153
|
-
return (
|
|
154
|
-
<AdProvider
|
|
155
|
-
config={{
|
|
156
|
-
apiBaseUrl: 'https://your-ad-network.com/api/v1',
|
|
157
|
-
apiKey: 'ak_your_tenant_your_key', // Get from admin
|
|
158
|
-
debug: process.env.NODE_ENV === 'development',
|
|
159
|
-
}}
|
|
160
|
-
>
|
|
161
|
-
<ChatApp />
|
|
162
|
-
</AdProvider>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function ChatApp() {
|
|
167
|
-
const [query, setQuery] = useState('');
|
|
168
|
-
const [response, setResponse] = useState('');
|
|
169
|
-
const [isFinished, setIsFinished] = useState(false);
|
|
190
|
+
---
|
|
170
191
|
|
|
171
|
-
|
|
172
|
-
formats: ['action_card', 'suffix'],
|
|
173
|
-
placement: 'post_response',
|
|
174
|
-
});
|
|
192
|
+
## 📚 Documentation
|
|
175
193
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
{/* Your chat UI */}
|
|
179
|
-
{ads.map(ad => (
|
|
180
|
-
<ActionCardAd key={ad.id} ad={ad} />
|
|
181
|
-
))}
|
|
182
|
-
</div>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
```
|
|
194
|
+
- 📖 **[Quick Start Guide](./docs/QUICK_START.md)** - Get started in 3 minutes
|
|
195
|
+
- 📖 **[Universal SDK Guide](./docs/UNIVERSAL_SDK_GUIDE.md)** - Framework-agnostic SDK docs
|
|
186
196
|
|
|
187
|
-
|
|
197
|
+
**Universal SDK Guide includes:**
|
|
198
|
+
- AdManager API reference
|
|
199
|
+
- DOMRenderer and HTMLRenderer usage
|
|
200
|
+
- Web Components examples
|
|
201
|
+
- Vue/Angular/Vanilla JS integration
|
|
202
|
+
- ClientInfo API reference
|
|
203
|
+
- CDN usage
|
|
188
204
|
|
|
189
|
-
|
|
205
|
+
---
|
|
190
206
|
|
|
191
|
-
|
|
192
|
-
<AdProvider
|
|
193
|
-
config={{
|
|
194
|
-
// API Configuration
|
|
195
|
-
apiBaseUrl?: string; // Default: '/api/v1'
|
|
196
|
-
apiKey?: string; // Your API key (format: ak_tenant_key)
|
|
197
|
-
|
|
198
|
-
// Ad Behavior
|
|
199
|
-
defaultFormats?: string[]; // Default: ['action_card', 'suffix']
|
|
200
|
-
defaultPlacement?: string; // Default: 'post_response'
|
|
201
|
-
enabled?: boolean; // Default: true
|
|
202
|
-
|
|
203
|
-
// Debugging
|
|
204
|
-
debug?: boolean; // Default: false
|
|
205
|
-
headers?: Record<string, string>;
|
|
206
|
-
|
|
207
|
-
// Performance
|
|
208
|
-
timeout?: number; // Default: 5000
|
|
209
|
-
maxRetries?: number; // Default: 2
|
|
210
|
-
|
|
211
|
-
// Tracking
|
|
212
|
-
userId?: string;
|
|
213
|
-
}}
|
|
214
|
-
>
|
|
215
|
-
{children}
|
|
216
|
-
</AdProvider>
|
|
217
|
-
```
|
|
207
|
+
## 🎨 Available Ad Formats
|
|
218
208
|
|
|
219
|
-
|
|
209
|
+
### React Components
|
|
210
|
+
- **ActionCardAd** - Product cards (horizontal/vertical/compact)
|
|
211
|
+
- **SuffixAd** - Inline message enhancements (block/inline/minimal)
|
|
212
|
+
- **FollowUpAd** - Follow-up questions (bubble/pill/underline)
|
|
213
|
+
- **SponsoredSource** - Sponsored content sources (card/minimal)
|
|
214
|
+
- **LeadGenAd** - Lead generation forms
|
|
215
|
+
- **StaticAd** - Traditional banner ads
|
|
220
216
|
|
|
221
|
-
###
|
|
217
|
+
### Universal Renderers
|
|
218
|
+
- `DOMRenderer.renderActionCard()`
|
|
219
|
+
- `DOMRenderer.renderSuffixAd()`
|
|
220
|
+
- `DOMRenderer.renderSponsoredSource()`
|
|
221
|
+
- `DOMRenderer.renderLeadGenAd()`
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
### Web Components (Framework-Agnostic)
|
|
224
|
+
- `<ad-action-card>`
|
|
225
|
+
- `<ad-suffix>`
|
|
226
|
+
- `<ad-sponsored-source>`
|
|
227
|
+
- `<ad-lead-gen>`
|
|
224
228
|
|
|
225
|
-
|
|
226
|
-
<ActionCardAd
|
|
227
|
-
ad={ad}
|
|
228
|
-
variant="horizontal" // 'horizontal' | 'vertical' | 'compact'
|
|
229
|
-
onClick={() => console.log('Clicked!')}
|
|
230
|
-
/>
|
|
231
|
-
```
|
|
229
|
+
---
|
|
232
230
|
|
|
233
|
-
|
|
231
|
+
## ⚡ Performance & Optimization
|
|
234
232
|
|
|
235
|
-
|
|
233
|
+
- ✅ **SWR Caching** - Smart request deduplication
|
|
234
|
+
- ✅ **Intersection Observer** - Lazy impression tracking
|
|
235
|
+
- ✅ **Event Batching** - Optimized re-renders
|
|
236
|
+
- ✅ **Code Splitting** - Tree-shakeable exports
|
|
237
|
+
- ✅ **TypeScript** - Full type definitions
|
|
238
|
+
- ✅ **Zero Runtime Overhead** - Minimal bundle size
|
|
236
239
|
|
|
237
|
-
|
|
238
|
-
<SuffixAd
|
|
239
|
-
ad={ad}
|
|
240
|
-
aiContext={aiResponse}
|
|
241
|
-
variant="block" // 'block' | 'inline' | 'minimal'
|
|
242
|
-
/>
|
|
243
|
-
```
|
|
240
|
+
---
|
|
244
241
|
|
|
245
|
-
|
|
242
|
+
## 🎨 Styling & Customization
|
|
246
243
|
|
|
247
|
-
|
|
244
|
+
### CSS Variables
|
|
248
245
|
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
ad
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
246
|
+
```css
|
|
247
|
+
:root {
|
|
248
|
+
/* Card styling */
|
|
249
|
+
--ai-ad-card-bg: #ffffff;
|
|
250
|
+
--ai-ad-card-border: #e5e7eb;
|
|
251
|
+
--ai-ad-card-border-radius: 12px;
|
|
252
|
+
--ai-ad-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
253
|
+
|
|
254
|
+
/* Typography */
|
|
255
|
+
--ai-ad-title-color: #111827;
|
|
256
|
+
--ai-ad-body-color: #6b7280;
|
|
257
|
+
--ai-ad-cta-bg: #10b981;
|
|
258
|
+
--ai-ad-cta-color: #ffffff;
|
|
259
|
+
|
|
260
|
+
/* Spacing */
|
|
261
|
+
--ai-ad-padding: 16px;
|
|
262
|
+
--ai-ad-gap: 12px;
|
|
263
|
+
}
|
|
262
264
|
```
|
|
263
265
|
|
|
264
|
-
|
|
266
|
+
---
|
|
265
267
|
|
|
266
|
-
|
|
268
|
+
## 📊 Examples
|
|
267
269
|
|
|
268
|
-
|
|
269
|
-
<SponsoredSource
|
|
270
|
-
ad={ad}
|
|
271
|
-
variant="card" // 'card' | 'list-item' | 'minimal'
|
|
272
|
-
/>
|
|
273
|
-
|
|
274
|
-
// Or mix with regular sources
|
|
275
|
-
<SourceListWithAds
|
|
276
|
-
sources={[{ title: 'Wikipedia', url: '...' }]}
|
|
277
|
-
ad={ad}
|
|
278
|
-
adPosition={1}
|
|
279
|
-
/>
|
|
280
|
-
```
|
|
270
|
+
### Examples Directory
|
|
281
271
|
|
|
282
|
-
|
|
272
|
+
- `examples/vanilla-js.html` - Complete Vanilla JS demo
|
|
273
|
+
- `examples/vue-example.js` - Vue 3 integration
|
|
274
|
+
- `examples/client-info-usage.ts` - ClientInfo API examples
|
|
275
|
+
- `examples/client-info-demo.html` - Interactive ClientInfo demo
|
|
283
276
|
|
|
284
|
-
|
|
277
|
+
---
|
|
285
278
|
|
|
286
|
-
|
|
279
|
+
## ⚠️ Troubleshooting
|
|
287
280
|
|
|
288
|
-
|
|
289
|
-
const {
|
|
290
|
-
ads, // Array of KoahAd objects
|
|
291
|
-
intent, // Intent analysis result
|
|
292
|
-
routing, // Routing information
|
|
293
|
-
isLoading, // Loading state
|
|
294
|
-
error, // Error object
|
|
295
|
-
refetch, // Manual refetch function
|
|
296
|
-
} = useAiAds(
|
|
297
|
-
userQuery, // User's question
|
|
298
|
-
aiResponse, // AI's response
|
|
299
|
-
isStreamFinished, // Boolean
|
|
300
|
-
{
|
|
301
|
-
enabled: true,
|
|
302
|
-
formats: ['action_card', 'suffix'],
|
|
303
|
-
placement: 'post_response',
|
|
304
|
-
apiBaseUrl: '/api/v1',
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
```
|
|
281
|
+
### Ads not showing?
|
|
308
282
|
|
|
309
|
-
|
|
283
|
+
1. ✅ Console shows SDK v1.0.7+
|
|
284
|
+
2. ✅ `apiBaseUrl` is correct
|
|
285
|
+
3. ✅ `apiKey` is valid
|
|
286
|
+
4. ✅ Network requests succeed (DevTools → Network)
|
|
310
287
|
|
|
311
|
-
|
|
288
|
+
### Console shows old version?
|
|
312
289
|
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
handleClick, // Click handler
|
|
317
|
-
hasImpressed, // Boolean
|
|
318
|
-
isIntersecting, // Boolean
|
|
319
|
-
} = useAdTracking(ad, {
|
|
320
|
-
intersectionThreshold: 0.5,
|
|
321
|
-
minViewTimeMs: 1000,
|
|
322
|
-
onClick: () => console.log('Clicked'),
|
|
323
|
-
onImpression: () => console.log('Viewed'),
|
|
324
|
-
});
|
|
290
|
+
```bash
|
|
291
|
+
rm -rf node_modules package-lock.json
|
|
292
|
+
npm install @ai-ad-network/frontend-sdk@latest
|
|
325
293
|
```
|
|
326
294
|
|
|
327
|
-
|
|
295
|
+
### ClientInfo not in request?
|
|
328
296
|
|
|
329
|
-
|
|
297
|
+
- **React**: Check if using `useAdSlots` or `useAiAds`
|
|
298
|
+
- **Universal**: Check if using `AdManager`
|
|
299
|
+
- Console should show `[SDK] ClientInfo collection: ENABLED`
|
|
330
300
|
|
|
331
|
-
|
|
301
|
+
---
|
|
332
302
|
|
|
333
|
-
|
|
334
|
-
:root {
|
|
335
|
-
--ad-primary: #3b82f6;
|
|
336
|
-
--ad-secondary: #8b5cf6;
|
|
337
|
-
--ad-background: #f8fafc;
|
|
338
|
-
--ad-border: #e2e8f0;
|
|
339
|
-
--ad-text: #1e293b;
|
|
340
|
-
--ad-sponsored: #94a3b8;
|
|
341
|
-
}
|
|
342
|
-
```
|
|
303
|
+
## ✅ Integration Checklist
|
|
343
304
|
|
|
344
|
-
|
|
305
|
+
- [ ] SDK installed (`npm install @ai-ad-network/frontend-sdk`)
|
|
306
|
+
- [ ] Console shows version v1.0.7+
|
|
307
|
+
- [ ] React: App wrapped with `AdProvider`
|
|
308
|
+
- [ ] Universal: `AdManager` initialized
|
|
309
|
+
- [ ] Console shows ClientInfo collected
|
|
310
|
+
- [ ] Network requests include `clientInfo` field
|
|
311
|
+
- [ ] Ads are rendering
|
|
312
|
+
- [ ] Analytics events firing
|
|
345
313
|
|
|
346
|
-
|
|
314
|
+
**Done? 🎉 Successfully integrated!**
|
|
347
315
|
|
|
348
|
-
|
|
349
|
-
import { cn } from '@ai-ad-network/frontend-sdk';
|
|
316
|
+
---
|
|
350
317
|
|
|
351
|
-
|
|
352
|
-
'base-class',
|
|
353
|
-
isActive && 'active-class',
|
|
354
|
-
'more-classes'
|
|
355
|
-
)} />
|
|
356
|
-
```
|
|
318
|
+
## 🆘 Support
|
|
357
319
|
|
|
358
|
-
|
|
320
|
+
- 📧 Email: support@ai-ad-network.com
|
|
321
|
+
- 📖 Docs: https://docs.ai-ad-network.com
|
|
322
|
+
- 🐛 Issues: https://github.com/ai-ad-network/frontend-sdk/issues
|
|
359
323
|
|
|
360
|
-
|
|
324
|
+
---
|
|
361
325
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
326
|
+
## 📦 Package Exports
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"exports": {
|
|
331
|
+
".": {
|
|
332
|
+
"import": "./dist/index.esm.js",
|
|
333
|
+
"require": "./dist/index.js",
|
|
334
|
+
"types": "./dist/index.d.ts"
|
|
335
|
+
},
|
|
336
|
+
"./universal": {
|
|
337
|
+
"import": "./dist/universal/universal.esm.js",
|
|
338
|
+
"require": "./dist/universal/universal.cjs.js",
|
|
339
|
+
"types": "./dist/universal/universal.d.ts"
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
370
343
|
```
|
|
371
344
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
For detailed Chatbox integration instructions, see [CHATBOX_INTEGRATION.md](./CHATBOX_INTEGRATION.md).
|
|
375
|
-
|
|
376
|
-
## Development
|
|
377
|
-
|
|
378
|
-
```bash
|
|
379
|
-
# Install dependencies
|
|
380
|
-
npm install
|
|
381
|
-
|
|
382
|
-
# Run Storybook
|
|
383
|
-
npm run storybook
|
|
345
|
+
---
|
|
384
346
|
|
|
385
|
-
|
|
386
|
-
npm run build
|
|
347
|
+
## 📄 License
|
|
387
348
|
|
|
388
|
-
|
|
389
|
-
cd demo-app && npm run dev
|
|
390
|
-
```
|
|
349
|
+
MIT
|
|
391
350
|
|
|
392
|
-
|
|
351
|
+
---
|
|
393
352
|
|
|
394
|
-
|
|
353
|
+
**SDK Version**: 1.0.7
|
|
354
|
+
**Last Updated**: 2026-01-26
|
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import React, { useState, useRef, useCallback, useEffect, createContext, useContext, useMemo, Component } from "react";
|
|
5
5
|
import useSWR from "swr";
|
|
6
|
-
const SDK_VERSION = "1.0.
|
|
6
|
+
const SDK_VERSION = "1.0.8";
|
|
7
7
|
var IntentType = /* @__PURE__ */ ((IntentType2) => {
|
|
8
8
|
IntentType2["SHOPPING"] = "shopping";
|
|
9
9
|
IntentType2["LEAD_GEN"] = "lead_gen";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useSWR = require("swr");
|
|
8
|
-
const SDK_VERSION = "1.0.
|
|
8
|
+
const SDK_VERSION = "1.0.8";
|
|
9
9
|
var IntentType = /* @__PURE__ */ ((IntentType2) => {
|
|
10
10
|
IntentType2["SHOPPING"] = "shopping";
|
|
11
11
|
IntentType2["LEAD_GEN"] = "lead_gen";
|