# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2026-01-30

### Added
- **Tool Metering Support**: Meter arbitrary tool/function calls via the `@meter_tool` decorator from `revenium_middleware`
  - Track execution time, success/failure status, and attribution metadata for non-LLM operations
  - Works alongside automatic LLM API metering for end-to-end usage visibility
  - New example (`examples/example_meter_tool.py`) demonstrating tool metering with Google AI

### Changed
- **Renamed Fields**: Updated `productId` → `productName` and `organizationId` → `organizationName`
  - New field names clarify that these are names for lookup/auto-creation, not internal IDs
  - Backward compatibility maintained: old field names still work but emit deprecation warnings
  - Updated all examples to use new field names with realistic values (e.g., "AcmeCorp", "customer-chatbot")
- Updated `revenium_middleware` dependency to >=0.4.2 for new field support

### Backward Compatibility
- Old field names (`organizationId`, `organization_id`, `productId`, `product_id`) continue to work
- Deprecation warnings are logged when using old field names
- No breaking changes in this release

## [0.3.0] - 2026-01-15

### Added
- **Prompt Capture Support**: Capture and send system prompts, input messages, and output responses to Revenium
  - New `config.py` module with `CAPTURE_PROMPTS` and `MAX_PROMPT_LENGTH` settings
  - New `prompt_extractor.py` module for extracting prompts from Google Gemini API requests/responses
  - Support for both Google AI SDK and Vertex AI SDK
  - Support for both streaming and non-streaming requests
  - Automatic truncation of long prompts with `[TRUNCATED]` marker
  - Environment variable configuration: `REVENIUM_CAPTURE_PROMPTS` and `REVENIUM_MAX_PROMPT_LENGTH`
- New prompt capture example (`examples/prompt_capture_example.py`) demonstrating both SDKs
- Comprehensive test suite for prompt extraction (`tests/test_prompt_capture.py`)

### Changed
- Updated `revenium_middleware` dependency to >=0.4.1 for prompt capture field support
- Enhanced `google_ai/middleware.py` to extract and send prompt data
- Enhanced `vertex_ai/middleware.py` to extract and send prompt data
- Updated README with "Prompt Capture (v0.3.0+)" section including privacy considerations

### Documentation
- Added prompt capture configuration guide to README
- Added privacy and security considerations for prompt capture
- Added example demonstrating prompt capture for both Google AI and Vertex AI
- Updated `.env.example` with prompt capture environment variables

## [0.2.0] - 2025-12-05

### Added
- Trace visualization support with 8 new fields for enhanced observability:
  - `environment` - Deployment environment tracking (production, staging, etc.)
  - `region` - Cloud region identifier with auto-detection from AWS/Azure/GCP env vars
  - `credential_alias` - Human-readable API key identification
  - `trace_type` - Workflow category identifier for grouping (max 128 chars)
  - `trace_name` - Human-readable trace labels (max 256 chars)
  - `parent_transaction_id` - Distributed tracing support for linking operations
  - `transaction_name` - Operation-level naming with fallback to task_type
  - `retry_number` - Retry attempt counter for tracking failed operations
- New `trace_fields.py` module in common package for trace field capture and validation
- Comprehensive trace visualization example (`examples/trace_visualization_example.py`)
- Support for both environment variables and `usage_metadata` parameters for trace fields
- Auto-detection of environment and region from common cloud provider environment variables
- `.env.example` file with detailed trace field documentation

### Changed
- Updated `revenium_middleware` dependency to >=0.3.5 for trace visualization support
- Enhanced `common/utils.py` to capture and validate trace visualization fields
- Updated README with "Trace Visualization Fields (v0.2.0+)" section
- Improved metadata handling with dual support for env vars and parameters

### Documentation
- Added comprehensive trace visualization example with 5 scenarios
- Updated `.env.example` with trace field examples and detailed comments
- Added trace visualization fields table to README
- Linked to API reference and example files in documentation

## [0.1.2] - 2025-11-17

### Changed
- Added virtual environment setup instructions to examples/README.md for better user experience

## [0.1.1] - 2025-01-13

### Added
- Nested metadata structure support for enhanced subscriber tracking
- Comprehensive documentation for implementation patterns and validation

### Changed
- Improved metadata handling with backward compatibility for existing integrations

## [0.1.0] - 2025-09-08

### Added
- Support for Google AI SDK (Gemini Developer API)
- Support for Vertex AI SDK
- Token counting and usage tracking for both text generation and embeddings
- Streaming response support
- Optional dependencies for flexible installation (`[genai]`, `[vertex]`, `[all]`)
- Comprehensive example scripts
- Python 3.8+ support

[0.1.2]: https://github.com/revenium/revenium-middleware-google-python/releases/tag/v0.1.2
[0.1.1]: https://github.com/revenium/revenium-middleware-google-python/releases/tag/v0.1.1
[0.1.0]: https://github.com/revenium/revenium-middleware-google-python/releases/tag/v0.1.0
