analytics_gen 0.2.1
analytics_gen: ^0.2.1 copied to clipboard
Type-safe analytics event tracking with code generation from YAML configuration. Supports multiple providers, testing utilities, and export formats.
Changelog #
All notable changes to this project will be documented in this file.
0.2.1 - 2025-11-21 #
Breaking Changes #
- Configuration Structure Update: The
analytics_gen.yamlfile has been completely restructured into logical groups (inputs,outputs,targets,rules) to improve readability and organization.- Migration Guide:
# Old (v0.2.0) analytics_gen: events_path: events output_path: lib/src/analytics docs_path: docs/analytics.md generate_docs: true strict_event_names: true event_parameters_path: events/shared.yaml # New (v0.2.1) analytics_gen: inputs: events: events shared_parameters: - events/shared.yaml outputs: dart: lib/src/analytics docs: docs/analytics.md targets: docs: true rules: strict_event_names: true - Note: The old flat structure is deprecated but may still work for some fields during a transition period, though migration is strongly recommended.
event_parameters_pathis strictly removed in favor ofinputs.shared_parameters.
- Migration Guide:
Highlights #
- Improved error reporting, validation, and generated code ergonomics.
- Better CSV/exports, optional PII scrubbing, and safer enum generation for parameter values.
- Added telemetry hooks and testing helpers (e.g.,
Analytics.reset()).
Documentation & DX #
- Clarified
BatchingAnalytics.flush()behavior and updated README guidance. - Added CI example for plan validation in
doc/VALIDATION.md.
Key Additions #
- Shared Event Parameters: Support for centrally defined parameters via
shared_parameters.- Reuse parameters across events by referencing them (or leaving value as
null). - Enforce consistency with
enforce_centrally_defined_parameters. - Prevent duplicates with
prevent_event_parameter_duplicates.
- Reuse parameters across events by referencing them (or leaving value as
- Enhanced CSV export (multiple files, better escaping).
- Parameter validation DSL:
regex,min_length,max_length,min,maxwith runtime checks. - PII scrubbing support (
PiiRenderer+Analytics.sanitizeParams). - Enum generation for parameters with
allowed_values.
Internal Improvements #
BaseRendererto share common rendering logic across generators.- Generation telemetry (
GenerationTelemetry+ implementations) integrated intoCodeGenerator. - Validator separation:
SchemaValidatorextracted fromYamlParserwith tests. YamlParserrefactored to useloadYamlNodeand enforces strict event-name rules.
Misc #
- Added
ignore_for_filelints and generation timestamp to generated files. Analytics.reset()for testing and hot-restart scenarios.
0.2.0 - 2025-11-20 #
- Updates:
- Optimized generator performance with parallel processing and smart I/O.
- Stable API supporting both Dependency Injection and Singleton patterns.
- Major Features:
- Extensible Metadata: Support for arbitrary key-value pairs (
meta) in YAML, propagated to code and exports. - Batching & Async: Added
BatchingAnalyticsfor buffering events andAsyncAnalyticsAdapterfor heavy providers. - Flexible Naming: Configurable naming strategies for domains, events, and parameters.
- Strict Mode: Added
strict_event_namesto prevent high-cardinality anti-patterns.
- Extensible Metadata: Support for arbitrary key-value pairs (
- Developer Experience:
- Improved Error Reporting: Aggregated validation errors for faster debugging.
- Performance: Parallelized generation and incremental file writes.
- Documentation: Added migration guides, scalability benchmarks, and onboarding checklists.
- Quality Assurance:
- Full test coverage (100%).
- Stricter linting rules and CI guardrails.
0.1.6 - 2025-11-17 #
- Add
include_event_descriptionconfig option to optionally include an event'sdescriptionproperty inside the emittedlogger.logEventparameters map. This flag defaults tofalseto preserve existing behavior; enable it viaanalytics_gen.yaml(key:include_event_description).- The code generator now inserts a
'description'key for events that have a non-empty description when the flag is enabled. - The example config and
README.mdwere updated to document this flag. - Unit tests assert that descriptions are properly included when enabled and omitted otherwise.
- The code generator now inserts a
- Support interpolated placeholders in custom
event_namestrings- You can now include parameter placeholders in
event_nameusing{parameter_name}and the code generator will replace them with Dart string interpolation in generated methods (for example,"Screen: {screen_name}"→"Screen: ${screenName}"). - The raw
event_namestill appears unchanged in docs/exports so metadata remains stable across teams and exports. - If a placeholder doesn't match a parameter, it is preserved as-is (no silent mutations), so designs and engineers can detect typos or handle advanced use cases explicitly.
- You can now include parameter placeholders in
0.1.5 - 2025-11-16 #
- The entire package is 100% tested.
- Github Actions have been added for code review and testing.
- Improved documentation with usage examples.
0.1.4 - 2025-11-15 #
- Library vs CLI logging cleanup: internal generators and parsers now emit logs only when a verbose callback is provided, while the CLI keeps the rich user-friendly output.
- Core models (
AnalyticsParameter,AnalyticsEvent,AnalyticsDomain) implement value semantics and have dedicated equality tests. - YAML parser is much stricter: domains/events/parameters must be maps, errors surface file + key context, and malformed structures throw
FormatException. - Public API ergonomics:
- Added
typedef AnalyticsParams = Map<String, Object?>. IAnalytics.logEventand generated methods use typed params while remaining synchronous by design.- README explains serialization expectations and sync logging rationale.
- Added
- Enforced snake_case domain naming and documented expectations so files stay filesystem-safe.
- CLI UX:
- Added
--validate-only,--watch,--verbose, and negatable--code/--docs/--exportsflags for flexible runs. --docs/--exportsnow respectanalytics_gen.yamldefaults with--no-docs/--no-exportsoverrides.--helphighlights all new options.
- Added
- Generators & exports now include thorough tests (code, docs, JSON, SQL, SQLite) using temp directories.
MultiProviderAnalyticscatches provider errors, emits aMultiProviderAnalyticsFailurepayload, fires an optionalonProviderFailurehook for logging/metrics, and still callsonErrorso the rest of the providers keep running.- Documentation expanded with analytics best practices, naming guidance, cardinality tips, and example YAML snippets.
- Internal polish: shared string helpers extracted,
MockAnalyticsServicealigns withAnalyticsParams, and CI discipline enforced viadart analyze/dart test. - Mock analytics service now exposes immutable
RecordedAnalyticsEventsnapshots throughrecordswhile keeping the legacy map helpers for compatibility. - Event deprecation lifecycle: YAML accepts
deprecated+replacement, generators emit@Deprecated, and metadata is surfaced in docs/exports. - Parameters support
allowed_values, propagated through docs/JSON/SQL/CSV with validation. - Validation/DX enhancements:
--validate-onlymode verifies the tracking plan without writing files and fails fast on structural issues. - Docs/JSON/SQL exports embed deterministic fingerprints (no timestamps) so repeated runs stay diff-friendly across machines.
- Docs tables gained a Status column that marks deprecated events (and their replacements) so migrations are visible without leaving the Markdown export.
- Parser now enforces that every analytics event name (custom
event_nameor the default<domain>: <event>) is unique across domains so generation fails fast on collisions. - Added a
--planCLI flag that surfaces the tracking plan fingerprint, domain/event counts, and parameter lists without writing files so teams can inspect instrumentation quickly.
0.1.3 - 2025-11-14 #
- Fix badge issues
0.1.2 - 2025-11-14 #
- Refactor string interpolation and formatting in code generation
0.1.1 - 2025-11-13 #
- Some minor updates and fixes.
0.1.0 - 2025-11-13 #
- Some minor updates and fixes.
0.0.1 - 2025-11-13 #
- Initial release of
analytics_genpackage.