Skip to content

Commit ad0e671

Browse files
authored
fix: proxy Plausible analytics via first-party paths (#575)
Load the Plausible script from /js/ and send events to /api/e on librechat.ai, proxied through a Cloudflare Worker to the self-hosted Plausible instance at plausible.librechat.ai. This avoids ad-blocker false positives that were blocking the third-party script. Update the Plausible sections of the privacy and cookie policies to explain the proxy, and revise the opt-out guidance to point at the new first-party paths instead of plausible.librechat.ai (which the browser no longer contacts directly).
1 parent b8f7b2e commit ad0e671

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

app/cookie/page.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ export default function CookiePolicyPage() {
8484
twenty-four hours and the IP address itself is never written to disk, which means the
8585
hash cannot be linked across days and cannot be reversed back to a person or a device.
8686
</p>
87+
<p>
88+
The Plausible script and its event endpoint are served from first-party paths on this
89+
Site &mdash; <code>librechat.ai/js/</code> for the script and{' '}
90+
<code>librechat.ai/api/e</code> for event ingestion &mdash; and proxied through a
91+
Cloudflare Worker to our self-hosted Plausible instance at{' '}
92+
<code>plausible.librechat.ai</code>. Some browser blocklists match on the word
93+
&ldquo;plausible&rdquo; in a domain name and will block our self-hosted instance even
94+
though it never sends data to a third party; serving the script and endpoint from{' '}
95+
<code>librechat.ai</code> avoids this false positive. The proxy performs no additional
96+
data collection. If you prefer to opt out, you can block <code>librechat.ai/api/e</code>{' '}
97+
in your browser or disable JavaScript on this Site.
98+
</p>
8799

88100
<h3>3.2 Core Web Vitals Monitoring</h3>
89101
<p>
@@ -160,8 +172,9 @@ export default function CookiePolicyPage() {
160172
tracker-blocking features in your browser.
161173
</li>
162174
<li>
163-
Installing a content-blocking extension that blocks requests to{' '}
164-
<code>plausible.librechat.ai</code> and any performance-monitoring endpoint we
175+
Installing a content-blocking extension or browser rule that blocks requests to the
176+
first-party analytics paths <code>librechat.ai/js/</code> and{' '}
177+
<code>librechat.ai/api/e</code>, as well as any performance-monitoring endpoint we
165178
configure.
166179
</li>
167180
<li>Disabling JavaScript, in which case no analytics or performance data is sent.</li>

app/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export default function RootLayout({ children }: { children: ReactNode }) {
9494
<Script
9595
async
9696
id="plausible-script"
97-
src="https://plausible.librechat.ai/js/pa-AxQn4zbc0KTWDDkxjlFGs.js"
97+
src="/js/pa-AxQn4zbc0KTWDDkxjlFGs.js"
98+
data-api="/api/e"
9899
strategy="afterInteractive"
99100
/>
100101
{cwvEnabled && (

app/privacy/page.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ export default function PrivacyPolicyPage() {
107107
cannot use them to identify you, contact you, or correlate your visits to this Site with
108108
your activity on any other site.
109109
</p>
110+
<p>
111+
The Plausible script and event requests are served from first-party paths on{' '}
112+
<code>librechat.ai</code> &mdash; specifically <code>librechat.ai/js/</code> for the
113+
script and <code>librechat.ai/api/e</code> for event ingestion &mdash; and proxied
114+
through a Cloudflare Worker that forwards them to our self-hosted Plausible instance at{' '}
115+
<code>plausible.librechat.ai</code>. Some browser blocklists match on the word
116+
&ldquo;plausible&rdquo; in a domain name and will block this self-hosted instance
117+
despite the fact that it never shares data with a third party. Serving the script and
118+
endpoint from <code>librechat.ai</code> directly avoids that false positive. No
119+
additional data is collected as a result of this proxying; it is purely network-level
120+
routing. You can opt out by blocking <code>librechat.ai/api/e</code> in your browser or
121+
disabling JavaScript on this Site.
122+
</p>
110123

111124
<h3>3.2 Performance Monitoring &mdash; Core Web Vitals</h3>
112125
<p>
@@ -294,8 +307,9 @@ export default function PrivacyPolicyPage() {
294307
your browser; we will continue to honor these signals where practical.
295308
</li>
296309
<li>
297-
Using a content blocker or privacy-focused browser extension to block requests to{' '}
298-
<code>plausible.librechat.ai</code> and the performance ingestion endpoint.
310+
Using a content blocker, browser rule, or privacy-focused extension to block requests
311+
to the first-party analytics paths <code>librechat.ai/js/</code> and{' '}
312+
<code>librechat.ai/api/e</code> &mdash; as well as the performance ingestion endpoint.
299313
</li>
300314
<li>Disabling JavaScript for this Site, in which case no analytics will be sent.</li>
301315
</ul>

0 commit comments

Comments
 (0)