Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,22 @@ app.*.map.json
/ios/Runner/pigeon.h
/ios/Runner/pigeon.m

# Firebase config
android/app/google-services.json

# Generated localization files
assets/l10n/app_localizations*.dart

# Generated mock files
*.mocks.dart

# Flutter generated plugin files
linux/flutter/generated_plugin_registrant.*
linux/flutter/generated_plugins.cmake

windows/flutter/generated_plugin_registrant.*
windows/flutter/generated_plugins.cmake

macos/Flutter/GeneratedPluginRegistrant.swift

generate_all_pigeon.bat
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ flutter gen-l10n

* The label and application logo can be changed here android/app/src/main/AndroidManifest.xml

### Firebase Setup

Firebase Analytics requires a `google-services.json` configuration file.

1. Go to the Firebase Console.
2. Open the MOSIP Firebase project.
3. Download the `google-services.json` file.
4. Place the file in the following directory:

```text
android/app/
```

**Important Notes:**

- `google-services.json` is excluded from version control using `.gitignore`.
- Each developer must add the Firebase configuration file locally.
- CI/CD pipelines should securely store this file as a secret and inject it during build time.

#### Step 3: Build and Run the Application

* The `pigeon.sh` file consists of the necessary commands for downloading dependencies and generating Flutter - Android native communication code. Please execute the `pigeon.sh` file or execute the commands within the file separately.
Expand Down
11 changes: 11 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Firebase config
app/google-services.json

# Flutter generated files
.flutter-plugins
.flutter-plugins-dependencies
.dart_tool/
build/

# Mock files
*.mocks.dart
gradle-wrapper.jar
/.gradle
/captures/
Expand Down
12 changes: 10 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ afterEvaluate {
}

android {
namespace "io.mosip.registration_client"
lintOptions {
abortOnError false
ignoreWarnings true
}
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 34
ndkVersion flutter.ndkVersion

buildFeatures {
buildConfig true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -61,7 +66,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 28
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -153,6 +158,8 @@ dependencies {
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation 'com.cronutils:cron-utils:9.1.7'
implementation platform('com.google.firebase:firebase-bom:34.12.0')//firebase
implementation 'com.google.firebase:firebase-analytics' //firebase analytics
Comment thread
coderabbitai[bot] marked this conversation as resolved.

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down Expand Up @@ -315,3 +322,4 @@ dependencies {
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.0-alpha7'
}
apply plugin: 'com.google.gms.google-services'
11 changes: 6 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.ibotta:plugin:1.2.0"
//Jacoco Plugin
classpath "org.jacoco:org.jacoco.core:0.8.12"
classpath 'com.google.gms:google-services:4.4.4'// Google Services plugin for Firebase integration
}
}

Expand Down Expand Up @@ -46,11 +47,11 @@ allprojects {
}

ext {
compileSdkVersion = 33
buildToolsVersion = "33.0.0"
compileSdkVersion = 34
buildToolsVersion = "34.0.0"

minSdkVersion = 28
targetSdkVersion = 33
targetSdkVersion = 34

junitVersion = "4.+"

Expand Down
5 changes: 5 additions & 0 deletions android/clientmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ tasks.register('dexifyBiosdkAars') {
}

android {
namespace "io.mosip.registration.clientmanager" // Required for AGP 8.0+ to avoid "Namespace not found" errors in generated code
buildFeatures {
buildConfig true
}

lintOptions {
abortOnError false
ignoreWarnings true
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
6 changes: 4 additions & 2 deletions android/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def createVariantCoverage(variant) {
description = "Generate Jacoco coverage reports for the ${variantName.capitalize()} build."

reports {
html.enabled = true
xml.enabled = true
// html.enabled = true
// xml.enabled = true
xml.required = true
html.required = true
}

def javaClasses = fileTree(dir: variant.javaCompileProvider.get().destinationDir, excludes: project.excludes)
Expand Down
5 changes: 5 additions & 0 deletions android/keymanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ plugins {
apply from: '../jacoco.gradle'

android {
namespace "io.mosip.registration.keymanager" // Required for AGP 8.0+ to avoid "Namespace not found" errors in generated code
buildFeatures {
buildConfig true
}

lintOptions {
abortOnError false
ignoreWarnings true
Expand Down
5 changes: 5 additions & 0 deletions android/packetmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ plugins {
apply from: '../jacoco.gradle'

android {
namespace "io.mosip.registration.packetmanager"
buildFeatures {
buildConfig true
}

lintOptions {
abortOnError false
ignoreWarnings true
Expand Down
5 changes: 5 additions & 0 deletions android/transliterationmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ plugins {
apply from: '../jacoco.gradle'

android {

buildFeatures {
buildConfig true
}

lintOptions {
abortOnError false
ignoreWarnings true
Expand Down
37 changes: 37 additions & 0 deletions lib/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,48 @@ import 'package:registration_client/ui/process_ui/process_type.dart';
import 'package:registration_client/ui/login_page.dart';
import 'package:registration_client/ui/onboard/onboard_landing_page.dart';
import 'package:registration_client/ui/onboard/home_page.dart';
// import 'package:registration_client/telemetry/telemetry_screen_wrapper.dart';

class AppRouter {
AppRouter._();

static Map<String, Widget Function(BuildContext)> routes = {
//telementary screen
// LoginPage.route: (context) => const TelemetryScreenWrapper(
// screenName: "LoginPage",
// child: LoginPage(),
// ),

// '/new_process': (context) => const TelemetryScreenWrapper(
// screenName: "NewProcess",
// child: GenericProcess(processType: ProcessType.newProcess),
// ),

// '/update_process': (context) => const TelemetryScreenWrapper(
// screenName: "UpdateProcess",
// child: GenericProcess(processType: ProcessType.updateProcess),
// ),

// '/lost_process': (context) => const TelemetryScreenWrapper(
// screenName: "LostProcess",
// child: GenericProcess(processType: ProcessType.lostProcess),
// ),

// '/correction_process': (context) => const TelemetryScreenWrapper(
// screenName: "CorrectionProcess",
// child: GenericProcess(processType: ProcessType.correctionProcess),
// ),

// OnboardLandingPage.route: (context) => const TelemetryScreenWrapper(
// screenName: "OnboardLandingPage",
// child: OnboardLandingPage(),
// ),

// HomePage.route: (context) => const TelemetryScreenWrapper(
// screenName: "HomePage",
// child: HomePage(),
// ),
//
LoginPage.route: (context) => const LoginPage(),
'/new_process': (context) => const GenericProcess(processType: ProcessType.newProcess),
'/update_process': (context) => const GenericProcess(processType: ProcessType.updateProcess),
Expand Down
12 changes: 12 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter/services.dart';
import 'package:registration_client/utils/inactivity_tracker.dart';
import 'package:restart_app/restart_app.dart';
import 'package:registration_client/telemetry/telemetry_service.dart';// Telemetry imports
import 'package:registration_client/telemetry/telemetry_navigation.dart';// Telemetry imports
import 'package:firebase_core/firebase_core.dart';// Firebase core for initialization;
import 'package:registration_client/telemetry/telemetry_manager.dart';// Telemetry manager to initialize and log events

final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<ScaffoldMessengerState> rootScaffoldMessengerKey =
Expand All @@ -34,10 +38,17 @@ const String _syncRestartChannel = 'io.mosip.registration_client/sync_restart';
void main() async {
enableFlutterDriverExtension(enableTextEntryEmulation: false);
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();// Initialize Firebase before anything else (especially Telemetry)
_setupSyncRestartChannel();
final GlobalProvider appLanguage = GlobalProvider();
await FlutterConfig.loadEnvVariables();
await appLanguage.fetchLocale();
// Load telemetry config from backend or local config
// await TelemetryService.init();
// await TelemetryManager.initialize();// Initialize telemetry manager (loads user consent and configures Firebase accordingly)
await TelemetryManager.initialize();
await TelemetryService.init();
//
runApp(
const RestartWidget(child: RegistrationClientApp()),
);
Expand Down Expand Up @@ -232,6 +243,7 @@ class _BuildAppState extends State<BuildApp> {
scaffoldMessengerKey: rootScaffoldMessengerKey,
title: 'Registration Client',
routes: AppRouter.routes,
navigatorObservers: [TelemetryNavigationObserver()],// Telemetry navigation observer
Comment thread
coderabbitai[bot] marked this conversation as resolved.
debugShowCheckedModeBanner: false,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
Expand Down
4 changes: 2 additions & 2 deletions lib/platform_android/auth_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AuthServiceImpl implements AuthService {

@override
Future<String> getIdleTime() async {
late String idleTime;
String idleTime = "0"; // ✅ default safe value
try {
idleTime = await AuthResponseApi().getIdleTime();
} on PlatformException {
Expand All @@ -113,7 +113,7 @@ class AuthServiceImpl implements AuthService {

@override
Future<String> getAutoLogoutPopupTimeout() async {
late String refreshLoginTime;
String refreshLoginTime = "0";
try {
refreshLoginTime = await AuthResponseApi().getAutoLogoutPopupTimeout();
} on PlatformException {
Expand Down
28 changes: 26 additions & 2 deletions lib/platform_android/network_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import 'package:registration_client/model/actuator_info.dart';
import 'package:registration_client/pigeon/common_details_pigeon.dart';
import 'package:registration_client/platform_spi/network_service.dart';
import 'package:http/http.dart' as http;
//telementary import
import 'package:registration_client/telemetry/telemetry_service.dart';

class NetworkServiceImpl implements NetworkService {
@override
Expand All @@ -24,8 +26,30 @@ class NetworkServiceImpl implements NetworkService {
FlutterConfig.get('HEALTH_CHECK_PATH')))
.timeout(const Duration(seconds: 2));
return response.statusCode.toString();
} catch (e) {
debugPrint("Network Connection failed $e");
// } catch (e) {
// debugPrint("Network Connection failed $e");
// // log network failure event to telemetry with error details
// TelemetryService.trackEvent("network_failure", data: {
// "error": e.toString(),
// "api": "health_check"
// });
// TelemetryService.logError(e);
//
}catch (e) {
try {
TelemetryService.trackEvent(
"network_failure",
data: {
"error": e.toString(),
"api": "health_check",
},
);

TelemetryService.logError(e);
} catch (_) {
debugPrint("Telemetry logging failed");
}
//
}
return "";
}
Expand Down
3 changes: 2 additions & 1 deletion lib/provider/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AuthProvider with ChangeNotifier {
String get refreshedLoginTime => _refreshedLoginTime;
String get idleTime => _idleTime;
String get passwordLength => _passwordLength;
//for dummy data

setIsLoggedIn(bool value) {
_isLoggedIn = value;
Expand Down Expand Up @@ -111,7 +112,7 @@ class AuthProvider with ChangeNotifier {
}

setIsLoggingIn(bool value) {
_isLoggingIn = false;
_isLoggingIn = value;
notifyListeners();
}

Expand Down
8 changes: 8 additions & 0 deletions lib/telemetry/telemetry_config.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class TelemetryConfig {
static bool enabled = true;

// later you can load this from app_config or backend
static void update({required bool isEnabled}) {
enabled = isEnabled;
}
}
Loading