Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d6e70b

Browse files
committed
added firebase analytics methods and roots observer
1 parent 50d7e5d commit 9d6e70b

File tree

5 files changed

+129
-30
lines changed

5 files changed

+129
-30
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import 'package:firebase_analytics/firebase_analytics.dart';
2+
import 'package:firebase_analytics/observer.dart';
3+
4+
class AnalytcisManager{
5+
static final AnalytcisManager _instance = AnalytcisManager._init();
6+
static AnalytcisManager get instance => _instance;
7+
AnalytcisManager._init();
8+
9+
static final _analytics = FirebaseAnalytics();
10+
11+
final observer = FirebaseAnalyticsObserver(analytics: _analytics);
12+
13+
Future<void> customEvent(String name) async {
14+
//her şey yapılabilir
15+
await observer.analytics.logEvent(name: name);
16+
}
17+
18+
//USER ANALYTICS
19+
//kayıt sırasında user ıd yi almak için
20+
Future setUserAnalytics(
21+
{ String userID, String name, String value}) async {
22+
await _analytics.setUserId(userID);
23+
24+
//kullanıcılara rol vermek için kullanılabilir (ADMİN-KULLANICI-PREMIUMS VS VS)
25+
//bunu yapacaksak öncelikle
26+
//firebase consola git
27+
//custom definision tıkla
28+
//sap üstte create custom dimensions bas
29+
//user property ye bu parametrdeki name ile aynı ismi ver
30+
//scope den user ı seç
31+
//dimension name ya raporda gözükecek olan başlığı yaz
32+
//descriptiona ufak bi açıklamasını yaz
33+
if (name != null && value != null) {
34+
await observer.analytics.setUserProperty(name: name, value: value);
35+
}
36+
}
37+
38+
Future<void> userLogin(String signUpMethod) async {
39+
await _analytics.logLogin(loginMethod: signUpMethod);
40+
}
41+
42+
Future<void> userSignUp(String signUpMethod) async {
43+
await observer.analytics.logSignUp(signUpMethod: signUpMethod);
44+
}
45+
}

‎lib/core/init/navigation/navigation_route.dart‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,27 @@ import '../../components/card/not_found_navigation_widget.dart';
66
import '../../constants/navigation/navigation_constants.dart';
77

88
class NavigationRoute {
9-
static NavigationRoute _instance = NavigationRoute._init();
9+
static finalNavigationRoute _instance = NavigationRoute._init();
1010
static NavigationRoute get instance => _instance;
1111

1212
NavigationRoute._init();
1313

1414
Route<dynamic> generateRoute(RouteSettings args) {
1515
switch (args.name) {
1616
case NavigationConstants.TEST_VIEW:
17-
return normalNavigate(TestsView());
17+
return normalNavigate(TestsView(),NavigationConstants.TEST_VIEW);
1818
default:
1919
return MaterialPageRoute(
2020
builder: (context) => NotFoundNavigationWidget(),
2121
);
2222
}
2323
}
2424

25-
MaterialPageRoute normalNavigate(Widget widget) {
25+
MaterialPageRoute normalNavigate(Widget widget,String pageName) {
2626
return MaterialPageRoute(
2727
builder: (context) => widget,
28+
//analytciste görülecek olan sayfa ismi için pageName veriyoruz
29+
settings: RouteSettings(name: pageName)
2830
);
2931
}
3032
}

‎lib/main.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:easy_localization/easy_localization.dart';
22
import 'package:flutter/material.dart';
3+
import 'package:fluttermvvmtemplate/core/init/analytics/analytics_manager.dart';
34
import 'package:provider/provider.dart';
45

56
import 'core/constants/app/app_constants.dart';
@@ -29,6 +30,7 @@ class MyApp extends StatelessWidget {
2930
home: GameView(),
3031
onGenerateRoute: NavigationRoute.instance.generateRoute,
3132
navigatorKey: NavigationService.instance.navigatorKey,
33+
navigatorObservers: [AnalytcisManager.instance.observer],
3234
);
3335
}
3436
}

‎pubspec.lock‎

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ packages:
4242
name: async
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "2.5.0-nullsafety.1"
45+
version: "2.5.0"
4646
auto_size_text:
4747
dependency: "direct main"
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: boolean_selector
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "2.1.0-nullsafety.1"
59+
version: "2.1.0"
6060
build:
6161
dependency: transitive
6262
description:
@@ -126,14 +126,14 @@ packages:
126126
name: characters
127127
url: "https://pub.dartlang.org"
128128
source: hosted
129-
version: "1.1.0-nullsafety.3"
129+
version: "1.1.0"
130130
charcode:
131131
dependency: transitive
132132
description:
133133
name: charcode
134134
url: "https://pub.dartlang.org"
135135
source: hosted
136-
version: "1.2.0-nullsafety.1"
136+
version: "1.2.0"
137137
checked_yaml:
138138
dependency: transitive
139139
description:
@@ -154,7 +154,7 @@ packages:
154154
name: clock
155155
url: "https://pub.dartlang.org"
156156
source: hosted
157-
version: "1.1.0-nullsafety.1"
157+
version: "1.1.0"
158158
code_builder:
159159
dependency: transitive
160160
description:
@@ -168,7 +168,7 @@ packages:
168168
name: collection
169169
url: "https://pub.dartlang.org"
170170
source: hosted
171-
version: "1.15.0-nullsafety.3"
171+
version: "1.15.0"
172172
convert:
173173
dependency: transitive
174174
description:
@@ -224,14 +224,14 @@ packages:
224224
name: easy_localization
225225
url: "https://pub.dartlang.org"
226226
source: hosted
227-
version: "2.3.3"
227+
version: "2.3.3+1"
228228
fake_async:
229229
dependency: transitive
230230
description:
231231
name: fake_async
232232
url: "https://pub.dartlang.org"
233233
source: hosted
234-
version: "1.2.0-nullsafety.1"
234+
version: "1.2.0"
235235
ffi:
236236
dependency: transitive
237237
description:
@@ -245,7 +245,56 @@ packages:
245245
name: file
246246
url: "https://pub.dartlang.org"
247247
source: hosted
248-
version: "5.2.1"
248+
version: "6.1.0"
249+
firebase:
250+
dependency: transitive
251+
description:
252+
name: firebase
253+
url: "https://pub.dartlang.org"
254+
source: hosted
255+
version: "7.3.3"
256+
firebase_analytics:
257+
dependency: "direct main"
258+
description:
259+
name: firebase_analytics
260+
url: "https://pub.dartlang.org"
261+
source: hosted
262+
version: "7.0.1"
263+
firebase_analytics_platform_interface:
264+
dependency: transitive
265+
description:
266+
name: firebase_analytics_platform_interface
267+
url: "https://pub.dartlang.org"
268+
source: hosted
269+
version: "1.1.0"
270+
firebase_analytics_web:
271+
dependency: transitive
272+
description:
273+
name: firebase_analytics_web
274+
url: "https://pub.dartlang.org"
275+
source: hosted
276+
version: "0.1.1"
277+
firebase_core:
278+
dependency: transitive
279+
description:
280+
name: firebase_core
281+
url: "https://pub.dartlang.org"
282+
source: hosted
283+
version: "0.7.0"
284+
firebase_core_platform_interface:
285+
dependency: transitive
286+
description:
287+
name: firebase_core_platform_interface
288+
url: "https://pub.dartlang.org"
289+
source: hosted
290+
version: "3.0.1"
291+
firebase_core_web:
292+
dependency: transitive
293+
description:
294+
name: firebase_core_web
295+
url: "https://pub.dartlang.org"
296+
source: hosted
297+
version: "0.2.1+3"
249298
fixnum:
250299
dependency: transitive
251300
description:
@@ -349,7 +398,7 @@ packages:
349398
name: intl
350399
url: "https://pub.dartlang.org"
351400
source: hosted
352-
version: "0.16.1"
401+
version: "0.17.0"
353402
io:
354403
dependency: transitive
355404
description:
@@ -363,7 +412,7 @@ packages:
363412
name: js
364413
url: "https://pub.dartlang.org"
365414
source: hosted
366-
version: "0.6.2"
415+
version: "0.6.3"
367416
json_annotation:
368417
dependency: "direct main"
369418
description:
@@ -405,14 +454,14 @@ packages:
405454
name: matcher
406455
url: "https://pub.dartlang.org"
407456
source: hosted
408-
version: "0.12.10-nullsafety.1"
457+
version: "0.12.10"
409458
meta:
410459
dependency: transitive
411460
description:
412461
name: meta
413462
url: "https://pub.dartlang.org"
414463
source: hosted
415-
version: "1.3.0-nullsafety.3"
464+
version: "1.3.0"
416465
mime:
417466
dependency: transitive
418467
description:
@@ -461,7 +510,7 @@ packages:
461510
name: node_io
462511
url: "https://pub.dartlang.org"
463512
source: hosted
464-
version: "1.2.0"
513+
version: "1.1.1"
465514
octo_image:
466515
dependency: transitive
467516
description:
@@ -482,7 +531,7 @@ packages:
482531
name: path
483532
url: "https://pub.dartlang.org"
484533
source: hosted
485-
version: "1.8.0-nullsafety.1"
534+
version: "1.8.0"
486535
path_drawing:
487536
dependency: transitive
488537
description:
@@ -552,7 +601,7 @@ packages:
552601
name: platform
553602
url: "https://pub.dartlang.org"
554603
source: hosted
555-
version: "2.2.1"
604+
version: "3.0.0"
556605
plugin_platform_interface:
557606
dependency: transitive
558607
description:
@@ -573,7 +622,7 @@ packages:
573622
name: process
574623
url: "https://pub.dartlang.org"
575624
source: hosted
576-
version: "3.0.13"
625+
version: "4.2.1"
577626
provider:
578627
dependency: "direct main"
579628
description:
@@ -697,7 +746,7 @@ packages:
697746
name: source_span
698747
url: "https://pub.dartlang.org"
699748
source: hosted
700-
version: "1.8.0-nullsafety.2"
749+
version: "1.8.0"
701750
sqflite:
702751
dependency: transitive
703752
description:
@@ -718,14 +767,14 @@ packages:
718767
name: stack_trace
719768
url: "https://pub.dartlang.org"
720769
source: hosted
721-
version: "1.10.0-nullsafety.1"
770+
version: "1.10.0"
722771
stream_channel:
723772
dependency: transitive
724773
description:
725774
name: stream_channel
726775
url: "https://pub.dartlang.org"
727776
source: hosted
728-
version: "2.1.0-nullsafety.1"
777+
version: "2.1.0"
729778
stream_transform:
730779
dependency: transitive
731780
description:
@@ -739,7 +788,7 @@ packages:
739788
name: string_scanner
740789
url: "https://pub.dartlang.org"
741790
source: hosted
742-
version: "1.1.0-nullsafety.1"
791+
version: "1.1.0"
743792
synchronized:
744793
dependency: transitive
745794
description:
@@ -753,14 +802,14 @@ packages:
753802
name: term_glyph
754803
url: "https://pub.dartlang.org"
755804
source: hosted
756-
version: "1.2.0-nullsafety.1"
805+
version: "1.2.0"
757806
test_api:
758807
dependency: transitive
759808
description:
760809
name: test_api
761810
url: "https://pub.dartlang.org"
762811
source: hosted
763-
version: "0.2.19-nullsafety.2"
812+
version: "0.2.19"
764813
timing:
765814
dependency: transitive
766815
description:
@@ -774,7 +823,7 @@ packages:
774823
name: typed_data
775824
url: "https://pub.dartlang.org"
776825
source: hosted
777-
version: "1.3.0-nullsafety.3"
826+
version: "1.3.0"
778827
url_launcher:
779828
dependency: transitive
780829
description:
@@ -830,7 +879,7 @@ packages:
830879
name: vector_math
831880
url: "https://pub.dartlang.org"
832881
source: hosted
833-
version: "2.1.0-nullsafety.3"
882+
version: "2.1.0"
834883
vexana:
835884
dependency: "direct main"
836885
description:
@@ -881,5 +930,5 @@ packages:
881930
source: hosted
882931
version: "2.2.1"
883932
sdks:
884-
dart: ">=2.10.2 <2.11.0"
885-
flutter: ">=1.22.2 <2.0.0"
933+
dart: ">=2.12.0-0.0 <3.0.0"
934+
flutter: ">=1.22.2"

‎pubspec.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies:
3030
cupertino_icons: ^0.1.3
3131
dio: ^3.0.9
3232
easy_localization: ^2.3.2
33+
firebase_analytics: any
3334
flutter_mobx: ^1.1.0
3435
flutter_svg: any
3536
json_annotation: ^3.0.1

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /