diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle
index 5085736..83a26de 100644
--- a/packages/core/android/build.gradle
+++ b/packages/core/android/build.gradle
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
android {
namespace 'com.segment.analytics'
- compileSdkVersion 31
+ compileSdkVersion 35 //Patch for for Github issue #147
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -44,4 +44,4 @@ android {
defaultConfig {
minSdkVersion 16
}
-}
+}
\ No newline at end of file
diff --git a/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt b/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt
index ef8d597..0388fc2 100644
--- a/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt
+++ b/packages/core/android/src/main/kotlin/com/segment/analytics/AnalyticsPlugin.kt
@@ -143,9 +143,17 @@ class AnalyticsPlugin : FlutterPlugin, NativeContextApi, EventChannel.StreamHand
NativeContext(
app = NativeContextApp(
build = appBuild,
- name = packageInfo.applicationInfo.loadLabel(
- packageManager
- ).toString(),
+
+ /* Retrieves the application name from the package info, using the application's label
+ (i.e., the app name displayed on the device). If the application name cannot be fetched
+ (e.g., due to a missing label or other issues), the fallback value "Unknown" will be used
+ to ensure the app doesn't break due to a null value.
+
+ Patch for for Github issue #147 - Replaced following line:
+ name = packageInfo.applicationInfo.loadLabel(packageManager).toString(), with the line below
+ */
+ name = packageInfo.applicationInfo?.loadLabel(packageManager)?.toString() ?: "Unknown",
+
namespace = packageInfo.packageName,
version = packageInfo.versionName
),
diff --git a/packages/core/lib/analytics_web.dart b/packages/core/lib/analytics_web.dart
index 303661a..ba01d25 100644
--- a/packages/core/lib/analytics_web.dart
+++ b/packages/core/lib/analytics_web.dart
@@ -18,7 +18,7 @@ class AnalyticsPlatformImpl extends AnalyticsPlatform {
NativeContext(
app: NativeContextApp(
name: web.window.navigator.appName,
- version: web.window.navigator.appVersion,
+ version: getAppVersion(),
namespace: web.window.navigator.appCodeName,
),
userAgent: web.window.navigator.userAgent,
@@ -28,6 +28,16 @@ class AnalyticsPlatformImpl extends AnalyticsPlatform {
width: web.window.screen.width,
),
);
+
+ /*
+ - Checks for in /web/index.html
+ and return the value inside 'content'
+ - Returns the browser version as fallback
+ */
+ String getAppVersion() {
+ final meta = web.document.querySelector('meta[name="app-version"]');
+ return meta?.getAttribute('content') ?? web.window.navigator.appVersion;
+ }
}
class AnalyticsWeb {
diff --git a/packages/core/lib/state.dart b/packages/core/lib/state.dart
index eaec773..e8f8cb2 100644
--- a/packages/core/lib/state.dart
+++ b/packages/core/lib/state.dart
@@ -583,5 +583,6 @@ Configuration setFlushPolicies(
trackApplicationLifecycleEvents: a.trackApplicationLifecycleEvents,
trackDeeplinks: a.trackDeeplinks,
storageJson: a.storageJson,
- token: a.token);
+ token: a.token,
+ collectDeviceId: a.collectDeviceId); //Patch for for Github issue #144
}