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
| SELECT | |
| count(*) | |
| FROM | |
| `<your_project>.analytics_196169157.events_*` | |
| WHERE | |
| event_name = 'event_name' | |
| AND _TABLE_SUFFIX >= format_date('%Y%m%d', CURRENT_DATE() - 30) |
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
| SELECT | |
| count(*) as events | |
| FROM `<project-name>.analytics_<id>.events_*` | |
| WHERE _TABLE_SUFFIX >= FORMAT_DATE('%Y%m%d', CURRENT_DATE() - 7) |
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
| let hiragana = [...Array(0x3095 - 0x3041).keys()].map((i) => String.fromCharCode(0x3041 + i)) | |
| /* | |
| Generates 84 hiragana based on | |
| https://sites.psu.edu/symbolcodes/languages/asia/japanese/hiraganachart/ | |
| [ | |
| 'ぁ', 'あ', 'ぃ', 'い', 'ぅ', 'う', 'ぇ', 'え', | |
| 'ぉ', 'お', 'か', 'が', 'き', 'ぎ', 'く', 'ぐ', | |
| 'け', 'げ', 'こ', 'ご', 'さ', 'ざ', 'し', 'じ', | |
| 'す', 'ず', 'せ', 'ぜ', 'そ', 'ぞ', 'た', 'だ', |
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
| import * as functions from "firebase-functions" | |
| import * as admin from "firebase-admin" | |
| const getUsers = async (pageToken?: string) : Promise<admin.auth.UserRecord[]> => { | |
| const result = await admin.auth().listUsers(1000, pageToken) | |
| if (result.pageToken) { | |
| return [...result.users, ...await getUsers(result.pageToken)] | |
| } | |
| return result.users | |
| } |
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
| SELECT | |
| case | |
| when engagement.minutes > 20 then '>20 min' | |
| when engagement.minutes > 10 then '10-20 min' | |
| when engagement.minutes > 5 then '5-10 min' | |
| when engagement.minutes > 2 then '2-5 min' | |
| else '<2 min' | |
| end as segment, | |
| count(*) as users | |
| FROM ( |
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
| const req = require('request'); | |
| const fs = require('fs'); | |
| req.post({ | |
| headers: { | |
| 'Content-Type': 'multipart/form-data', | |
| 'X-Api-Key': 'MY_KEY' | |
| }, | |
| url: 'https://api.facy.jp/integration/inventory', | |
| method: 'POST', |
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
| require 'net/http' | |
| File.open("MY_CSV_FILE.csv") do |csv_file| | |
| uri = URI.parse('https://api.facy.jp/integration/inventory') | |
| req = Net::HTTP::Post.new(uri.path) | |
| req["X-Api-Key"] = "MY_KEY" | |
| req.set_form([["file", csv_file]], "multipart/form-data") | |
| res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| | |
| http.request(req) |
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
| // This is my example gist | |
| console.log(`it will even syntax highlight for ${user}`); |
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
| SELECT | |
| DATE(DATE_TRUNC(TIMESTAMP_MICROS(event_timestamp), WEEK)) as week, | |
| COUNT(DISTINCT(user_pseudo_id)) as users | |
| FROM `<project>.events_*` | |
| WHERE event_name = 'app_open' | |
| -- past six weeks | |
| AND DATE(DATE_TRUNC(TIMESTAMP_MICROS(event_timestamp), WEEK)) > DATE_SUB(DATE_TRUNC(CURRENT_DATE(), WEEK), INTERVAL 6 WEEK) | |
| GROUP BY week | |
| ORDER BY week |
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
| SELECT | |
| last as last_month, | |
| DATETIME_DIFF(last, first, MONTH) as retained_months, | |
| COUNT(*) as users | |
| FROM ( | |
| SELECT | |
| DATE(DATE_TRUNC(TIMESTAMP_MICROS(min(event_timestamp)), MONTH)) as first, | |
| DATE(DATE_TRUNC(TIMESTAMP_MICROS(max(event_timestamp)), MONTH)) as last | |
| FROM `<your-project>.events_*` | |
| WHERE event_name = 'view_item' |
NewerOlder