Skip to content

Commit

Permalink
chore: don't wait for response from plausible
Browse files Browse the repository at this point in the history
  • Loading branch information
akoenig committed May 6, 2024
1 parent e98d88b commit f8d6521
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions app/routes/$category.$id/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,20 @@ export async function loader({ params, request }: LoaderFunctionArgs) {

const xForwardedFor = request.headers.get("X-Forwarded-For");

try {
const response = await fetch(
"https://plausible.openformation.io/api/event",
{
method: "POST",
headers: {
...(xForwardedFor && { "X-Forwarded-For": xForwardedFor }),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "InstallScriptWasDownloaded",
domain,
url: request.url,
}),
},
);

console.log(response.status, await response.text());
console.log(response.headers);
} catch (cause) {
console.error(`failed to send event to Plausible: ${cause}`);
}
fetch("https://plausible.openformation.io/api/event", {
method: "POST",
headers: {
...(xForwardedFor && { "X-Forwarded-For": xForwardedFor }),
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "InstallScriptWasDownloaded",
domain,
url: request.url,
}),
}).catch((cause) =>
console.error(`failed to send event to Plausible: ${cause}`),
);

const response = new Response(script, {
headers: {
Expand Down

0 comments on commit f8d6521

Please sign in to comment.