Make segment tracking more explicit
Problem
We're moving away from using ja_resource and canary through #864
This makes controllers and authorization policies much more explicit and easier to follow.
However, segment tracking still relies on a plug which does it's tracking through inference of actions. We should make this explicit as well, by moving the code into controllers.
Additionally, all we should ensure all API actions which are supposed to call segment tracking actually do so.
Blocked, partially, by #864
In addition to the above, I'm thinking we should write assertion helpers which are more explicit, such as assert_segment_tracked(current_user, action, resource)
I'm moving this out of the milestone. The changes in the milestone should serve as an example of what we want here, but this specific task is not directly related.
I'm also tagging it as "needs clarification".
I'll tackle a controller when I get the chance, so it becomes clearer what we have to do. Then I'll do a write up and create individual issues.
@begedin what is the status of this?
@joshsmith Still in progress, I'm afraid. We've veered off of the implicit tracking in newer controller actions, but several older ones still use implicit tracking via the plug:
# lib/code_corps/analytics/segment_tracking_support.ex
def includes?(:create, %CodeCorps.Comment{}), do: true
def includes?(:update, %CodeCorps.Comment{}), do: true
def includes?(:create, %CodeCorps.DonationGoal{}), do: true
def includes?(:update, %CodeCorps.DonationGoal{}), do: true
def includes?(:create, %CodeCorps.ProjectUser{}), do: true
def includes?(:update, %CodeCorps.ProjectUser{}), do: true
def includes?(:create, %CodeCorps.StripeConnectAccount{}), do: true
def includes?(:create, %CodeCorps.StripeConnectCharge{}), do: true
def includes?(:create, %CodeCorps.StripeConnectPlan{}), do: true
def includes?(:create, %CodeCorps.StripeConnectSubscription{}), do: true
def includes?(:create, %CodeCorps.StripePlatformCard{}), do: true
def includes?(:create, %CodeCorps.StripePlatformCustomer{}), do: true
def includes?(:create, %CodeCorps.User{}), do: true
def includes?(:update, %CodeCorps.User{}), do: true
def includes?(:create, %CodeCorps.UserCategory{}), do: true
def includes?(:delete, %CodeCorps.UserCategory{}), do: true
def includes?(:create, %CodeCorps.UserRole{}), do: true
def includes?(:delete, %CodeCorps.UserRole{}), do: true
def includes?(:create, %CodeCorps.UserSkill{}), do: true
def includes?(:delete, %CodeCorps.UserSkill{}), do: true
def includes?(:create, %{token: _, user_id: _}), do: true
def includes?(_, _), do: false
We should split these off into smaller issues, possibly even convert this issue into a milestone