Skip to content

Commit

Permalink
Use macros for field lists where possible (Close #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlh1994 committed Feb 26, 2024
1 parent 416aad7 commit 36bbde7
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 350 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
snowplow-unified 0.2.0 (2024-02-XX)
snowplow-unified 0.2.1 (2024-02-XX)
---------------------------------------
## Summary
XXX

## Features
- Add new passthrough aggregations to the views, sessions, and users table, enabled using `snowplow__view/session/user_aggregations`
- Reorder and add some additional context fields to derived tables (non-breaking change)

## Under the hood
- Prefix all macro calls with package name for easier customization
- Use macros for grouped fields (e.g. contexts) where possible

## Upgrading
Bump the snowplow-unified version in your `packages.yml` file.
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

242 changes: 121 additions & 121 deletions integration_tests/data/expected/snowplow_unified_views_expected.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ select
,iab__spider_or_robot
,yauaa__device_name
,yauaa__agent_class
,yauaa__device_brand
,yauaa__agent_name
,yauaa__agent_name_version
,yauaa__agent_name_version_major
Expand All @@ -172,6 +173,7 @@ select
,yauaa__layout_engine_version
,yauaa__layout_engine_version_major
,ua__device_family
,ua__os_family
,ua__os_version
,ua__os_major
,ua__os_minor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ iab__primary_impact,
iab__reason,
iab__spider_or_robot,
yauaa__device_name,
yauaa__device_brand,
yauaa__agent_class,
yauaa__agent_name,
yauaa__agent_name_version,
Expand All @@ -186,6 +187,7 @@ yauaa__layout_engine_name_version_major,
yauaa__layout_engine_version,
yauaa__layout_engine_version_major,
ua__device_family,
ua__os_family,
ua__os_version,
ua__os_major,
ua__os_minor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ SELECT
,os_timezone
,screen_resolution
,yauaa__device_class
,yauaa__device_brand
,yauaa__device_version
,yauaa__operating_system_version
,yauaa__operating_system_class
Expand Down Expand Up @@ -181,6 +182,7 @@ SELECT
,yauaa__layout_engine_name_version_major
,yauaa__layout_engine_version
,yauaa__layout_engine_version_major
,ua__os_family
,ua__device_family
,ua__os_version
,ua__os_major
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ iab__reason,
iab__spider_or_robot,
yauaa__device_name,
yauaa__agent_class,
yauaa__device_brand,
yauaa__agent_name,
yauaa__agent_name_version,
yauaa__agent_name_version_major,
Expand All @@ -185,6 +186,7 @@ yauaa__layout_engine_name_version_major,
yauaa__layout_engine_version,
yauaa__layout_engine_version_major,
ua__device_family,
ua__os_family,
ua__os_version,
ua__os_major,
ua__os_minor,
Expand Down
50 changes: 5 additions & 45 deletions models/sessions/scratch/snowplow_unified_sessions_this_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@ select

, f.screen_resolution

{% if var('snowplow__enable_yauaa') %}
, f.yauaa__device_class
, f.yauaa__device_version
, f.yauaa__operating_system_version
, f.yauaa__operating_system_class
, f.yauaa__operating_system_name
, f.yauaa__operating_system_name_version
{% endif %}

{% if var('snowplow__enable_mobile_context') %}
{{ snowplow_unified.mobile_context_fields('f')}}
Expand Down Expand Up @@ -387,42 +379,17 @@ select

-- iab enrichment fields
{% if var('snowplow__enable_iab') %}
, f.iab__category
, f.iab__primary_impact
, f.iab__reason
, f.iab__spider_or_robot
{{ snowplow_unified.iab_context_fields('f') }}
{% endif %}

-- yauaa enrichment fields
{% if var('snowplow__enable_yauaa') %}
, f.yauaa__device_name
, f.yauaa__agent_class
, f.yauaa__agent_name
, f.yauaa__agent_name_version
, f.yauaa__agent_name_version_major
, f.yauaa__agent_version
, f.yauaa__agent_version_major
, f.yauaa__layout_engine_class
, f.yauaa__layout_engine_name
, f.yauaa__layout_engine_name_version
, f.yauaa__layout_engine_name_version_major
, f.yauaa__layout_engine_version
, f.yauaa__layout_engine_version_major
{{ snowplow_unified.yauaa_context_fields('f') }}
{% endif %}

-- ua parser enrichment fields
{% if var('snowplow__enable_ua') %}
, f.ua__device_family
, f.ua__os_version
, f.ua__os_major
, f.ua__os_minor
, f.ua__os_patch
, f.ua__os_patch_minor
, f.ua__useragent_family
, f.ua__useragent_major
, f.ua__useragent_minor
, f.ua__useragent_patch
, f.ua__useragent_version
{{ snowplow_unified.ua_context_fields('f') }}
{% endif %}

-- mobile only
Expand All @@ -439,18 +406,11 @@ select
{% endif %}

{% if var('snowplow__enable_application_context') %}
, f.app__build as first_app__build
, f.app__version as first_app__version
{{ snowplow_unified.app_context_fields('f', 'first') }}
{% endif %}

{% if var('snowplow__enable_geolocation_context') %}
, f.geo__altitude as first_geo__altitude
, f.geo__altitude_accuracy as first_geo__altitude_accuracy
, f.geo__bearing as first_geo__bearing
, f.geo__latitude as first_geo__latitude
, f.geo__latitude_longitude_accuracy as first_geo__latitude_longitude_accuracy
, f.geo__longitude as first_geo__longitude
, f.geo__speed as first_geo__speed
{{ snowplow_unified.geo_context_fields('f', 'first') }}
{% endif %}

{% if var('snowplow__enable_screen_context') %}
Expand Down
92 changes: 9 additions & 83 deletions models/views/scratch/snowplow_unified_views_this_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ select
, pve.session_identifier
, pve.view_in_session_index
, max(pve.view_in_session_index) over (partition by pve.session_identifier) as views_in_session
{% if var('snowplow__enable_mobile') %}
, pve.session__previous_session_id
{% endif %}

-- user id fields
, pve.user_id
Expand All @@ -204,18 +201,7 @@ select
{% if var('snowplow__enable_mobile_context') %}
{{ snowplow_unified.mobile_context_fields('pve')}}
{% endif %}
{% if var('snowplow__enable_web') %}
, pve.os_timezone
{% endif %}
, pve.screen_resolution
{% if var('snowplow__enable_yauaa') %}
, pve.yauaa__device_class
, pve.yauaa__device_version
, pve.yauaa__operating_system_version
, pve.yauaa__operating_system_class
, pve.yauaa__operating_system_name
, pve.yauaa__operating_system_name_version
{% endif %}

-- geo fields
, pve.geo_country
Expand Down Expand Up @@ -261,97 +247,37 @@ select
, pve.refr_term

{% if var('snowplow__enable_web') %}

, pve.page_title
, pve.content_group

, pve.page_urlscheme
, pve.page_urlhost
, pve.page_urlpath
, pve.page_urlquery
, pve.page_urlfragment

, pve.refr_urlscheme
, pve.refr_urlhost
, pve.refr_urlpath
, pve.refr_urlquery
, pve.refr_urlfragment


, pve.br_lang
, pve.br_viewwidth
, pve.br_viewheight
, pve.br_colordepth
, pve.br_renderengine

, pve.doc_width
, pve.doc_height

, br_colordepth
{{ snowplow_unified.web_only_fields('pve') }}
, content_group
{% endif %}

-- iab enrichment fields
{% if var('snowplow__enable_iab') %}
, pve.iab__category
, pve.iab__primary_impact
, pve.iab__reason
, pve.iab__spider_or_robot
{{ snowplow_unified.iab_context_fields('pve') }}
{% endif %}

-- yauaa enrichment fields
{% if var('snowplow__enable_yauaa') %}
, pve.yauaa__device_name
, pve.yauaa__agent_class
, pve.yauaa__agent_name
, pve.yauaa__agent_name_version
, pve.yauaa__agent_name_version_major
, pve.yauaa__agent_version
, pve.yauaa__agent_version_major
, pve.yauaa__layout_engine_class
, pve.yauaa__layout_engine_name
, pve.yauaa__layout_engine_name_version
, pve.yauaa__layout_engine_name_version_major
, pve.yauaa__layout_engine_version
, pve.yauaa__layout_engine_version_major
{{ snowplow_unified.yauaa_context_fields('pve') }}
{% endif %}

-- ua parser enrichment fields
{% if var('snowplow__enable_ua') %}
, pve.ua__device_family
, pve.ua__os_version
, pve.ua__os_major
, pve.ua__os_minor
, pve.ua__os_patch
, pve.ua__os_patch_minor
, pve.ua__useragent_family
, pve.ua__useragent_major
, pve.ua__useragent_minor
, pve.ua__useragent_patch
, pve.ua__useragent_version
{{ snowplow_unified.ua_context_fields('pve') }}
{% endif %}

-- mobile only
{% if var('snowplow__enable_mobile') %}
, pve.screen_view__name
, pve.screen_view__previous_id
, pve.screen_view__previous_name
, pve.screen_view__previous_type
, pve.screen_view__transition_type
, pve.screen_view__type
{{ snowplow_unified.mobile_only_fields('pve') }}
{% endif %}

{% if var('snowplow__enable_application_context') %}
, pve.app__build
, pve.app__version
{{ snowplow_unified.app_context_fields('pve') }}
{% endif %}

{% if var('snowplow__enable_geolocation_context') %}
, pve.geo__altitude
, pve.geo__altitude_accuracy
, pve.geo__bearing
, pve.geo__latitude
, pve.geo__latitude_longitude_accuracy
, pve.geo__longitude
, pve.geo__speed
{{ snowplow_unified.geo_context_fields('pve') }}
{% endif %}

{% if var('snowplow__enable_screen_context') %}
Expand Down

0 comments on commit 36bbde7

Please sign in to comment.