Add affiliate code revenue analytics (#4883)

* Add affiliate code revenue analytics

* clean up some error handling

* Add conversions to affiliate code analytics

* Only include affiliate subscriptions which have an associated successful charge

* wip: affiliate code clicks

* affiliate code click ingest route

* Add affiliate code clicks to analytics

* add new cols
This commit is contained in:
aecsocket
2025-12-18 18:02:49 +00:00
committed by GitHub
parent dc16a65b62
commit 8d894541e8
12 changed files with 662 additions and 131 deletions

View File

@@ -135,5 +135,30 @@ pub async fn init_client_with_database(
.execute()
.await?;
client
.query(&format!(
"
CREATE TABLE IF NOT EXISTS {database}.affiliate_code_clicks {cluster_line}
(
recorded DateTime64(4),
domain String,
user_id UInt64,
affiliate_code_id UInt64,
ip IPv6,
country String,
user_agent String,
headers Array(Tuple(String, String))
)
ENGINE = {engine}
{ttl}
PRIMARY KEY (affiliate_code_id, recorded)
SETTINGS index_granularity = 8192
"
))
.execute()
.await?;
Ok(client.with_database(database))
}