Skip to content

Commit d3094a0

Browse files
committed
add analytics layer
1 parent 4d7b528 commit d3094a0

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// Additional method to track custom events with a specific type.
2+
/// Follow the naming convention for event types.
3+
/// Future trackInitLoginFlow() => trackEvent('init_login', properties: {...});
4+
/// Future trackErrorLogin() => trackEvent('error_login', properties: {...});
5+
6+
abstract class AnalyticsClient {
7+
/// Tracks an event with a function call and a name.
8+
/// This is useful for tracking events that are triggered by specific actions.
9+
/// Example usage:
10+
/// trackFunction(() => loginWithEmailPassword(email, password), 'login_triggered', properties: {email: email});
11+
Future trackFunction(
12+
Function fn,
13+
String name, {
14+
Map<String, dynamic>? properties,
15+
});
16+
17+
Future trackEvent(String name, {Map<String, dynamic>? properties});
18+
19+
Future setUserId(String? userId);
20+
21+
Future setUserProperties(Map<String, dynamic> properties);
22+
23+
Future setUserProperty(String name, String value);
24+
25+
Future reset();
26+
27+
Future trackAppCreated();
28+
29+
Future trackAppUpdated();
30+
31+
Future trackAppDeleted();
32+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'package:common/analytics/abstract/analytics_client.dart';
2+
3+
class FirebaseAnalytics implements AnalyticsClient {
4+
@override
5+
Future reset() {
6+
// TODO: implement reset
7+
throw UnimplementedError();
8+
}
9+
10+
@override
11+
Future setUserId(String? userId) {
12+
// TODO: implement setUserId
13+
throw UnimplementedError();
14+
}
15+
16+
@override
17+
Future setUserProperties(Map<String, dynamic> properties) {
18+
// TODO: implement setUserProperties
19+
throw UnimplementedError();
20+
}
21+
22+
@override
23+
Future setUserProperty(String name, String value) {
24+
// TODO: implement setUserProperty
25+
throw UnimplementedError();
26+
}
27+
28+
@override
29+
Future trackAppCreated() {
30+
// TODO: implement trackAppCreated
31+
throw UnimplementedError();
32+
}
33+
34+
@override
35+
Future trackAppDeleted() {
36+
// TODO: implement trackAppDeleted
37+
throw UnimplementedError();
38+
}
39+
40+
@override
41+
Future trackAppUpdated() {
42+
// TODO: implement trackAppUpdated
43+
throw UnimplementedError();
44+
}
45+
46+
@override
47+
Future trackEvent(String name, {Map<String, dynamic>? properties}) {
48+
// TODO: implement trackEvent
49+
throw UnimplementedError();
50+
}
51+
52+
@override
53+
Future trackFunction(
54+
Function fn,
55+
String name, {
56+
Map<String, dynamic>? properties,
57+
}) => fn().then((_) => trackEvent(name, properties: properties));
58+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
class SetupAnalytics {
3+
static void initialize() {
4+
// Initialize analytics services here
5+
print("Analytics services initialized.");
6+
}
7+
}

0 commit comments

Comments
 (0)