Skip to content

Custom Event - #9

Merged
Ret2Hell merged 3 commits into
mainfrom
dev
Apr 19, 2026
Merged

Ret2Hell merged 3 commits into
mainfrom
dev

Conversation

@Ret2Hell

@Ret2Hell Ret2Hell commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for custom events with event names; custom event names are captured, carried through processing, and persisted.
  • Bug Fixes / Data Integrity

    • Page-view events continue to have no event name by default (empty), avoiding accidental attribution.
  • Tests

    • Updated and added tests to verify preservation of custom event names and empty names for page views.

@coderabbitai

coderabbitai Bot commented Apr 19, 2026 •

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 15ed6d80-8b48-4c1d-b2ee-1934d1fe88e3

📥 Commits

Reviewing files that changed from the base of the PR and between 70bef3f and ced4afc.

📒 Files selected for processing (1)
  • internal/pipeline/pipeline_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/pipeline/pipeline_test.go

📝 Walkthrough

Walkthrough

A new custom event type and an optional EventName field were added to event models. EventName is propagated from the consumer through pipeline processing and included in ClickHouse inserts. Tests updated to verify preservation or emptiness of EventName.

Changes

Cohort / File(s) Summary
Model Extensions
internal/models/event.go
Added EventCustom EventType constant. Added EventName string \json:"event_name,omitempty"`toInternalEventandEventName stringtoProcessedEvent`.
Consumer Tests
internal/consumer/consumer_test.go
Updated tests to expect event_type "custom" and assert EventName == "test_new_track"; added assertion that minimal input yields empty EventName.
Pipeline Processing
internal/pipeline/pipeline.go
processEvent now copies raw.EventName into the returned models.ProcessedEvent.EventName.
Pipeline Tests
internal/pipeline/pipeline_test.go
Refactored tests to use shared helpers; added assertion that page view events produce empty EventName; added TestProcessEventPreservesCustomEventName.
Storage Integration
internal/storage/clickhouse.go
INSERT statement updated to include event_name column; batch appends now pass e.EventName when writing rows.

Sequence Diagram

sequenceDiagram
    participant Consumer as Consumer
    participant Pipeline as Pipeline
    participant Storage as ClickHouse

    Consumer->>Consumer: Parse JSON -> InternalEvent (may include event_name)
    Consumer->>Pipeline: processEvent(InternalEvent)
    Pipeline->>Pipeline: Build ProcessedEvent (copy EventName)
    Pipeline->>Storage: WriteBatch(ProcessedEvent)
    Storage->>Storage: INSERT INTO events (..., event_name, ...)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled JSON in the night,
EventName tucked snug and tight,
From consumer burrow to pipeline stream,
I carried names like carrot cream,
Now ClickHouse stores each hopping dream. 🥕


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

Copy link
Copy Markdown

@Ret2Hell
Ret2Hell merged commit 3a72ff3 into main Apr 19, 2026
5 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