Skip to content

Commit 4905f18

Browse files
Patch for Github issue #138
1 parent 01e3a28 commit 4905f18

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/core/lib/analytics_web.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AnalyticsPlatformImpl extends AnalyticsPlatform {
1818
NativeContext(
1919
app: NativeContextApp(
2020
name: web.window.navigator.appName,
21-
version: web.window.navigator.appVersion,
21+
version: getAppVersion(),
2222
namespace: web.window.navigator.appCodeName,
2323
),
2424
userAgent: web.window.navigator.userAgent,
@@ -28,6 +28,16 @@ class AnalyticsPlatformImpl extends AnalyticsPlatform {
2828
width: web.window.screen.width,
2929
),
3030
);
31+
32+
/*
33+
- Checks for <meta name="app-version" content="1.2.3"> in <root>/web/index.html
34+
and return the value inside 'content'
35+
- Returns the browser version as fallback
36+
*/
37+
String getAppVersion() {
38+
final meta = web.document.querySelector('meta[name="app-version"]');
39+
return meta?.getAttribute('content') ?? web.window.navigator.appVersion;
40+
}
3141
}
3242

3343
class AnalyticsWeb {

0 commit comments

Comments
 (0)