@thead-vantage/react 2.1.0 → 2.1.2
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 +429 -84
- package/package.json +71 -49
- package/src/app/api/ads/route.ts +174 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +26 -0
- package/src/app/layout.tsx +34 -0
- package/src/app/page.tsx +103 -0
- package/src/components/AdBanner.tsx +119 -0
- package/src/components/AdDisplay.tsx +98 -0
- package/src/index.ts +33 -0
- package/src/lib/ads.ts +275 -0
- package/src/lib/thead-vantage-config.ts +108 -0
- package/dist/components/AdBanner.d.ts +0 -12
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,84 +1,429 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
# TheAd Vantage React Library
|
|
2
|
+
|
|
3
|
+
This is a [Next.js](https://nextjs.org) project that integrates with TheAd Vantage platform for ad serving. The integration supports three distinct development modes to accommodate different development and production scenarios.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
First, run the development server:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run dev
|
|
11
|
+
# or
|
|
12
|
+
yarn dev
|
|
13
|
+
# or
|
|
14
|
+
pnpm dev
|
|
15
|
+
# or
|
|
16
|
+
bun dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## TheAd Vantage Integration - Three Development Modes
|
|
26
|
+
|
|
27
|
+
The TheAd Vantage integration supports three distinct modes of operation:
|
|
28
|
+
|
|
29
|
+
### 1. Production Mode (Default)
|
|
30
|
+
|
|
31
|
+
**Use Case**: Platform developers using the component in production or their own development environments.
|
|
32
|
+
|
|
33
|
+
**Behavior**:
|
|
34
|
+
- Connects to `https://thead-vantage.com/api/ads` by default
|
|
35
|
+
- Full tracking enabled (impressions and clicks are recorded)
|
|
36
|
+
- No configuration required
|
|
37
|
+
|
|
38
|
+
**Configuration**: None needed - this is the default behavior.
|
|
39
|
+
|
|
40
|
+
**Example Usage**:
|
|
41
|
+
```tsx
|
|
42
|
+
import { AdBanner } from '@/components/AdBanner';
|
|
43
|
+
|
|
44
|
+
export default function MyPage() {
|
|
45
|
+
return (
|
|
46
|
+
<AdBanner
|
|
47
|
+
platformId="10"
|
|
48
|
+
apiKey="your-api-key-here"
|
|
49
|
+
size="leaderboard"
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. Platform Developer Dev Mode
|
|
56
|
+
|
|
57
|
+
**Use Case**: Platform developers testing locally with their own platform instance.
|
|
58
|
+
|
|
59
|
+
**Behavior**:
|
|
60
|
+
- Connects to a custom API URL (your platform's API endpoint)
|
|
61
|
+
- Full tracking enabled (impressions and clicks are recorded)
|
|
62
|
+
- Allows testing with your own platform without affecting production
|
|
63
|
+
|
|
64
|
+
**Configuration**: Set the `NEXT_PUBLIC_THEAD_VANTAGE_API_URL` environment variable in `.env.local`:
|
|
65
|
+
|
|
66
|
+
```env
|
|
67
|
+
# .env.local
|
|
68
|
+
NEXT_PUBLIC_THEAD_VANTAGE_API_URL=https://your-platform.com/api/ads
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Example Usage**:
|
|
72
|
+
```tsx
|
|
73
|
+
// Option 1: Use environment variable (recommended)
|
|
74
|
+
<AdBanner
|
|
75
|
+
platformId="10"
|
|
76
|
+
apiKey="your-api-key"
|
|
77
|
+
size="leaderboard"
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
// Option 2: Override directly in component
|
|
81
|
+
<AdBanner
|
|
82
|
+
platformId="10"
|
|
83
|
+
apiKey="your-api-key"
|
|
84
|
+
size="leaderboard"
|
|
85
|
+
apiUrl="https://your-platform.com/api/ads"
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. TheAd Vantage Dev Mode
|
|
90
|
+
|
|
91
|
+
**Use Case**: TheAd Vantage developers testing the component with a local platform instance.
|
|
92
|
+
|
|
93
|
+
**Behavior**:
|
|
94
|
+
- Connects to `http://localhost:3001/api/ads`
|
|
95
|
+
- Tracking disabled (impressions and clicks are NOT recorded)
|
|
96
|
+
- Returns mock data if local platform is unavailable
|
|
97
|
+
- Shows dev mode indicators in the UI
|
|
98
|
+
|
|
99
|
+
**Configuration**: Set the `NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE` environment variable in `.env.local`:
|
|
100
|
+
|
|
101
|
+
```env
|
|
102
|
+
# .env.local
|
|
103
|
+
NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Example Usage**:
|
|
107
|
+
```tsx
|
|
108
|
+
// Automatically uses localhost:3001 when dev mode is enabled
|
|
109
|
+
<AdBanner
|
|
110
|
+
platformId="10"
|
|
111
|
+
apiKey="your-api-key"
|
|
112
|
+
size="leaderboard"
|
|
113
|
+
/>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Component API
|
|
119
|
+
|
|
120
|
+
### AdBanner Component
|
|
121
|
+
|
|
122
|
+
The main component for displaying ads from TheAd Vantage.
|
|
123
|
+
|
|
124
|
+
**Props**:
|
|
125
|
+
|
|
126
|
+
| Prop | Type | Required | Default | Description |
|
|
127
|
+
|------|------|----------|---------|-------------|
|
|
128
|
+
| `platformId` | `string` | Yes | - | Your platform ID from TheAd Vantage |
|
|
129
|
+
| `apiKey` | `string` | Yes | - | Your API key from TheAd Vantage |
|
|
130
|
+
| `size` | `'leaderboard' \| 'medium-rectangle' \| 'wide-skyscraper' \| 'banner'` | No | `'banner'` | Ad size specification |
|
|
131
|
+
| `apiUrl` | `string` | No | - | Override API endpoint URL (highest priority) |
|
|
132
|
+
| `userId` | `string \| null` | No | `null` | User ID for ad targeting |
|
|
133
|
+
| `userSegment` | `string \| null` | No | `null` | User segment for ad targeting |
|
|
134
|
+
| `className` | `string` | No | `''` | Additional CSS classes |
|
|
135
|
+
|
|
136
|
+
**Example**:
|
|
137
|
+
```tsx
|
|
138
|
+
import { AdBanner } from '@/components/AdBanner';
|
|
139
|
+
|
|
140
|
+
export default function ArticlePage() {
|
|
141
|
+
return (
|
|
142
|
+
<div>
|
|
143
|
+
<article>
|
|
144
|
+
<h1>My Article</h1>
|
|
145
|
+
<p>Article content...</p>
|
|
146
|
+
</article>
|
|
147
|
+
|
|
148
|
+
<aside>
|
|
149
|
+
<AdBanner
|
|
150
|
+
platformId="10"
|
|
151
|
+
apiKey="abc123xyz"
|
|
152
|
+
size="medium-rectangle"
|
|
153
|
+
userId="user-123"
|
|
154
|
+
userSegment="premium"
|
|
155
|
+
className="my-4"
|
|
156
|
+
/>
|
|
157
|
+
</aside>
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Utility Functions
|
|
164
|
+
|
|
165
|
+
You can also use the utility functions directly:
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
import { fetchAdBanner, trackImpression, trackClick } from '@/lib/ads';
|
|
169
|
+
|
|
170
|
+
// Fetch an ad
|
|
171
|
+
const response = await fetchAdBanner({
|
|
172
|
+
platformId: '10',
|
|
173
|
+
apiKey: 'your-api-key',
|
|
174
|
+
size: 'leaderboard',
|
|
175
|
+
userId: 'user-123',
|
|
176
|
+
userSegment: 'premium',
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Track events (automatically skipped in TheAd Vantage dev mode)
|
|
180
|
+
trackImpression(adId);
|
|
181
|
+
trackClick(adId);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Environment Variables
|
|
187
|
+
|
|
188
|
+
### For Platform Developers
|
|
189
|
+
|
|
190
|
+
```env
|
|
191
|
+
# .env.local
|
|
192
|
+
# Optional: Point to your own platform instance
|
|
193
|
+
NEXT_PUBLIC_THEAD_VANTAGE_API_URL=https://your-platform.com/api/ads
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### For TheAd Vantage Developers
|
|
197
|
+
|
|
198
|
+
```env
|
|
199
|
+
# .env.local
|
|
200
|
+
# Enable TheAd Vantage dev mode (uses localhost:3001, disables tracking)
|
|
201
|
+
NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Priority Order** (highest to lowest):
|
|
205
|
+
1. Explicit `apiUrl` prop in component
|
|
206
|
+
2. `NEXT_PUBLIC_THEAD_VANTAGE_API_URL` environment variable
|
|
207
|
+
3. `NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true` (uses localhost:3001)
|
|
208
|
+
4. Production mode (default: https://thead-vantage.com/api/ads)
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## API Routes
|
|
213
|
+
|
|
214
|
+
The integration includes Next.js API routes that proxy requests to TheAd Vantage:
|
|
215
|
+
|
|
216
|
+
- **`GET /api/ads`** - Fetches ads from TheAd Vantage platform
|
|
217
|
+
- Automatically handles all three modes
|
|
218
|
+
- Adds `dev_mode`, `no_track`, and `no_click_track` parameters in dev mode
|
|
219
|
+
- Returns mock data if platform is unavailable in TheAd Vantage dev mode
|
|
220
|
+
|
|
221
|
+
- **`POST /api/ads`** - Tracks ad impressions/clicks
|
|
222
|
+
- Automatically skipped in TheAd Vantage dev mode
|
|
223
|
+
- Logs dev mode messages when tracking is skipped
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Development Mode Features
|
|
228
|
+
|
|
229
|
+
When in **TheAd Vantage Dev Mode** (`NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true`):
|
|
230
|
+
|
|
231
|
+
- ✅ **No Tracking**: Impressions and clicks are NOT recorded
|
|
232
|
+
- ✅ **Mock Fallback**: If localhost:3001 is unavailable, uses mock ad data
|
|
233
|
+
- ✅ **Dev Indicators**: UI shows "[DEV] No tracking active" message
|
|
234
|
+
- ✅ **Console Logging**: Dev mode actions are logged to console
|
|
235
|
+
- ✅ **Error Resilience**: Connection failures won't break your development workflow
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Learn More
|
|
240
|
+
|
|
241
|
+
To learn more about Next.js, take a look at the following resources:
|
|
242
|
+
|
|
243
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
244
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
245
|
+
|
|
246
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Deploy on Vercel
|
|
251
|
+
|
|
252
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
253
|
+
|
|
254
|
+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
# AI Agent Implementation Guide
|
|
259
|
+
|
|
260
|
+
> **For AI Agents (Cursor, GitHub Copilot, etc.)**: This section provides comprehensive instructions for implementing and using TheAd Vantage integration in this codebase.
|
|
261
|
+
|
|
262
|
+
## System Architecture
|
|
263
|
+
|
|
264
|
+
The TheAd Vantage integration uses a three-mode system to support different development scenarios:
|
|
265
|
+
|
|
266
|
+
1. **Production Mode**: Default behavior, connects to `https://thead-vantage.com/api/ads`
|
|
267
|
+
2. **Platform Developer Dev Mode**: Custom API URL via `NEXT_PUBLIC_THEAD_VANTAGE_API_URL` env var
|
|
268
|
+
3. **TheAd Vantage Dev Mode**: Local development via `NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true` env var
|
|
269
|
+
|
|
270
|
+
## Key Files and Their Purposes
|
|
271
|
+
|
|
272
|
+
### Configuration
|
|
273
|
+
- **`src/lib/thead-vantage-config.ts`**: Core configuration utility that determines API URL based on mode priority
|
|
274
|
+
- `getApiBaseUrl(explicitApiUrl?)`: Returns the appropriate API base URL
|
|
275
|
+
- `isTheadVantageDevMode()`: Checks if TheAd Vantage dev mode is active
|
|
276
|
+
- `setTheadVantageConfig(config)`: Runtime configuration for browser contexts
|
|
277
|
+
|
|
278
|
+
### API Routes
|
|
279
|
+
- **`src/app/api/ads/route.ts`**: Next.js API route that proxies requests to TheAd Vantage
|
|
280
|
+
- `GET /api/ads`: Fetches ads, handles all three modes, adds dev flags when needed
|
|
281
|
+
- `POST /api/ads`: Tracks impressions/clicks, skips tracking in dev mode
|
|
282
|
+
|
|
283
|
+
### Components
|
|
284
|
+
- **`src/components/AdBanner.tsx`**: Main React component for displaying ads
|
|
285
|
+
- Props: `platformId`, `apiKey`, `size`, `apiUrl?`, `userId?`, `userSegment?`, `className?`
|
|
286
|
+
- Automatically handles loading, error states, and dev mode indicators
|
|
287
|
+
|
|
288
|
+
### Utilities
|
|
289
|
+
- **`src/lib/ads.ts`**: Utility functions for fetching and tracking ads
|
|
290
|
+
- `fetchAdBanner(params)`: Fetches ads with full parameter support
|
|
291
|
+
- `trackImpression(adId)`: Tracks ad impressions (skipped in dev mode)
|
|
292
|
+
- `trackClick(adId)`: Tracks ad clicks (skipped in dev mode)
|
|
293
|
+
|
|
294
|
+
## Implementation Instructions for AI Agents
|
|
295
|
+
|
|
296
|
+
### When Adding TheAd Vantage Integration to a New Component
|
|
297
|
+
|
|
298
|
+
1. **Import the AdBanner component**:
|
|
299
|
+
```tsx
|
|
300
|
+
import { AdBanner } from '@/components/AdBanner';
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
2. **Use the component with required props**:
|
|
304
|
+
```tsx
|
|
305
|
+
<AdBanner
|
|
306
|
+
platformId="10"
|
|
307
|
+
apiKey="your-api-key"
|
|
308
|
+
size="leaderboard"
|
|
309
|
+
/>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
3. **For platform developers using custom API**: Ensure they set `NEXT_PUBLIC_THEAD_VANTAGE_API_URL` in `.env.local`
|
|
313
|
+
|
|
314
|
+
4. **For TheAd Vantage developers**: Ensure they set `NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true` in `.env.local`
|
|
315
|
+
|
|
316
|
+
### When Debugging Ad Loading Issues
|
|
317
|
+
|
|
318
|
+
1. **Check environment variables**: Verify `.env.local` has correct configuration
|
|
319
|
+
2. **Check console logs**: Look for `[AdBanner]` prefixed messages
|
|
320
|
+
3. **Verify API URL resolution**: The `getApiBaseUrl()` function logs which mode is active
|
|
321
|
+
4. **Check network tab**: Verify requests are going to the correct endpoint
|
|
322
|
+
|
|
323
|
+
### When Implementing Custom Ad Fetching
|
|
324
|
+
|
|
325
|
+
1. **Use `fetchAdBanner()` utility** instead of direct fetch calls
|
|
326
|
+
2. **Pass `apiUrl` parameter** if you need to override the default
|
|
327
|
+
3. **Handle `dev_mode` flag** in response to show appropriate UI indicators
|
|
328
|
+
4. **Use `trackImpression()` and `trackClick()`** for tracking (automatically skipped in dev mode)
|
|
329
|
+
|
|
330
|
+
### Mode Detection Priority (Important for AI Agents)
|
|
331
|
+
|
|
332
|
+
The system uses this priority order to determine which API URL to use:
|
|
333
|
+
|
|
334
|
+
1. **Explicit `apiUrl` prop** (highest priority) - passed directly to component
|
|
335
|
+
2. **`NEXT_PUBLIC_THEAD_VANTAGE_API_URL` env var** - for platform developers
|
|
336
|
+
3. **`NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true`** - for TheAd Vantage developers (uses localhost:3001)
|
|
337
|
+
4. **Production mode** (lowest priority) - default: https://thead-vantage.com/api/ads
|
|
338
|
+
|
|
339
|
+
### Common Patterns
|
|
340
|
+
|
|
341
|
+
**Pattern 1: Basic Ad Display**
|
|
342
|
+
```tsx
|
|
343
|
+
<AdBanner platformId="10" apiKey="key" size="banner" />
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Pattern 2: Ad with User Targeting**
|
|
347
|
+
```tsx
|
|
348
|
+
<AdBanner
|
|
349
|
+
platformId="10"
|
|
350
|
+
apiKey="key"
|
|
351
|
+
size="leaderboard"
|
|
352
|
+
userId={user?.id}
|
|
353
|
+
userSegment={user?.segment}
|
|
354
|
+
/>
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
**Pattern 3: Custom API URL Override**
|
|
358
|
+
```tsx
|
|
359
|
+
<AdBanner
|
|
360
|
+
platformId="10"
|
|
361
|
+
apiKey="key"
|
|
362
|
+
size="banner"
|
|
363
|
+
apiUrl="https://custom-api.com/ads"
|
|
364
|
+
/>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Pattern 4: Programmatic Ad Fetching**
|
|
368
|
+
```tsx
|
|
369
|
+
const response = await fetchAdBanner({
|
|
370
|
+
platformId: '10',
|
|
371
|
+
apiKey: 'key',
|
|
372
|
+
size: 'medium-rectangle',
|
|
373
|
+
apiUrl: customUrl, // Optional override
|
|
374
|
+
});
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Error Handling
|
|
378
|
+
|
|
379
|
+
- The component automatically handles loading and error states
|
|
380
|
+
- In TheAd Vantage dev mode, connection failures return mock data instead of errors
|
|
381
|
+
- Tracking failures are logged but don't throw errors (non-blocking)
|
|
382
|
+
|
|
383
|
+
### Testing Checklist for AI Agents
|
|
384
|
+
|
|
385
|
+
When implementing or modifying TheAd Vantage integration:
|
|
386
|
+
|
|
387
|
+
- [ ] Verify production mode connects to https://thead-vantage.com/api/ads
|
|
388
|
+
- [ ] Verify platform dev mode respects `NEXT_PUBLIC_THEAD_VANTAGE_API_URL`
|
|
389
|
+
- [ ] Verify TheAd Vantage dev mode uses localhost:3001 when flag is set
|
|
390
|
+
- [ ] Verify tracking is disabled in TheAd Vantage dev mode
|
|
391
|
+
- [ ] Verify mock data is returned when platform is unavailable in dev mode
|
|
392
|
+
- [ ] Verify explicit `apiUrl` prop overrides all other settings
|
|
393
|
+
- [ ] Verify component handles loading states correctly
|
|
394
|
+
- [ ] Verify component handles error states gracefully
|
|
395
|
+
- [ ] Verify dev mode indicators show in UI when appropriate
|
|
396
|
+
|
|
397
|
+
### Environment Variable Reference
|
|
398
|
+
|
|
399
|
+
```env
|
|
400
|
+
# Platform Developer Dev Mode
|
|
401
|
+
NEXT_PUBLIC_THEAD_VANTAGE_API_URL=https://your-platform.com/api/ads
|
|
402
|
+
|
|
403
|
+
# TheAd Vantage Dev Mode
|
|
404
|
+
NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### TypeScript Types
|
|
408
|
+
|
|
409
|
+
Key types for reference:
|
|
410
|
+
- `AdBannerProps`: Component props interface
|
|
411
|
+
- `Ad`: Ad data structure
|
|
412
|
+
- `AdsResponse`: API response structure
|
|
413
|
+
- `FetchAdBannerParams`: Parameters for `fetchAdBanner()` function
|
|
414
|
+
|
|
415
|
+
All types are exported from `@/lib/ads` and `@/components/AdBanner`.
|
|
416
|
+
|
|
417
|
+
---
|
|
418
|
+
|
|
419
|
+
## Quick Reference
|
|
420
|
+
|
|
421
|
+
**Default Behavior**: Connects to `https://thead-vantage.com/api/ads` (production)
|
|
422
|
+
|
|
423
|
+
**Platform Developer Setup**: Add `NEXT_PUBLIC_THEAD_VANTAGE_API_URL` to `.env.local`
|
|
424
|
+
|
|
425
|
+
**TheAd Vantage Developer Setup**: Add `NEXT_PUBLIC_THEAD_VANTAGE_DEV_MODE=true` to `.env.local`
|
|
426
|
+
|
|
427
|
+
**Component Import**: `import { AdBanner } from '@/components/AdBanner';`
|
|
428
|
+
|
|
429
|
+
**Utility Import**: `import { fetchAdBanner, trackImpression, trackClick } from '@/lib/ads';`
|
package/package.json
CHANGED
|
@@ -1,49 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@thead-vantage/react",
|
|
3
|
+
"version": "2.1.2",
|
|
4
|
+
"description": "React components and utilities for TheAd Vantage ad platform integration",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"module": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./src/index.ts",
|
|
11
|
+
"require": "./src/index.ts",
|
|
12
|
+
"types": "./src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"./components/AdBanner": {
|
|
15
|
+
"import": "./src/components/AdBanner.tsx",
|
|
16
|
+
"require": "./src/components/AdBanner.tsx",
|
|
17
|
+
"types": "./src/components/AdBanner.tsx"
|
|
18
|
+
},
|
|
19
|
+
"./components/AdDisplay": {
|
|
20
|
+
"import": "./src/components/AdDisplay.tsx",
|
|
21
|
+
"require": "./src/components/AdDisplay.tsx",
|
|
22
|
+
"types": "./src/components/AdDisplay.tsx"
|
|
23
|
+
},
|
|
24
|
+
"./lib/ads": {
|
|
25
|
+
"import": "./src/lib/ads.ts",
|
|
26
|
+
"require": "./src/lib/ads.ts",
|
|
27
|
+
"types": "./src/lib/ads.ts"
|
|
28
|
+
},
|
|
29
|
+
"./lib/thead-vantage-config": {
|
|
30
|
+
"import": "./src/lib/thead-vantage-config.ts",
|
|
31
|
+
"require": "./src/lib/thead-vantage-config.ts",
|
|
32
|
+
"types": "./src/lib/thead-vantage-config.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"src",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"keywords": [
|
|
40
|
+
"react",
|
|
41
|
+
"ads",
|
|
42
|
+
"advertising",
|
|
43
|
+
"thead-vantage",
|
|
44
|
+
"nextjs"
|
|
45
|
+
],
|
|
46
|
+
"author": "",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
50
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
51
|
+
"next": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"dev": "next dev --turbopack",
|
|
55
|
+
"build": "next build",
|
|
56
|
+
"start": "next start",
|
|
57
|
+
"lint": "next lint"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@tailwindcss/postcss": "^4",
|
|
62
|
+
"@types/node": "^20",
|
|
63
|
+
"@types/react": "^19",
|
|
64
|
+
"@types/react-dom": "^19",
|
|
65
|
+
"next": "^16.1.0",
|
|
66
|
+
"react": "^19.0.0",
|
|
67
|
+
"react-dom": "^19.0.0",
|
|
68
|
+
"tailwindcss": "^4",
|
|
69
|
+
"typescript": "^5"
|
|
70
|
+
}
|
|
71
|
+
}
|