Skip to content

Remove hardcoded Posthog project token (even though it's meant to be public)#76

Open
brendan-priorlabs wants to merge 3 commits into
mainfrom
brendan/veracode_01
Open

Remove hardcoded Posthog project token (even though it's meant to be public)#76
brendan-priorlabs wants to merge 3 commits into
mainfrom
brendan/veracode_01

Conversation

@brendan-priorlabs

Copy link
Copy Markdown
Contributor

To remove all doubt that this token is misplaced, and given that we don't collect analytics in OSS anyway, replace a hardcoded token with an environment variable.

@brendan-priorlabs brendan-priorlabs requested a review from a team as a code owner June 8, 2026 17:31
@brendan-priorlabs brendan-priorlabs requested review from psinger-prior and safaricd and removed request for a team and psinger-prior June 8, 2026 17:31

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

Copy link
Copy Markdown
Contributor

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 telemetry service to load the PostHog API key from the environment variable TABPFN_POSTHOG_PROJECT_TOKEN instead of using a hardcoded value, and gracefully handles missing keys by disabling telemetry. The reviewer suggested converting PROJECT_API_KEY into a property to ensure the environment variable is evaluated dynamically at initialization rather than once at module import time.

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 on lines +29 to +31
# PostHog project ingestion token, read from the environment so no
# credential ships in the package. When unset, telemetry is a no-op.
PROJECT_API_KEY: Optional[str] = os.getenv("TABPFN_POSTHOG_PROJECT_TOKEN")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Evaluating os.getenv at the class definition level means the environment variable is read only once when the module is first imported. If the environment variable TABPFN_POSTHOG_PROJECT_TOKEN is set or modified dynamically after the module is imported (for example, in a Jupyter notebook, a test suite, or via dynamic configuration), the change will not be picked up.\n\nBy converting PROJECT_API_KEY into a property, the environment variable is evaluated dynamically when the telemetry service is initialized, making the configuration much more robust and easier to test.

    @property\n    def PROJECT_API_KEY(self) -> Optional[str]:\n        # PostHog project ingestion token, read from the environment so no\n        # credential ships in the package. When unset, telemetry is a no-op.\n        return os.getenv("TABPFN_POSTHOG_PROJECT_TOKEN")

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