Skip to content

Add analytics service rpc endpoints for bog analytics sdk - #212

Merged
UZ9 merged 8 commits into
mainfrom
davidgu/Add_analytics_service_RPC_endpoints_for_bog-analytics_SDK
Sep 28, 2025
Merged

UZ9 merged 8 commits into
mainfrom
davidgu/Add_analytics_service_RPC_endpoints_for_bog-analytics_SDK

Conversation

@UZ9

@UZ9 UZ9 commented Sep 28, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@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

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-analytics dependency 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
Loading

13 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread packages/analytics-service/src/modules/analytics/analytics.module.ts Outdated
Comment thread packages/analytics-service/src/modules/analytics/analytics.service.ts Outdated
@UZ9

UZ9 commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

should really have husky or something to run a pre-commit lint check

@UZ9

UZ9 commented Sep 28, 2025

Copy link
Copy Markdown
Contributor Author

Looks solid, thanks!

@UZ9
UZ9 merged commit cbddf5a into main Sep 28, 2025
7 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