-
Notifications
You must be signed in to change notification settings - Fork 0
Add analytics layer #104
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
Add analytics layer #104
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/// Additional method to track custom events with a specific type. | ||
/// Follow the naming convention for event types. | ||
/// Future trackInitLoginFlow() => trackEvent('init_login', properties: {...}); | ||
/// Future trackErrorLogin() => trackEvent('error_login', properties: {...}); | ||
|
||
abstract class AnalyticsClient { | ||
/// Tracks an event with a function call and a name. | ||
/// This is useful for tracking events that are triggered by specific actions. | ||
/// Example usage: | ||
/// trackFunction(() => loginWithEmailPassword(email, password), 'login_triggered', properties: {email: email}); | ||
Future trackFunction( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Function type is too generic and doesn't provide type safety. Consider using FutureOr Function() or separate methods for sync/async functions to ensure proper type checking and runtime behavior. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
Function fn, | ||
String name, { | ||
Map<String, dynamic>? properties, | ||
}); | ||
|
||
Future trackEvent(String name, {Map<String, dynamic>? properties}); | ||
|
||
Future setUserId(String? userId); | ||
|
||
Future setUserProperties(Map<String, dynamic> properties); | ||
|
||
Future setUserProperty(String name, String value); | ||
|
||
Future reset(); | ||
|
||
Future trackAppCreated(); | ||
|
||
Future trackAppUpdated(); | ||
|
||
Future trackAppDeleted(); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,58 @@ | ||||||||||||||||||
import 'package:common/analytics/abstract/analytics_client.dart'; | ||||||||||||||||||
|
||||||||||||||||||
class FirebaseAnalytics implements AnalyticsClient { | ||||||||||||||||||
@override | ||||||||||||||||||
Future reset() { | ||||||||||||||||||
// TODO: implement reset | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future setUserId(String? userId) { | ||||||||||||||||||
// TODO: implement setUserId | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future setUserProperties(Map<String, dynamic> properties) { | ||||||||||||||||||
// TODO: implement setUserProperties | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future setUserProperty(String name, String value) { | ||||||||||||||||||
// TODO: implement setUserProperty | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future trackAppCreated() { | ||||||||||||||||||
// TODO: implement trackAppCreated | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future trackAppDeleted() { | ||||||||||||||||||
// TODO: implement trackAppDeleted | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future trackAppUpdated() { | ||||||||||||||||||
// TODO: implement trackAppUpdated | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future trackEvent(String name, {Map<String, dynamic>? properties}) { | ||||||||||||||||||
// TODO: implement trackEvent | ||||||||||||||||||
throw UnimplementedError(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
@override | ||||||||||||||||||
Future trackFunction( | ||||||||||||||||||
Function fn, | ||||||||||||||||||
String name, { | ||||||||||||||||||
Map<String, dynamic>? properties, | ||||||||||||||||||
}) => fn().then((_) => trackEvent(name, properties: properties)); | ||||||||||||||||||
|
Function fn, | |
String name, { | |
Map<String, dynamic>? properties, | |
}) => fn().then((_) => trackEvent(name, properties: properties)); | |
FutureOr<void> Function() fn, | |
String name, { | |
Map<String, dynamic>? properties, | |
}) => Future.value(fn()).then((_) => trackEvent(name, properties: properties)); |
Copilot uses AI. Check for mistakes.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
class SetupAnalytics { | ||
static void initialize() { | ||
// Initialize analytics services here | ||
print("Analytics services initialized."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using print() statements for logging is not recommended in production code. Consider using a proper logging framework or removing debug prints before production deployment. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} | ||
} |
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.
The example shows tracking email addresses in analytics properties, which could be sensitive user data. Consider using hashed identifiers or removing PII from analytics examples to avoid accidental data exposure.
Copilot uses AI. Check for mistakes.