Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from fishtown-analytics/feature/field_updates
Browse files Browse the repository at this point in the history
parsing device out of context agent
  • Loading branch information
eogilvy12 authored Jan 25, 2019
2 parents b84760d + 2b42273 commit ddf851f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 24 additions & 3 deletions macros/cross-adapter-modeling/base/segment_web_page_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,33 @@ renamed as (
context_campaign_content as utm_content,
{{ dbt_utils.get_url_parameter('url', 'gclid') }} as gclid,
context_ip as ip,
context_user_agent as user_agent

context_user_agent as user_agent,
case
when context_user_agent ilike '%Android%' then 'Android'
else replace(
split_part(split_part(context_user_agent,'(', 2), ' ', 1),
';','')
end as device

from source

),

final as (

select
*,
case
when device = 'iPhone' then 'iPhone'
when device = 'Android' then 'Android'
when device in ('iPad', 'iPod') then 'Tablet'
when device in ('Windows', 'Macintosh', 'X11') then 'Desktop'
else 'uncategorized'
end as device_category
from renamed

)

select * from renamed
select * from final

{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
'page_url_path' : 'first_page_url_path',
'page_url_query' : 'first_page_url_query',
'referrer' : 'referrer',
'referrer_host' : 'referrer_host'
'referrer_host' : 'referrer_host',
'device' : 'device',
'device_category' : 'device_category'
} %}

{% set last_values = {
Expand Down

0 comments on commit ddf851f

Please sign in to comment.