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(plugin-server): project_id in clickhouse_events_json #25873

Merged
merged 6 commits into from
Nov 4, 2024

Conversation

Twixes
Copy link
Member

@Twixes Twixes commented Oct 29, 2024

Problem

To do project-based taxonomy, rather than team-based, property-defs-rs needs to be getting project_id as part of event payloads. To do this, I propose we start including property project_id in the clickhouse_events_json topic's payloads.

Changes

We're now adding project_id right before producing events to clickhouse_events_json.

We are not using this project_id anywhere yet. The only place I'm planning to use it is property-defs-rs in a follow-up PR.

How did you test this code?

I saw we don't have any plugin server tests observing the clickhouse_events_json topic – all event processing tests fetch from ClickHouse instead. That's all good for most cases, except this particular one, as project_id is specifically key in Kafka payloads and ignored in ClickHouse.

Hence added Kafka observation to plugin-server/tests/worker/ingestion/process-event.test.ts – inspired by plugin-server/functional_tests/scheduled-tasks-runner.test.ts – and added a project_id assertion based on that.

@Twixes Twixes requested a review from oliverb123 October 29, 2024 14:56
@Twixes Twixes force-pushed the clickhouse-events-json-project branch from 97f98ce to c0345d0 Compare October 29, 2024 15:00
const { eventUuid: uuid, event, teamId, distinctId, properties, timestamp } = preIngestionEvent

let team = this.teamManager.getCachedTeam(teamId)
Copy link
Contributor

@oliverb123 oliverb123 Oct 30, 2024

Choose a reason for hiding this comment

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

Not blocking, but this feels a bit like spooky action at a distance - is there any chance we could do this in the populateTeamData step instead, where we know we're already fetching the team? I know that'd require a bit more wiring, but I'd prefer the "larger" change here I think

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Have rewritten to avoid any extra teamManager calls. Now we set the project_id here: https://github.com/PostHog/posthog/pull/25873/files#diff-51ee2dd21f9a70e91c6e2bf4a0c856040b7f5b7708cbea1c5d674fe1bd92b843R190

@Twixes Twixes requested a review from a team as a code owner October 31, 2024 15:21
@Twixes Twixes force-pushed the clickhouse-events-json-project branch from ea6b373 to 47ca021 Compare October 31, 2024 17:07
Base automatically changed from group-type-project to master October 31, 2024 23:12
An error occurred while trying to automatically change base from group-type-project to master October 31, 2024 23:12
@Twixes Twixes force-pushed the clickhouse-events-json-project branch from 47ca021 to 4e41d8a Compare October 31, 2024 23:13
@Twixes Twixes enabled auto-merge (squash) November 4, 2024 12:02
@Twixes Twixes disabled auto-merge November 4, 2024 12:03
@Twixes Twixes requested a review from oliverb123 November 4, 2024 12:03
@Twixes Twixes enabled auto-merge (squash) November 4, 2024 16:46
@Twixes Twixes disabled auto-merge November 4, 2024 16:46
@Twixes Twixes merged commit bfceab6 into master Nov 4, 2024
89 checks passed
@Twixes Twixes deleted the clickhouse-events-json-project branch November 4, 2024 22:39
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