@thead-vantage/react 2.13.0 → 2.14.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/lib/ads.ts +8 -4
package/package.json
CHANGED
package/src/lib/ads.ts
CHANGED
|
@@ -418,9 +418,11 @@ export async function trackImpression(adId: string): Promise<void> {
|
|
|
418
418
|
console.log(`[DEV] Impression tracking skipped for ad: ${adId}`);
|
|
419
419
|
}
|
|
420
420
|
} catch (error) {
|
|
421
|
-
// Handle CORS errors
|
|
421
|
+
// Handle CORS errors gracefully (tracking failures shouldn't break the app)
|
|
422
422
|
if (error instanceof TypeError && (error.message.includes('CORS') || error.message.includes('Failed to fetch'))) {
|
|
423
|
-
|
|
423
|
+
// This is expected until the server configures CORS for /api/ads/track endpoint
|
|
424
|
+
// The ad still displays correctly, tracking just won't work until server-side CORS is fixed
|
|
425
|
+
console.debug(`[AdBanner] Tracking impression failed (CORS): The /api/ads/track endpoint needs CORS headers configured on the server. Ad still displayed successfully.`);
|
|
424
426
|
} else {
|
|
425
427
|
console.error('Error tracking impression:', error);
|
|
426
428
|
}
|
|
@@ -486,9 +488,11 @@ export async function trackClick(adId: string): Promise<void> {
|
|
|
486
488
|
console.log(`[DEV] Click tracking skipped for ad: ${adId}`);
|
|
487
489
|
}
|
|
488
490
|
} catch (error) {
|
|
489
|
-
// Handle CORS errors
|
|
491
|
+
// Handle CORS errors gracefully (tracking failures shouldn't break the app)
|
|
490
492
|
if (error instanceof TypeError && (error.message.includes('CORS') || error.message.includes('Failed to fetch'))) {
|
|
491
|
-
|
|
493
|
+
// This is expected until the server configures CORS for /api/ads/track endpoint
|
|
494
|
+
// The ad still works correctly, click tracking just won't work until server-side CORS is fixed
|
|
495
|
+
console.debug(`[AdBanner] Tracking click failed (CORS): The /api/ads/track endpoint needs CORS headers configured on the server. Ad still works correctly.`);
|
|
492
496
|
} else {
|
|
493
497
|
console.error('Error tracking click:', error);
|
|
494
498
|
}
|