File tree Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change 11import metrics from "../metrics" ;
2- import { APIContext } from "astro" ;
32
4- export async function onRequest ( { request, clientAddress } : APIContext , next : ( ) => any ) {
3+ export async function onRequest ( { request } : any , next : ( ) => any ) {
54 const path = new URL ( request . url ) . pathname . slice ( 1 ) ;
6-
7- await fetch ( "https://plausible.io/api/event" , {
8- method : "POST" ,
9- headers : {
10- "Content-Type" : "application/json" ,
11- "User-Agent" : request . headers . get ( "User-Agent" ) ! ,
12- "X-Forwarded-For" : clientAddress ,
13- } ,
14- body : JSON . stringify ( {
15- domain : "sprig.hackclub.com" ,
16- url : request . url ,
17- name : "pageview"
18- } )
19- } )
20-
5+
216 if ( ! path . includes ( "api" ) ) return next ( ) ;
227
238 const metricName = path . split ( "/" ) . join ( "_" ) ;
You can’t perform that action at this time.
0 commit comments