Skip to content

Various Refactorings - #224

Merged
UZ9 merged 3 commits into
mainfrom
ryder/various-refactorings
Nov 4, 2025
Merged

UZ9 merged 3 commits into
mainfrom
ryder/various-refactorings

Conversation

@UZ9

@UZ9 UZ9 commented Nov 4, 2025

Copy link
Copy Markdown
Contributor
  • Fixed issues with bog-analyitcs mysteriously failing without any warning
  • Added more logging to bog-analytics custom analytics errors (these should eventually be uniform across all events)
  • Removed implicit transformations due to them breaking user type routes
  • Returned file information when retrieving config. This was the original vision outlined in the design for file services, although I'm not 100% sold on it. A better way might be returning minimal information on the config route and having dedicated routes for retrieving all buckets and all files -- will probably make this a sprint ticket

UZ9 added 3 commits November 1, 2025 19:15
Implicit conversion was causing grief with transforming user types and
are no longer needed.

@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

This PR improves error handling, fixes type validation issues, and implements file/bucket retrieval functionality.

Key Changes:

  • Analytics Error Handling: Wrapped logger.logCustomEvent in try-catch with enhanced error messages that include category and subcategory for easier debugging
  • ValidationPipe Fix: Removed enableImplicitConversion which was conflicting with explicit @Transform decorators in DTOs like SetUserTypeModel.type
  • File Config Enhancement: Implemented full data retrieval in getConfig, returning actual files and buckets with relationships instead of empty arrays

Architecture Impact:
The file config change moves from returning minimal data to full relationship graphs. While functional, the PR author notes this may benefit from dedicated routes for retrieving buckets/files separately.

Confidence Score: 4/5

  • This PR is safe to merge with low risk - changes are defensive improvements and bug fixes
  • Score reflects well-tested bug fixes with one consideration: the file_config changes add complexity without formal type definitions (TODO comment acknowledges this). The changes are sound but could benefit from follow-up work on the API design as the author notes
  • Check packages/db-service/src/modules/file_config/file_config.controller.ts - verify the nested data structure matches proto definitions in production use cases

Important Files Changed

File Analysis

Filename Score Overview
packages/analytics-service/src/modules/analytics/analytics.service.ts 5/5 Added try-catch around logger.logCustomEvent call with detailed error messages including category/subcategory to aid debugging
packages/api-gateway/src/main.ts 5/5 Removed enableImplicitConversion from ValidationPipe to prevent conflicts with explicit @Transform decorators in DTOs
packages/db-service/src/modules/file_config/file_config.controller.ts 4/5 Extended getConfig to return full file and bucket data with nested relationships instead of empty arrays

Sequence Diagram

sequenceDiagram
    participant Client
    participant APIGateway
    participant AnalyticsService
    participant BogAnalytics
    participant DBService
    participant Database

    Note over APIGateway: ValidationPipe (no implicit conversion)
    Client->>APIGateway: POST /user/set-type {type: "ADMIN"}
    APIGateway->>APIGateway: Transform decorator converts string to enum
    APIGateway->>DBService: Update user type
    DBService->>Database: Update query
    Database-->>DBService: Success
    DBService-->>APIGateway: User updated
    APIGateway-->>Client: Success response

    Client->>APIGateway: POST /analytics/custom-event
    APIGateway->>AnalyticsService: logCustomEvent(category, subcategory, properties)
    AnalyticsService->>AnalyticsService: getAnalyticsLogger()
    AnalyticsService->>BogAnalytics: logger.logCustomEvent(...)
    alt Success
        BogAnalytics-->>AnalyticsService: Event response
        AnalyticsService-->>APIGateway: Event logged
    else Error
        BogAnalytics-->>AnalyticsService: Throws error
        AnalyticsService->>AnalyticsService: Catch error, enhance message
        AnalyticsService-->>APIGateway: RpcException with details
    end

    Client->>APIGateway: GET /file-config
    APIGateway->>DBService: getConfig(id, environment)
    DBService->>Database: Query with includes (buckets, FileServiceFile)
    Database-->>DBService: Config with relations
    DBService->>DBService: Transform Prisma to Proto format
    DBService->>DBService: Map files and buckets arrays
    DBService->>DBService: Filter files by bucket
    DBService-->>APIGateway: Config with files and buckets
    APIGateway-->>Client: Full config data
Loading

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@UZ9

UZ9 commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

LGTM

@UZ9
UZ9 merged commit 8410f69 into main Nov 4, 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.

1 participant