Skip to content

v0.2.0 - Client-Server Refactor and EmitAndSend

Choose a tag to compare

@t0mk t0mk released this 27 Aug 12:17
· 4 commits to main since this release

πŸš€ Major Architecture Refactor

This release introduces significant improvements to the tlytics architecture, separating client and server concerns for better usability and maintainability.

✨ New Features

EmitAndSend Method

  • client.EmitAndSend(event) - Send events immediately with error handling
  • Perfect for testing server connectivity
  • Returns errors for connection issues
  • Bypasses the internal queue for instant transmission

Clean Client-Server Separation

  • NewClient() now returns *Client instead of *Tlytics
  • Tlytics struct is now server-only
  • Removed the isServer boolean field
  • Simplified API with clear separation of concerns

Emitter Interface

  • New Emitter interface implemented by both Client and Server
  • Middleware now accepts Emitter for flexibility
  • Clean abstraction for event emission

πŸ§ͺ Testing Improvements

Comprehensive Integration Tests

  • TestClientServerIntegration - Full end-to-end testing
  • TestEmitAndSendConnectionError - Connection error handling
  • TestMultipleEventsIntegration - Concurrent event testing
  • Verifies message delivery and storage in database

πŸ”„ API Changes

Breaking Changes

  • NewClient() returns *Client instead of *Tlytics
  • Middleware functions now accept Emitter interface
  • Tlytics struct no longer has client-related fields

Migration Guide

// Before v0.2.0
analytics, err := tlytics.NewClient(config) // returns *Tlytics
defer analytics.Close()

// v0.2.0+
client, err := tlytics.NewClient(config) // returns *Client
defer client.Close()

// For immediate sending (new feature)
err := client.EmitAndSend(event) // Send immediately with error handling

πŸ—οΈ Internal Improvements

  • Cleaner separation of client and server logic
  • Removed conditional isServer logic throughout codebase
  • Better error handling for network operations
  • More focused struct responsibilities

🧩 Compatibility

  • Middleware functions remain compatible (now use Emitter interface)
  • Close() method added to Client for API consistency
  • Backward compatibility maintained where possible

Full Changelog: v0.1.0...v0.2.0