-
Notifications
You must be signed in to change notification settings - Fork 474
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
High level overview for building your own plugin #1467
Conversation
|
||
1. Every plugin acts on a single event coming in. | ||
|
||
2. Plugins act on events before they are stored. |
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.
There's just one problem with this line in that it's not technically true. I'm not sure if this is written like this for simplicity or just in error. However some plugins act on events before they are stored. Some plugins act on events at the same time that the event is being stored.
Basically:
event = await getNextEvent()
event = await processEvent1(event)
event = await processEvent2(event)
await Promise.all([
storeEventInDatabase(event),
onEvent1(event),
onEvent2(event),
])
This means also that the figure for the GeoIP plugin example is correct, but the one for the S3 plugin is not. It goes into S3 and our db at the same time, two parallel arrows.
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.
Indeed, that's right! I wanted to emphasise how some special functions mutate and others don't.
I think it's a technical detail that doesn't add extra information from the user's perspective? (i.e., I don't think knowing this will help them make better plugins? / understand plugins?)
I could do a footnote saying how this isn't exactly 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.
I guess a footnote would suffice. The only technically important thing to clarify here is that even if an onEvent
fails, the event still ends up in the database (as they are running in parallel). Otherwise people might get the wrong idea, and believe that a failure here will block the event.
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.
Hmm, makes sense, that's the crux: there's no data loss. I'll highlight that here, and skip the footnote about the extra technical details.
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.
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.
I've made a note to add this bit in the developer reference, but not in the high level overview.
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.
This is great! I like the structure and love how this takes me on a journey from the very basics.
Left a bunch of minor inline comments, but nothing particularly major.
One thing I'm not a fan of are the images. First, they're not transparent nor a neutral color that works in both light and dark mode. Second, I can't read what's going on. Third, they're not particularly beautiful (in comparison to our website images as a whole). Could be worth getting @lottiecoxon to quickly give this a look? I'm also happy to help
|
||
For example, you can send an event to AWS S3 whenever you see it in PostHog. Indeed, the [S3 plugin](https://posthog.com/plugins/s3-export) does exactly that. In this case, it doesn't matter if the S3 export succeeds or not, the event will always be stored. | ||
|
||
![S3 Plugin Example](../../../images/plugins/s3-plugin-example.png) |
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.
this image is a bit wrong, as it gives me processEvent
vibes. I'd personally prefer 2 arrows coming out of the event, one going via the plugin to S3, and the other to the DB
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.
Hmmmm, as a reader I feel that to be more confusing: how/why did the event go to both places?
I think if I remove the second event from the diagram, it feels closer to onEvent
?
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.
I really do think this raises more questions than it answers.
Disregarding how things actually happen, a good model helps people reason about the system without knowing exactly what's happening in the system. And I think all people need to know is that it's like processEvent
, but the return value doesn't matter, so they can do all sorts of "side stuff" with onEvent
.
|
||
#### Plugin Naming Conventions | ||
|
||
When creating your repository, follow the naming convention of `posthog-<plugin-name>-plugin`. For example, the hello world plugin repository would be called `posthog-hello-world-plugin`. |
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.
I wonder how people will feel given a lot of our plugins don't follow this
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.
Should be fine still, just wondering
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.
Precisely why I want to have this section, so that atleast starting from now all plugins follow this convention
Regarding the images, (1) and (3) make sense. For (2) - I'd expect people to click on the image to see the high res one with all details. Did this not feel obvious? |
Hiya! Are there any remaining concerns which stop us from publishing these changes? I'll put in a design request to polish the images. Regarding what the images should have: @mariusandra @yakkomajuri - does this comment help alleviate concerns? #1467 (comment) |
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.
I'm happy to get this in the name of iteration.
It's great stuff, I'd just like the images to at least be transparent (plus a few other tweaks mentioned above)
Sounds good! I should've gotten to all the tweaks, except for the images, in aff2114 |
Changes
Did a first pass through this, capturing feedback before I polish this further.
FigJam for the images: GeoIP - https://www.figma.com/file/luaMsTScYN1fMoYliEfjrq/Plugin-Events?node-id=0%3A1
And S3 - https://www.figma.com/file/rr8QlwmSceKRaUq3Cg5vs1/Plugin-Events-External
Not sure if worth getting these made better via the great @lottiecoxon ^
Checklist