diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb52a78..83f138d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.0.6
+* Support dart sdk environment for the dart applications.
+* Update README.md
+* Update example to use the latest version of the package.
+* Update description of the pubspec.yaml file.
+
## 1.0.5
* Update description of the pubspec.yaml file.
diff --git a/README.md b/README.md
index e39147d..1846f2f 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,14 @@
# analytics_logger_gen
-[analytics_logger_gen](https://github.com/9oya/analytics_logger_gen) is a code generator that generates an event logger for analytics tools like FirebaseAnalytics and AppsFlyer. Import events from Google Spreadsheets, remote repositories or CSV files.
+[analytics_logger_gen](https://github.com/9oya/analytics_logger_gen) is a code generator that generates analytics events for tools like FirebaseAnalytics. Import events from Google Spreadsheets, remote repositories or local CSV files.
## Running the generator
```shell
flutter packages pub run build_runner build
```
+
+Other useful commands
+
```shell
flutter packages pub run build_runner build --delete-conflicting-outputs
# if you want to delete the generated files before building
@@ -13,6 +16,8 @@ flutter packages pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner clean
# if generated files are not updated after modifying the CSV file
```
+
+
## Basic Usage
### Calling the generated code
```dart
@@ -39,7 +44,7 @@ part 'analytics_logger.g.dart';
})
// The class should be declared private '_' to avoid conflicts with the generated class
// ignore: unused_element
-class _CommonAnalyticsLogger {}
+class _EventLoggerContainer {}
// You can declare any number of loggers for third-party analytics tools.
class FirebaseAnalyticsLogger extends EventLogger {
@@ -57,11 +62,11 @@ class FirebaseAnalyticsLogger extends EventLogger {
void logEvent(String event, {required Map attributes}) {
// Do something with the event and attributes
- switch (AnalyticsEvent.fromName(event)) {
- case AnalyticsEvent.setUserId:
+ switch (EventType.fromName(event)) {
+ case EventType.setUserId:
_analytics.setUserId(id: attributes.values.first?.value.toString());
break;
- case AnalyticsEvent.setUserInfo:
+ case EventType.setUserInfo:
for (final entry in attributes.entries) {
_analytics.setUserProperty(
name: entry.key,
@@ -128,7 +133,7 @@ part 'logger_from_local_file.g.dart';
providerName: 'EventProvider',
eventTypeName: 'EventType')
// ignore: unused_element
-class _CommonEventLogger {}
+class _EventLoggerContainer {}
```
#### Remote CSV file
```dart
@@ -152,7 +157,7 @@ part 'logger_from_google_spread_sheet.g.dart';
providerName: 'EventProvider',
eventTypeName: 'EventType')
// ignore: unused_element
-class _CommonEventLogger {}
+class _EventLoggerContainer {}
class FirebaseAnalyticsLogger extends EventLogger {
FirebaseAnalyticsLogger();
@@ -286,26 +291,26 @@ class EventProvider {
'title': title,
'message': message,
};
- CommonAnalyticsLogger.logEvent(EventType.appStarted, attributes);
+ EventLoggerContainer.logEvent(EventType.appStarted, attributes);
}
static void homePageEntered({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonAnalyticsLogger.logEvent(EventType.homePageEntered, attributes);
+ EventLoggerContainer.logEvent(EventType.homePageEntered, attributes);
}
static void appEnded() {
Map attributes = {};
- CommonAnalyticsLogger.logEvent(EventType.appEnded, attributes);
+ EventLoggerContainer.logEvent(EventType.appEnded, attributes);
}
static void buttonClicked({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonAnalyticsLogger.logEvent(EventType.buttonClicked, attributes);
+ EventLoggerContainer.logEvent(EventType.buttonClicked, attributes);
}
static void selectContents({dynamic contentType, dynamic itemId}) {
@@ -313,7 +318,7 @@ class EventProvider {
'contentType': contentType,
'itemId': itemId,
};
- CommonAnalyticsLogger.logEvent(EventType.selectContents, attributes);
+ EventLoggerContainer.logEvent(EventType.selectContents, attributes);
}
static void sendMessage({dynamic title, dynamic message}) {
@@ -321,26 +326,26 @@ class EventProvider {
'title': title,
'message': message,
};
- CommonAnalyticsLogger.logEvent(EventType.sendMessage, attributes);
+ EventLoggerContainer.logEvent(EventType.sendMessage, attributes);
}
static void countIncreased({dynamic count}) {
Map attributes = {
'count': count,
};
- CommonAnalyticsLogger.logEvent(EventType.countIncreased, attributes);
+ EventLoggerContainer.logEvent(EventType.countIncreased, attributes);
}
static void bannerClicked() {
Map attributes = {};
- CommonAnalyticsLogger.logEvent(EventType.bannerClicked, attributes);
+ EventLoggerContainer.logEvent(EventType.bannerClicked, attributes);
}
static void setUserId({dynamic id}) {
Map attributes = {
'id': id,
};
- CommonAnalyticsLogger.logEvent(EventType.setUserId, attributes);
+ EventLoggerContainer.logEvent(EventType.setUserId, attributes);
}
static void setUserInfo({dynamic age, dynamic gender}) {
@@ -348,7 +353,7 @@ class EventProvider {
'age': age,
'gender': gender,
};
- CommonAnalyticsLogger.logEvent(EventType.setUserInfo, attributes);
+ EventLoggerContainer.logEvent(EventType.setUserInfo, attributes);
}
static void purchase(
@@ -359,12 +364,12 @@ class EventProvider {
'currency': currency,
'quantity': quantity,
};
- CommonAnalyticsLogger.logEvent(EventType.purchase, attributes);
+ EventLoggerContainer.logEvent(EventType.purchase, attributes);
}
}
-class CommonAnalyticsLogger {
- CommonAnalyticsLogger._();
+class EventLoggerContainer {
+ EventLoggerContainer._();
static FirebaseAnalyticsLogger firebaseAnalyticsLogger =
FirebaseAnalyticsLogger();
static AppsFlyerLogger appsFlyerLogger = AppsFlyerLogger();
diff --git a/example/lib/generated_event_providers/logger_from_github_repo.dart b/example/lib/generated_event_providers/logger_from_github_repo.dart
index fb1a7a2..d799e1c 100644
--- a/example/lib/generated_event_providers/logger_from_github_repo.dart
+++ b/example/lib/generated_event_providers/logger_from_github_repo.dart
@@ -18,4 +18,4 @@ part 'logger_from_github_repo.g.dart';
providerName: 'EventProviderA',
eventTypeName: 'EventTypeA')
// ignore: unused_element
-class _CommonEventLoggerA {}
+class _EventLoggerContainerA {}
diff --git a/example/lib/generated_event_providers/logger_from_github_repo.g.dart b/example/lib/generated_event_providers/logger_from_github_repo.g.dart
index a69a5dd..f03f4fa 100644
--- a/example/lib/generated_event_providers/logger_from_github_repo.g.dart
+++ b/example/lib/generated_event_providers/logger_from_github_repo.g.dart
@@ -67,31 +67,32 @@ enum EventTypeA {
class EventProviderA {
EventProviderA._();
+
static void appStarted({dynamic title, dynamic message}) {
Map attributes = {
'title': title,
'message': message,
};
- CommonEventLoggerA.logEvent(EventTypeA.appStarted, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.appStarted, attributes);
}
static void homePageEntered({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerA.logEvent(EventTypeA.homePageEntered, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.homePageEntered, attributes);
}
static void appEnded() {
Map attributes = {};
- CommonEventLoggerA.logEvent(EventTypeA.appEnded, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.appEnded, attributes);
}
static void buttonClicked({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerA.logEvent(EventTypeA.buttonClicked, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.buttonClicked, attributes);
}
static void selectContents({dynamic contentType, dynamic itemId}) {
@@ -99,7 +100,7 @@ class EventProviderA {
'contentType': contentType,
'itemId': itemId,
};
- CommonEventLoggerA.logEvent(EventTypeA.selectContents, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.selectContents, attributes);
}
static void sendMessage({dynamic title, dynamic message}) {
@@ -107,26 +108,26 @@ class EventProviderA {
'title': title,
'message': message,
};
- CommonEventLoggerA.logEvent(EventTypeA.sendMessage, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.sendMessage, attributes);
}
static void countIncreased({dynamic count}) {
Map attributes = {
'count': count,
};
- CommonEventLoggerA.logEvent(EventTypeA.countIncreased, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.countIncreased, attributes);
}
static void bannerClicked() {
Map attributes = {};
- CommonEventLoggerA.logEvent(EventTypeA.bannerClicked, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.bannerClicked, attributes);
}
static void setUserId({dynamic id}) {
Map attributes = {
'id': id,
};
- CommonEventLoggerA.logEvent(EventTypeA.setUserId, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.setUserId, attributes);
}
static void setUserInfo({dynamic age, dynamic gender}) {
@@ -134,7 +135,7 @@ class EventProviderA {
'age': age,
'gender': gender,
};
- CommonEventLoggerA.logEvent(EventTypeA.setUserInfo, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.setUserInfo, attributes);
}
static void purchase(
@@ -145,12 +146,12 @@ class EventProviderA {
'currency': currency,
'quantity': quantity,
};
- CommonEventLoggerA.logEvent(EventTypeA.purchase, attributes);
+ EventLoggerContainerA.logEvent(EventTypeA.purchase, attributes);
}
}
-class CommonEventLoggerA {
- CommonEventLoggerA._();
+class EventLoggerContainerA {
+ EventLoggerContainerA._();
static FirebaseAnalyticsLogger firebaseAnalyticsLogger =
FirebaseAnalyticsLogger();
static AppsFlyerLogger appsFlyerLogger = AppsFlyerLogger();
@@ -158,6 +159,7 @@ class CommonEventLoggerA {
static MixpanelLogger mixpanelLogger = MixpanelLogger();
static SingularLogger singularLogger = SingularLogger();
static DatadogDebugLogger datadogDebugLogger = DatadogDebugLogger();
+
static void setup() {
firebaseAnalyticsLogger.setup();
appsFlyerLogger.setup();
diff --git a/example/lib/generated_event_providers/logger_from_google_spread_sheet.dart b/example/lib/generated_event_providers/logger_from_google_spread_sheet.dart
index eab06a3..7b69092 100644
--- a/example/lib/generated_event_providers/logger_from_google_spread_sheet.dart
+++ b/example/lib/generated_event_providers/logger_from_google_spread_sheet.dart
@@ -18,4 +18,4 @@ part 'logger_from_google_spread_sheet.g.dart';
providerName: 'EventProviderB',
eventTypeName: 'EventTypeB')
// ignore: unused_element
-class _CommonEventLoggerB {}
+class _EventLoggerContainerB {}
diff --git a/example/lib/generated_event_providers/logger_from_google_spread_sheet.g.dart b/example/lib/generated_event_providers/logger_from_google_spread_sheet.g.dart
index ece5c79..35ba68b 100644
--- a/example/lib/generated_event_providers/logger_from_google_spread_sheet.g.dart
+++ b/example/lib/generated_event_providers/logger_from_google_spread_sheet.g.dart
@@ -67,31 +67,32 @@ enum EventTypeB {
class EventProviderB {
EventProviderB._();
+
static void appStarted({dynamic title, dynamic message}) {
Map attributes = {
'title': title,
'message': message,
};
- CommonEventLoggerB.logEvent(EventTypeB.appStarted, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.appStarted, attributes);
}
static void homePageEntered({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerB.logEvent(EventTypeB.homePageEntered, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.homePageEntered, attributes);
}
static void appEnded() {
Map attributes = {};
- CommonEventLoggerB.logEvent(EventTypeB.appEnded, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.appEnded, attributes);
}
static void buttonClicked({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerB.logEvent(EventTypeB.buttonClicked, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.buttonClicked, attributes);
}
static void selectContents({dynamic contentType, dynamic itemId}) {
@@ -99,7 +100,7 @@ class EventProviderB {
'contentType': contentType,
'itemId': itemId,
};
- CommonEventLoggerB.logEvent(EventTypeB.selectContents, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.selectContents, attributes);
}
static void sendMessage({dynamic title, dynamic message}) {
@@ -107,26 +108,26 @@ class EventProviderB {
'title': title,
'message': message,
};
- CommonEventLoggerB.logEvent(EventTypeB.sendMessage, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.sendMessage, attributes);
}
static void countIncreased({dynamic count}) {
Map attributes = {
'count': count,
};
- CommonEventLoggerB.logEvent(EventTypeB.countIncreased, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.countIncreased, attributes);
}
static void bannerClicked() {
Map attributes = {};
- CommonEventLoggerB.logEvent(EventTypeB.bannerClicked, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.bannerClicked, attributes);
}
static void setUserId({dynamic id}) {
Map attributes = {
'id': id,
};
- CommonEventLoggerB.logEvent(EventTypeB.setUserId, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.setUserId, attributes);
}
static void setUserInfo({dynamic age, dynamic gender}) {
@@ -134,7 +135,7 @@ class EventProviderB {
'age': age,
'gender': gender,
};
- CommonEventLoggerB.logEvent(EventTypeB.setUserInfo, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.setUserInfo, attributes);
}
static void purchase(
@@ -145,12 +146,12 @@ class EventProviderB {
'currency': currency,
'quantity': quantity,
};
- CommonEventLoggerB.logEvent(EventTypeB.purchase, attributes);
+ EventLoggerContainerB.logEvent(EventTypeB.purchase, attributes);
}
}
-class CommonEventLoggerB {
- CommonEventLoggerB._();
+class EventLoggerContainerB {
+ EventLoggerContainerB._();
static FirebaseAnalyticsLogger firebaseAnalyticsLogger =
FirebaseAnalyticsLogger();
static AppsFlyerLogger appsFlyerLogger = AppsFlyerLogger();
@@ -158,6 +159,7 @@ class CommonEventLoggerB {
static MixpanelLogger mixpanelLogger = MixpanelLogger();
static SingularLogger singularLogger = SingularLogger();
static DatadogDebugLogger datadogDebugLogger = DatadogDebugLogger();
+
static void setup() {
firebaseAnalyticsLogger.setup();
appsFlyerLogger.setup();
diff --git a/example/lib/generated_event_providers/logger_from_local_file.dart b/example/lib/generated_event_providers/logger_from_local_file.dart
index 7c1627d..9a23391 100644
--- a/example/lib/generated_event_providers/logger_from_local_file.dart
+++ b/example/lib/generated_event_providers/logger_from_local_file.dart
@@ -17,4 +17,4 @@ part 'logger_from_local_file.g.dart';
providerName: 'EventProviderC',
eventTypeName: 'EventTypeC')
// ignore: unused_element
-class _CommonEventLoggerC {}
+class _EventLoggerContainerC {}
diff --git a/example/lib/generated_event_providers/logger_from_local_file.g.dart b/example/lib/generated_event_providers/logger_from_local_file.g.dart
index cca1883..014b3a1 100644
--- a/example/lib/generated_event_providers/logger_from_local_file.g.dart
+++ b/example/lib/generated_event_providers/logger_from_local_file.g.dart
@@ -67,31 +67,32 @@ enum EventTypeC {
class EventProviderC {
EventProviderC._();
+
static void appStarted({dynamic title, dynamic message}) {
Map attributes = {
'title': title,
'message': message,
};
- CommonEventLoggerC.logEvent(EventTypeC.appStarted, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.appStarted, attributes);
}
static void homePageEntered({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerC.logEvent(EventTypeC.homePageEntered, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.homePageEntered, attributes);
}
static void appEnded() {
Map attributes = {};
- CommonEventLoggerC.logEvent(EventTypeC.appEnded, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.appEnded, attributes);
}
static void buttonClicked({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonEventLoggerC.logEvent(EventTypeC.buttonClicked, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.buttonClicked, attributes);
}
static void selectContents({dynamic contentType, dynamic itemId}) {
@@ -99,7 +100,7 @@ class EventProviderC {
'contentType': contentType,
'itemId': itemId,
};
- CommonEventLoggerC.logEvent(EventTypeC.selectContents, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.selectContents, attributes);
}
static void sendMessage({dynamic title, dynamic message}) {
@@ -107,26 +108,26 @@ class EventProviderC {
'title': title,
'message': message,
};
- CommonEventLoggerC.logEvent(EventTypeC.sendMessage, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.sendMessage, attributes);
}
static void countIncreased({dynamic count}) {
Map attributes = {
'count': count,
};
- CommonEventLoggerC.logEvent(EventTypeC.countIncreased, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.countIncreased, attributes);
}
static void bannerClicked() {
Map attributes = {};
- CommonEventLoggerC.logEvent(EventTypeC.bannerClicked, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.bannerClicked, attributes);
}
static void setUserId({dynamic id}) {
Map attributes = {
'id': id,
};
- CommonEventLoggerC.logEvent(EventTypeC.setUserId, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.setUserId, attributes);
}
static void setUserInfo({dynamic age, dynamic gender}) {
@@ -134,7 +135,7 @@ class EventProviderC {
'age': age,
'gender': gender,
};
- CommonEventLoggerC.logEvent(EventTypeC.setUserInfo, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.setUserInfo, attributes);
}
static void purchase(
@@ -145,12 +146,12 @@ class EventProviderC {
'currency': currency,
'quantity': quantity,
};
- CommonEventLoggerC.logEvent(EventTypeC.purchase, attributes);
+ EventLoggerContainerC.logEvent(EventTypeC.purchase, attributes);
}
}
-class CommonEventLoggerC {
- CommonEventLoggerC._();
+class EventLoggerContainerC {
+ EventLoggerContainerC._();
static FirebaseAnalyticsLogger firebaseAnalyticsLogger =
FirebaseAnalyticsLogger();
static AppsFlyerLogger appsFlyerLogger = AppsFlyerLogger();
@@ -158,6 +159,7 @@ class CommonEventLoggerC {
static MixpanelLogger mixpanelLogger = MixpanelLogger();
static SingularLogger singularLogger = SingularLogger();
static DatadogDebugLogger datadogDebugLogger = DatadogDebugLogger();
+
static void setup() {
firebaseAnalyticsLogger.setup();
appsFlyerLogger.setup();
diff --git a/example/lib/main.dart b/example/lib/main.dart
index bfbb9ac..7a6dee2 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -10,7 +10,7 @@ part 'main.g.dart';
@AnalyticsLogger(
localCsvPath: 'assets/logger_gen_example_v3.csv',
- loggers: {
+ loggers: {
FirebaseAnalyticsLogger: 'isFirebaseEnabled',
AppsFlyerLogger: 'isAppsFlyerEnabled',
AmplitudeLogger: 'isAmplitudeEnabled',
@@ -21,7 +21,7 @@ part 'main.g.dart';
providerName: 'EventProvider',
eventTypeName: 'EventType')
// ignore: unused_element
-class _CommonAnalyticsLogger {}
+class _EventLoggerContainer {}
void main() {
runApp(const MyApp());
@@ -64,7 +64,13 @@ class _MyHomePageState extends State {
@override
void initState() {
super.initState();
- CommonAnalyticsLogger.setup();
+
+ // Initialize all event loggers
+ EventLoggerContainer.setup();
+
+ // or initialize each event logger individually
+ EventLoggerContainer.firebaseAnalyticsLogger.setup();
+
EventProvider.appStarted();
}
diff --git a/example/lib/main.g.dart b/example/lib/main.g.dart
index 9c37c4d..064ed3a 100644
--- a/example/lib/main.g.dart
+++ b/example/lib/main.g.dart
@@ -67,31 +67,32 @@ enum EventType {
class EventProvider {
EventProvider._();
+
static void appStarted({dynamic title, dynamic message}) {
Map attributes = {
'title': title,
'message': message,
};
- CommonAnalyticsLogger.logEvent(EventType.appStarted, attributes);
+ EventLoggerContainer.logEvent(EventType.appStarted, attributes);
}
static void homePageEntered({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonAnalyticsLogger.logEvent(EventType.homePageEntered, attributes);
+ EventLoggerContainer.logEvent(EventType.homePageEntered, attributes);
}
static void appEnded() {
Map attributes = {};
- CommonAnalyticsLogger.logEvent(EventType.appEnded, attributes);
+ EventLoggerContainer.logEvent(EventType.appEnded, attributes);
}
static void buttonClicked({dynamic abTestCase}) {
Map attributes = {
'abTestCase': abTestCase,
};
- CommonAnalyticsLogger.logEvent(EventType.buttonClicked, attributes);
+ EventLoggerContainer.logEvent(EventType.buttonClicked, attributes);
}
static void selectContents({dynamic contentType, dynamic itemId}) {
@@ -99,7 +100,7 @@ class EventProvider {
'contentType': contentType,
'itemId': itemId,
};
- CommonAnalyticsLogger.logEvent(EventType.selectContents, attributes);
+ EventLoggerContainer.logEvent(EventType.selectContents, attributes);
}
static void sendMessage({dynamic title, dynamic message}) {
@@ -107,26 +108,26 @@ class EventProvider {
'title': title,
'message': message,
};
- CommonAnalyticsLogger.logEvent(EventType.sendMessage, attributes);
+ EventLoggerContainer.logEvent(EventType.sendMessage, attributes);
}
static void countIncreased({dynamic count}) {
Map attributes = {
'count': count,
};
- CommonAnalyticsLogger.logEvent(EventType.countIncreased, attributes);
+ EventLoggerContainer.logEvent(EventType.countIncreased, attributes);
}
static void bannerClicked() {
Map attributes = {};
- CommonAnalyticsLogger.logEvent(EventType.bannerClicked, attributes);
+ EventLoggerContainer.logEvent(EventType.bannerClicked, attributes);
}
static void setUserId({dynamic id}) {
Map attributes = {
'id': id,
};
- CommonAnalyticsLogger.logEvent(EventType.setUserId, attributes);
+ EventLoggerContainer.logEvent(EventType.setUserId, attributes);
}
static void setUserInfo({dynamic age, dynamic gender}) {
@@ -134,7 +135,7 @@ class EventProvider {
'age': age,
'gender': gender,
};
- CommonAnalyticsLogger.logEvent(EventType.setUserInfo, attributes);
+ EventLoggerContainer.logEvent(EventType.setUserInfo, attributes);
}
static void purchase(
@@ -145,12 +146,12 @@ class EventProvider {
'currency': currency,
'quantity': quantity,
};
- CommonAnalyticsLogger.logEvent(EventType.purchase, attributes);
+ EventLoggerContainer.logEvent(EventType.purchase, attributes);
}
}
-class CommonAnalyticsLogger {
- CommonAnalyticsLogger._();
+class EventLoggerContainer {
+ EventLoggerContainer._();
static FirebaseAnalyticsLogger firebaseAnalyticsLogger =
FirebaseAnalyticsLogger();
static AppsFlyerLogger appsFlyerLogger = AppsFlyerLogger();
@@ -158,6 +159,7 @@ class CommonAnalyticsLogger {
static MixpanelLogger mixpanelLogger = MixpanelLogger();
static SingularLogger singularLogger = SingularLogger();
static DatadogDebugLogger datadogDebugLogger = DatadogDebugLogger();
+
static void setup() {
firebaseAnalyticsLogger.setup();
appsFlyerLogger.setup();
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 4927725..794eec7 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -31,7 +31,7 @@ packages:
path: ".."
relative: true
source: path
- version: "1.0.3"
+ version: "1.0.5"
analyzer:
dependency: transitive
description:
@@ -646,4 +646,4 @@ packages:
version: "3.1.1"
sdks:
dart: ">=2.19.0 <3.0.0"
- flutter: ">=2.5.0"
+ flutter: ">=2.0.0"
diff --git a/lib/src/analytics_logger.dart b/lib/src/analytics_logger.dart
index 892c2d2..b97add6 100644
--- a/lib/src/analytics_logger.dart
+++ b/lib/src/analytics_logger.dart
@@ -22,38 +22,42 @@ class AnalyticsLogger {
/// 'Accept': 'application/vnd.github.v3.raw',
/// 'Authorization': 'Bearer [YOUR-TOKEN]',
/// },
- /// loggers: {
- /// FirebaseAnalyticsLogger: 'enableFirebase',
- /// AppsFlyerLogger: 'hasAppsFlyer',
- /// AmplitudeLogger: 'customizableName1',
- /// MixpanelLogger: 'customizableName2',
- /// SingularLogger: 'customizableName3',
- /// DatadogDebugLogger: 'customizableName4',
- /// },
+ /// loggers: {
+ /// FirebaseAnalyticsLogger: 'isFirebaseEnabled',
+ /// AppsFlyerLogger: 'isAppsFlyerEnabled',
+ /// AmplitudeLogger: 'isAmplitudeEnabled',
+ /// MixpanelLogger: 'isMixpanelEnabled',
+ /// SingularLogger: 'isSingularEnabled',
+ /// DatadogDebugLogger: 'isDatadogEnabled',
+ /// },
/// // ignore: unused_element
- /// class _CustomAnalyticsLogger {}
+ /// class _EventLoggerContainer {}
/// ```
final Map httpHeaders;
/// You can add analytics event loggers to the loggers.
- /// - The [KEY] is the name of the logger class.
+ /// - The [KEY] of the map is the [Type] of the class that implements the [EventLogger] interface.
/// - The [VALUE] is the name of the column in the [CSV file].
/// - The value of the [COLUMN_NAME] in the CSV file should be [TRUE] or [1] to enable the logger.
- /// - The value of the [COLUMN_NAME] in the CSV file should be [FALSE], [0] or [NULL] to disable the logger.
+ /// - The value of the [COLUMN_NAME] in the CSV file should be [FALSE], [0] or [] to disable the logger.
///
/// ```dart
/// @AnalyticsLogger(
+ /// // ex) (from project root)assets/logger_gen_example_sheet.csv
/// localCsvPath: '',
- /// loggers: {
- /// // COLUMN_NAME is the name of the column in the CSV file
- /// // The value of the [COLUMN_NAME] in the CSV file should be [TRUE] or [1] to enable the logger,
- /// // and [FALSE], [0] or [NULL] to disable the logger.
- /// FirebaseAnalyticsLogger: '[COLUMN_NAME]',
+ /// // When you declare the localCsvPath, the remoteCsvUrl is ignored.
+ /// remoteCsvUrl: '',
+ ///
+ /// loggers: {
+ /// // The key of the map is the Type of the class that implements the [EventLogger] interface.
+ /// //
+ /// // Matching in @AnalyticsLogger with CSV column determines which analytics tool to call for generated events.
+ /// FirebaseAnalyticsLogger: '',
/// })
- /// class _CustomAnalyticsLogger {}
+ /// class _EventLoggerContainer {}
///
/// class FirebaseAnalyticsLogger extends EventLogger {
- /// const SomeAnalyticsLogger();
+ /// FirebaseAnalyticsLogger();
///
/// @override
/// void logEvent(String event, {required Map attributes}) {
diff --git a/lib/src/analytics_logger_generator.dart b/lib/src/analytics_logger_generator.dart
index 0171c46..2182193 100644
--- a/lib/src/analytics_logger_generator.dart
+++ b/lib/src/analytics_logger_generator.dart
@@ -83,7 +83,7 @@ class AnalyticsLoggerGenerator extends GeneratorForAnnotation {
'Failed to parse CSV. Please check the format of the CSV file. Error: $e');
}
- // enum AnalyticsEvent
+ // enum EventType
final String _enumName = annotation.read('eventTypeName').stringValue;
buffer.writeln('enum $_enumName {');
final Map eventLoggerNamesDict = annotation
@@ -171,10 +171,12 @@ class AnalyticsLoggerGenerator extends GeneratorForAnnotation {
buffer.writeln('}'); // end of static AnalyticsEvent fromName(String name)
buffer.writeln('}'); // end of enum AnalyticsEvent
- // class AnalyticsEventProvider
+ // class EventProvider
final String providerName = annotation.read('providerName').stringValue;
buffer.writeln('class $providerName {');
buffer.writeln('$providerName._();');
+ buffer.writeln('');
+
for (int i = 0; i < bodyRows.length; i++) {
String? eventName = bodyRows[i][headerRows[0]]!.toString().toCamelCase();
String params = '';
@@ -213,7 +215,7 @@ class AnalyticsLoggerGenerator extends GeneratorForAnnotation {
}
buffer.writeln('}');
- //class IntegratedAnalyticsLogger
+ //class EventLoggerContainer
buffer.writeln('class $className {');
buffer.writeln('$className._();');
@@ -222,6 +224,7 @@ class AnalyticsLoggerGenerator extends GeneratorForAnnotation {
'static $_loggerName ${_loggerName.toLowerFirstCase()} = $_loggerName();');
}
+ buffer.writeln('');
buffer.writeln('static void setup() {');
for (String _loggerName in eventLoggerNamesDict.keys) {
buffer.writeln('${_loggerName.toLowerFirstCase()}.setup();');
diff --git a/pubspec.yaml b/pubspec.yaml
index 0c7fbfe..795f87b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,23 +1,15 @@
name: analytics_logger_gen
-description: A code generator that generates an event logger for analytics tools like FirebaseAnalytics. Import events from Google Spreadsheets, remote repositories or local CSV files.
-version: 1.0.5
+description: A code generator that generates analytics events for tools like FirebaseAnalytics. Import events from Google Spreadsheets, remote repositories or local CSV files.
+version: 1.0.6
homepage: https://github.com/9oya
repository: https://github.com/9oya/analytics_logger_gen
issue_tracker: https://github.com/9oya/analytics_logger_gen/issues
-platforms:
- linux:
- macos:
- windows:
-
environment:
sdk: '>=2.18.6 <3.0.0'
- flutter: ">=2.5.0"
dependencies:
- flutter:
- sdk: flutter
- analyzer: ^5.10.0
+ analyzer: '>=5.2.0 <6.0.0'
build: ^2.3.1
source_gen: ^1.2.7
http: ^0.13.5
@@ -28,6 +20,4 @@ dependencies:
dev_dependencies:
build_runner: ^2.3.3
build_test:
- test: ^1.0.0
-
-flutter:
\ No newline at end of file
+ test: ^1.0.0
\ No newline at end of file