Skip to content

Commit 9344431

Browse files
authored
Fix API URL we proxy insights events to (#3665)
1 parent 622ecbe commit 9344431

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/calm-ties-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
Fix missing geo data in site insights because of incorrect proxying of events.

packages/gitbook/src/lib/tracking.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { headers as nextHeaders } from 'next/headers';
2-
import { GITBOOK_API_URL, GITBOOK_DISABLE_TRACKING } from './env';
2+
import { GITBOOK_API_PUBLIC_URL, GITBOOK_DISABLE_TRACKING } from './env';
33

44
/**
55
* Return true if events should be tracked on the site.
@@ -36,7 +36,9 @@ export async function serveProxyAnalyticsEvent(req: Request) {
3636
headers: { 'content-type': 'text/plain' },
3737
});
3838
}
39-
const url = new URL(`${GITBOOK_API_URL}/v1/orgs/${org}/sites/${site}/insights/events`);
39+
40+
// We make the request to the public API URL to ensure the request is properly enriched by the router..
41+
const url = new URL(`${GITBOOK_API_PUBLIC_URL}/v1/orgs/${org}/sites/${site}/insights/events`);
4042
return await fetch(url.toString(), {
4143
method: 'POST',
4244
headers: {

0 commit comments

Comments
 (0)