Ignore errors when tracking page views (#193)

This commit is contained in:
Samy Pessé
2024-02-27 16:27:09 +01:00
committed by GitHub
parent 7ed89fe0fe
commit 5e12c0a9be
2 changed files with 12 additions and 7 deletions
+11 -7
View File
@@ -54,11 +54,15 @@ async function trackPageView(apiHost: string, spaceId: string, pageId: string |
const url = new URL(apiHost);
url.pathname = `/v1/spaces/${spaceId}/insights/track_view`;
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
try {
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
} catch (error) {
console.error('Failed to track page view', error);
}
}
+1
View File
@@ -59,6 +59,7 @@ async function fetchVisitorID(): Promise<string> {
const { deviceId } = (await resp.json()) as { deviceId: string };
return deviceId;
} catch (error) {
console.error('Failed to fetch visitor session ID', error);
return proposed;
}
}