Added logging of icon searches

This commit is contained in:
squidfunk
2021-02-15 17:17:11 +01:00
parent 6ad24784cc
commit 8de8da222f
6 changed files with 21 additions and 8 deletions

View File

@@ -24,8 +24,10 @@ import { Observable, combineLatest, fromEvent, merge } from "rxjs"
import {
delay,
distinctUntilChanged,
filter,
map,
startWith
startWith,
withLatestFrom
} from "rxjs/operators"
import { watchElementFocus } from "~/browser"
@@ -71,6 +73,17 @@ export function mountIconSearchQuery(
distinctUntilChanged()
)
/* Log search on blur */
focus$
.pipe(
filter(active => !active),
withLatestFrom(value$)
)
.subscribe(([, value]) => {
const path = document.location.pathname
ga("send", "pageview", `${path}?q=[icon]+${value}`)
})
/* Combine into single observable */
return combineLatest([value$, focus$])
.pipe(