-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: manual exception capture calls #31135
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
chore: manual exception capture calls #31135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR centralizes exception handling by replacing direct Sentry SDK calls with PostHog's own exception capture implementation.
- Modified
posthog/exceptions_capture.py
to remove Sentry integration, focusing solely on PostHog's analytics exception capture with a newproperties
parameter - Changed import sources across multiple files from
sentry_sdk.capture_exception
to a custom implementation inposthog.exceptions
- Renamed parameter
extras
toproperties
in allcapture_exception
calls in RBAC migration files - Potential issue with import path in
rbac_feature_flag_migration.py
which may need to be a relative import from a PostHog module - Standardized exception capturing approach across the codebase while maintaining the same error handling functionality
6 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
posthog/email.py
Outdated
@@ -11,7 +11,7 @@ | |||
from django.template.loader import get_template | |||
from django.utils import timezone | |||
from django.utils.module_loading import import_string | |||
from sentry_sdk import capture_exception | |||
from exceptions import capture_exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The import path from exceptions import capture_exception
appears incorrect. Based on the context, this should likely be from posthog.exceptions_capture import capture_exception
since 'exceptions' is not a standard Python module and the custom implementation is likely in the posthog package.
posthog/api/organization.py
Outdated
@@ -33,7 +33,7 @@ | |||
from rest_framework.decorators import action | |||
from posthog.rbac.migrations.rbac_team_migration import rbac_team_access_control_migration | |||
from posthog.rbac.migrations.rbac_feature_flag_migration import rbac_feature_flag_role_access_migration | |||
from sentry_sdk import capture_exception | |||
from exceptions import capture_exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The import should be from posthog.exceptions_capture import capture_exception
based on the file structure shown in the context. The current import path may cause import errors.
@@ -5,7 +5,7 @@ | |||
from ee.models.rbac.role import Role | |||
from django.db import transaction | |||
import structlog | |||
from sentry_sdk import capture_exception | |||
from exceptions import capture_exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: The import path 'exceptions' appears incorrect. Based on other files in the codebase, this should likely be 'posthog.exceptions_capture' or similar. An incorrect import path will cause the migration to fail when executed.
@@ -3,7 +3,7 @@ | |||
from ee.models.explicit_team_membership import ExplicitTeamMembership | |||
import structlog | |||
from posthog.models.organization import Organization, OrganizationMembership | |||
from sentry_sdk import capture_exception | |||
from exceptions import capture_exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Import should be from posthog.exceptions_capture
instead of just exceptions
. This will likely cause an ImportError since there's no top-level exceptions
module.
from exceptions import capture_exception | |
from posthog.exceptions import capture_exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big moves
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
Size Change: -203 kB (-1.51%) Total Size: 13.2 MB
|
…ub.com:PostHog/posthog into dn-chore/update-manual-exception-capture-calls
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
…ub.com:PostHog/posthog into dn-chore/update-manual-exception-capture-calls
from posthoganalytics import api_key, capture_exception as posthog_capture_exception | ||
import structlog | ||
|
||
logger = structlog.get_logger(__name__) | ||
|
||
sentry_capture_exception(error, scope=sentry_scope, **sentry_scope_kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmarticus I dug a little further and it looks like removing this line is what is causing the number of query assertions to fail under the hood. Don't exactly know why but it feels like a pretty safe change to make. Going to update the test and merge this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we replace frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx
and get rid of unused deps as well ?
@@ -120,9 +120,9 @@ export const Settings = ({ | |||
} | |||
|
|||
return ( | |||
<ErrorBoundary> | |||
<PostHogErrorBoundary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
More generic exception capture