Skip to content

Commit bc7b398

Browse files
* ✨ Firebase analytics Co-authored-by: sanni prasad <prasadsunny1@gmail.com>
1 parent 15c6269 commit bc7b398

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ build/
2121
/.flutter-plugins
2222
/android/app/google-services.json
2323
/android/misc/api-8857670977859340350-9644-c1e382e20443.json
24+
.flutter-plugins-dependencies
25+
.dart_tool/

android/app/build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if (flutterVersionName == null) {
2424
apply plugin: 'com.android.application'
2525
apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
27+
apply plugin: 'com.google.gms.google-services' // Google Services plugin
2828
def keystoreProperties = new Properties()
2929
def keystorePropertiesFile = rootProject.file('key.properties')
3030
if (keystorePropertiesFile.exists()) {
@@ -63,10 +63,7 @@ android {
6363
buildTypes {
6464
release {
6565
signingConfig signingConfigs.release
66-
minifyEnabled true
67-
useProguard true
6866

69-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7067
}
7168
}
7269
}
@@ -78,6 +75,7 @@ flutter {
7875
dependencies {
7976
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
8077
testImplementation 'junit:junit:4.12'
81-
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
82-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
78+
androidTestImplementation 'androidx.test:runner:1.3.0-alpha03'
79+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
80+
implementation 'com.google.firebase:firebase-analytics:17.2.0'
8381
}

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ buildscript {
88
dependencies {
99
classpath 'com.android.tools.build:gradle:3.5.3'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11+
classpath 'com.google.gms:google-services:4.3.3'
1112
}
1213
}
1314

lib/ExampleNameItem.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:firebase_analytics/firebase_analytics.dart';
56
import 'package:flutter/material.dart';
67
import 'package:flutter_playground/models/ExapmleNames.dart';
8+
import 'package:flutter_playground/values/imports.dart';
79
import 'package:meta/meta.dart';
810

911
/// A [ExampleNameItem] to display a [ExampleNames].
@@ -42,6 +44,7 @@ class ExampleNameItem extends StatelessWidget {
4244
child: InkWell(
4345
onTap: () {
4446
Navigator.pushNamed(context, "/${exampleNames.title}");
47+
FirebaseAnalytics().setCurrentScreen(screenName: exampleNames.title);
4548
},
4649
child: Row(
4750
mainAxisAlignment: MainAxisAlignment.spaceBetween,

lib/my_app.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:firebase_analytics/firebase_analytics.dart';
2+
import 'package:firebase_analytics/observer.dart';
13
import 'package:flutter/material.dart';
24
import 'package:flutter_mobx/flutter_mobx.dart';
35
import 'package:flutter_playground/ui_ux/home_page/my_home_page.dart';
@@ -10,6 +12,10 @@ import 'ui_ux/home_page/my_home_page_store.dart';
1012
import 'utils/Strings.dart';
1113

1214
class MyApp extends StatelessObserverWidget {
15+
static FirebaseAnalytics analytics = FirebaseAnalytics();
16+
static FirebaseAnalyticsObserver observer =
17+
FirebaseAnalyticsObserver(analytics: analytics);
18+
1319
@override
1420
Widget build(BuildContext context) {
1521
return MaterialApp(

pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ description: A Flutter application contains a list of Flutter Examples.
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 1.2.6+9
14+
version: 1.2.7+10
1515

1616
environment:
1717
sdk: ">=2.7.0-dev.2.1 <3.0.0"
@@ -33,6 +33,9 @@ dependencies:
3333
provider: ^4.0.1
3434
url_launcher: ^5.4.1
3535
webview_flutter: 0.3.19+5
36+
firebase_analytics: ^5.0.10
37+
firebase_core: ^0.4.3+2
38+
3639

3740
dev_dependencies:
3841
flutter_test:

0 commit comments

Comments
 (0)