Skip to content

Commit

Permalink
feat: Send and log version in data requests from OFM clients (#1843)
Browse files Browse the repository at this point in the history
* Send and log version in data requests from OFM clients

* Always include logging params for triptych, even if we fail to determine pane
  • Loading branch information
jzimbel-mbta authored Aug 31, 2023
1 parent af3cb8c commit 6f5753f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions assets/src/hooks/v2/use_api_response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { isDup, isOFM, isTriptych, getTriptychPane } from "Util/outfront";
import { getScreenSide, isRealScreen } from "Util/util";
import * as SentryLogger from "Util/sentry";
import { ROTATION_INDEX } from "Components/v2/dup/rotation_index";
import { DUP_VERSION } from "Components/v2/dup/version";
import { TRIPTYCH_VERSION } from "Components/v2/triptych/version";

const MINUTE_IN_MS = 60_000;

Expand Down Expand Up @@ -131,14 +133,12 @@ const getRequestorParam = () => {

const getLoggingParams = () => {
if (isDup()) {
return `&rotation_index=${ROTATION_INDEX}`;
return `&rotation_index=${ROTATION_INDEX}&version=${DUP_VERSION}`;
}

if (isTriptych()) {
const triptychPane = getTriptychPane();
if (triptychPane != null) {
return `&pane=${triptychPane}`;
}
return `&pane=${triptychPane || "UNKNOWN"}&version=${TRIPTYCH_VERSION}`;
}

return "";
Expand Down
7 changes: 6 additions & 1 deletion lib/screens/log_screen_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule Screens.LogScreenData do
requestor,
screen_side \\ nil,
rotation_index \\ nil,
triptych_pane \\ nil
triptych_pane \\ nil,
ofm_app_package_version \\ nil
) do
if is_screen or not is_nil(requestor) do
data =
Expand All @@ -33,6 +34,7 @@ defmodule Screens.LogScreenData do
|> insert_requestor(requestor)
|> insert_dup_rotation_index(rotation_index)
|> insert_triptych_pane(triptych_pane)
|> insert_version(ofm_app_package_version)

log_message("[screen data request]", data)
end
Expand Down Expand Up @@ -149,4 +151,7 @@ defmodule Screens.LogScreenData do

defp insert_triptych_pane(data, triptych_pane),
do: Map.put(data, :triptych_pane, triptych_pane)

defp insert_version(data, nil), do: data
defp insert_version(data, version), do: Map.put(data, :ofm_app_package_version, version)
end
4 changes: 3 additions & 1 deletion lib/screens_web/controllers/v2/screen_api_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defmodule ScreensWeb.V2.ScreenApiController do
screen_side = params["screen_side"]
rotation_index = params["rotation_index"]
triptych_pane = params["pane"]
ofm_app_package_version = params["version"]

Screens.LogScreenData.log_data_request(
screen_id,
Expand All @@ -31,7 +32,8 @@ defmodule ScreensWeb.V2.ScreenApiController do
params["requestor"],
screen_side,
rotation_index,
triptych_pane
triptych_pane,
ofm_app_package_version
)

cond do
Expand Down

0 comments on commit 6f5753f

Please sign in to comment.