You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Readable**— domain-per-file keeps each area focused and reviewable
183
-
-**Maintainable**— changes to one domain aren’t scattered across the codebase
184
-
-**Scalable**— new domains don’t bloat a single generated file
185
-
-**Simple imports**— a barrel file provides one canonical import for generated events
182
+
-**Readable**- domain-per-file keeps each area focused and reviewable
183
+
-**Maintainable**- changes to one domain aren't scattered across the codebase
184
+
-**Scalable**- new domains don't bloat a single generated file
185
+
-**Simple imports**- a barrel file provides one canonical import for generated events
186
186
187
187
## Configuration
188
188
@@ -275,12 +275,12 @@ screen:
275
275
276
276
- Domain keys (top-level YAML keys) must be snake_case, using only lowercase letters, digits, and underscores (e.g. `auth`, `screen_navigation`).
277
277
- This keeps generated file and class names stable and filesystem‑safe.
278
-
- Each event's effective name—either the optional `event_name` override or the default `<domain>: <event>` string—must be unique across your entire tracking plan. Duplicate names cause the parser to throw a `FormatException`, which surfaces immediately when you run the generator (including `--validate-only`), preventing conflicting analytics payloads from being emitted.
278
+
- Each event's effective name-either the optional `event_name` override or the default `<domain>: <event>` string-must be unique across your entire tracking plan. Duplicate names cause the parser to throw a `FormatException`, which surfaces immediately when you run the generator (including `--validate-only`), preventing conflicting analytics payloads from being emitted.
279
279
280
280
## Validation Guarantees
281
281
282
282
- `dart run analytics_gen:generate --validate-only`(or any run that parses your YAML) now enforces the same uniqueness constraint, so duplicate event names fail fast before any generated files are written.
283
-
- Since the parser sorts files, domains, and events before visiting them, every validation failure is predictable and repeatable—no ordering surprises in CI or on different machines.
283
+
- Since the parser sorts files, domains, and events before visiting them, every validation failure is predictable and repeatable-no ordering surprises in CI or on different machines.
284
284
- `dart run analytics_gen:generate --plan`prints the parsed tracking plan (domains, events, parameters, and fingerprint) so you can inspect instrumentation without writing any generated files.
285
285
286
286
## CLI Commands
@@ -427,9 +427,9 @@ filtered.logEvent(name: 'auth_login'); // only sent to amplitude
427
427
```dart
428
428
class FirebaseAnalyticsService implements IAnalytics {
429
429
final FirebaseAnalytics _firebase;
430
-
430
+
431
431
FirebaseAnalyticsService(this._firebase);
432
-
432
+
433
433
@override
434
434
void logEvent({
435
435
required String name,
@@ -474,15 +474,15 @@ Unit tests should initialize `Analytics` with `MockAnalyticsService` (or other a
474
474
void main() {
475
475
group('Analytics', () {
476
476
late MockAnalyticsService analytics;
477
-
477
+
478
478
setUp(() {
479
479
analytics = MockAnalyticsService();
480
480
Analytics.initialize(analytics);
481
481
});
482
-
482
+
483
483
test('logs login event', () {
484
484
Analytics.instance.logAuthLogin(method: 'email');
485
-
485
+
486
486
expect(analytics.totalEvents, equals(1));
487
487
final event = analytics.events.first;
488
488
expect(event['name'], equals('auth: login'));
@@ -523,14 +523,14 @@ Licensed under the Apache License, Version 2.0. See [`LICENSE`](LICENSE) for det
523
523
524
524
## FAQ
525
525
526
-
**Why YAML instead of defining events directly in Dart?**
527
-
YAML keeps the tracking plan tooling‑agnostic: product and analytics teams can read and edit it, and you can export the same source of truth to code, docs, and data formats.
526
+
-**Why YAML instead of defining events directly in Dart?**
527
+
YAML keeps the tracking plan tooling‑agnostic: product and analytics teams can read and edit it, and you can export the same source of truth to code, docs, and data formats.
528
528
529
-
**Can I migrate existing events?**
530
-
Yes. Start by describing your current events in YAML, generate Dart code, then gradually replace existing manual `logEvent` calls with the generated methods.
529
+
-**Can I migrate existing events?**
530
+
Yes. Start by describing your current events in YAML, generate Dart code, then gradually replace existing manual `logEvent` calls with the generated methods.
531
531
532
-
**Does this lock me into a single analytics provider?**
533
-
No. You implement `IAnalytics` adapters for each provider and can use `MultiProviderAnalytics` to send the same event to several backends.
532
+
-**Does this lock me into a single analytics provider?**
533
+
No. You implement `IAnalytics` adapters for each provider and can use `MultiProviderAnalytics` to send the same event to several backends.
534
534
535
-
**Is this safe to commit to source control?**
536
-
Yes. The YAML definitions and generated code are designed to be code‑review friendly and should live in your repo alongside application code.
535
+
-**Is this safe to commit to source control?**
536
+
Yes. The YAML definitions and generated code are designed to be code‑review friendly and should live in your repo alongside application code.
0 commit comments