Skip to content

Commit

Permalink
Add optional conversions module
Browse files Browse the repository at this point in the history
  • Loading branch information
agnessnowplow committed Jan 30, 2024
1 parent 2eaa90b commit 800ed47
Show file tree
Hide file tree
Showing 31 changed files with 453 additions and 209 deletions.
9 changes: 9 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ vars:
snowplow__session_lookback_days: 730
snowplow__session_stitching: true
snowplow__view_stitching: false
snowplow__conversion_stitching: true
snowplow__session_timestamp: collector_tstamp
snowplow__start_date: '2020-01-01'
# snowplow__total_all_conversions: false
Expand Down Expand Up @@ -91,10 +92,12 @@ vars:
snowplow__session_passthroughs: []
snowplow__user_first_passthroughs: []
snowplow__user_last_passthroughs: []
snowplow__conversion_passthroughs: []
# enable custom modules:
snowplow__enable_consent: false
snowplow__enable_cwv: false
snowplow__enable_app_errors: false
snowplow__enable_conversions: false

# WAREHOUSE SPECIFIC

Expand Down Expand Up @@ -169,6 +172,12 @@ models:
scratch:
+schema: "scratch"
+tags: "scratch"
conversions:
+schema: "derived"
+tags: ["snowplow_unified_incremental", "derived", "conversions"]
scratch:
+schema: "scratch"
+tags: "scratch"
core_web_vitals:
+schema: "derived"
+tags: ["snowplow_unified_incremental", "derived", "core_web_vitals"]
Expand Down
2 changes: 1 addition & 1 deletion docs/markdown/snowplow_unified_macros_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ The specific sql to be used for the relevant warehouse to calculate the count of
{% endraw %}
{% enddocs %}

{% docs macro_get_conversion_columns %}
{% docs macro_conversion_query %}
{% raw %}

A macro to keep the different ways of calculating conversion fields per warehouse abstracted away for the sessions table.
Expand Down
15 changes: 4 additions & 11 deletions integration_tests/.scripts/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,26 @@ fi
for db in ${DATABASES[@]}; do

echo "Snowplow unified integration tests: Seeding data"

eval "dbt seed --full-refresh --target $db" || exit 1;

echo "Snowplow unified integration tests: App errors module"
echo "Snowplow unified integration tests: Conversions"
eval "dbt run --full-refresh --select +snowplow_unified_conversions snowplow_unified_integration_tests.source --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 220, snowplow__enable_cwv: false, snowplow__enable_conversions: true}' --target $db" || exit 1;

echo "Snowplow unified integration tests: App errors module"
eval "dbt run --full-refresh --select +snowplow_unified_app_errors snowplow_unified_integration_tests.source --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 220, snowplow__enable_cwv: false, snowplow__enable_app_errors: true}' --target $db" || exit 1;

echo "Snowplow unified integration tests: Late enabled contexts"

eval "dbt run --full-refresh --select +test_late_enabled_contexts snowplow_unified_integration_tests.source --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 220, snowplow__enable_cwv: false, snowplow__enable_mobile_context: false, snowplow__enable_geolocation_context: false, snowplow__enable_application_context: false, snowplow__enable_screen_context: false, snowplow__enable_app_errors: false, snowplow__enable_deep_link_context: false, snowplow__enable_cwv: false, snowplow__enable_iab: false, snowplow__enable_ua: false, snowplow__enable_browser_context: false, snowplow__enable_consent: false}' --target $db" || exit 1;

eval "dbt run --select +test_late_enabled_contexts run --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 250, snowplow__enable_cwv: false}' --target $db"

echo "Snowplow unified integration tests: Late enabled contexts test passed"

echo "Snowplow unified integration tests: Execute models (all contexts except for cwv) - run 1/4"

eval "dbt run --full-refresh --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 243, snowplow__enable_cwv: false}' --target $db" || exit 1;

for i in {2..4}
do
echo "Snowplow unified integration tests: Execute models (all contexts except for cwv) - run $i/4"

eval "dbt run --vars '{snowplow__enable_cwv: false}' --target $db" || exit 1;
done

Expand All @@ -55,19 +52,15 @@ for db in ${DATABASES[@]}; do
eval "dbt test --exclude snowplow_unified_web_vital_measurements snowplow_unified_web_vital_measurements_actual snowplow_unified_web_vital_events_this_run snowplow_unified_views_mobile_screen_engagement_actual test_name:not_null --store-failures --target $db" || exit 1;

echo "Snowplow unified integration tests: All non-CWV tests passed"

echo "Snowplow unified integration tests - Core Web Vitals: Execute models"

eval "dbt run --select +snowplow_unified_web_vital_measurements_actual snowplow_unified_web_vital_measurements_expected_stg source --full-refresh --vars '{snowplow__allow_refresh: true, snowplow__start_date: '2023-03-01', snowplow__backfill_limit_days: 50, snowplow__cwv_days_to_measure: 999, snowplow__enable_mobile: false, snowplow__enable_mobile_context: false, snowplow__enable_geolocation_context: false, snowplow__enable_application_context: false, snowplow__enable_screen_context: false, snowplow__enable_app_errors: false, snowplow__enable_deep_link_context: false, snowplow__enable_ua: false, snowplow__enable_browser_context: false, snowplow__enable_consent: false}' --target $db" || exit 1;

eval "dbt test --select snowplow_unified_web_vital_measurements_actual --store-failures --target $db" || exit 1;

echo "Snowplow unified integration tests: Execute web (all web contexts except for cwv)"

eval "dbt run --full-refresh --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 9999, snowplow__enable_mobile: false, snowplow__enable_mobile_context: false, snowplow__enable_geolocation_context: false, snowplow__enable_application_context: false, snowplow__enable_screen_context: false, snowplow__enable_app_errors: false, snowplow__enable_deep_link_context: false, snowplow__enable_cwv: false}' --select +snowplow_unified_users snowplow_unified_events_stg --target $db" || exit 1;

echo "Snowplow unified integration tests: Execute mobile (all mobile contexts)"

eval "dbt run --full-refresh --vars '{snowplow__allow_refresh: true, snowplow__backfill_limit_days: 9999, snowplow__enable_web: false, snowplow__enable_iab: false, snowplow__enable_ua: false, snowplow__enable_browser_context: false, snowplow__enable_consent: false, snowplow__enable_cwv: false}' --select +snowplow_unified_users snowplow_unified_events_stg --target $db" || exit 1;

echo "Snowplow unified integration tests: All CWV tests passed"
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ vars:
snowplow__enable_web: true
snowplow__enable_mobile: true
snowplow__yauaa_context: snowplow_unified_yauaa_context_stg
snowplow__conversion_stitching: false
# web only contexts
snowplow__cwv_events: snowplow_unified_cwv_stg
snowplow__page_view_context: snowplow_unified_page_view_context_stg
Expand Down Expand Up @@ -96,6 +97,7 @@ vars:
snowplow__total_all_conversions: true
snowplow__list_event_counts: true


seeds:
quote_columns: false
snowplow_unified_integration_tests:
Expand Down
6 changes: 6 additions & 0 deletions macros/config_check.sql
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0
) }}
{% endif %}
{% endif %}

{% if var('snowplow__enable_conversions') and not var('snowplow__conversion_events') %}
{{ exceptions.raise_compiler_error(
"Snowplow Error: var('snowplow__conversion_events') is not configured but the conversions optional module is enabled. Please configure this variable before proceeding."
) }}
{% endif %}

{% endmacro %}
Loading

0 comments on commit 800ed47

Please sign in to comment.