-
Notifications
You must be signed in to change notification settings - Fork 462
[chore] Clean up logs #3511
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
base: release/v0.80.4
Are you sure you want to change the base?
[chore] Clean up logs #3511
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
| posthog.capture( | ||
| distinct_id=distinct_id, | ||
| event="$identify", | ||
| properties={ | ||
| "$set_once": { | ||
| property_name: True, |
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.
🔴 Incorrect PostHog API usage: posthog.capture(event="$identify") instead of posthog.identify()
The change replaces the proper posthog.identify() API call with posthog.capture(event="$identify"). While $identify is a special event in PostHog, the identify() method is the correct SDK function for setting person properties.
Original code:
posthog.identify(
distinct_id=distinct_id,
properties={
"$set_once": {
property_name: True,
}
},
)New code:
posthog.capture(
distinct_id=distinct_id,
event="$identify",
properties={
"$set_once": {
property_name: True,
}
},
)The posthog.identify() method has special handling for person property operations like $set_once. When using capture() directly, the properties parameter is treated as event properties, not person properties. The $set_once modifier nested inside properties may not be processed correctly by PostHog's ingestion pipeline.
Impact: Activation properties (like activated_prompt_management, activated_observability, etc.) may fail to be set on user profiles in PostHog, breaking activation tracking analytics.
(Refers to lines 86-94)
Recommendation: Revert to using posthog.identify() which is the proper SDK method for setting person properties:
posthog.identify(
distinct_id=distinct_id,
properties={
"$set_once": {
property_name: True,
}
},
)Was this helpful? React with 👍 or 👎 to provide feedback.
| except HTTPException as exc: | ||
| log.error("%s: %s", exc.status_code, exc.detail) | ||
| # Only log server errors (5xx), not client errors like 401/403 | ||
| if exc.status_code >= 500: | ||
| log.error("%s: %s", exc.status_code, exc.detail) | ||
| # elif 400 <= exc.status_code < 500: | ||
| # log.warn("%s: %s", exc.status_code, exc.detail) | ||
|
|
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.
🚩 Auth middleware logging reduction may impact debugging
The change at auth_service.py:122-127 stops logging 4xx HTTP errors (401, 403, 404, etc.) and only logs 5xx server errors. While this reduces log noise from normal client errors (invalid tokens, forbidden access), it could make it harder to investigate:
- Brute force or credential stuffing attacks (many 401s)
- Permission escalation attempts (403s)
- Suspicious patterns of 4xx errors
The commented-out code suggests the team considered logging 4xx at warn level. For security-sensitive applications, some level of 4xx logging (even sampled) can be valuable for detecting attacks.
Was this helpful? React with 👍 or 👎 to provide feedback.
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.
Looks intended but just in case
| try: | ||
| # Set the property using PostHog's $set_once (idempotent) | ||
| posthog.identify( | ||
| posthog.capture( |
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.
why this change?
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.
ncorrect PostHog API usage: posthog.capture(event="$identify") instead of posthog.identify()
The change replaces the proper posthog.identify() API call with posthog.capture(event="$identify"). While $identify is a special event in PostHog, the identify() method is the correct SDK function for setting person properties.
Original code:
posthog.identify(
distinct_id=distinct_id,
properties={
"$set_once": {
property_name: True,
}
},
)
New code:
posthog.capture(
distinct_id=distinct_id,
event="$identify",
properties={
"$set_once": {
property_name: True,
}
},
)
The posthog.identify() method has special handling for person property operations like $set_once. When using capture() directly, the properties parameter is treated as event properties, not person properties. The $set_once modifier nested inside properties may not be processed correctly by PostHog's ingestion pipeline.
Impact: Activation properties (like activated_prompt_management, activated_observability, etc.) may fail to be set on user profiles in PostHog, breaking activation tracking analytics.
Recommendation
Revert to using posthog.identify() which is the proper SDK method for setting person properties:
posthog.identify(
distinct_id=distinct_id,
properties={
"$set_once": {
property_name: True,
}
},
)
| except HTTPException as exc: | ||
| log.error("%s: %s", exc.status_code, exc.detail) | ||
| # Only log server errors (5xx), not client errors like 401/403 | ||
| if exc.status_code >= 500: | ||
| log.error("%s: %s", exc.status_code, exc.detail) | ||
| # elif 400 <= exc.status_code < 500: | ||
| # log.warn("%s: %s", exc.status_code, exc.detail) | ||
|
|
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.
Looks intended but just in case
Uh oh!
There was an error while loading. Please reload this page.