Skip to content

feat: add production GA4 Silver validation model#22

Merged
O-E2 merged 3 commits into
mainfrom
agent/silver-ga4-events
Jul 22, 2026
Merged

feat: add production GA4 Silver validation model#22
O-E2 merged 3 commits into
mainfrom
agent/silver-ga4-events

Conversation

@O-E2

@O-E2 O-E2 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

변경 사항

  • event_params를 key와 typed value 기준으로 정렬한 canonical raw payload로 raw_event_id를 생성합니다.
  • GA4 전송·배치 키는 유일성 키가 아니라 진단용 raw_delivery_id로 보존합니다.
  • 파라미터 pivot도 canonical_event_params를 사용해 배열 순서에 따른 비결정성을 제거합니다.
  • 기존 event_id 정의는 유지합니다.
  • 원본 custom_session_id는 그대로 사용하고, NULL인 Android 가입 이벤트에만 만드는 sign_up_strict_* 보정값의 생성식을 기존 Dataform과 일치시켰습니다.
  • 전체 적재 시작 경계를 2024-07-11 00:00 KST로 고정하고, 이후 범위만 Android 가입 세션용 15분 lookback을 적용합니다.
  • start_date / end_date 변수로 기간별 백필과 파티션 교체가 가능하도록 했습니다.

배경

  1. 초기 WEB 데이터는 일부 batch 필드가 NULL이라 서로 다른 이벤트가 같은 전송 키를 공유했습니다.
  2. iOS 데이터에는 내용은 같고 event_params 배열 순서만 다른 행이 있어, 정렬 전 payload 해시가 거짓 충돌을 만들었습니다.
  3. 기존 Dataform과 신규 모델이 원본 NULL을 보정해 생성하는 가입 세션 ID의 시간·MD5 입력이 달라 425개 공통 이벤트의 보정값이 달랐습니다.

운영 영향

  • 기존 silver_events를 즉시 교체하지 않고 silver_events_temp로 생성·검증합니다.
  • production GA4 기본 원본과 * text=auto eol=lf 줄바꿈 규칙을 유지합니다.
  • 최초 적재는 날짜 변수를 이용해 월별 또는 주별로 나눠 수행할 수 있습니다.
  • 원본 로그에 이미 존재하는 custom_session_id 값은 변경하지 않습니다.

검증

  • 로컬 dbt Core 1.9.10 / dbt-bigquery 1.9.2에서 dbt parse 통과
  • 전체, 최근 3일 증분, 첫 백필, 후속 백필 분기 오프라인 렌더링 통과
  • 렌더링된 네 분기 모두 BigQuery dialect SQL parser 통과
  • Lightsail dbt 1.9.0 컨테이너에서 전체·첫 백필·후속 백필 dbt compile 통과
  • production source가 kap-chat.analytics_432041405.events_*로 컴파일되는 것을 확인
  • 수정 전 전체 기간 4구간 BigQuery 검증: raw_event_id / event_id NULL·중복과 필수 컬럼 오류 모두 0
  • 전체 비교에서 기준 뷰 전용 1,210건은 가입 세션 보정 ID 425건과 2026-06-01 구 스냅샷 785건으로 분류
  • 최신 보정 ID 호환성 수정 후 네 분기 오프라인 렌더링·BigQuery parser·git diff --check 통과

남은 검증

최신 커밋은 원본 로그가 아니라 NULL 가입 세션 보정 ID 생성식만 변경합니다. 전체 24.852GB를 반복 실행하지 않고, 보정 ID가 존재했던 2025-07-01~2026-01-15 구간만 기준 뷰와 재비교하면 됩니다.

Summary by CodeRabbit

  • New Features

    • Added a refined GA4 event dataset with standardized event fields, timestamps, screen categories, and session identifiers.
    • Added deduplication and validation to improve event accuracy and consistency.
    • Added support for Android signup session tracking.
  • Configuration

    • Updated analytics settings to use the production GA4 data source.
    • Added configurable GA4 project and dataset settings for different environments.
  • Documentation

    • Documented the new event dataset, fields, and data quality checks.

@O-E2 O-E2 changed the title feat:add-production-GA4-silver-model feat:add-silver_events_temp-model Jul 21, 2026
@O-E2 O-E2 changed the title feat:add-silver_events_temp-model feat: add production GA4 Silver validation model Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0511746b-207b-409e-bef7-a06b0c761e37

📥 Commits

Reviewing files that changed from the base of the PR and between 9abdaa9 and c35b449.

📒 Files selected for processing (5)
  • .env.example
  • .gitattributes
  • dbt/models/silver/_ga4__sources.yml
  • dbt/models/silver/_silver_events_temp.yml
  • dbt/models/silver/silver_events_temp.sql

📝 Walkthrough

Walkthrough

Adds production GA4 environment configuration and source metadata, plus a new incremental silver_events_temp dbt model that filters daily exports, canonicalizes and deduplicates events, normalizes parameters, and generates Android signup session identifiers.

Changes

GA4 silver events pipeline

Layer / File(s) Summary
GA4 source and model contract
.env.example, .gitattributes, dbt/models/silver/_ga4__sources.yml, dbt/models/silver/_silver_events_temp.yml
Adds GA4 project and dataset variables, updates production source defaults and descriptions, documents silver_events_temp, and defines metadata and tests for core columns.
Incremental input window
dbt/models/silver/silver_events_temp.sql
Configures incremental insert_overwrite processing and computes validated partition and KST timestamp windows for finalized daily GA4 tables.
Canonical identity and deduplication
dbt/models/silver/silver_events_temp.sql
Canonicalizes event parameters, hashes and validates raw and logical identities, and deterministically removes physical and logical duplicates.
Parameter normalization and Android sessionization
dbt/models/silver/silver_events_temp.sql
Pivots typed parameters, normalizes screen classes, derives signup stages, generates Android custom session IDs, and emits rows for target partitions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GA4 as GA4 daily tables
  participant dbt as silver_events_temp
  participant BigQuery as BigQuery target
  GA4->>dbt: Read filtered daily events
  dbt->>dbt: Canonicalize and deduplicate identities
  dbt->>dbt: Normalize parameters and sessionize Android signup events
  dbt->>BigQuery: Insert-overwrite event_dt partitions
Loading

Possibly related PRs

Suggested reviewers: rimsm

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/silver-ga4-events

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
dbt/models/silver/_ga4__sources.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

dbt/models/silver/_silver_events_temp.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@O-E2
O-E2 marked this pull request as ready for review July 22, 2026 15:32
@O-E2
O-E2 merged commit 0f9f0e1 into main Jul 22, 2026
1 check was pending
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