Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-ties-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gitbook": patch
---

Fix missing geo data in site insights because of incorrect proxying of events.
6 changes: 4 additions & 2 deletions packages/gitbook/src/lib/tracking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { headers as nextHeaders } from 'next/headers';
import { GITBOOK_API_URL, GITBOOK_DISABLE_TRACKING } from './env';
import { GITBOOK_API_PUBLIC_URL, GITBOOK_DISABLE_TRACKING } from './env';

/**
* Return true if events should be tracked on the site.
Expand Down Expand Up @@ -36,7 +36,9 @@ export async function serveProxyAnalyticsEvent(req: Request) {
headers: { 'content-type': 'text/plain' },
});
}
const url = new URL(`${GITBOOK_API_URL}/v1/orgs/${org}/sites/${site}/insights/events`);

// We make the request to the public API URL to ensure the request is properly enriched by the router..
const url = new URL(`${GITBOOK_API_PUBLIC_URL}/v1/orgs/${org}/sites/${site}/insights/events`);
return await fetch(url.toString(), {
method: 'POST',
headers: {
Expand Down