|
|
@@ -25,29 +25,27 @@ module.exports = function({ data }) {
|
|
|
|
|
|
tasks.push(query.link.incrementVisit({ id: data.link.id }));
|
|
|
|
|
|
- if (data.link.visit_count < getStatsLimit()) {
|
|
|
- // the following line is for backward compatibility
|
|
|
- // used to send the whole header to get the user agent
|
|
|
- const userAgent = data.userAgent || data.headers?.["user-agent"];
|
|
|
- const agent = useragent.parse(userAgent);
|
|
|
- const [browser = "Other"] = browsersList.filter(filterInBrowser(agent));
|
|
|
- const [os = "Other"] = osList.filter(filterInOs(agent));
|
|
|
- const referrer =
|
|
|
- data.referrer && removeWww(URL.parse(data.referrer).hostname);
|
|
|
- const location = geoip.lookup(data.ip);
|
|
|
- const country = location && location.country;
|
|
|
+ // the following line is for backward compatibility
|
|
|
+ // used to send the whole header to get the user agent
|
|
|
+ const userAgent = data.userAgent || data.headers?.["user-agent"];
|
|
|
+ const agent = useragent.parse(userAgent);
|
|
|
+ const [browser = "Other"] = browsersList.filter(filterInBrowser(agent));
|
|
|
+ const [os = "Other"] = osList.filter(filterInOs(agent));
|
|
|
+ const referrer =
|
|
|
+ data.referrer && removeWww(URL.parse(data.referrer).hostname);
|
|
|
+ const location = geoip.lookup(data.ip);
|
|
|
+ const country = location && location.country;
|
|
|
|
|
|
-
|
|
|
- tasks.push(
|
|
|
- query.visit.add({
|
|
|
- browser: browser.toLowerCase(),
|
|
|
- country: country || "Unknown",
|
|
|
- id: data.link.id,
|
|
|
- os: os.toLowerCase().replace(/\s/gi, ""),
|
|
|
- referrer: (referrer && referrer.replace(/\./gi, "[dot]")) || "Direct"
|
|
|
- })
|
|
|
- );
|
|
|
- }
|
|
|
+
|
|
|
+ tasks.push(
|
|
|
+ query.visit.add({
|
|
|
+ browser: browser.toLowerCase(),
|
|
|
+ country: country || "Unknown",
|
|
|
+ id: data.link.id,
|
|
|
+ os: os.toLowerCase().replace(/\s/gi, ""),
|
|
|
+ referrer: (referrer && referrer.replace(/\./gi, "[dot]")) || "Direct"
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
return Promise.all(tasks);
|
|
|
}
|