donni106 / matomo-tracker-react-native

Stand alone library for using Matomo tracking in React Native and Expo projects.
MIT License
47 stars 15 forks source link

feature request: Set userInfo once #24

Open angelxmoreno opened 1 year ago

angelxmoreno commented 1 year ago

Is your feature request related to a problem? Please describe. It would be nice if we could set default params on the instance of the tracker and have it use those values on subsequent calls.

Describe the solution you'd like have the constructor take in a userInfo object that it merges with the params sent to the matomo server.

Describe alternatives you've considered Currently, I need to make a series of async calls to populate the userInfo object. Setting them once would improve app performance.

Additional context none

donni106 commented 1 year ago

Good point! This would make it even more straight forward to use.

angelxmoreno commented 1 year ago

as part of this PR I'd like to add userInfo defaults. Here are a few mentioned in #13

import {Dimensions} from "react-native";
import Constants from "expo-constants";
import * as Localization from "expo-localization";
{
  lang: Localization.locale,
  res: `${Dimentions.get('screen').width}x${Dimentions.get('screen').height}`,
  ua: await Constants.getWebViewUserAgentAsync(),
  _id: Constants.sessionId,
}