Expand my Community achievements bar.

Activity Logging for Omnisearch similar to Day CQ DAM Event Recorder (om.day.cq.dam.core.impl.DamEventRecorderImpl)

Avatar

Level 2

The Day CQ DAM Event Recorder OSGi bundle provides activity logging on the user's /home/user/ folder in a node like the following: 

/home/users/O/OO/activities/dam/2024/04/24/xxx

... and contains information that we can later write activity reports on (who uploaded or published what and when, etc)

 

What would be the best way to do something similar with site Omnisearch asset searches, say for instance to be able to report on what users were searching for in the DAM? Basically when the user runs a search from the DAM Assets interface, I want to log the search term they used to a node off of their /home/users/nnn/activities/ folder.

 

I considered listening for events but Omnisearch doesn't appear to be triggering any.  I also considered registering my own AssetOmniSearchHandler.class based on com.day.cq.dam.core.impl.omnisearch.AssetOmniSearchHandler but cannot find the bundle sources for the current version of com.day.cq.dam ca-dam-core 5.12.382 which includes the omnisearch dependencies.  

 

Can this be done reasonably?  

 

Thanks!!!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

3 Replies

Avatar

Community Advisor

Hi @WesleyGrant 

To log the search terms used by users in the DAM Assets interface and store them in a node under their `/home/users/nnn/activities/` folder, 

1. Create a custom event listener: Create a custom event listener that listens for the search events triggered by the DAM Assets interface. You can implement this by creating a custom OSGi bundle and registering an event listener using the `org.osgi.service.event.EventAdmin` service.

2. Listen for the search events: In your custom event listener, listen for events related to DAM asset searches. The event topic you need to listen for is `com/day/cq/search/promote/event/SEARCH`. You can use the `EventConstants.EVENT_TOPIC` property to specify the event topic.

3. Extract the search term: In the event listener, extract the search term used by the user from the event properties. The search term can be obtained from the `query` property of the event.

4. Get the user's home folder: Retrieve the user's home folder path from the event properties. You can use the `userId` property to identify the user and then construct the path to their home folder.

5. Create the activity node: Create a new node under the user's `/home/users/nnn/activities/` folder to store the search activity. You can use the `ResourceResolver` to create the node and set the necessary properties like the search term and timestamp.

6. Save the activity node: Save the activity node to persist the search activity information.

By implementing this custom event listener, you can capture the search terms used by users in the DAM Assets interface and store them in the user's activity node for reporting purposes.
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-search-function-6-5/m-... 
https://experienceleague.adobe.com/en/docs/experience-manager-learn/assets/search-and-discovery/sear... 
https://experienceleague.adobe.com/en/docs/experience-manager-learn/sites/developing/search-tutorial... 




Avatar

Level 2

I may be mistaken but my understanding of org.osgi.service.event.EventAdmin is that it's used to send events where I'm looking to listen for events that are being sent by OmniSearch.  Do you know of an example I could look at in regards to steps 1 and 2 above?  I have a pretty good understanding of how I will accomplish steps 3-6.  It is listening for the search event that I'm stuck on.

Avatar

Level 2

In digging further into this, I've found that I can see all events that occur in this console: 

http://localhost:4502/system/console/events

I reloaded that right after running a site omnisearch and see no entries regarding my search, so I'm assuming that running an omnisearch does not fire an event that I can listen for