Skip to content

Gate SimpleAnalytics injection behind VITE_APP_DISABLE_TRACKING - #2

Open
dimafa wants to merge 2 commits into
BetterAndBetterII:multi-canvasfrom
dimafa:gate-analytics-tracking
Open

Gate SimpleAnalytics injection behind VITE_APP_DISABLE_TRACKING#2
dimafa wants to merge 2 commits into
BetterAndBetterII:multi-canvasfrom
dimafa:gate-analytics-tracking

Conversation

@dimafa

@dimafa dimafa commented Jun 6, 2026

Copy link
Copy Markdown

What

The third-party SimpleAnalytics script (scripts.simpleanalyticscdn.com/latest.js) is injected in excalidraw-app/index.html on every PROD build — the injection is gated only by PROD, not by VITE_APP_DISABLE_TRACKING. As a result, self-hosted deployments that set VITE_APP_DISABLE_TRACKING=yes (e.g. the excalidraw-full Docker build) still ship a third-party tracker that beacons page paths on every load.

Change

Gate the analytics injection on the existing flag:

<% if (typeof PROD != 'undefined' && PROD == true && (typeof VITE_APP_DISABLE_TRACKING == 'undefined' || VITE_APP_DISABLE_TRACKING != 'yes')) { %>

This follows the same template pattern already used for VITE_APP_DEV_DISABLE_LIVE_RELOAD (index.html L145). When the flag is unset, behavior is unchanged; when VITE_APP_DISABLE_TRACKING=yes, the tracker is not injected.

Why

Privacy: a self-hosted instance shouldn't phone home to a third party, and the project already exposes a flag whose name implies exactly this. One-line, behavior-preserving by default.

Notes

  • There's also a separate VITE_APP_ENABLE_TRACKING used by the build:app script; this PR intentionally honors the DISABLE_TRACKING flag the self-host path sets, but happy to also key off ENABLE_TRACKING if you'd prefer a single source of truth.

The third-party SimpleAnalytics script (scripts.simpleanalyticscdn.com) was
injected on every PROD build, ignoring VITE_APP_DISABLE_TRACKING. Self-hosters
who set that flag (as the excalidraw-full deployment does) still shipped a
third-party tracker that beacons page paths.

Gate the injection on the flag, matching the existing template pattern used for
VITE_APP_DEV_DISABLE_LIVE_RELOAD. Default behavior is unchanged when the flag is
unset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the analytics script inclusion in excalidraw-app/index.html to be skipped when the VITE_APP_DISABLE_TRACKING environment variable is set to 'yes'. The reviewer suggests enhancing this check to also support 'true' or boolean true values, making the configuration more robust and user-friendly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread excalidraw-app/index.html Outdated
Comment on lines +219 to +220
<% if (typeof PROD != 'undefined' && PROD == true && (typeof VITE_APP_DISABLE_TRACKING == 'undefined' || VITE_APP_DISABLE_TRACKING != 'yes')) { %>
<!-- Analytics (skipped when VITE_APP_DISABLE_TRACKING=yes) -->

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To make the tracking disablement more robust, we should also handle cases where VITE_APP_DISABLE_TRACKING is set to "true" or boolean true. Users frequently use these values for boolean-like environment variables, and only checking for "yes" might lead to unexpected tracking if they configure it as true.

    <% if (typeof PROD != 'undefined' && PROD == true && (typeof VITE_APP_DISABLE_TRACKING == 'undefined' || (VITE_APP_DISABLE_TRACKING != 'yes' && VITE_APP_DISABLE_TRACKING != 'true' && VITE_APP_DISABLE_TRACKING !== true))) { %>
    <!-- Analytics (skipped when VITE_APP_DISABLE_TRACKING is enabled) -->

…TRACKING

Users often set boolean-like env vars to true; accept 'yes', 'true', or boolean
true so tracking is reliably disabled regardless of the form used.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dimafa

dimafa commented Jun 6, 2026

Copy link
Copy Markdown
Author

Good point — applied. Now treats yes, true, and boolean true as disabling, so it works regardless of how the flag is expressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant