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): handle process_person=false #21262

Merged
merged 4 commits into from
Apr 5, 2024
Merged

Conversation

bretthoerner
Copy link
Contributor

@bretthoerner bretthoerner commented Apr 1, 2024

Problem

We need to support $process_person=false by not handling person properties, groups, and by dropping some fields from the event.

Note that we also need to skip some plugins, but that doesn't depend on this code and will be coming separately.

Changes

First, I'm not in love with where I had to squeeze things in. We want to get this out soon, so I can't afford to do the refactoring that I'd like to do. I do think a lot of this will become cleaner in the next phase, when (I think) the person object becomes optional and so we aren't passing around the extra bool to most steps, we just do work based on whether or not a real person object exists or not.

Anyway, changes:

  • Early on in event processing (runner.ts) extract the proper processPerson boolean that is used for the rest of event processing
  • Pass that processPerson down so that we:
    • Don't lookup or update person properties in PG
    • Don't add person properties to the event
    • Drop $set and related properties
    • Drop certain events like $identify with an ingestion warning
    • Don't update groups or add group related columns

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

Yes.

How did you test this code?

Updated existing and added more.

@bretthoerner bretthoerner force-pushed the brett/personless branch 16 times, most recently from bb714cb to 35753a7 Compare April 3, 2024 22:14
@bretthoerner bretthoerner requested a review from a team April 3, 2024 22:24
@bretthoerner
Copy link
Contributor Author

bretthoerner commented Apr 4, 2024

Oh, this one was unrelated but seems costly. I think by my count we were proactively serializing the whole event 6 times per full processing loop? I'm hoping I'm JSing wrong again. :)
e15a798

Comment on lines +232 to +238
// TODO: Move this into `normalizeEventStep` where it belongs, but the code structure
// and tests demand this for now.
for (let groupTypeIndex = 0; groupTypeIndex < this.db.MAX_GROUP_TYPES_PER_TEAM; ++groupTypeIndex) {
const key = `$group_${groupTypeIndex}`
delete properties[key]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm my understanding: we're removing group properties from the event here to match what we do for $set and friends, correct?
But we keep group info, then we'll want to have these here.
I'd propose that we move everything groups into a separate step and handle it all there and not do anything within normalizeEventStep - because later we might want to make that also look at their add-on selection - i.e. skip group properties if they have disabled that add-on

Copy link
Contributor Author

@bretthoerner bretthoerner Apr 4, 2024

Choose a reason for hiding this comment

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

I agree we should refactor to have a group processing step.

But I'm not sure I follow these parts:

But we keep group info, then we'll want to have these here.
i.e. skip group properties if they have disabled that add-on

I thought for $process_person=false we want don't want to process Group stuff at all? So I'm avoiding doing any Group lookups or adding Group fields. I can't tell if you're saying we want to do (some?) Group stuff for $process_person=false events?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a separate follow-up I think we should do, sorry for the confusion here.
What I'm thinking is

  1. we move all group stuff into a separate step
  2. we make that step be ignored if $process_person=false or group analytics addon is disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah OK, agreed!

delete event.$set_once
delete properties.$set
delete properties.$set_once
delete properties.$unset
Copy link
Contributor

Choose a reason for hiding this comment

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

is event.$unset a thing also?

Copy link
Contributor Author

@bretthoerner bretthoerner Apr 4, 2024

Choose a reason for hiding this comment

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

I was going by what's on the type, but it appears we don't expect one. And we only read it from within properties.

I can delete event['$unset'] to be safe if we want.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see, might be good to do that for consistency indeed (in case someone changes something later somewhere else)

delete properties.$set
delete properties.$set_once
delete properties.$unset
properties.$process_person = false
Copy link
Contributor

@tiina303 tiina303 Apr 4, 2024

Choose a reason for hiding this comment

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

Maybe we either always keep it or always remove it, atm we keep if false and remove otherwise

Copy link
Contributor Author

@bretthoerner bretthoerner Apr 4, 2024

Choose a reason for hiding this comment

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

That's what I chose to do yeah, I'm up for either. My thinking was it feels weird to add properties to every event when they aren't sending it, and true is the default. (We also have the person_mode column.)

If we'd rather always add it to every event, I can definitely do that. Will it not throw current users off to see a new $process_person=true property on every event?

Copy link
Contributor

Choose a reason for hiding this comment

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

how about we just always remove it?

@bretthoerner bretthoerner force-pushed the brett/personless branch 5 times, most recently from ac9caab to 13c8aa2 Compare April 4, 2024 20:46
@bretthoerner bretthoerner merged commit ea05d8e into master Apr 5, 2024
77 checks passed
@bretthoerner bretthoerner deleted the brett/personless branch April 5, 2024 14:34
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.

3 participants