Skip to content

Conversation

@oliverb123
Copy link
Contributor

Figured while I was here we may as well let people use the tagging infrastructure without forcing them to use error tracking - it seems like a nice pattern for using posthog generally.

I do think we should default opt-in to error tracking tho - if we get complaints, we can expose a global config to disable it at the client level, but capturing exceptions in the most deeply nested context means getting the most tags on them, which is the ideal scenario.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Updates scoping functionality in PostHog Python SDK to make error tracking optional while retaining tagging infrastructure.

  • Added new capturing parameter to new_context and scoped functions, defaulting to True for backward compatibility
  • Renamed exported decorator from tracked to scoped in posthog/__init__.py for better clarity
  • Incremented version from 4.7.0 to 4.8.0 to reflect new functionality
  • Maintained tag isolation and context inheritance behavior while making error tracking optional

4 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

yield
except Exception as e:
capture_exception(e)
if capturing:
Copy link
Contributor

Choose a reason for hiding this comment

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

We could default to enable_exception_autocapture if this is not set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, for some reason I thought that was client specific?

Copy link
Contributor

Choose a reason for hiding this comment

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

It can be globally set using the proxy if the customer has configured their setup like

import posthog

posthog.enable_exception_autocapture = True

If that is None we should default (probably to True)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Defaults to False rather than None, sadly :/.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think, given if we deferred to the global setting it'd always be off, it's good enough for now to default to on and let users disable. We can revisit it later, if we decide it's warranted

More broadly, I dislike complex behaviours and global configurations taking precedence over local ones - there may be good reasons a user wants to say "absolutely do not autocapture exceptions at this scope level", and we should respect it, imo.

@oliverb123 oliverb123 enabled auto-merge (squash) June 11, 2025 20:35
@oliverb123 oliverb123 merged commit 9db1b7e into master Jun 12, 2025
6 checks passed
@oliverb123 oliverb123 deleted the err/fix-export-and-allow-no-track branch June 12, 2025 09:29
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.

3 participants