Don't log undefined search terms.

This was caused by undefined values being checked directly, rather than checking against the `typeof`. The `undefined` issue occurred in other locations, so I took the liberty of fixing those, too.

[This](https://github.com/borkweb/bstat/compare/3835-dont-log-undefined-search-terms?expand=1#diff-cf0991899b9a89a6f955844bf105fcd0R218) is the line that should fix the problem.

See: https://github.com/GigaOM/legacy-pro/issues/3835