A bit different from #57020 as this is more of an in-app thing.
CSMs/AEs should be alerted whenever the accounts they manage have a usage spike. We currently detect these spikes in our billing system and even send out emails for customers letting them know.
In parallel, we have the concept of in-app notifications in PostHog. When you're assigned a support ticket or @-mentioned in a comment, you get a notification.
This issue is pretty much stitching those two together in the accounts context.
Implementation details
This will involve changes both in billing and posthog repos. Decided to leverage the SQS communication via BillingConsumer rather than a webhook call, as it is async, resilient and requires no new auth surface.
Billing
Emit a new message to SQS in detect_spikes Celery task, alongside the analytics event. We don't want the conditional logic from email to be here. Let's over-notify to start with. This is pretty much all the change needed in billing.
PostHog
- Update
BillingConsumer to process usage_spike_detected message type
- Add
usage_spike notification type to NotificationEvent model
- Create a service to notify folks
- Find account (organization_id == external_id)
- Find account csm/executive
- Build notification payload
- Create
NotificationEvent from spike data
A bit different from #57020 as this is more of an in-app thing.
CSMs/AEs should be alerted whenever the accounts they manage have a usage spike. We currently detect these spikes in our billing system and even send out emails for customers letting them know.
In parallel, we have the concept of in-app notifications in PostHog. When you're assigned a support ticket or @-mentioned in a comment, you get a notification.
This issue is pretty much stitching those two together in the accounts context.
Implementation details
This will involve changes both in billing and posthog repos. Decided to leverage the SQS communication via
BillingConsumerrather than a webhook call, as it is async, resilient and requires no new auth surface.Billing
Emit a new message to SQS in
detect_spikesCelery task, alongside the analytics event. We don't want the conditional logic from email to be here. Let's over-notify to start with. This is pretty much all the change needed in billing.PostHog
BillingConsumerto processusage_spike_detectedmessage typeusage_spikenotification type toNotificationEventmodelNotificationEventfrom spike data