Skip to content

Conversation

@oliverb123
Copy link
Contributor

Many people construct a client instance, rather than using the module methods, and need a way to use that initialised client in the django middleware

@oliverb123 oliverb123 requested review from a team, daibhin and hpouillot July 9, 2025 13:54
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

Added support for custom PostHog client instances in Django middleware through a new POSTHOG_MW_CLIENT setting, enhancing flexibility for users who prefer instance-based client management over module-level methods.

  • Added setting in posthog/integrations/django.py to allow configurable client instance in middleware
  • Updated version from 6.0.3 to 6.0.4 in posthog/version.py for this backward-compatible fix
  • Added documentation in CHANGELOG.md to reflect the new middleware client customization feature

3 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

The context will also auto-capture exceptions and send them to PostHog, unless you disable it by setting
`POSTHOG_MW_CAPTURE_EXCEPTIONS` to `False` in your Django settings.
`POSTHOG_MW_CAPTURE_EXCEPTIONS` to `False` in your Django settings. The exceptions are captured using the
global client, unless the setting `POSTHOG_MW_CLIENT` is set to a custom client instant.
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: 'instant' should be 'instance'

Suggested change
global client, unless the setting `POSTHOG_MW_CLIENT` is set to a custom client instant.
global client, unless the setting `POSTHOG_MW_CLIENT` is set to a custom client instance.

@oliverb123 oliverb123 merged commit c61236b into master Jul 9, 2025
7 checks passed
@oliverb123 oliverb123 deleted the err/custom-client-mw-support branch July 9, 2025 14:06
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