Repository navigation
Davidgu/analyticsroutes premerge - #218
Merged
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
Greptile Summary
This PR adds analytics data retrieval capabilities to the Juno platform by implementing 10 new viewer endpoints that expose read-only access to analytics events (click, visit, input, and custom events) through both the gRPC analytics service and REST API gateway.
Key Changes:
- Added
AnalyticsViewerServiceextending bog-analytics SDK'sAnalyticsViewerclass for read operations - Implemented 11 new service methods with pagination support and proper authentication/validation
- Created proto definitions for all new RPC endpoints with corresponding auto-generated TypeScript types
- Exposed 10 REST endpoints in API gateway with comprehensive OpenAPI documentation
- Added complete test coverage for both analytics service and API gateway
- All endpoints require API key authentication for security
Minor Issues Found:
- Typo in method name:
getCustomGraphTypesbyIdshould begetCustomGraphTypesById(line 264 in analytics.service.ts) - TODO comment indicates hardcoded DEVELOPMENT environment needs production configuration
Confidence Score: 4/5
- This PR is safe to merge with one minor typo fix needed
- Score reflects well-structured implementation with comprehensive test coverage and proper validation/authentication patterns. The typo in the method name will cause a runtime error when calling getCustomGraphTypesById, preventing this specific endpoint from working correctly. All other endpoints follow consistent patterns and should work properly. The hardcoded DEVELOPMENT environment is noted but acceptable for initial implementation.
- packages/analytics-service/src/modules/analytics/analytics.service.ts requires a one-character fix to correct the method name typo on line 264
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/proto/definitions/analytics.proto | 5/5 | Added proto definitions for analytics viewer methods (10 new RPC endpoints for retrieving analytics data with pagination support) |
| packages/analytics-service/src/modules/analytics/analytics.module.ts | 4/5 | Configured AnalyticsViewerService provider with DEVELOPMENT environment (TODO comment notes this needs to be updated for production) |
| packages/analytics-service/src/modules/analytics/analytics.service.ts | 3/5 | Implemented 11 analytics viewer methods with validation and authentication; contains typo in method name getCustomGraphTypesbyId (should be getId with capital B) |
| packages/api-gateway/src/models/analytics.dto.ts | 5/5 | Added DTO classes for all new analytics viewer endpoints with proper validation decorators and Swagger documentation |
| packages/api-gateway/src/modules/analytics/analytics.controller.ts | 5/5 | Added 10 REST endpoints (GET routes) for analytics data retrieval with proper OpenAPI decorations and validation |
Sequence Diagram
sequenceDiagram
participant Client
participant APIGateway as API Gateway<br/>(REST)
participant AnalyticsService as Analytics Service<br/>(gRPC)
participant BogAnalytics as bog-analytics SDK<br/>(AnalyticsViewer)
participant Database as MongoDB
Note over Client,Database: Analytics Data Retrieval Flow
Client->>APIGateway: GET /analytics/events/click?projectName=X
APIGateway->>APIGateway: Validate API Key
APIGateway->>APIGateway: Validate Query Params
APIGateway->>AnalyticsService: gRPC getClickEventsPaginated(request)
AnalyticsService->>AnalyticsService: authenticateViewer(apiKey)
AnalyticsService->>AnalyticsService: Validate projectName
AnalyticsService->>BogAnalytics: getClickEventsPaginated(queryParams)
BogAnalytics->>Database: Query click events
Database-->>BogAnalytics: Return events + pagination cursor
BogAnalytics-->>AnalyticsService: Return events array
AnalyticsService->>AnalyticsService: Transform dates to ISO strings
AnalyticsService-->>APIGateway: Return GetClickEventsResponse
APIGateway->>APIGateway: Map to DTO
APIGateway-->>Client: Return JSON response
Note over Client,Database: Similar flow for Visit, Input, and Custom Events
Client->>APIGateway: GET /analytics/custom-event-types?projectName=X
APIGateway->>AnalyticsService: gRPC getCustomEventTypes(request)
AnalyticsService->>BogAnalytics: getCustomEventTypes(projectName)
BogAnalytics->>Database: Query event type definitions
Database-->>BogAnalytics: Return event types
BogAnalytics-->>AnalyticsService: Return event type array
AnalyticsService-->>APIGateway: Return first event type
APIGateway-->>Client: Return CustomEventTypeResponse
12 files reviewed, 1 comment
UZ9
commented
Oct 24, 2025
| } | ||
|
|
||
| // Return the first custom event type for now | ||
| const eventType = response[0]; |
Contributor
Author
There was a problem hiding this comment.
Only returns first type; this should be all types
Contributor
Author
|
Analytics tests will be rewritten during sprint day; critical functions tested by hand |
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.
PR created for merging visibility