Log search terms for analytics insight

This commit is contained in:
Noah Petherbridge 2025-01-04 18:09:40 -08:00
parent 61b047feaa
commit 9afe7718f1
3 changed files with 17 additions and 0 deletions

View File

@ -162,6 +162,15 @@ func Search() http.HandlerFunc {
}
}
// Log the search terms for analytics.
if searchTerm != "" {
message := "Searched the member directory by keyword: " + searchTerm
if restricted != nil {
message += " (which was restricted)"
}
models.LogEvent(currentUser, nil, models.ChangeLogAnalytics, "users.search", 0, message)
}
pager := &models.Pagination{
PerPage: config.PageSizeMemberSearch,
Sort: sort,

View File

@ -109,6 +109,12 @@ func Search() http.HandlerFunc {
log.Error("Couldn't MapCommentPhotos: %s", err)
}
// Log the search terms for analytics.
if searchTerm != "" {
message := "Searched the forums by keyword: " + searchTerm
models.LogEvent(currentUser, nil, models.ChangeLogAnalytics, "forums.search", 0, message)
}
var vars = map[string]interface{}{
"CurrentForumTab": "search",
"Pager": pager,

View File

@ -38,6 +38,7 @@ const (
ChangeLogBanned = "banned"
ChangeLogAdmin = "admin" // admin status toggle
ChangeLogLifecycle = "lifecycle" // de/reactivated accounts
ChangeLogAnalytics = "analytics" // misc analytics
)
var ChangeLogEventTypes = []string{
@ -49,6 +50,7 @@ var ChangeLogEventTypes = []string{
ChangeLogBanned,
ChangeLogAdmin,
ChangeLogLifecycle,
ChangeLogAnalytics,
}
// PaginateChangeLog lists the change logs.