major: import Fresh 2.0 code (#2449)

🎉
This commit is contained in:
Marvin Hagemeister
2024-05-24 09:40:08 +02:00
committed by GitHub
parent 990357629e
commit 287929e4d2
958 changed files with 15794 additions and 28287 deletions
+11 -5
View File
@@ -1,4 +1,4 @@
import { type FreshContext } from "$fresh/server.ts";
import type { FreshContext } from "@fresh/core";
import type { Event } from "$ga4";
import { GA4Report, isDocument, isServerError } from "$ga4";
@@ -62,7 +62,14 @@ function ga4(
// Create basic report.
const measurementId = GA4_MEASUREMENT_ID;
// @ts-ignore GA4Report doesn't even use the localAddress parameter
const report = new GA4Report({ measurementId, request, response, conn });
const report = new GA4Report({
measurementId,
request,
response,
// Doesn't use localAddr
// deno-lint-ignore no-explicit-any
conn: conn.info as any,
});
// Override the default (page_view) event.
report.event = event;
@@ -74,12 +81,11 @@ function ga4(
await report.send();
}).catch((err) => {
console.error(`Internal error: ${err}`);
console.error(err);
});
}
export async function handler(
req: Request,
ctx: FreshContext,
): Promise<Response> {
let err;
@@ -98,7 +104,7 @@ export async function handler(
throw e;
} finally {
ga4(
req,
ctx.req,
ctx,
res!,
start,