Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #340 fill null event key #341

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions models/staging/stg_ga4__events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ include_session_partition_key as (
CONCAT(session_key, CAST(event_date_dt as STRING)) as session_partition_key
from include_session_key
),
-- Add unique key for events
-- Add unique key for events. Potential to not be unique if client_key or session_id is null and uniqueness depends on differentiation by that value.
include_event_key as (
select
*,
to_base64(md5(CONCAT(session_key, event_name, CAST(event_timestamp as STRING), to_json_string(event_params)))) as event_key -- Surrogate key for unique events.
to_base64(md5(ARRAY_TO_STRING([
client_key,
CAST(session_id as STRING),
event_name,
CAST(event_timestamp as STRING),
to_json_string(event_params)
], ""))) as event_key -- Surrogate key for unique events.
from include_session_partition_key
),
detect_gclid as (
Expand Down
3 changes: 3 additions & 0 deletions models/staging/stg_ga4__events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ models:
- name: client_key
description: Surrogate key created from stream_id and user_pseudo_id. Provides a way to uniquely identify a user's device within a stream. Important when using the package to combine data across properties and streams.
- name: event_key
description: >
Surrogate key for events. Potential for uniqueness test to fail if client_key or session_id is null
and uniqueness depends on differentiation by that value.
tests:
- unique
- name: page_path
Expand Down
Loading