Skip to content

Fix GA4 compatibility and add automation#2

Merged
fmontes merged 6 commits intomainfrom
fix/ga4-compatibility
Feb 16, 2026
Merged

Fix GA4 compatibility and add automation#2
fmontes merged 6 commits intomainfrom
fix/ga4-compatibility

Conversation

@fmontes
Copy link
Copy Markdown
Member

@fmontes fmontes commented Feb 16, 2026

Summary

Fixes OSGi dependency issues and updates the plugin for Google Analytics 4 (GA4) compatibility.

What Changed

Core Fixes

  • OSGi Import-Package: Fixed dependency resolution by using a whitelist approach that excludes all third-party packages (gRPC, Netty, Brotli, Zstd, etc.) and only imports what's needed from dotCMS
  • Velocity Tools: Added org.apache.velocity.* to Import-Package whitelist to fix NoClassDefFoundError: ToolInfo
  • GA4 Compatibility: Changed default metric from ga:visits (Universal Analytics) to sessions (GA4)
  • Dependency Bundling: All Google Analytics Data API dependencies are now bundled inside the plugin JAR via Bundle-ClassPath

Automation & Documentation

  • GitHub Actions: Added workflow to automatically build and release the plugin JAR on every merge to main
  • README.md: Comprehensive guide with quick start, usage examples, and link to full integration guide
  • CONTRIBUTING.md: Development guidelines, code style, OSGi considerations, and PR process

Why

The plugin was failing to load in local/Docker dotCMS instances due to OSGi wiring errors. Multiple missing dependencies (brotli4j, zstd, jzlib, ning, etc.) were causing deployment failures. The default metric also caused API errors since ga:visits is not valid in GA4.

Testing

  • ✅ Built plugin locally with ./gradlew jar
  • ✅ Uploaded to local Docker dotCMS instance
  • ✅ OSGi bundle loads successfully (logs show "Starting Google Analytics OSGI plugin")
  • ✅ Viewtool available as $analytics in Velocity
  • ✅ Successfully queried real GA4 data (property ID 488595222)
  • ✅ Verified sessions metric works as default

Breaking Changes

None. Existing Velocity code continues to work. The default metric change only affects users who don't explicitly set metrics (best practice is to always set them explicitly anyway).

Related Issues

Resolves OSGi dependency issues reported in local deployments.

Next Steps

After merge, the GitHub Actions workflow will automatically:

  1. Build the plugin JAR
  2. Create a GitHub release tagged v0.4.1
  3. Attach the JAR to the release for easy download

- Fix Import-Package to exclude all third-party dependencies (gRPC, Netty, compression libs, etc.)
- Add Velocity tools to Import-Package whitelist
- Change default metric from ga:visits (GA3) to sessions (GA4)
- Bundle all Google Analytics Data API dependencies inside plugin JAR

This resolves OSGi wiring errors when deploying to local/Docker dotCMS instances and makes the plugin compatible with Google Analytics 4.
Automatically builds and releases the plugin JAR whenever code is merged to main.
Skips releases if the version already exists to avoid duplicates.
- Quick installation and setup instructions
- Basic usage example
- Link to full integration guide at dotcms.com/integrations/google-analytics
- Common metrics reference
- Version history and contributing guidelines
- Bug reporting and enhancement request guidelines
- Development setup and workflow
- Code style and OSGi considerations
- Testing checklist
- Pull request process
- Semantic versioning explanation
Build with Java 21 (matching local development environment) while maintaining Java 11 bytecode compatibility via sourceCompatibility setting.
- Remove issue reporting section (not actively monitored)
- Add clear versioning requirement for PRs
- Explain GitHub Actions release behavior
- Streamline before-you-start section
@fmontes fmontes merged commit 6bec826 into main Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant