Skip to content

Commit 4a1e5d8

Browse files
feat: utm param support
Signed-off-by: Henry Gressmann <[email protected]>
1 parent d3d5133 commit 4a1e5d8

File tree

22 files changed

+124
-60
lines changed

22 files changed

+124
-60
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@ The format is roughly based on the output of `git-cliff` and this project adhere
1616
Since this is not a library, this changelog focuses on the changes that are relevant to the end-users. For a detailed list of changes, see the commit history, which adheres to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). New releases are created automatically when a new tag is pushed (Commit message: chore(release): vX.X.X).
1717
-->
1818

19-
<!-- ## [Unreleased] -->
19+
## [Unreleased]
20+
21+
### 🚀 Features
22+
23+
- **UTM parameters**: Added support for UTM parameters. You can filter and search by UTM source, medium, campaign, content, and term.
24+
25+
### 🐛 Bug Fixes
26+
27+
- Fixed a potential panic when entities are not found in the database (https://github.com/explodingcamera/liwan/commit/31405a721dc5c5493098e211927281cca7816fec)
28+
- Fixed issues with the `Yesterday` Date Range (https://github.com/explodingcamera/liwan/commit/76278b579c5fe1557bf1c184542ed6ed2aba57cd)
2029

2130
## **Liwan v0.1.1** - 2024-09-24
2231

23-
This release just drops some of the duckdb indexes to improve performance and reduce the database size.
32+
### ⚡ Performance
33+
34+
- **Database indexes**: Removed all unnecessary indexes to improve performance and reduce disk usage (https://github.com/explodingcamera/liwan/commit/6191a72f08e8659237bc6c22139bde94432f66bb)
2435

2536
## **Liwan v0.1.0** - 2024-09-18
2637

Cargo.lock

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name="liwan"
33
version="0.1.1"
44
edition="2021"
5-
rust-version="1.80"
5+
rust-version="1.82"
66
repository="https://github.com/explodingcamera/liwan"
77
license="AGPL-3.0-only OR LicenseRef-Liwan"
88
publish=false
@@ -48,7 +48,6 @@ tracing-subscriber={version="0.3", features=["env-filter"]}
4848
poem={version="3.1", default-features=false, features=[
4949
"time",
5050
"embed",
51-
"session",
5251
"cookie",
5352
"compression",
5453
"tower-compat",

src/app/core/entities.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use eyre::{bail, Result};
22

3-
use crate::{
4-
app::{models, SqlitePool},
5-
utils::validate,
6-
};
3+
use crate::app::{models, SqlitePool};
4+
use crate::utils::validate;
75

86
#[derive(Clone)]
97
pub struct LiwanEntities {

src/app/core/events.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ use crossbeam::{channel::Receiver, sync::ShardedLock};
44
use eyre::{bail, Result};
55
use time::OffsetDateTime;
66

7-
use crate::{
8-
app::{
9-
models::{event_params, Event},
10-
DuckDBPool, SqlitePool, EVENT_BATCH_INTERVAL,
11-
},
12-
utils::hash::generate_salt,
13-
};
7+
use crate::app::models::{event_params, Event};
8+
use crate::app::{DuckDBPool, SqlitePool, EVENT_BATCH_INTERVAL};
9+
use crate::utils::hash::generate_salt;
1410

1511
#[derive(Clone)]
1612
pub struct LiwanEvents {

src/app/core/geoip.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#![allow(dead_code)]
22

3-
use std::{
4-
collections::HashMap,
5-
net::IpAddr,
6-
path::{Path, PathBuf},
7-
sync::{
8-
atomic::{AtomicBool, Ordering},
9-
Arc,
10-
},
11-
};
3+
use std::collections::HashMap;
4+
use std::net::IpAddr;
5+
use std::path::{Path, PathBuf};
6+
use std::sync::atomic::{AtomicBool, Ordering};
7+
use std::sync::Arc;
128

139
use crate::app::SqlitePool;
1410
use crossbeam::sync::ShardedLock;

src/app/core/projects.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use eyre::{bail, Result};
22

3-
use crate::{
4-
app::{models, SqlitePool},
5-
utils::validate,
6-
};
3+
use crate::app::{models, SqlitePool};
4+
use crate::utils::validate;
75

86
#[derive(Clone)]
97
pub struct LiwanProjects {

src/app/core/reports.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ pub enum Dimension {
5656
Mobile,
5757
Country,
5858
City,
59+
UtmSource,
60+
UtmMedium,
61+
UtmCampaign,
62+
UtmContent,
63+
UtmTerm,
5964
}
6065

6166
#[derive(Enum, Debug, Clone, Copy, PartialEq)]
@@ -174,6 +179,11 @@ fn filter_sql(filters: &[DimensionFilter]) -> Result<(String, ParamVec)> {
174179
Dimension::Mobile => format!("mobile::text {filter_value}"),
175180
Dimension::Country => format!("country {filter_value}"),
176181
Dimension::City => format!("city {filter_value}"),
182+
Dimension::UtmSource => format!("utm_source {filter_value}"),
183+
Dimension::UtmMedium => format!("utm_medium {filter_value}"),
184+
Dimension::UtmCampaign => format!("utm_campaign {filter_value}"),
185+
Dimension::UtmContent => format!("utm_content {filter_value}"),
186+
Dimension::UtmTerm => format!("utm_term {filter_value}"),
177187
})
178188
})
179189
.collect::<Result<Vec<String>>>()?;
@@ -401,6 +411,11 @@ pub fn dimension_report(
401411
Dimension::Mobile => ("mobile::text", "mobile"),
402412
Dimension::Country => ("country", "country"),
403413
Dimension::City => ("concat(country, city)", "country, city"),
414+
Dimension::UtmSource => ("utm_source", "utm_source"),
415+
Dimension::UtmMedium => ("utm_medium", "utm_medium"),
416+
Dimension::UtmCampaign => ("utm_campaign", "utm_campaign"),
417+
Dimension::UtmContent => ("utm_content", "utm_content"),
418+
Dimension::UtmTerm => ("utm_term", "utm_term"),
404419
};
405420

406421
params.push(range.start());

src/app/core/users.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
use crate::{
2-
app::{models, SqlitePool},
3-
utils::{
4-
hash::{hash_password, verify_password},
5-
validate,
6-
},
7-
};
1+
use crate::app::{models, SqlitePool};
2+
use crate::utils::hash::{hash_password, verify_password};
3+
use crate::utils::validate;
84
use eyre::{bail, Result};
95

106
#[derive(Clone)]

src/app/db.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::utils::refinery_duckdb::DuckDBConnection;
33
use crate::utils::refinery_sqlite::RqlConnection;
44

55
use duckdb::DuckdbConnectionManager;
6-
use eyre::Result;
6+
use eyre::{bail, Result};
77
use r2d2_sqlite::SqliteConnectionManager;
88
use refinery::Runner;
99
use std::path::PathBuf;
@@ -16,7 +16,17 @@ pub(super) fn init_duckdb(
1616
let conn = DuckdbConnectionManager::file(path)?;
1717
let pool = r2d2::Pool::new(conn)?;
1818
migrations_runner.set_migration_table_name("migrations");
19-
migrations_runner.run(&mut DuckDBConnection(pool.get()?))?;
19+
20+
for migration in migrations_runner.run_iter(&mut DuckDBConnection(pool.get()?)) {
21+
match migration {
22+
Ok(migration) => {
23+
tracing::info!("Applied migration: {}", migration);
24+
}
25+
Err(err) => {
26+
bail!("Failed to apply migration: {}", err);
27+
}
28+
}
29+
}
2030

2131
{
2232
let conn = pool.get()?;

0 commit comments

Comments
 (0)