@thead-vantage/react 2.8.0 → 2.9.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.
- package/package.json +1 -1
- package/src/components/AdDisplay.tsx +15 -6
- package/src/lib/ads.ts +3 -0
package/package.json
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import Image from 'next/image';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
fetchAds,
|
|
7
|
+
trackImpression,
|
|
8
|
+
trackClick,
|
|
9
|
+
type AdData,
|
|
10
|
+
type AdsResponse
|
|
11
|
+
} from '../lib/ads';
|
|
6
12
|
|
|
7
13
|
interface AdDisplayProps {
|
|
8
14
|
position?: string;
|
|
@@ -21,12 +27,15 @@ export default function AdDisplay({ position, className = '' }: AdDisplayProps)
|
|
|
21
27
|
setLoading(true);
|
|
22
28
|
setError(null);
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
// Build params object - fetchAds accepts Record<string, string> | undefined
|
|
31
|
+
// Note: fetchAds is different from fetchAdBanner (which requires platformId/apiKey)
|
|
32
|
+
const params: Record<string, string> | undefined = position
|
|
33
|
+
? { position }
|
|
34
|
+
: undefined;
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
// Explicitly type to avoid confusion with fetchAdBanner's FetchAdBannerParams
|
|
37
|
+
const fetchAdsTyped: (params?: Record<string, string>) => Promise<AdsResponse> = fetchAds;
|
|
38
|
+
const response = await fetchAdsTyped(params);
|
|
30
39
|
|
|
31
40
|
if (response.success && response.ad) {
|
|
32
41
|
setAd(response.ad);
|
package/src/lib/ads.ts
CHANGED
|
@@ -56,6 +56,9 @@ export interface FetchAdBannerParams {
|
|
|
56
56
|
/**
|
|
57
57
|
* Fetch ads from TheAd Vantage platform (generic)
|
|
58
58
|
* In development mode, uses mock data and prevents tracking
|
|
59
|
+
*
|
|
60
|
+
* @param params - Optional query parameters as key-value pairs
|
|
61
|
+
* @returns Promise resolving to AdsResponse
|
|
59
62
|
*/
|
|
60
63
|
export async function fetchAds(params?: Record<string, string>): Promise<AdsResponse> {
|
|
61
64
|
try {
|