Skip to content

Context app version wrong on Flutter web #138

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

Closed
nmazidi opened this issue Jan 16, 2025 · 2 comments
Closed

Context app version wrong on Flutter web #138

nmazidi opened this issue Jan 16, 2025 · 2 comments

Comments

@nmazidi
Copy link

nmazidi commented Jan 16, 2025

Segment is receiving AppleWebKit version instead of the app version in flutter web.

Here are 2 event contexts received, one from Flutter mobile and the other from Flutter web.

Mobile:
"context": { "app": { "build": "120", "name": "APPNAME", "namespace": "com.APP.APPNAME", "version": "1.5.30" },

Web:
"context": { "app": { "build": "", "name": "Netscape", "namespace": "Mozilla", "version": "5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" },

Thanks!

@neelkanth-kaushik
Copy link
Contributor

We are working on this.

neelkanth-kaushik added a commit that referenced this issue May 15, 2025
MichaelGHSeg pushed a commit that referenced this issue May 20, 2025
* Patch for Github Issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #138

* Patch for Github issue #138

* Patch for Github Issue #152

* Patch for Github Issue #152

* Testing patch for Github Issue #157

* Patch for Github Issue #157
MichaelGHSeg added a commit that referenced this issue May 20, 2025
* Patches for Github Issues (#159)

* Patch for Github Issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #144

* Patch for Github issue #147

* Patch for Github issue #147

* Patch for Github issue #138

* Patch for Github issue #138

* Patch for Github Issue #152

* Patch for Github Issue #152

* Testing patch for Github Issue #157

* Patch for Github Issue #157

* Updating for 1.1.7 release

* Removing unnecessary library name

---------

Co-authored-by: Neelkanth Kaushik <[email protected]>
@neelkanth-kaushik
Copy link
Contributor

Please update to version 1.1.7.

In a Flutter web app, the pubspec.yaml file isn't directly accessible at runtime—especially from within client-side browser code—since it's a build-time configuration. Hence till version 1.1.6, the following line in analytics_web.dart:

version: web.window.navigator.appVersion

used to return the browser version string, not the app's version from pubspec.yaml. In a web app, to make the app's version available at runtime, we need to manually expose it.

In version 1.1.7, the line version: web.window.navigator.appVersion has been replaced with version: getAppVersion() method in analytics_web.dart. This method looks for <meta name="app-version" content="1.2.3"> in <project-root>/web/index.html and return the value inside 'content' attribute. This method returns the browser version as fallback.

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

No branches or pull requests

2 participants