Closed samuk closed 2 months ago
I believe this would be a great module idea, I say this due to already creating a module based on User-Agents, with some refactoring I could probably implement such a function for admins in the backend that will help with such a thing, although the module currently wasn't ideal for the marketplace I believe it can be a very useful tool in this aspect.
Nice, do you think that the Android app will be able to define a user agent?
Looking at my report again I guess it's the chrome webview figure for Chrome mobile users?
What does the 'headless chrome' figure relate to?
@PrimozRatej Maybe you add a custom identifier in the user-agent?
E.g.: HumHubMobileApp
I'm not a DART developer, but it might be something like that:
import 'package:http/http.dart' as http;
class CustomClient extends http.BaseClient {
final http.Client _inner = http.Client();
Future<http.StreamedResponse> send(http.BaseRequest request) {
request.headers['User-Agent'] = 'HumHubMobileApp';
return _inner.send(request);
}
}
Here's a demo implementation through a module;
@ArchBlood Thanks. The Analytics module already stores the Browser in the DB. So if we can have a custom user agent for the Mobile App, I'll be able to detect it. And then, I can add statistics about Browser usages (currently the module only displays this info for a specific user).
Hey @marc-farre, @samuk, @ArchBlood, I'm sorry for the late response. Yes, it is possible to define a custom user agent. Currently, we have it configured the same for every instance. Additionally, there is a custom header appended to every request to define traffic from the mobile app.
static const String userAgent =
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
InAppWebViewOptions(
javaScriptEnabled: true,
useShouldOverrideUrlLoading: true,
userAgent: userAgent,
applicationNameForUserAgent: 'HumHub-Mobile'),
// If 'x-humhub-app' is present, that indicates mobile app traffic.
Map<String, String> get customHeaders => {
'x-humhub-app-token': randomHash!,
'x-humhub-app': appVersion ?? '1.0.0',
'x-humhub-app-ostate': isHideOpener ? '1' : '0'
};
@marc-farre Could we add device type/app use to your Analytics module?
Done in the Analytics module. Currently being tested for one month. The new version of the module with this feature will be released in the marketplace mid-October.
New Analytics version released: https://community.humhub.com/content/perma?id=281974
I've started promoting the Android app to my users. Is there a way to tell how many are actually using it? Are you able to adjust the user-agent perhaps? Or is it just using the devices default browser?
I use Matomo for analytics which provides this report