Skip to content
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

feat: CDP Internal events processor #27007

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

benjackwhite
Copy link
Contributor

@benjackwhite benjackwhite commented Dec 18, 2024

Problem

We want to trigger CDP destinations via "internal events".

This sets up the internal events stream and service to process it.

Changes

  • New consumer to consume from new topic
  • Proper event validation with Zod
  • Uses new hog function types for loading from the DB
  • Make these internal hog functions source-closed so that we can control updates
  • Disables a bunch of messaging stuff for now (I will fix in follow up but given that is all pre-alpha code I don't want to waste time on it right now)

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

@benjackwhite benjackwhite changed the title feat: Started adding internal events topic feat: CDP Internal events processor Dec 18, 2024
@benjackwhite benjackwhite marked this pull request as ready for review December 18, 2024 15:19
export type HogFunctionTypeType =
| 'destination'
| 'transformation'
| 'internal-destination'
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we say that the type would be more specific (e.g. error_tracking_alert) and just make the Kafka topic generic. I'm easy either way

Comment on lines +5 to +13
event: z.object({
uuid: z.string(),
event: z.string(),
// In this context distinct_id should be whatever we want to use if doing follow up things (like tracking a standard event)
distinct_id: z.string(),
properties: z.record(z.any()),
timestamp: z.string(),
url: z.string().optional(),
}),
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably have a much better grasp on this than me but are we "hacking the system" in any way by reusing the name event here?

When pushing to Kafka we can absolutely use the event that triggered the error tracking issue to be created as the value for most of these properties but I'm guessing we should be using the issue itself instead. E.g. we should push something like:

...
event: z.object({
        uuid: issue.id,
        event: "$$error_tracking_issue_created",
        distinct_id: uuidv4(),
        properties: { name: issue.name, description: issue.description, event: processed_event },
        timestamp: issue.created_at,
        url: `https://us.posthog.com/error_tracking/${issue.id}`,
    }),

The event within properties is totally optional but maybe it'd be worth adding

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.

2 participants