-
Notifications
You must be signed in to change notification settings - Fork 117
feat: build win10 user targeting for braze to start ip warming #8135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+162
−0
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1e395b9
feat: build win10 user targeting for braze
LiamMcFall bb278a1
Merge branch 'main' into win10_users_activation
LiamMcFall 00ef716
reworking win10 users to handle duplication and create braze sync table
LiamMcFall 28d6318
Merge branch 'main' into win10_users_activation
LiamMcFall 247d7b1
Merge branch 'main' into win10_users_activation
LiamMcFall 38e58c4
refactor braze derived and external tables for windows 10 sync
LiamMcFall 7427e54
Merge branch 'main' into win10_users_activation
LiamMcFall f0c4d23
change incremental strategy to true
LiamMcFall eb62d5b
Merge branch 'main' into win10_users_activation
LiamMcFall e53388a
Merge branch 'main' into win10_users_activation
LiamMcFall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
sql/moz-fx-data-shared-prod/braze_derived/fxa_win10_users_v1/metadata.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
friendly_name: Fxa Win10 Users | ||
description: |- | ||
This query identifies Firefox Accounts users on Windows 10 who have been inactive for exactly 14 days and | ||
prepares their records for Braze by assigning an external ID and email. | ||
owners: | ||
- [email protected] | ||
labels: | ||
incremental: false | ||
schedule: daily | ||
owner: lmcfall | ||
scheduling: | ||
dag_name: bqetl_braze |
72 changes: 72 additions & 0 deletions
72
sql/moz-fx-data-shared-prod/braze_derived/fxa_win10_users_v1/query.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
WITH win10_users AS ( | ||
SELECT DISTINCT | ||
TO_HEX(SHA256(metrics.string.client_association_uid)) AS fxa_id_sha256, | ||
FIRST_VALUE(client_info.os) OVER ( | ||
PARTITION BY | ||
TO_HEX(SHA256(metrics.string.client_association_uid)) | ||
ORDER BY | ||
submission_timestamp DESC | ||
) AS os, | ||
FIRST_VALUE(client_info.os_version) OVER ( | ||
PARTITION BY | ||
TO_HEX(SHA256(metrics.string.client_association_uid)) | ||
ORDER BY | ||
submission_timestamp DESC | ||
) AS os_version, | ||
FIRST_VALUE(client_info.locale) OVER ( | ||
PARTITION BY | ||
TO_HEX(SHA256(metrics.string.client_association_uid)) | ||
ORDER BY | ||
submission_timestamp DESC | ||
) AS locale | ||
FROM | ||
`moz-fx-data-shared-prod.firefox_desktop.fx_accounts` | ||
WHERE | ||
DATE(submission_timestamp) = @submission_date | ||
AND client_info.os = 'Windows' | ||
AND client_info.os_version = '10.0' | ||
), | ||
last_seen_14_days AS ( | ||
SELECT DISTINCT | ||
user_id_sha256 | ||
FROM | ||
`moz-fx-data-shared-prod.accounts_backend_derived.users_services_last_seen_v1` | ||
WHERE | ||
submission_date = @submission_date | ||
-- bit pattern 100000000000000, last seen 14 days from submission date | ||
AND days_seen_bits >= 16384 | ||
-- bit pattern 1000000000000000000000, last seen 21 days from submission date | ||
-- Only useful for the initial pull of these users, they will already be in the table for subsquent runs | ||
AND days_seen_bits < 2097152 | ||
), | ||
inactive_win10_users AS ( | ||
SELECT | ||
last_seen.user_id_sha256, | ||
win10.os, | ||
win10.os_version, | ||
win10.locale | ||
FROM | ||
last_seen_14_days AS last_seen | ||
LEFT JOIN | ||
win10_users AS win10 | ||
ON last_seen.user_id_sha256 = win10.fxa_id_sha256 | ||
-- filter out users that don't have an FX account | ||
WHERE | ||
win10.fxa_id_sha256 IS NOT NULL | ||
) | ||
SELECT | ||
braze_users.external_id AS external_id, | ||
-- if user is in our braze users table use their email, otherwise use the email associated with their fxa_id | ||
IFNULL(braze_users.email, fxa_emails.normalizedEmail) AS email, | ||
inactive.user_id_sha256, | ||
inactive.locale | ||
FROM | ||
inactive_win10_users AS inactive | ||
LEFT JOIN | ||
`moz-fx-data-shared-prod.braze_derived.users_v1` AS braze_users | ||
ON inactive.user_id_sha256 = braze_users.fxa_id_sha256 | ||
LEFT JOIN | ||
`moz-fx-data-shared-prod.accounts_backend_external.emails_v1` AS fxa_emails | ||
ON inactive.user_id_sha256 = TO_HEX(SHA256(fxa_emails.uid)) | ||
-- some users have multiple email addresses in this table, only use primary | ||
AND fxa_emails.isPrimary = TRUE |
11 changes: 11 additions & 0 deletions
11
sql/moz-fx-data-shared-prod/braze_external/win10_users_sync_v1/metadata.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
friendly_name: Win10 Users Sync | ||
description: |- | ||
This table will sync inactive Windows 10 Firefox users to Braze to be contacted | ||
in the Win10 Inactive User Campaign. | ||
owners: | ||
- [email protected] | ||
labels: | ||
incremental: true | ||
owner1: lmcfall | ||
scheduling: | ||
dag_name: bqetl_braze |
17 changes: 17 additions & 0 deletions
17
sql/moz-fx-data-shared-prod/braze_external/win10_users_sync_v1/query.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SELECT | ||
CURRENT_TIMESTAMP() AS updated_at, | ||
IFNULL(external_id, TO_HEX(SHA256(GENERATE_UUID()))) AS external_id, | ||
TO_JSON( | ||
STRUCT( | ||
email AS email, | ||
"subscribed" AS email_subscribe, | ||
ARRAY_AGG( | ||
STRUCT("TODO" AS subscription_group_id, "subscribed" AS subscription_state) | ||
) AS subscription_groups, | ||
locale AS locale, | ||
user_id_sha256 AS fxa_id_sha256 | ||
) | ||
) AS payload, | ||
user_id_sha256 AS fxa_id_sha256 | ||
FROM | ||
`moz-fx-data-shared-prod.braze_derived.fxa_win10_users_v1` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.