Snowplow Mobile Macros
This page is auto-generated from our dbt packages, some information may be incomplete
Snowplow Mobileโ
Allow Refreshโ
macros/allow_refresh.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro allow_refresh() %}
{{ return(adapter.dispatch('allow_refresh', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__allow_refresh() %}
{% set allow_refresh = snowplow_utils.get_value_by_target(
dev_value=none,
default_value=var('snowplow__allow_refresh'),
dev_target_name=var('snowplow__dev_target_name')
) %}
{{ return(allow_refresh) }}
{% endmacro %}
Depends On
Referenced By
App Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro app_context_fields() %}
{% set app_context_fields = [
{'field':'build', 'dtype':'string'},
{'field':'version', 'dtype':'string'}
] %}
{{ return(app_context_fields) }}
{% endmacro %}
Referenced By
App Error Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro app_error_context_fields() %}
{% set app_error_context_fields = [
{'field':'message', 'dtype':'string'},
{'field':'programming_language', 'dtype':'string'},
{'field':'class_name', 'dtype':'string'},
{'field':'exception_name', 'dtype':'string'},
{'field':'file_name', 'dtype':'string'},
{'field':'is_fatal', 'dtype':'boolean'},
{'field':'line_column', 'dtype':'integer'},
{'field':'line_number', 'dtype':'integer'},
{'field':'stack_trace', 'dtype':'string'},
{'field':'thread_id', 'dtype':'integer'},
{'field':'thread_name', 'dtype':'string'}
] %}
{{ return(app_error_context_fields) }}
{% endmacro %}
Referenced By
Bool Orโ
macros/bool_or.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- bigquery
- default
- snowflake
{% macro bool_or(field) %}
{{ return(adapter.dispatch('bool_or', 'snowplow_mobile')(field)) }}
{% endmacro %}
{% macro bigquery__bool_or(field) %}
LOGICAL_OR(
{{ field }}
)
{% endmacro %}
{% macro default__bool_or(field) %}
BOOL_OR(
{{ field }}
)
{% endmacro %}
{% macro snowflake__bool_or(field) %}
BOOLOR_AGG(
{{ field }}
)
{% endmacro %}
Referenced By
Cluster By Fields App Errorsโ
macros/cluster_by_fields.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro cluster_by_fields_app_errors() %}
{{ return(adapter.dispatch('cluster_by_fields_app_errors', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__cluster_by_fields_app_errors() %}
{{ return(snowplow_utils.get_value_by_target_type(bigquery_val=["session_id"], snowflake_val=["to_date(derived_tstamp)"])) }}
{% endmacro %}
Depends On
Referenced By
Geo Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro geo_context_fields() %}
{% set geo_context_fields = [
{'field':('latitude', 'device_latitude'), 'dtype':'float64'},
{'field':('longitude', 'device_longitude'), 'dtype':'float64'},
{'field':('latitude_longitude_accuracy', 'device_latitude_longitude_accuracy'), 'dtype':'float64'},
{'field':('altitude', 'device_altitude'), 'dtype':'float64'},
{'field':('altitude_accuracy', 'device_altitude_accuracy'), 'dtype':'float64'},
{'field':('bearing', 'device_bearing'), 'dtype':'float64'},
{'field':('speed', 'device_speed'), 'dtype':'float64'}
] %}
{{ return(geo_context_fields) }}
{% endmacro %}
Referenced By
Get Device User Id Path Sqlโ
macros/get_path_sql.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- bigquery
- databricks
- default
- spark
{% macro get_device_user_id_path_sql(relation_alias) %}
{{ return(adapter.dispatch('get_device_user_id_path_sql', 'snowplow_mobile')(relation_alias)) }}
{% endmacro %}
{% macro bigquery__get_device_user_id_path_sql(relation_alias) %}
-- setting relation through variable is not currently supported (recognised as string), different logic for integration tests
{% if target.schema.startswith('gh_sp_mobile_dbt_') %}
{%- set relation=ref('snowplow_mobile_events_stg') %}
{% else %}
{%- set relation=source('atomic','events') %}
{% endif %}
{%- set user_id = snowplow_utils.combine_column_versions(
relation=relation,
column_prefix='contexts_com_snowplowanalytics_snowplow_client_session_1_',
required_fields=['user_id'],
relation_alias=relation_alias,
include_field_alias=false
)|join('') -%}
{{ return(user_id) }}
{% endmacro %}
{% macro databricks__get_device_user_id_path_sql(relation_alias) %}
{% set user_id %}
{{ relation_alias }}.contexts_com_snowplowanalytics_snowplow_client_session_1[0].user_id::STRING
{% endset %}
{{ return(user_id) }}
{% endmacro %}
{% macro default__get_device_user_id_path_sql(relation_alias) %}
{% set user_id %}
{{ relation_alias }}.contexts_com_snowplowanalytics_snowplow_client_session_1[0]:userId::VARCHAR(36)
{% endset %}
{{ return(user_id) }}
{% endmacro %}
{% macro spark__get_device_user_id_path_sql(relation_alias) %}
{{ return(snowplow_mobile.databricks__get_device_user_id_path_sql(relation_alias)) }}
{% endmacro %}
Depends On
Referenced By
Get Session Id Path Sqlโ
macros/get_path_sql.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- bigquery
- databricks
- default
- spark
{% macro get_session_id_path_sql(relation_alias) %}
{{ return(adapter.dispatch('get_session_id_path_sql', 'snowplow_mobile')(relation_alias)) }}
{% endmacro %}
{% macro bigquery__get_session_id_path_sql(relation_alias) %}
-- setting relation through variable is not currently supported (recognised as string)
{%- set relation=source('atomic','events') %}
{%- set session_id = snowplow_utils.combine_column_versions(
relation=relation,
column_prefix='contexts_com_snowplowanalytics_snowplow_client_session_1_',
required_fields=['session_id'],
relation_alias=relation_alias,
include_field_alias=false
)|join('') -%}
{{ return(session_id) }}
{% endmacro %}
{% macro databricks__get_session_id_path_sql(relation_alias) %}
{% set session_id %}
{{ relation_alias }}.contexts_com_snowplowanalytics_snowplow_client_session_1[0].session_id::STRING
{% endset %}
{{ return(session_id) }}
{% endmacro %}
{% macro default__get_session_id_path_sql(relation_alias) %}
{% set session_id %}
{{ relation_alias }}.contexts_com_snowplowanalytics_snowplow_client_session_1[0]:sessionId::VARCHAR(36)
{% endset %}
{{ return(session_id) }}
{% endmacro %}
{% macro spark__get_session_id_path_sql(relation_alias) %}
{{ return(snowplow_mobile.databricks__get_session_id_path_sql(relation_alias)) }}
{% endmacro %}
Depends On
Referenced By
Mobile Cluster By Fields Screen Viewsโ
macros/cluster_by_fields.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro mobile_cluster_by_fields_screen_views() %}
{{ return(adapter.dispatch('mobile_cluster_by_fields_screen_views', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__mobile_cluster_by_fields_screen_views() %}
{{ return(snowplow_utils.get_value_by_target_type(bigquery_val=["device_user_id", "session_id"], snowflake_val=["to_date(derived_tstamp)"])) }}
{% endmacro %}
Depends On
Referenced By
Mobile Cluster By Fields Sessionsโ
macros/cluster_by_fields.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro mobile_cluster_by_fields_sessions() %}
{{ return(adapter.dispatch('mobile_cluster_by_fields_sessions', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__mobile_cluster_by_fields_sessions() %}
{{ return(snowplow_utils.get_value_by_target_type(bigquery_val=["device_user_id"], snowflake_val=["to_date(start_tstamp)"])) }}
{% endmacro %}
Depends On
Referenced By
Mobile Cluster By Fields Sessions Lifecycleโ
macros/cluster_by_fields.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro mobile_cluster_by_fields_sessions_lifecycle() %}
{{ return(adapter.dispatch('mobile_cluster_by_fields_sessions_lifecycle', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__mobile_cluster_by_fields_sessions_lifecycle() %}
{{ return(snowplow_utils.get_value_by_target_type(bigquery_val=["session_id"], snowflake_val=["to_date(start_tstamp)"])) }}
{% endmacro %}
Depends On
Referenced By
Mobile Cluster By Fields Usersโ
macros/cluster_by_fields.sql
Description
This macro does not currently have a description.
Details
Code
- raw
- default
{% macro mobile_cluster_by_fields_users() %}
{{ return(adapter.dispatch('mobile_cluster_by_fields_users', 'snowplow_mobile')()) }}
{% endmacro %}
{% macro default__mobile_cluster_by_fields_users() %}
{{ return(snowplow_utils.get_value_by_target_type(bigquery_val=["device_user_id"], snowflake_val=["to_date(start_tstamp)"])) }}
{% endmacro %}
Depends On
Referenced By
Mobile Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro mobile_context_fields() %}
{% set mobile_context_fields = [
{'field':'device_manufacturer', 'dtype':'string'},
{'field':'device_model', 'dtype':'string'},
{'field':'os_type', 'dtype':'string'},
{'field':'os_version', 'dtype':'string'},
{'field':'android_idfa', 'dtype':'string'},
{'field':'apple_idfa', 'dtype':'string'},
{'field':'apple_idfv', 'dtype':'string'},
{'field':'carrier', 'dtype':'string'},
{'field':'open_idfa', 'dtype':'string'},
{'field':'network_technology', 'dtype':'string'},
{'field':'network_type', 'dtype':'string'}
] %}
{{ return(mobile_context_fields) }}
{% endmacro %}
Referenced By
Screen Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro screen_context_fields() %}
{% set screen_context_fields = [
{'field':('id', 'screen_id'), 'dtype':'string'},
{'field':('name', 'screen_name'), 'dtype':'string'},
{'field':('activity', 'screen_activity'), 'dtype':'string'},
{'field':('fragment', 'screen_fragment'), 'dtype':'string'},
{'field':('top_view_controller', 'screen_top_view_controller'), 'dtype':'string'},
{'field':('type', 'screen_type'), 'dtype':'string'},
{'field':('view_controller', 'screen_view_controller'), 'dtype':'string'}
] %}
{{ return(screen_context_fields) }}
{% endmacro %}
Referenced By
Screen View Event Fieldsโ
macros/bigquery/unstruct_event_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro screen_view_event_fields() %}
{% set screen_view_event_fields = [
{'field':('id', 'screen_view_id'), 'dtype':'string'},
{'field':('name', 'screen_view_name'), 'dtype':'string'},
{'field':('previous_id', 'screen_view_previous_id'), 'dtype':'string'},
{'field':('previous_name', 'screen_view_previous_name'), 'dtype':'string'},
{'field':('previous_type', 'screen_view_previous_type'), 'dtype':'string'},
{'field':('transition_type', 'screen_view_transition_type'), 'dtype':'string'},
{'field':('type', 'screen_view_type'), 'dtype':'string'}
] %}
{{ return(screen_view_event_fields) }}
{% endmacro %}
Referenced By
Session Context Fieldsโ
macros/bigquery/context_fields.sql
Description
This macro does not currently have a description.
Details
Code
{% macro session_context_fields() %}
{% set session_context_fields = [
{'field':'session_id', 'dtype':'string'},
{'field':'session_index', 'dtype':'integer'},
{'field':'previous_session_id', 'dtype':'string'},
{'field':('user_id', 'device_user_id'), 'dtype':'string'},
{'field':('first_event_id', 'session_first_event_id'), 'dtype':'string'}
] %}
{{ return(session_context_fields) }}
{% endmacro %}
Referenced By
Stitch User Identifiersโ
macros/stitch_user_identifiers.sql
Description
This macro does not currently have a description.
Details
Code
{% macro stitch_user_identifiers(enabled, relation=this, user_mapping_relation='snowplow_mobile_user_mapping') %}
{% if enabled and target.type not in ['databricks', 'spark'] | as_bool() %}
-- Update sessions table with mapping
update {{ relation }} as s
set stitched_user_id = um.user_id
from {{ ref(user_mapping_relation) }} as um
where s.device_user_id = um.device_user_id;
{% elif enabled and target.type in ['databricks', 'spark'] | as_bool() %}
-- Update sessions table with mapping
merge into {{ relation }} as s
using {{ ref(user_mapping_relation) }} as um
on s.device_user_id = um.device_user_id
when matched then
update set s.stitched_user_id = um.user_id;
{% endif %}
{% endmacro %}