Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add header to Codex API requests for capturing product analytics data #53

Merged
merged 11 commits into from
Mar 7, 2025

Conversation

kelsey-wong
Copy link
Contributor

@kelsey-wong kelsey-wong commented Feb 27, 2025

Key Info

  • PRD: link
  • GitHub issue: link
  • Priority: normal

What changed?

  • Added concept of AnalyticsMetadata which is passed in request headers to Codex API, for the purpose of capturing product analytics about usage; mainly, what integration type (tool or backup) the request is associated with
  • Peripheral changes:
    • Removed legacy utils/project.py and moved into project.py
    • Removed unnecessary mocks from test_codex_tool

What do you want the reviewer(s) to focus on?

  • Do you have any ideas for other metadata that would be helpful to pass?
    • Note: We already have the Python package version in headers (e.g. 'user-agent': 'Codex/Python 0.1.0-alpha.9'), which I do plan on passing to Posthog as well

Checklist

  • Did you link the GitHub issue?
  • Did you follow deployment steps or bump the version if needed?
    • Not yet, will need to do this
  • Did you add/update tests?
  • What QA did you do?
    • Tested by creating a Python notebook and calling Project.query to my local Codex (overrode CODEX_BASE_URL); verified that the headers are passed properly
    • 3/4 9AM: Re-tested by building the package locally and going through a Codex tutorial; headers pass properly to the backend

@kelsey-wong kelsey-wong changed the title Posthog Add header to Codex API requests for capturing product analytics data Mar 3, 2025
@kelsey-wong kelsey-wong marked this pull request as ready for review March 3, 2025 17:12
@kelsey-wong kelsey-wong requested a review from axl1313 March 3, 2025 17:12
@axl1313
Copy link
Collaborator

axl1313 commented Mar 3, 2025

The Python package version we're currently including in headers is from the codex-sdk package right? Should we also include the cleanlab-codex package version?

@axl1313
Copy link
Collaborator

axl1313 commented Mar 3, 2025

The PRD mentions supporting the ability to opt out of telemetry. Seems like that's not addressed here, so wondering if you had a plan for that?

@kelsey-wong
Copy link
Contributor Author

The Python package version we're currently including in headers is from the codex-sdk package right? Should we also include the cleanlab-codex package version?

I'm not including the codex-python version here actually, just tagging that it's from the client library. We already pass the version in headers, e.g.

 'user-agent': 'Codex/Python 0.1.0-alpha.9', 'x-stainless-lang': 'python', 'x-stainless-package-version': '0.1.0-alpha.9', 

Including the cleanlab-codex version is a good idea, I'll make that change!

@kelsey-wong
Copy link
Contributor Author

The PRD mentions supporting the ability to opt out of telemetry. Seems like that's not addressed here, so wondering if you had a plan for that?

The telemetry won't be sent directly from this client library code - it'll be sent from the Codex backend (I'm still in the middle of making that change). So we should be alright on that requirement!

@kelsey-wong
Copy link
Contributor Author

@axl1313 branch is updated and re-tested according to your feedback!

Copy link
Collaborator

@axl1313 axl1313 left a comment

Choose a reason for hiding this comment

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

a couple non-blocking comments, but looks good!

@@ -90,6 +90,13 @@ Automated releases are handled by the [release workflow][release-workflow] which
[hatch-version]: https://hatch.pypa.io/latest/version/#updating
[changelog]: CHANGELOG.md


### How to build and install the package locally
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can also just do pip install -e <local path to repo>

self, *, integration_type: str, package_version: str = package_version, source: str = "cleanlab-codex-python"
):
class IntegrationType(str, Enum):
"""Types of integrations that can use the SDK."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
"""Types of integrations that can use the SDK."""
"""Supported methods for integrating Codex into a RAG system using this library"""

@kelsey-wong kelsey-wong merged commit a8b7419 into main Mar 7, 2025
11 checks passed
@kelsey-wong kelsey-wong deleted the posthog branch March 7, 2025 18:19
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.

2 participants