-
Notifications
You must be signed in to change notification settings - Fork 18
Expand ahoy #835
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
Expand ahoy #835
Conversation
jmilljr24
left a 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.
Good stuff!
I see there is a start with the action_policy stuff. I can finish it off in another PR if its too much to include in this one.
| - To see your data | ||
| - The home page will show Workshops, CommunityNews, Resources, Events, and Stories | ||
| - The [Admin Dashboard](http://localhost:3000/dashboard/admin) provides CRUD access for most models | ||
| - The [Admin Home](http://localhost:3000/admin) provides CRUD access for most models |
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.
"Admin Dashboard" wasn't accurate since it doesn't have any analytics on it. And also since we use the word Dashboard a lot wrt the old site, it seemed smart to change this to "Admin Home" instead.
|
|
||
| it "denies access to analytics page" do | ||
| get "/admin/analytics" | ||
| get "/admin/activities/counts" |
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.
analytics was a little too vague. this is really just rolling up ahoy event (user activity) counts.
| gem "dotenv-rails" | ||
| gem "faker" | ||
| gem "factory_bot_rails" | ||
| gem "launchy" |
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.
| gem "launchy" |
This is in group :test already.
| @@ -0,0 +1,9 @@ | |||
| class AddResourceDimensionsToAhoyEvents < ActiveRecord::Migration[8.1] | |||
| def change | |||
| add_column :ahoy_events, :resource_type, :string | |||
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.
ahoy by default stuffs everything into properties, but since we're querying and running charts, i wanted to pull some data into columns
| get "contact_us", to: "contact_us#index" | ||
| post "contact_us", to: "contact_us#create" | ||
| get "dashboard/admin", to: "dashboard#admin" | ||
| get "dashboard/recent_activities", to: "dashboard#recent_activities" |
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.
these didn't belong in DashboardController. that should only run the site home page.
config/routes.rb
Outdated
| get "/", to: "home#index" | ||
| get "activities", to: "ahoy_activities#index", as: "activities" | ||
| get "activities/charts", to: "ahoy_activities#charts", as: "activities_charts" | ||
| get "activities/recent", to: "ahoy_activities#recent", as: "activities_recent" |
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.
still on the fence about /activities/recent since that content is now at /activities/. still might be good to have a separate, faster page that's just pulling most recent 50 activities.
| @@ -0,0 +1,6 @@ | |||
| Geocoder.configure( | |||
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 needed for the charts, incl the "Top Cities". maxmind requires you to store this mmdb file locally, so that's why it's referring to that file on line 4.
| # customize Ahoy::Event to extract resource dimensions from properties | ||
| Rails.application.config.to_prepare do | ||
| Ahoy::Event.class_eval do | ||
| before_validation :extract_resource_dimensions, on: :create |
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 callback is needed in order to populate those extra fields on ahoy events table
|
|
||
| <%= render "tagged_items_carousel", items: items %> | ||
|
|
||
| <div class="mt-6 text-right"> |
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.
ux update while i was there. added a linked text in bottom right so it functions just like the site landing page.
|
|
||
| </button> | ||
| <!-- Dropdown menu --> | ||
| <div |
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 rearranging user dropdown. this must be coming from rebase.
| @@ -15,30 +15,30 @@ | |||
| <div class="row"> | |||
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.
all changes in this file are rubocop
| @@ -19,7 +19,7 @@ | |||
| <%= f.hidden_field :type %> | |||
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.
rubocop changes in this file
| <div class="flex-1 min-w-[220px]"> | ||
| <%= f.input :category_type_id, | ||
| label: "Category Type", | ||
| required: 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.
this is required by validation but was missing from form
| ) | ||
|
|
||
|
|
||
| Rails.logger.info({ |
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.
decided not to create ahoy events for notifications. so, adding to logs for visibility.
| @@ -0,0 +1,22 @@ | |||
| # app/services/analytics/lifecycle_buffer.rb | |||
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 needed so we don't have to pollute models w ahoy logic
| # app/services/analytics/event_builder.rb | ||
| module Analytics | ||
| class EventBuilder | ||
| def self.lifecycle(action, resource, user: nil) |
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 needed so we can append the custom data to our custom ahoy fields (resource_type, resource_id, resource_title)
| end | ||
|
|
||
| def safe_for_tracking?(attribute) | ||
| !attribute.match?(/password|token|secret|key|digest|salt|otp/i) |
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.
don't store these fields in ahoy
…Add ahoy charts that required geo gems.
…cludes/joins bc joins doesn't preload.
…or AS records. only capture after_update if true update and not a create.
|
yes please, @jmilljr24 ! |
What is the goal of this PR and why is this important?
Add more events to ahoy activity tracking. Rearrange admin and activity-related files. Surface ahoy events on a new charts page.
track_lifecycle_eventwithout littering all controllersbrowse.taggingsand also to capture search queries on Workshops and ResourcesHow did you approach the change?
already_tracked?to prevent duplicate activities from being created as Events within the same VisitAnything else to add?