code-corps-api icon indicating copy to clipboard operation
code-corps-api copied to clipboard

Make segment tracking more explicit

Open begedin opened this issue 8 years ago • 5 comments

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.

begedin avatar Sep 13 '17 10:09 begedin

Blocked, partially, by #864

begedin avatar Sep 13 '17 10:09 begedin

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)

begedin avatar Sep 14 '17 06:09 begedin

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 avatar Oct 15 '17 14:10 begedin

@begedin what is the status of this?

joshsmith avatar Dec 31 '17 16:12 joshsmith

@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

begedin avatar Jan 02 '18 13:01 begedin