Skip to content

chore(analytics): [ENG-1524] add product analytics with Posthog#84

Open
henchaves wants to merge 20 commits into
mainfrom
feature/eng-1524-add-product-analytics-posthog
Open

chore(analytics): [ENG-1524] add product analytics with Posthog#84
henchaves wants to merge 20 commits into
mainfrom
feature/eng-1524-add-product-analytics-posthog

Conversation

@henchaves
Copy link
Copy Markdown
Member

No description provided.

@linear
Copy link
Copy Markdown

linear Bot commented Apr 22, 2026

@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented Apr 22, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Copy Markdown
Contributor

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

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 introduces telemetry tracking using PostHog across the SDK. It adds a new _analytics.py module to handle event capture and provides a disable_telemetry utility. Integration points include client initialization, API error handling, and resource creation for agents, datasets, projects, and scans. Feedback focuses on improving the robustness of the telemetry implementation, specifically handling missing API keys in make_distinct_id to prevent crashes, ensuring thread safety during client initialization, and capturing events before raising exceptions in helper methods to ensure complete telemetry coverage.

Comment thread src/giskard_hub/_analytics.py
Comment thread src/giskard_hub/_analytics.py Outdated
Comment thread src/giskard_hub/resources/helpers.py Outdated
Comment thread src/giskard_hub/resources/helpers.py Outdated
@henchaves henchaves self-assigned this Apr 22, 2026
@henchaves henchaves requested review from kevinmessiaen and removed request for kevinmessiaen April 22, 2026 14:15
@henchaves
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 introduces telemetry tracking using PostHog. It adds a new _analytics.py module to handle event capture and opt-out logic, and integrates telemetry calls across the SDK, including client initialization, resource creation, and error handling. Feedback includes correcting a non-existent method call in the PostHog client, adding version constraints for the new dependency, and optimizing environment variable lookups.

Comment thread src/giskard_hub/_analytics.py Outdated
Comment thread pyproject.toml
"distro>=1.7.0, <2",
"rich",
"sniffio",
"posthog",
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

It is recommended to specify a version range for new dependencies to ensure compatibility and prevent breaking changes from future updates. For example, posthog>=3.0.0,<4 if version 3 is the current stable major version.

Suggested change
"posthog",
"posthog>=3.0.0,<4",

Comment thread src/giskard_hub/_analytics.py Outdated
@henchaves henchaves requested a review from kevinmessiaen April 23, 2026 09:22
@henchaves
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 implements anonymous product-usage telemetry using PostHog, including a new _analytics module, documentation for opt-out mechanisms, and integration across the SDK to track client initialization, resource creation, and errors. The review identifies a high-risk security concern where capturing full exception objects could leak sensitive data (PII) to PostHog, recommending sanitized event capture instead. Additionally, feedback suggests evaluating opt-out environment variables dynamically at runtime rather than once at module import to ensure user preferences are correctly respected if modified after the library is loaded.

Comment thread src/giskard_hub/_client.py Outdated
Comment thread src/giskard_hub/_client.py Outdated
Comment thread src/giskard_hub/_analytics.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant