Repository navigation
changes to custom event type in analytics to return array of custom event types instead of one - #227
Merged
Merged
Conversation
…vent types instead of one
Closed
2 tasks
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
Changed the getCustomEventTypes endpoint to return an array of all custom event types instead of only the first one, addressing a previous TODO.
Key Changes:
- Added new
GetAllCustomEventTypeResponseproto message and TypeScript types wrappingeventTypesarray - Updated analytics service to map all event types instead of returning only
response[0] - Updated API gateway controller and DTOs to use the new response type
- Response structure changed from single object to
{eventTypes: [...]}format
Issues Found:
- Critical: E2E test in analytics-service still expects old response format and will fail
- Important: API gateway DTO constructor may leave
eventTypesundefined on empty response
Confidence Score: 2/5
- This PR has critical test failures that will break the build
- While the code changes are well-structured and the refactoring addresses a legitimate issue (returning all event types instead of just one), the analytics-service E2E tests were not updated to match the new response format. The tests expect
CustomEventTypeResponsewith direct properties likeresponse.id, but the endpoint now returnsGetAllCustomEventTypeResponsewithresponse.eventTypes[0].id. Additionally, the DTO constructor has a bug that could return undefinedeventTypesproperty. - Pay close attention to
packages/analytics-service/test/analytics.e2e-spec.ts(tests will fail) andpackages/api-gateway/src/models/analytics.dto.ts(constructor bug)
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/analytics-service/src/modules/analytics/analytics.service.ts | 5/5 | Removed TODO comment and refactored to return all custom event types in an array instead of just the first one |
| packages/api-gateway/src/models/analytics.dto.ts | 3/5 | Added new GetAllCustomEventTypeResponse DTO class, but constructor has potential issue with undefined eventTypes property |
| packages/analytics-service/test/analytics.e2e-spec.ts | 0/5 | Tests not updated - still expects old CustomEventTypeResponse format instead of new GetAllCustomEventTypeResponse with array |
Sequence Diagram
sequenceDiagram
participant Client
participant APIGateway as API Gateway Controller
participant AnalyticsService as Analytics Service
participant AnalyticsViewer as Analytics Viewer
participant Database
Client->>APIGateway: GET /analytics/custom-event-types?projectName=X
APIGateway->>APIGateway: Validate API Key & Query
APIGateway->>AnalyticsService: getCustomEventTypes(request)
AnalyticsService->>AnalyticsService: Validate projectName
AnalyticsService->>AnalyticsViewer: authenticate & getAnalyticsViewer()
AnalyticsViewer-->>AnalyticsService: viewer instance
AnalyticsService->>AnalyticsViewer: getCustomEventTypes(projectName)
AnalyticsViewer->>Database: Query custom event types
Database-->>AnalyticsViewer: Array of event types
AnalyticsViewer-->>AnalyticsService: Array of event types
AnalyticsService->>AnalyticsService: Map to GetAllCustomEventTypeResponse
AnalyticsService-->>APIGateway: GetAllCustomEventTypeResponse {eventTypes: [...]}
APIGateway->>APIGateway: new GetAllCustomEventTypeResponse(response)
APIGateway-->>Client: 200 OK {eventTypes: [...]}
Additional Comments (1)
-
packages/analytics-service/test/analytics.e2e-spec.ts, line 671-688 (link)logic: test expects
CustomEventTypeResponsebut the endpoint now returnsGetAllCustomEventTypeResponsewitheventTypesarray
6 files reviewed, 2 comments
Contributor
|
LGTM, 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.
changes in Juno to support multiple custom event types returned
200 Response:
{
"eventTypes": [
{
"id": "**",
"category": "foo",
"subcategory": "bar",
"properties": [
"formType",
"source"
],
"projectId": ""
},
{
"id": "",
"category": "user_interaction",
"subcategory": "image_zoom_interaction",
"properties": [
"zoom_level",
"action",
"image_id"
],
"projectId": ""
}
]
}