@thead-vantage/react 2.2.0 → 2.3.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/AdBanner.tsx +18 -2
- package/src/lib/ads.ts +24 -5
package/package.json
CHANGED
|
@@ -48,22 +48,38 @@ export function AdBanner({
|
|
|
48
48
|
hasAd: !!response.ad,
|
|
49
49
|
devMode: response.dev_mode,
|
|
50
50
|
message: response.message,
|
|
51
|
+
_dev_note: response._dev_note,
|
|
52
|
+
fullResponse: response,
|
|
51
53
|
});
|
|
52
54
|
|
|
53
55
|
if (response.success && response.ad) {
|
|
56
|
+
console.log('[AdBanner] Setting ad:', response.ad);
|
|
54
57
|
setAd(response.ad);
|
|
55
58
|
setDevMode(response.dev_mode || false);
|
|
56
59
|
|
|
57
60
|
// Track impression (will be skipped in dev mode)
|
|
58
61
|
trackImpression(response.ad.id);
|
|
59
62
|
} else {
|
|
60
|
-
|
|
63
|
+
// Create a more detailed error message
|
|
64
|
+
const errorDetails = [];
|
|
65
|
+
if (!response.success) errorDetails.push('API returned success=false');
|
|
66
|
+
if (!response.ad) errorDetails.push('No ad object in response');
|
|
67
|
+
if (response.message) errorDetails.push(`Message: ${response.message}`);
|
|
68
|
+
if (response._dev_note) errorDetails.push(`Note: ${response._dev_note}`);
|
|
69
|
+
|
|
70
|
+
const errorMsg = errorDetails.length > 0
|
|
71
|
+
? `No ads available: ${errorDetails.join(', ')}`
|
|
72
|
+
: 'No ads available';
|
|
73
|
+
|
|
74
|
+
console.error('[AdBanner] No ad available - Full details:', {
|
|
61
75
|
success: response.success,
|
|
62
76
|
hasAd: !!response.ad,
|
|
63
77
|
message: response.message,
|
|
64
78
|
_dev_note: response._dev_note,
|
|
79
|
+
fullResponse: response,
|
|
80
|
+
errorDetails,
|
|
65
81
|
});
|
|
66
|
-
setError(
|
|
82
|
+
setError(errorMsg);
|
|
67
83
|
}
|
|
68
84
|
} catch (err) {
|
|
69
85
|
console.error('[AdBanner] Error fetching ad:', err);
|
package/src/lib/ads.ts
CHANGED
|
@@ -137,14 +137,17 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
137
137
|
|
|
138
138
|
const data: AdsResponse = await response.json();
|
|
139
139
|
|
|
140
|
-
// Debug logging to see what we're getting
|
|
141
|
-
console.log('[AdBanner] API Response:',
|
|
140
|
+
// Debug logging - log the FULL response to see exactly what we're getting
|
|
141
|
+
console.log('[AdBanner] Full API Response:', JSON.stringify(data, null, 2));
|
|
142
|
+
console.log('[AdBanner] API Response Summary:', {
|
|
142
143
|
success: data.success,
|
|
143
144
|
hasAd: !!data.ad,
|
|
144
145
|
hasAds: !!(data.ads && Array.isArray(data.ads)),
|
|
145
146
|
adsLength: Array.isArray(data.ads) ? data.ads.length : 0,
|
|
146
147
|
message: data.message,
|
|
147
148
|
dataKeys: Object.keys(data),
|
|
149
|
+
adType: data.ad ? typeof data.ad : 'none',
|
|
150
|
+
adsType: data.ads ? (Array.isArray(data.ads) ? 'array' : typeof data.ads) : 'none',
|
|
148
151
|
});
|
|
149
152
|
|
|
150
153
|
// Type guard to check if an object is Ad type (for arrays that might contain either)
|
|
@@ -170,11 +173,15 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
170
173
|
if (data.ads && Array.isArray(data.ads) && data.ads.length > 0) {
|
|
171
174
|
// If we get an array, use the first ad and ensure it's Ad type
|
|
172
175
|
const firstAd = data.ads[0];
|
|
176
|
+
console.log('[AdBanner] Processing ads array, first ad:', JSON.stringify(firstAd, null, 2));
|
|
177
|
+
|
|
173
178
|
// Check if it's already an Ad, otherwise convert from AdData
|
|
174
179
|
const ad: Ad = isAd(firstAd)
|
|
175
180
|
? firstAd
|
|
176
181
|
: convertToAd(firstAd as AdData);
|
|
177
182
|
|
|
183
|
+
console.log('[AdBanner] Converted ad:', JSON.stringify(ad, null, 2));
|
|
184
|
+
|
|
178
185
|
return {
|
|
179
186
|
success: data.success,
|
|
180
187
|
ad,
|
|
@@ -187,7 +194,9 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
187
194
|
// Handle single ad response - convert AdData to Ad
|
|
188
195
|
// Since data.ad is typed as AdData, we always convert it
|
|
189
196
|
if (data.ad) {
|
|
197
|
+
console.log('[AdBanner] Processing single ad:', JSON.stringify(data.ad, null, 2));
|
|
190
198
|
const ad: Ad = convertToAd(data.ad);
|
|
199
|
+
console.log('[AdBanner] Converted ad:', JSON.stringify(ad, null, 2));
|
|
191
200
|
|
|
192
201
|
return {
|
|
193
202
|
success: data.success,
|
|
@@ -198,11 +207,21 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
198
207
|
};
|
|
199
208
|
}
|
|
200
209
|
|
|
201
|
-
|
|
210
|
+
// No ad found - log detailed info
|
|
211
|
+
console.warn('[AdBanner] No ad found in response:', {
|
|
202
212
|
success: data.success,
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
hasAd: !!data.ad,
|
|
214
|
+
hasAds: !!(data.ads && Array.isArray(data.ads)),
|
|
215
|
+
adsLength: Array.isArray(data.ads) ? data.ads.length : 0,
|
|
205
216
|
message: data.message,
|
|
217
|
+
fullData: data,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
success: data.success || false,
|
|
222
|
+
dev_mode: data.dev_mode,
|
|
223
|
+
_dev_note: data._dev_note || 'No ad data in response',
|
|
224
|
+
message: data.message || 'No ads available in response',
|
|
206
225
|
};
|
|
207
226
|
} catch (error) {
|
|
208
227
|
console.error('[AdBanner] Error fetching ad:', error);
|