Skip to content

Change screen_size to use browser user agent - #1659

Closed
eriknakata wants to merge 4 commits into
plausible:masterfrom
eriknakata:master
Closed

Change screen_size to use browser user agent#1659
eriknakata wants to merge 4 commits into
plausible:masterfrom
eriknakata:master

Conversation

@eriknakata

Copy link
Copy Markdown
Contributor

Changes

Change how the screen size is calculated. The library UA inspector is already used by the project. So is possible use it to calculate the screen size. If not founded by the UA inspector the mechanism of calculate from screen_width is used as a kind of fallback. The existent function is still used to calculate Desktop and Laptop devices.

Original discussion: #157

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@metmarkosaric

metmarkosaric commented Feb 9, 2022

Copy link
Copy Markdown
Contributor

thanks for your contribution @eriknakata!

@ukutaht can add more details. our idea for how to improve this section was:

  1. Use user-agent for detecting device type
  2. Remove screen width tracking altogether
  3. Combine laptop / desktop into one group

in the ui, we would need to retitle "Size" to "Device" in the tab itself and "Screen size" to "Device" in the header when the tab is open. and then remove the tooltip that shows up on the hover and tells you the screen size in px.

@eriknakata

eriknakata commented Feb 10, 2022

Copy link
Copy Markdown
Contributor Author

hey @metmarkosaric,

What's the name of the group combination of desktop and laptop ? How you are going to work with old data ?

@metmarkosaric

Copy link
Copy Markdown
Contributor

What's the name of the group combination of desktop and laptop ?

"Desktop" makes most sense I think

How you are going to work with old data ?

@ukutaht is best to answer this one

@eriknakata

Copy link
Copy Markdown
Contributor Author

Maybe run a script to update Laptop to Desktop

@eriknakata

Copy link
Copy Markdown
Contributor Author

hey @metmarkosaric

I see a filter "screen size is Desktop". Should I change screen size to Device as well ?

Screen Shot 2022-02-16 at 19 00 21

@ukutaht ukutaht left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a few things.

  1. Comment below about going through all the possible device types exhaustively
  2. Dealing with old data: yes let's create a database migration to change Laptop to Desktop. I can help with that if needed.
  3. Screen width tracking can be removed completely from the tracking script

defp calculate_screen_size(width) when width < 992, do: "Tablet"
defp calculate_screen_size(width) when width < 1440, do: "Laptop"
defp calculate_screen_size(width) when width >= 1440, do: "Desktop"
defp calculate_screen_size(%UAInspector.Result{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go through the list of device types in `matomo/device-detector' exhaustively. They have a 'phablet' device type for example, which would be classified by this as 'Desktop' which is incorrect.

@ukutaht

ukutaht commented Feb 15, 2023

Copy link
Copy Markdown
Contributor

Hey 👋 This PR has conflicts and I wanted to make some changes. Closing this in favour of #2680 for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants