Repository navigation
Add analytics service rpc endpoints for bog analytics sdk - #212
Merged
UZ9 merged 8 commits intoSep 28, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Disclaimer: This comment was AI-generated and is not necessarily completely accurate. Please take code comments with a grain of salt.
Greptile Overview
Summary
This PR adds GRPC endpoints for the analytics service to integrate with the bog-analytics SDK. The implementation provides four analytics event types (click, visit, input, custom) with API key authentication and comprehensive validation.
- Added
bog-analyticsdependency and service wrapper - Implemented GRPC controller with four analytics endpoints
- Added comprehensive end-to-end tests with proper mocking
- Created protocol buffer definitions for analytics events
- Integrated with existing NestJS microservice architecture
Key Issues Found
- Critical: Duplicate provider definitions in analytics module causing potential injection conflicts
- Style: Unused import in analytics service
- Configuration: Hardcoded development environment should be configurable
Confidence Score: 3/5
- This PR has a critical module configuration issue that needs fixing before deployment
- Score reflects one critical syntax issue with duplicate provider definitions that would cause runtime injection errors, plus minor style improvements needed
- packages/analytics-service/src/modules/analytics/analytics.module.ts requires immediate attention due to duplicate provider definitions
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/analytics-service/src/modules/analytics/analytics.module.ts | 2/5 | Module configuration with duplicate provider definitions and hardcoded environment |
| packages/analytics-service/src/modules/analytics/analytics.service.ts | 4/5 | Business logic for analytics events with validation and bog-analytics integration |
| packages/analytics-service/src/modules/analytics/analytics.controller.ts | 5/5 | GRPC controller implementation for analytics service endpoints |
| packages/proto/definitions/analytics.proto | 5/5 | Protocol buffer definitions for analytics service GRPC endpoints |
| packages/analytics-service/test/analytics.e2e-spec.ts | 5/5 | Comprehensive end-to-end tests for all analytics service endpoints |
Sequence Diagram
sequenceDiagram
participant Client as Client Application
participant Controller as AnalyticsController
participant Service as AnalyticsService
participant BogService as BogAnalyticsService
participant BogAPI as Bog Analytics API
Client->>+Controller: GRPC Request (logClickEvent/logVisitEvent/logInputEvent/logCustomEvent)
Controller->>+Service: Forward request with analytics data
Service->>Service: authenticateAnalytics(apiKey)
Service->>BogService: authenticate(apiKey)
alt Invalid API Key
BogService-->>Service: throws error
Service-->>Controller: RpcException(UNAUTHENTICATED)
Controller-->>Client: GRPC Error
end
Service->>Service: Validate request parameters
alt Invalid Parameters
Service-->>Controller: RpcException(INVALID_ARGUMENT)
Controller-->>Client: GRPC Error
end
Service->>+BogService: logEvent(eventData)
BogService->>+BogAPI: HTTP Request to log analytics event
BogAPI-->>-BogService: Event response with ID and metadata
BogService-->>-Service: Event response object
Service->>Service: Transform response (dates to ISO strings)
Service-->>-Controller: Formatted AnalyticsResponse
Controller-->>-Client: GRPC Response with event details
13 files reviewed, 3 comments
Contributor
Author
|
should really have husky or something to run a pre-commit lint check |
Contributor
Author
|
Looks solid, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.