Skip to content

Try profound#5301

Open
fabianrbz wants to merge 2 commits into
mainfrom
feat/try-profound
Open

Try profound#5301
fabianrbz wants to merge 2 commits into
mainfrom
feat/try-profound

Conversation

@fabianrbz
Copy link
Copy Markdown
Contributor

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

  • Tested how-to docs. If not, note why here.
  • All pages contain metadata.
  • Any new docs link to existing docs.
  • All autogenerated instructions render correctly (API, decK, Konnect, Kong Manager).
  • Style guide (capitalized gateway entities, placeholder URLs) implemented correctly.
  • Every page has a description entry in frontmatter.
  • Add new pages to the product documentation index (if applicable).

fabianrbz added 2 commits May 20, 2026 09:51
Avoids unnecessary overhead and should catch assets with extensions that
aren't listed in the config
@fabianrbz fabianrbz added the do not merge Issues/ PRs whose changes should not be merged at this time label May 20, 2026
@fabianrbz fabianrbz requested a review from a team as a code owner May 20, 2026 08:03
Copilot AI review requested due to automatic review settings May 20, 2026 08:03
@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for kongdeveloper ready!

Name Link
🔨 Latest commit 05f5fd9
🔍 Latest deploy log https://app.netlify.com/projects/kongdeveloper/deploys/6a0d6ad1e88d820008590ca2
😎 Deploy Preview https://deploy-preview-5301--kongdeveloper.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Context and uses context.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 excludedPath to 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',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge Issues/ PRs whose changes should not be merged at this time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants