-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firabase analytics #250
Open
sush67
wants to merge
1
commit into
himanshusharma89:master
Choose a base branch
from
sush67:analytics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Firabase analytics #250
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
import 'package:firebase_analytics/firebase_analytics.dart'; | ||
import 'package:firebase_analytics/observer.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
|
||
class AnalyticsService { | ||
|
||
final FirebaseAnalytics _analytics = FirebaseAnalytics(); | ||
FirebaseAnalyticsObserver getAnalyticsObserver() => | ||
FirebaseAnalyticsObserver(analytics: _analytics); | ||
|
||
//how to add analytics to a new screen? | ||
//create a Future async function | ||
//create an instance of analyticservice inside the required file like: | ||
// final AnalyticsService analyticsService = locator<AnalyticsService>(); | ||
//call the function with required parameters | ||
Future logLogin({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: 'Login', | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
}); | ||
} | ||
Future loginError({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: 'LoginError', | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
}); | ||
} | ||
|
||
Future logSignUp({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: 'SignUp', | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
}); | ||
} | ||
|
||
Future logSignOut({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "SignOut", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
}); | ||
} | ||
|
||
Future backToShop({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "BackToShop", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
|
||
Future home({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Home", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
|
||
Future search({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "SearchScreen", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future profilePage({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "ProfilePage", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future about({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "About", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future dashboard({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Dashboard", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future productPage({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Product Page", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future wishList({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Wishlist", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future manageAddress({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Manage Address", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future order({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Order", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future changeUsername({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Change Usename", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future settings({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Settings", | ||
parameters: <String, dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
|
||
Future privacyPolicy({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "Privacy Policy", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future notification({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "ToggleNotification", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future termsAndConditions({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "TermsConditions", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future getUserDetails({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "GetUserDetails", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future faq({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "FAQ", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future successPayment({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "SuccessfulPayment", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future gitWebView({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "GitWebView", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future drawer({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "MenuOpened", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future visitCartClicked({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "VisitCart", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future cartScreen({@required String userId}) async { | ||
await _analytics.logEvent( | ||
name: "CartScreen", | ||
parameters: <String,dynamic>{ | ||
'userId': userId, | ||
} | ||
); | ||
} | ||
Future setUserProperties({@required String userId}) async { | ||
await _analytics.setUserId(userId); | ||
} | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:get_it/get_it.dart'; | ||
import 'analytic_service.dart'; | ||
|
||
GetIt locator = GetIt.instance; | ||
void setUpLocator(){ | ||
locator.registerLazySingleton(() => AnalyticsService()); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to pass the userId for every function. Get the userId once and send it to analytics.