Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #236 from Western-Health-Covid19-Collaboration/fea…
Browse files Browse the repository at this point in the history
…ture/add-analytics-crashreporting

Feature - Firebase Analytics & Crashlytics
  • Loading branch information
workerbee22 committed Apr 10, 2020
2 parents a936f17 + 4c54d5b commit de5e341
Show file tree
Hide file tree
Showing 32 changed files with 467 additions and 45 deletions.
5 changes: 4 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ if (flutterVersionName == null) {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
Expand Down Expand Up @@ -75,3 +74,7 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

// Crashlytics and Google Services required at the bottom
apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'
6 changes: 6 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ buildscript {
repositories {
google()
jcenter()
// Additional repository for Crashlytics resources
maven {
url 'https://maven.fabric.io/public'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
// Add Crashlytics classpath
classpath 'io.fabric.tools:gradle:1.26.1'
}
}

Expand Down
127 changes: 127 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,97 @@
PODS:
- Crashlytics (3.14.0):
- Fabric (~> 1.10.2)
- Fabric (1.10.2)
- Firebase/Analytics (6.21.0):
- Firebase/Core
- Firebase/Core (6.21.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 6.4.0)
- Firebase/CoreOnly (6.21.0):
- FirebaseCore (= 6.6.5)
- firebase_analytics (0.0.1):
- Firebase/Analytics (~> 6.0)
- Firebase/Core
- Flutter
- firebase_core (0.0.1):
- Firebase/Core
- Flutter
- firebase_core_web (0.1.0):
- Flutter
- firebase_crashlytics (0.0.1):
- Crashlytics
- Fabric
- Firebase/Core
- Flutter
- FirebaseAnalytics (6.4.0):
- FirebaseCore (~> 6.6)
- FirebaseInstallations (~> 1.1)
- GoogleAppMeasurement (= 6.4.0)
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (= 0.3.9011)
- FirebaseCore (6.6.5):
- FirebaseCoreDiagnostics (~> 1.2)
- FirebaseCoreDiagnosticsInterop (~> 1.2)
- GoogleUtilities/Environment (~> 6.5)
- GoogleUtilities/Logger (~> 6.5)
- FirebaseCoreDiagnostics (1.2.2):
- FirebaseCoreDiagnosticsInterop (~> 1.2)
- GoogleDataTransportCCTSupport (~> 2.0)
- GoogleUtilities/Environment (~> 6.5)
- GoogleUtilities/Logger (~> 6.5)
- nanopb (~> 0.3.901)
- FirebaseCoreDiagnosticsInterop (1.2.0)
- FirebaseInstallations (1.1.1):
- FirebaseCore (~> 6.6)
- GoogleUtilities/UserDefaults (~> 6.5)
- PromisesObjC (~> 1.2)
- Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- GoogleAppMeasurement (6.4.0):
- GoogleUtilities/AppDelegateSwizzler (~> 6.0)
- GoogleUtilities/MethodSwizzler (~> 6.0)
- GoogleUtilities/Network (~> 6.0)
- "GoogleUtilities/NSData+zlib (~> 6.0)"
- nanopb (= 0.3.9011)
- GoogleDataTransport (5.1.0)
- GoogleDataTransportCCTSupport (2.0.1):
- GoogleDataTransport (~> 5.1)
- nanopb (~> 0.3.901)
- GoogleUtilities/AppDelegateSwizzler (6.5.2):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (6.5.2)
- GoogleUtilities/Logger (6.5.2):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (6.5.2):
- GoogleUtilities/Logger
- GoogleUtilities/Network (6.5.2):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (6.5.2)"
- GoogleUtilities/Reachability (6.5.2):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (6.5.2):
- GoogleUtilities/Logger
- nanopb (0.3.9011):
- nanopb/decode (= 0.3.9011)
- nanopb/encode (= 0.3.9011)
- nanopb/decode (0.3.9011)
- nanopb/encode (0.3.9011)
- package_info (0.0.1):
- Flutter
- path_provider (0.0.1):
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- PromisesObjC (1.2.8)
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
Expand All @@ -34,6 +117,10 @@ PODS:
- Flutter

DEPENDENCIES:
- firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_core_web (from `.symlinks/plugins/firebase_core_web/ios`)
- firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`)
- Flutter (from `Flutter`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
Expand All @@ -52,9 +139,31 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- Crashlytics
- Fabric
- Firebase
- FirebaseAnalytics
- FirebaseCore
- FirebaseCoreDiagnostics
- FirebaseCoreDiagnosticsInterop
- FirebaseInstallations
- FMDB
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleDataTransportCCTSupport
- GoogleUtilities
- nanopb
- PromisesObjC

EXTERNAL SOURCES:
firebase_analytics:
:path: ".symlinks/plugins/firebase_analytics/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_core_web:
:path: ".symlinks/plugins/firebase_core_web/ios"
firebase_crashlytics:
:path: ".symlinks/plugins/firebase_crashlytics/ios"
Flutter:
:path: Flutter
package_info:
Expand Down Expand Up @@ -87,11 +196,29 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter/ios"

SPEC CHECKSUMS:
Crashlytics: 540b7e5f5da5a042647227a5e3ac51d85eed06df
Fabric: 706c8b8098fff96c33c0db69cbf81f9c551d0d74
Firebase: f378c80340dd41c0ad0914af740c021eb282a04b
firebase_analytics: dacdcfc524d722fff13dcff942f0dfa47e6be567
firebase_core: 0d8be0e0d14c4902953aeb5ac5d7316d1fe4b978
firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1
firebase_crashlytics: bd8c58df07f107cb7e1a20cb190b9a468e0a69fd
FirebaseAnalytics: a1a0b3327ceb5cd5b4bacffdb293f6c909aa087d
FirebaseCore: 9f495d3afacb7b558711e6218ebb14b1c51b5802
FirebaseCoreDiagnostics: e9b4cd8ba60dee0f2d13347332e4b7898cca5b61
FirebaseCoreDiagnosticsInterop: 296e2c5f5314500a850ad0b83e9e7c10b011a850
FirebaseInstallations: acb3216eb9784d3b1d2d2d635ff74fa892cc0c44
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
GoogleAppMeasurement: 6e68a94d0eaeb1d73ef6b0ed4f7334e29d63ae29
GoogleDataTransport: b29a21d813e906014ca16c00897827e40e4a24ab
GoogleDataTransportCCTSupport: 6f15a89b0ca35d6fa523e1f752ef818588885988
GoogleUtilities: ad0f3b691c67909d03a3327cc205222ab8f42e0e
nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd
package_info: 48b108e75b8802c2d5e126f208ef540561c98aef
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
PromisesObjC: c119f3cd559f50b7ae681fa59dc1acd19173b7e6
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
Expand Down
21 changes: 20 additions & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
709A744B2C9F96E8324FCFAA /* [CP] Embed Pods Frameworks */,
30531896244020B4005AE004 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -209,6 +210,24 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
30531896244020B4005AE004 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)",
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "${PODS_ROOT}/Fabric/run\n\n";
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -252,7 +271,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n";
};
BCE766D7D4DAF9A8FBF015AC /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
32 changes: 32 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,36 @@ class Constants {
static const String settingDisclaimerVersion = 'disclaimer_version';
static const String settingDisclaimerAgreedDateTime =
'disclaimer_agreed_date_time';

/// Analytics screen names avoid changing to keep analytics data constant
/// Even if the UI screen name changes try to keep this as analytics name
static const String analyticsHomeScreen = 'home';
static const String analyticsDisclaimerScreen = 'disclaimer';
static const String analyticsPPEScreen = 'ppe';
static const String analyticsPPEOnScreen = 'ppeOn';
static const String analyticsPPEOffMethod1Screen = 'ppeOffMethod1';
static const String analyticsPPEOffMethod2Screen = 'ppeOffMethod2';
static const String analyticsPPEOnInfographic = 'ppeOnInfographic';
static const String analyticsPPEOffMethod1Infographic = 'ppeOffInfographicM'
'ethod1';
static const String analyticsPPEOffMethod2Infographic = 'ppeOffInfographicM'
'ethod2';
static const String analyticsInformationScreen = 'information';
static const String analyticsWelfareScreen = 'welfare';
static const String analyticsIntubationGuideScreen = 'intubationGuide';
static const String analyticsIntubationGuideInfographic = 'intubationGuideInf'
'ographic';
static const String analyticsIntubationChecklistScreen = 'intubationCheckli'
'st';
static const String analyticsIntubationChecklistInfographic = 'intubationCh'
'ecklistInfographic';
static const String analyticsExtubationGuideScreen = 'extubationGuide';
static const String analyticsExtubationGuideInfographic = 'extubationGuideIn'
'fographic';
static const String analyticsVentilationScreen = 'ventilation';
static const String analyticsVentilationInfographic = 'ventilationInfograph'
'ic';
static const String analyticsDailyRoundScreen = 'dailyRound';
static const String analyticsCrossSkillingScreen = 'crossSkilling';
static const String analyticsLicensesScreen = 'licenses';
}
28 changes: 25 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'dart:async';

import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/material.dart';

import 'hard_data.dart';
import 'intro_router.dart';
import 'routes.dart';
import 'strings.dart';
import 'style.dart';
import 'utils/firebase.dart';
import 'view/airway/checklist/intubation_checklist_infographic_page.dart';
import 'view/airway/checklist/intubation_checklist_page.dart';
import 'view/airway/extubation/extubation_guidance_page.dart';
Expand All @@ -31,7 +35,17 @@ import 'view/staff_welfare/your_welfare_view.dart';
import 'view/view_templates/html_text_card_view_template.dart';

void main() {
runApp(const MyApp());
// Add this, and it should be the first line in main method to ensure no crashes before runApp()
// Currently Crashlytics and SharedPreferences packages below use platform channels so need this before runApp()
WidgetsFlutterBinding.ensureInitialized();

// Crash Reporting configured for not reporting whilst doing Dev mode builds
crashReporting();

// Run Zoned to allow for catching Dart errors
runZoned(() {
runApp(const MyApp());
}, onError: Crashlytics.instance.recordError);
}

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -61,6 +75,8 @@ class MyApp extends StatelessWidget {
Routes.disclaimer: (context) => DisclaimerView(),
Routes.licenses: (context) => LicenseView(),
},
// Analytics route observer to track PageRoute transitions
navigatorObservers: <NavigatorObserver>[Analytics.observer],
onGenerateRoute: (settings) {
// Use onGenerateRoute to set fullscreenDialog=true
switch (settings.name) {
Expand Down Expand Up @@ -135,12 +151,18 @@ class MyApp extends StatelessWidget {
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return HtmlTextCardViewTemplate(
title: data.title, bgColor: data.bgColor, html: '');
title: data.title,
bgColor: data.bgColor,
html: '',
);
} else if (snapshot.hasError) {
return Text('Error: ${snapshot.error}');
} else {
return HtmlTextCardViewTemplate(
title: data.title, bgColor: data.bgColor, html: snapshot.data);
title: data.title,
bgColor: data.bgColor,
html: snapshot.data,
);
}
},
);
Expand Down

0 comments on commit de5e341

Please sign in to comment.