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

PostHog events & groups first pass #1922

Merged
merged 8 commits into from
Apr 11, 2023
Merged

PostHog events & groups first pass #1922

merged 8 commits into from
Apr 11, 2023

Conversation

joepavitt
Copy link
Contributor

@joepavitt joepavitt commented Apr 5, 2023

Description

  • New product.js service added to provide a centralised resource for calling PostHog. Also handles the case where no PostHog is configured or exists

Identify:

  • Now when a user logs in, we also record a ff-cloud-user: true and ff-cloud-joined: <utc-timestamp> against the Person object, as currently we rely on email and username existing to infer this, which is reliable, but may not be guaranteed.
  • We can also easily backdate this Person data using PostHog in Node-RED

Events Added:

  • $ff-application-created
  • $ff-application-deleted
  • $ff-instance-created
  • $ff-instance-deleted
  • $ff-device-created
  • $ff-device-deleted
  • $ff-snapshot-created
  • $ff-snapshot-deleted
  • $ff-team-created
    • Although, currently this is not triggered when a team is auto-created on sign-up as this is done server-side.
  • $ff-team-deleted
  • $ff-invite-sent
  • $ff-invite-removed
  • $ff-invite-accepted
  • $ff-invite-rejected
  • $ff-user-registered

Group Calls:

  • team group is identified whenever the getTeam function is called, this then updates the PH group with number of instances, applications members, etc.
  • application group is called upon instance creation, and currently only updated on deletion
  • instance group is called upon instance creation, and currently only updated on deletion
  • device group is called upon instance creation, and currently only updated on deletion

I have opted to architect this such that additional fields are required to pass to the services, e.g. team/application ids, then all of the PH logic is centralised to the services, rather than needing to be built on each page the functions/services are used.

Related Issue(s)

Closes #1904

Checklist

@joepavitt
Copy link
Contributor Author

joepavitt commented Apr 5, 2023

Other events I think we still want to capture here for pipeline/funnel analysis:

  • $ff-instance-suspended
  • $ff-instance-started

Features/events we cannot easily hook into are related to the Team Library, as that management is done via the Node-RED tooling. Similarly, any snapshots created via the NR Tools plugin, would also not get picked up.

billing-specific events too would be handy, but not 100% where to tag these in, specifically where we can rely on these from the Stripe callbacks:

  • $ff-billing-added
  • $ff-billing-removed

We do get the billing state from a team already though. Which will persists the trial fields beyond the trial no longer being valid, meaning we will be able to do trial conversion analysis

* @param {Object} proeprties - a JSON object defining features for this group, all can be overriden
*/
function groupUpdate (type, id, properties) {
capture('$groupidentify', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for context on this: PostHog/posthog-js#600

currently, in the client-side JS library, we cannot call just a groupIdentify, the client JS group() function currently sets a session variable such that all future events are bound to that group, which we do not want. In speaking with the dev team at PostHog (see the linked Slack thread) they informed me that I can just do this instead.

@Pezmc Pezmc mentioned this pull request Apr 6, 2023
2 tasks
@Pezmc
Copy link
Contributor

Pezmc commented Apr 11, 2023

@joepavitt And I went over this PR on Friday. I'm happy for this to move forward.

@joepavitt
Copy link
Contributor Author

@Pezmc fyi - got a couple of little extras to add in given the Trial effectiveness analysis I was doing end of last week

@joepavitt joepavitt marked this pull request as ready for review April 11, 2023 10:58
@joepavitt
Copy link
Contributor Author

@MarianRaphael this is good to go and has sign off code-side, but want your eyes on the list above too to make sure no obvious ones missed.

RE: the project suspended, started, I'll be putting those in now

@joepavitt joepavitt merged commit 7273b21 into main Apr 11, 2023
@joepavitt joepavitt deleted the 1904-ph-events branch April 11, 2023 15:15
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.

PostHog: Custom data & events review
3 participants