Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking device type #13

Open
BatDroid opened this issue Dec 7, 2022 · 16 comments
Open

Tracking device type #13

BatDroid opened this issue Dec 7, 2022 · 16 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BatDroid
Copy link
Contributor

BatDroid commented Dec 7, 2022

Is your feature request related to a problem? Please describe.
I wanted to know if there can be a way to define the device type. there is a section in dashboard for it which everyone will be marked unknown eventually. it could be good if we could implement it with expo-device package and at least know whether the users are with phone or tablets

@BatDroid BatDroid added the enhancement New feature or request label Dec 7, 2022
@donni106
Copy link
Owner

donni106 commented Dec 8, 2022

Hi @BatDroid, did you take a look at the possible options from Matomo at https://developer.matomo.org/api-reference/tracking-api#optional-user-info?
Maybe it is something you can transmit with the ua or uadata params?
image

@BatDroid
Copy link
Contributor Author

BatDroid commented Dec 8, 2022

no, sorry, I'm new at Matomo, and I have millions of questions now.
thanks to your fast response & guide, I think I could reach into these, which seems to be part of the uadata:

https://github.com/matomo-org/matomo-sdk-ios/blob/develop/MatomoTracker/Device.swift#L3

https://github.com/matomo-org/matomo-sdk-android/blob/master/tracker/src/main/java/org/matomo/sdk/tools/DeviceHelper.java#L49

if you think I'm correct then feel free to close the ticket

@donni106
Copy link
Owner

I don't know exactly what you mean. How did you plan your next steps?

@BatDroid
Copy link
Contributor Author

BatDroid commented Dec 14, 2022

@donni106 I want to attach more info about the device to my request, so that I'll be able to have an overview of device types, OS, etc. What I don't know is that I don't know how the format of my body should be.
as an example should be like:

{
uadata: {
device : {
type: "smartphone",
...
}
}
}

or something else ...
still researching on this.

@BatDroid
Copy link
Contributor Author

just to be more clear.
I don't see any statistics on how many users are using iPhone 12. how many are on what version of android and how many users are on smartphone and how many on tablet.
I made the uadata like this but only the model is being saved in dashboard, and it only get saved when I apply it like Json.stringify. here is an example:

import * as Device from 'expo-device';
{
uid: userID,
uadata: JSON.stringify({
model: Device.deviceName,
brand: Device.brand
type: Device.DeviceType.Phone
})
}

@BatDroid
Copy link
Contributor Author

I tried various combinations of data but here is all the data which I was able to let the Matomo detect. I wish I was able to make track more records. like the device type(table, smartphone), device brand (for android devices), etc

{
    uid: userId,
    res: `${Math.trunc(Dimensions.get('window').width)}x${Math.trunc(
      Dimensions.get('window').height,
    )}` as unknown as number,
    uadata: JSON.stringify({
      model: Device.deviceName,
      platform: `${Device.osName}`,
      platformVersion: `${Device.osVersion}`,
    }) as unknown as object,
  }

Screen Shot 1401-09-28 at 13 25 22

Screen Shot 1401-09-28 at 13 24 37

@donni106
Copy link
Owner

I understand your issue, thanks. I think this is something we need to ask Matomo directly. I do not know their system parameters. The way you send the informations with this library is totally correct. Now we need to know, which parameters uadata can receive, right?

I found some example in the API reference at https://developer.matomo.org/api-reference/tracking-api#example-tracking-request

image

Here they transmit the os version as custom variable with _cvar. Custom variables can be anything but maybe they also use some default ones for device brand and type.

I have created an issue at the Matomo GitHub asking for support on this.

@donni106 donni106 changed the title Tracking Device Type Tracking device type Mar 28, 2023
@donni106
Copy link
Owner

So as they said:

The values send with uadata then are checked with device detector. So it's not possible to send through random values, as they might get ignored then.

@BatDroid
Copy link
Contributor Author

BatDroid commented Apr 5, 2023

@donni106 thank you so much for following up.
so do you have any idea what can be done for it?

@donni106
Copy link
Owner

donni106 commented Apr 17, 2023

What react native and expo versions is your app running? Do you have new insights with the latest versions?
In my case, I can see more detailed information:

type brand model screen
image image image image

It seems that the point of logging is important. On app start, there are informations missing, but when tracking a screen, the details are present (at least on iOS, on Android it seems to be more often undefined):

app start screen
image image

Can you see some behavior like this in your case? As we need to rely on the underlying detection system ("device detector" as they said) and cannot pass information on our own, I cannot think of anything specific for us to do.

@angelxmoreno
Copy link
Contributor

a few points:

  1. relying on uadata feels very wrong for tracking mobile apps since Matomo's device detector works off of the UserAgent
  2. maybe we need a Matomo plugin that acknowledges react native device params
  3. how does the react-native-matomo handle this if at all?
  4. @donni106 what params are you sending to get the model and screen values you posted?

@donni106
Copy link
Owner

  1. @donni106 what params are you sending to get the model and screen values you posted?

this is what we do:

import Constants from 'expo-constants';
import * as Localization from 'expo-localization';

...
const ua = await Constants.getWebViewUserAgentAsync();
...
{
  lang: Localization.locale,
  res: `${device.width}x${device.height}`,
  ua
}
...

Expo Constants: https://docs.expo.dev/versions/latest/sdk/constants

@angelxmoreno
Copy link
Contributor

once we merge #23 I'd like to get started on #24 and incorporate

{
  lang: Localization.locale,
  res: `${device.width}x${device.height}`,
  ua: await Constants.getWebViewUserAgentAsync(),
  _id: Constants.sessionId,
}

@angelxmoreno
Copy link
Contributor

@BatDroid @donni106 should we consider this issue as closed ?

@donni106
Copy link
Owner

donni106 commented Jan 2, 2024

@BatDroid @donni106 should we consider this issue as closed ?

I still need to tackle the before mentioned PR and issue!

@donni106 donni106 added this to the 0.3.2 milestone Jan 2, 2024
@donni106
Copy link
Owner

donni106 commented Jan 2, 2024

#23 is merged, you can go on and I look forward to release a 0.3.3 after the changes.

@donni106 donni106 modified the milestones: 0.3.2, 0.3.3 Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants
@angelxmoreno @donni106 @BatDroid and others