Skip to content

Commit

Permalink
[#285] [NF] Screen Widgets. Fix Google Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
lyskouski committed Dec 5, 2024
1 parent 2c2571b commit b5c2b1c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 37 deletions.
7 changes: 6 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
// END: FlutterFire Configuration
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
id "kotlinx-serialization"
id "com.google.gms.google-services"
}

def localProperties = new Properties()
Expand Down Expand Up @@ -72,6 +75,8 @@ android {

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
implementation platform('com.google.firebase:firebase-bom:30.0.0')
implementation 'com.google.firebase:firebase-analytics'
}

flutter {
Expand Down
2 changes: 1 addition & 1 deletion android/app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"project_info": {
"project_number": "316045786606",
"project_id": "fingrom",
"storage_bucket": "fingrom.appspot.com"
"storage_bucket": "fingrom.firebasestorage.app"
},
"client": [
{
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.google.gms:google-services:4.3.15"
classpath "com.google.firebase:firebase-crashlytics-gradle:2.9.2"
}
}
allprojects {
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
id 'com.google.gms.google-services' version '4.4.2' apply false
id 'com.google.gms.google-services' version '4.3.15' apply false
}

include ":app"
49 changes: 23 additions & 26 deletions docs/implementation-flow/ch04-s03-telemetry.tex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ \subsubsection{Activating Google Analytics}
}
\end{lstlisting}

\noindent That might be the case for web, android, ios, and macos; but we have additionally linux and windows that are
\noindent That might be the case for web, android, ios, macos, and windows; but we have additionally linux that is
not supported by now, so, let's patch \q{firebase\_options.dart}-file to return null instead of throwing an exception:

\begin{lstlisting}
Expand All @@ -100,13 +100,7 @@ \subsubsection{Activating Google Analytics}
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
/* ... other cases ... */
case TargetPlatform.linux:
default:
return null;
Expand Down Expand Up @@ -148,45 +142,48 @@ \subsubsection{Activating Google Analytics}

\noindent It's not yet completed unless we follow additional instructions from
\href{https://firebase.google.com/docs/guides/}{https://firebase.google.com/docs/guides/} to configure
Firebase Analytics per each thread (Android, iOS, Macos, Web); as for Android:
Firebase Analytics per each thread (Android, iOS, Web); as for Android:

\begin{lstlisting}[language=yaml]
## ./android/settings.gradle
plugins {
\end{lstlisting}
{
\xpretocmd{\lstlisting}{\vspace{-12pt}}{}{}
\begin{lstlisting}[firstnumber=3, language=yaml, backgroundcolor=\color{backgreen}]
id 'com.google.gms.google-services' version '4.3.15' apply false
\end{lstlisting}
\begin{lstlisting}[firstnumber=4, language=yaml]
}(*@ \stopnumber @*)

## ./android/build.gradle
buildscript {
repositories {
\end{lstlisting}
{
\xpretocmd{\lstlisting}{\vspace{-12pt}}{}{}
\begin{lstlisting}[firstnumber=4, language=yaml, backgroundcolor=\color{backgreen}]
google()
google()
\end{lstlisting}
\begin{lstlisting}[firstnumber=5, language=yaml]
# ... other settings
mavenCentral()
}
dependencies {
# ... other settings
\end{lstlisting}
\begin{lstlisting}[firstnumber=9, language=yaml, backgroundcolor=\color{backgreen}]
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.15'
\end{lstlisting}
\begin{lstlisting}[firstnumber=10, language=yaml]
}(*@ \stopnumber @*)
}
}
}(*@ \stopnumber @*)

## ./android/app/build.gradle
\end{lstlisting}
\begin{lstlisting}[firstnumber=2, language=yaml, backgroundcolor=\color{backgreen}]
apply plugin: 'com.google.gms.google-services'
\end{lstlisting}
\begin{lstlisting}[firstnumber=3, language=yaml]
# ... other settings
dependencies {
plugins {
# ... other settings
\end{lstlisting}
\begin{lstlisting}[firstnumber=6, language=yaml, backgroundcolor=\color{backgreen}]
implementation 'com.google.firebase:firebase-analytics:17.4.1'
\begin{lstlisting}[firstnumber=4, language=yaml, backgroundcolor=\color{backgreen}]
id 'com.google.gms.google-services'
\end{lstlisting}
\begin{lstlisting}[firstnumber=7, language=yaml]
\begin{lstlisting}[firstnumber=5, language=yaml]
}
\end{lstlisting}
}
Expand Down
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"fingrom","appId":"1:316045786606:android:56767cb0c0a39bbfd562ff","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"fingrom","configurations":{"android":"1:316045786606:android:56767cb0c0a39bbfd562ff","ios":"1:316045786606:ios:87bd828f023ae743d562ff","macos":"1:316045786606:ios:87bd828f023ae743d562ff","web":"1:316045786606:web:e9346723741d371ad562ff","windows":"1:316045786606:web:8cdba83e8f2fd15ad562ff"}}}}}}
27 changes: 19 additions & 8 deletions lib/_configs/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform;

Expand All @@ -26,6 +26,7 @@ class DefaultFirebaseOptions {
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
return windows;
case TargetPlatform.linux:
default:
return null;
Expand All @@ -38,7 +39,7 @@ class DefaultFirebaseOptions {
messagingSenderId: '316045786606',
projectId: 'fingrom',
authDomain: 'fingrom.firebaseapp.com',
storageBucket: 'fingrom.appspot.com',
storageBucket: 'fingrom.firebasestorage.app',
measurementId: 'G-ZLKVBF1H4V',
);

Expand All @@ -47,26 +48,36 @@ class DefaultFirebaseOptions {
appId: '1:316045786606:android:56767cb0c0a39bbfd562ff',
messagingSenderId: '316045786606',
projectId: 'fingrom',
storageBucket: 'fingrom.appspot.com',
storageBucket: 'fingrom.firebasestorage.app',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyByWAdeAUDluD-dlJHrt4Z1oyValCuFBpM',
appId: '1:316045786606:ios:87bd828f023ae743d562ff',
messagingSenderId: '316045786606',
projectId: 'fingrom',
storageBucket: 'fingrom.appspot.com',
storageBucket: 'fingrom.firebasestorage.app',
iosClientId: '316045786606-d806bn8s90gj03nil8gooku2frptvrge.apps.googleusercontent.com',
iosBundleId: 'com.tercad.fingrom',
);

static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyByWAdeAUDluD-dlJHrt4Z1oyValCuFBpM',
appId: '1:316045786606:ios:34250e2deee54195d562ff',
appId: '1:316045786606:ios:87bd828f023ae743d562ff',
messagingSenderId: '316045786606',
projectId: 'fingrom',
storageBucket: 'fingrom.firebasestorage.app',
iosClientId: '316045786606-d806bn8s90gj03nil8gooku2frptvrge.apps.googleusercontent.com',
iosBundleId: 'com.tercad.fingrom',
);

static const FirebaseOptions windows = FirebaseOptions(
apiKey: 'AIzaSyDj5sNiVmNi4x1PcL5ciYrX90n2VlMlOwY',
appId: '1:316045786606:web:8cdba83e8f2fd15ad562ff',
messagingSenderId: '316045786606',
projectId: 'fingrom',
storageBucket: 'fingrom.appspot.com',
iosClientId: '316045786606-8tl5sft03rmf5tbdd4k9pk12a4f47d6m.apps.googleusercontent.com',
iosBundleId: 'com.tercad.fingrom.RunnerTests',
authDomain: 'fingrom.firebaseapp.com',
storageBucket: 'fingrom.firebasestorage.app',
measurementId: 'G-4XJJ4TVMGE',
);
}

0 comments on commit b5c2b1c

Please sign in to comment.