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

Adds backend instrumentation to actions & cohorts #2887

Merged
merged 6 commits into from Jan 10, 2021

Conversation

paolodamico
Copy link
Contributor

Changes

Closes #1575.

  • Implements action created & action updated server-side events with a bunch of metadata.
  • Implements cohort created & cohort updated events.
  • Removes some unused imports & other flake cleanup.

Particularly worth noting that there are no {action|cohort} deleted events because we currently only support soft-deleting these, which woudl trigger a {action|cohort updated event with a deleted = True attribute.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests

@timgl timgl temporarily deployed to posthog-cohorts-action--jje3bf January 8, 2021 02:02 Inactive
@@ -61,6 +61,24 @@ class Cohort(models.Model):

objects = CohortManager()

def get_analytics_metadata(self):
action_groups_count: int = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: imo cleaner:

action_groups_count = len(1 for group in self.groups if group.has("action_id"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed it's cleaner, but then we're doing 2n instead of n loop sequences because we would need one for each action & properties. I did optimize the code a bit based on this suggestion.

@timgl timgl temporarily deployed to posthog-cohorts-action--jje3bf January 10, 2021 21:37 Inactive
@paolodamico paolodamico merged commit a130784 into master Jan 10, 2021
@paolodamico paolodamico deleted the cohorts-action-instrumentation branch January 10, 2021 22:03
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.

Improve core action tracking
3 participants