Try profound#5301
Open
fabianrbz wants to merge 2 commits into
Open
Conversation
part of the edge function execution
Avoids unnecessary overhead and should catch assets with extensions that aren't listed in the config
✅ Deploy Preview for kongdeveloper ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds optional request logging from the Netlify Edge Function to ProFound, while keeping the existing “serve Markdown when Accept: text/markdown” rewrite behavior.
Changes:
- Extends the Edge Function signature to accept
Contextand usescontext.waitUntil()to send logs asynchronously. - Adds environment-flagged logging (
PROFOUND_API_KEY+LOG_TO_PROFOUND) with request metadata (method, host, path, IP, user-agent, query params, referer). - Expands
excludedPathto avoid running the Edge Function on additional asset paths.
Comment on lines
+23
to
+45
| const params: Record<string, string> = {}; | ||
| url.searchParams.forEach((value, key) => { | ||
| params[key] = value; | ||
| }); | ||
|
|
||
| context.waitUntil( | ||
| fetch("https://artemis.api.tryprofound.com/v1/logs/custom", { | ||
| method: "POST", | ||
| headers: { | ||
| 'x-api-key': apiKey, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify([{ | ||
| timestamp: new Date().toISOString(), | ||
| method: request.method, | ||
| host: request.headers.get("host"), | ||
| path: pathname, | ||
| status_code: 200, // hardcoded, we don't want to add extra overhead | ||
| ip: context.ip, | ||
| user_agent: request.headers.get("user-agent"), | ||
| query_params: params, | ||
| referer: request.headers.get("referer"), | ||
| }]), |
Comment on lines
+29
to
+46
| fetch("https://artemis.api.tryprofound.com/v1/logs/custom", { | ||
| method: "POST", | ||
| headers: { | ||
| 'x-api-key': apiKey, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify([{ | ||
| timestamp: new Date().toISOString(), | ||
| method: request.method, | ||
| host: request.headers.get("host"), | ||
| path: pathname, | ||
| status_code: 200, // hardcoded, we don't want to add extra overhead | ||
| ip: context.ip, | ||
| user_agent: request.headers.get("user-agent"), | ||
| query_params: params, | ||
| referer: request.headers.get("referer"), | ||
| }]), | ||
| }) |
Comment on lines
+36
to
+41
| timestamp: new Date().toISOString(), | ||
| method: request.method, | ||
| host: request.headers.get("host"), | ||
| path: pathname, | ||
| status_code: 200, // hardcoded, we don't want to add extra overhead | ||
| ip: context.ip, |
Comment on lines
+32
to
+33
| 'x-api-key': apiKey, | ||
| 'Content-Type': 'application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add logging to the edge-function
Description
Test if we can use the edge function to log the requests to profound after the response is sent to the user.
NOTE: I had to hardcode the http status code to 200 to avoid extra overhead of doing an extra request to get the actual status code.
Checklist
descriptionentry in frontmatter.