Skip to content

changes to custom event type in analytics to return array of custom event types instead of one - #227

Merged
UZ9 merged 7 commits into
mainfrom
charlie/custom-event-type-array
Nov 10, 2025
Merged

UZ9 merged 7 commits into
mainfrom
charlie/custom-event-type-array

Conversation

@charliejlin

Copy link
Copy Markdown
Contributor

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": "
"
}
]
}

@greptile-apps greptile-apps Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetAllCustomEventTypeResponse proto message and TypeScript types wrapping eventTypes array
  • 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 eventTypes undefined 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 CustomEventTypeResponse with direct properties like response.id, but the endpoint now returns GetAllCustomEventTypeResponse with response.eventTypes[0].id. Additionally, the DTO constructor has a bug that could return undefined eventTypes property.
  • Pay close attention to packages/analytics-service/test/analytics.e2e-spec.ts (tests will fail) and packages/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: [...]}
Loading

Additional Comments (1)

  1. packages/analytics-service/test/analytics.e2e-spec.ts, line 671-688 (link)

    logic: test expects CustomEventTypeResponse but the endpoint now returns GetAllCustomEventTypeResponse with eventTypes array

6 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread packages/api-gateway/src/models/analytics.dto.ts
@UZ9

UZ9 commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

LGTM, thanks!

@UZ9
UZ9 merged commit 2fd1fcd into main Nov 10, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants