Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/controllers/admin/ahoy_activities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def index
scope = scope.where(visit_id: params[:visit_id])
end

# Filter by props (full-text search across properties JSON)
if params[:props].present?
term = Ahoy::Event.sanitize_sql_like(params[:props])
scope = scope.where(
"CAST(ahoy_events.properties AS CHAR) LIKE ?",
"%#{term}%"
)
end

# Audience filter
scope = apply_audience_filter(scope)

Expand Down
24 changes: 23 additions & 1 deletion app/views/admin/ahoy_activities/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@
class: "w-full px-3 py-2 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500" %>
</div>

<!-- Visit ID -->
<div class="flex-1 min-w-0">
<label class="block text-sm font-medium text-gray-600 mb-1">
Visit ID
</label>
<%= number_field_tag :visit_id,
params[:visit_id],
placeholder: "e.g. 42",
class: "w-full px-3 py-2 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500" %>
</div>

<!-- Props -->
<div class="flex-1 min-w-0">
<label class="block text-sm font-medium text-gray-600 mb-1">
Props
</label>
<%= text_field_tag :props,
params[:props],
placeholder: "Search properties...",
class: "w-full px-3 py-2 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500" %>
</div>

<!-- User Filter -->
<div class="flex-1 min-w-0">
<label class="block text-sm font-medium text-gray-600 mb-1">
Expand Down Expand Up @@ -90,7 +112,7 @@
<!-- Quick Ranges -->
<div class="flex items-center gap-3 mt-6 text-sm">
<span class="text-gray-500">Quick:</span>
<% safe_params = params.slice(:name, :user_id, :from, :to).to_unsafe_h %>
<% safe_params = params.slice(:name, :visit_id, :props, :user_id, :from, :to).to_unsafe_h %>
<%= link_to "24h",
url_for(safe_params.merge(from: 1.day.ago.to_date)),
class: "text-indigo-600 hover:underline" %>
Expand Down
10 changes: 10 additions & 0 deletions app/views/admin/shared/_active_filters_subheader.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@
<%= label %>
</span>
<% end %>
<% if params[:visit_id].present? %>
<span class="inline-flex items-center px-3 py-1 rounded-full bg-yellow-100 text-yellow-800 font-medium">
Visit: <%= params[:visit_id] %>
</span>
<% end %>
<% if params[:props].present? %>
<span class="inline-flex items-center px-3 py-1 rounded-full bg-purple-100 text-purple-800 font-medium">
Props: <%= params[:props] %>
</span>
<% end %>
</div>
<% end %>