diff --git a/app/controllers/admin/ahoy_activities_controller.rb b/app/controllers/admin/ahoy_activities_controller.rb index bbde0a21f..593ff8e5e 100644 --- a/app/controllers/admin/ahoy_activities_controller.rb +++ b/app/controllers/admin/ahoy_activities_controller.rb @@ -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) diff --git a/app/views/admin/ahoy_activities/index.html.erb b/app/views/admin/ahoy_activities/index.html.erb index 40f817eb7..541824be7 100644 --- a/app/views/admin/ahoy_activities/index.html.erb +++ b/app/views/admin/ahoy_activities/index.html.erb @@ -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" %> + +
+ + <%= 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" %> +
+ + +
+ + <%= 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" %> +
+