Use event_types for cohort analyses

This commit is contained in:
Frank Bertsch 2021-03-11 21:21:50 +00:00
Родитель 2710f697e2
Коммит a480a7e011
6 изменённых файлов: 142 добавлений и 62 удалений

Просмотреть файл

@ -75,10 +75,26 @@ explore: funnel_analysis {
}
explore: cohort_analysis {
view_label: " User-Days"
view_label: " User Properties"
from: cohort
join: message_ids {
relationship: many_to_one
join: cohort_event_type_1 {
view_label: "Cohort 1"
relationship: one_to_one
type: cross
}
join: cohort_event_type_2 {
view_label: "Cohort 2"
relationship: one_to_one
type: cross
}
join: cohort_event_type_3 {
view_label: "Cohort 3"
relationship: one_to_one
type: cross
}
join: cohort_event_type_4 {
view_label: "Cohort 4"
relationship: one_to_one
type: cross
}
join: days_since_message {
@ -86,7 +102,7 @@ explore: cohort_analysis {
type: cross
}
join: clients_last_seen {
view_label: "Days of Use"
fields: []
relationship: one_to_one
type: left_outer
sql_on: ${cohort_analysis.sample_id} = ${clients_last_seen.sample_id}
@ -100,19 +116,28 @@ explore: cohort_analysis {
filters: [
date: "14 days",
days_since_message.time_period: "7",
message_ids.message_event: "ABOUT^_WELCOME - IMPRESSION",
cohort_event_type_1.event_type: "IMPRESSION",
cohort_event_type_1.message_id: "ABOUT^_WELCOME",
]
}
query: about_welcome_cohorts {
pivots: [message_ids.message_event]
dimensions: [days_since_message.days_since_message, message_ids.message_event]
measures: [clients_last_seen.average_days_of_use]
dimensions: [days_since_message.days_since_message]
measures: [
cohort_event_type_1.average_days_of_use,
cohort_event_type_2.average_days_of_use,
cohort_event_type_3.average_days_of_use,
]
label: "About Welcome - Cohorts"
description: "Average days of use for two weeks"
filters: [
date: "21 days",
days_since_message.time_period: "14",
message_ids.message_event: "ABOUT^_WELCOME - IMPRESSION,ABOUT^_WELCOME - CLICK^_BUTTON,ABOUT^_WELCOME - SESSION^_END"
cohort_event_type_1.event_type: "IMPRESSION",
cohort_event_type_1.message_id: "ABOUT^_WELCOME",
cohort_event_type_2.event_type: "CLICK^_BUTTON",
cohort_event_type_2.message_id: "ABOUT^_WELCOME",
cohort_event_type_3.event_type: "SESSION^_END",
cohort_event_type_3.message_id: "ABOUT^_WELCOME",
]
limit: 100
}

Просмотреть файл

@ -7,7 +7,15 @@ view: clients_last_seen {
`moz-fx-data-shared-prod`.search.search_clients_last_seen AS clients_last_seen
WHERE
{% condition cohort_analysis.date %} CAST(DATE_SUB(clients_last_seen.submission_date, INTERVAL 56 DAY) AS TIMESTAMP) {% endcondition %}
OR clients_last_seen.submission_date = DATE_SUB(current_date, INTERVAL 2 DAY);;
OR clients_last_seen.submission_date = DATE_SUB(current_date, INTERVAL 2 DAY)
AND {% if days_since_message.days_since_message._is_selected %}
TRUE
{% else %}
ERROR("""
Must use the days_since_mesage.days_since_message dimension in this explore.
This explore CROSS JOINS with all possible days. Unless we GROUP BY each of those days,
we'll get incorrect results for the outputted measures.""")
{% endif %};;
}
dimension: submission_date {
@ -52,20 +60,4 @@ view: clients_last_seen {
sql: BIT_COUNT(${days_seen_bits}) ;;
hidden: yes
}
measure: total_days_of_use {
type: sum
sql: ${days_of_use} ;;
filters: [
cohort_analysis.completed_message_id_event: "yes"
]
}
measure: average_days_of_use {
type: average
sql: ${days_of_use} ;;
filters: [
cohort_analysis.completed_message_id_event: "yes"
]
}
}

Просмотреть файл

@ -8,11 +8,24 @@ view: cohort {
sql: {% condition date %} CAST(cohort_analysis.submission_date AS TIMESTAMP) {% endcondition %} ;;
}
dimension: completed_message_id_event {
dimension: completed_event_1 {
type: yesno
sql: REGEXP_CONTAINS(${TABLE}.events, mozfun.event_analysis.create_funnel_regex([
${message_ids.match_string}],
True)) ;;
sql: REGEXP_CONTAINS(${TABLE}.events, ${cohort_event_type_1.match_string}) ;;
}
dimension: completed_event_2 {
type: yesno
sql: REGEXP_CONTAINS(${TABLE}.events, ${cohort_event_type_2.match_string}) ;;
}
dimension: completed_event_3 {
type: yesno
sql: REGEXP_CONTAINS(${TABLE}.events, ${cohort_event_type_3.match_string}) ;;
}
dimension: completed_event_4 {
type: yesno
sql: REGEXP_CONTAINS(${TABLE}.events, ${cohort_event_type_4.match_string}) ;;
}
measure: total_user_days {
@ -20,13 +33,5 @@ view: cohort {
hidden: yes
}
measure: count_user_days_completed_message_id_event {
label: "Count of User-Days"
type: count
filters: {
field: completed_message_id_event
value: "yes"
}
}
}

Просмотреть файл

@ -0,0 +1,81 @@
include: "/user_journey/views/event_type.view.lkml"
view: cohort_event_type_1 {
extends: [event_type]
measure: total_days_of_use {
type: sum
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_1: "yes"
]
}
measure: average_days_of_use {
type: average
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_1: "yes"
]
}
}
view: cohort_event_type_2 {
extends: [event_type]
measure: total_days_of_use {
type: sum
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_2: "yes"
]
}
measure: average_days_of_use {
type: average
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_2: "yes"
]
}
}
view: cohort_event_type_3 {
extends: [event_type]
measure: total_days_of_use {
type: sum
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_3: "yes"
]
}
measure: average_days_of_use {
type: average
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_3: "yes"
]
}
}
view: cohort_event_type_4 {
extends: [event_type]
measure: total_days_of_use {
type: sum
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_4: "yes"
]
}
measure: average_days_of_use {
type: average
sql: ${clients_last_seen.days_of_use} ;;
filters: [
cohort_analysis.completed_event_4: "yes"
]
}
}

Просмотреть файл

@ -1,24 +0,0 @@
view: message_ids {
derived_table: {
sql:
SELECT
CONCAT(category, ' - ', event) AS message_event,
mozfun.event_analysis.event_index_to_match_string(index) AS match_string,
FROM
mozdata.messaging_system.event_types event_types
WHERE
{% condition message_ids.message_event %}
CONCAT(event_types.category, ' - ', event_types.event)
{% endcondition %};;
}
dimension: message_event {
type: string
sql: ${TABLE}.message_event ;;
}
dimension: match_string {
hidden: yes
sql: ${TABLE}.match_string ;;
}
}

Просмотреть файл

@ -139,5 +139,6 @@ view: event_type {
dimension: match_string {
hidden: yes
sql: ${TABLE}.match_string ;;
primary_key: yes
}
}