From 25dc32208748473512bf1d1bb0332d057d966cd2 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 16 Feb 2023 10:25:16 +0200 Subject: [PATCH] Log on unhandled UAInspector device type --- lib/plausible/ingestion/event.ex | 54 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/plausible/ingestion/event.ex b/lib/plausible/ingestion/event.ex index f465da73d..a92557435 100644 --- a/lib/plausible/ingestion/event.ex +++ b/lib/plausible/ingestion/event.ex @@ -297,18 +297,48 @@ defmodule Plausible.Ingestion.Event do # credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity defp screen_size(ua) do case ua.device do - %UAInspector.Result.Device{type: "smartphone"} -> "Mobile" - %UAInspector.Result.Device{type: "feature phone"} -> "Mobile" - %UAInspector.Result.Device{type: "portable media player"} -> "Mobile" - %UAInspector.Result.Device{type: "phablet"} -> "Mobile" - %UAInspector.Result.Device{type: "wearable"} -> "Mobile" - %UAInspector.Result.Device{type: "camera"} -> "Mobile" - %UAInspector.Result.Device{type: "car browser"} -> "Tablet" - %UAInspector.Result.Device{type: "tablet"} -> "Tablet" - %UAInspector.Result.Device{type: "tv"} -> "Desktop" - %UAInspector.Result.Device{type: "console"} -> "Desktop" - %UAInspector.Result.Device{type: "desktop"} -> "Desktop" - _ -> nil + %UAInspector.Result.Device{type: "smartphone"} -> + "Mobile" + + %UAInspector.Result.Device{type: "feature phone"} -> + "Mobile" + + %UAInspector.Result.Device{type: "portable media player"} -> + "Mobile" + + %UAInspector.Result.Device{type: "phablet"} -> + "Mobile" + + %UAInspector.Result.Device{type: "wearable"} -> + "Mobile" + + %UAInspector.Result.Device{type: "camera"} -> + "Mobile" + + %UAInspector.Result.Device{type: "car browser"} -> + "Tablet" + + %UAInspector.Result.Device{type: "tablet"} -> + "Tablet" + + %UAInspector.Result.Device{type: "tv"} -> + "Desktop" + + %UAInspector.Result.Device{type: "console"} -> + "Desktop" + + %UAInspector.Result.Device{type: "desktop"} -> + "Desktop" + + %UAInspector.Result.Device{type: type} -> + Sentry.capture_message("Could not determine device type from UAInspector", + extra: %{type: type} + ) + + nil + + _ -> + nil end end