function handler(event) {
  const req = event.request;
  const url = new URL(req.url);

  if (url.pathname === "/log") {
    // Consider enriching the client-submitted data with extra stuff
    const clientGeo = event.client.geo;
    url.searchParams.set("clientCity", clientGeo.city);

    // Submit the final set of data (querystring only) as a log line
    // (ensure that 's3_rum_data' or equivalent log endpoint is configured on your service)
    const logger = fastly.getLogger("s3_rum_data");
    logger.log(url.searchParams.toString());

    return new Response(null, { status: 204 });
  } else {
    return new Response("Not found", { status: 404 });
  }
}

addEventListener("fetch", (event) => event.respondWith(handler(event)));