Skip to content

Commit

Permalink
feat: add ws user id (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen authored Mar 9, 2024
2 parents 5e60920 + cd2365d commit 49caf39
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 21 deletions.
54 changes: 48 additions & 6 deletions defs/api/app-analytics/GET/Output.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"stations",
"total_duration_ms",
"until",
"users",
"utc_offset_minutes"
],
"properties": {
Expand Down Expand Up @@ -123,6 +124,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand All @@ -148,7 +154,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand Down Expand Up @@ -186,6 +193,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down Expand Up @@ -219,7 +231,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand Down Expand Up @@ -263,6 +276,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down Expand Up @@ -296,7 +314,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand Down Expand Up @@ -565,6 +584,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down Expand Up @@ -598,7 +622,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand All @@ -614,6 +639,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down Expand Up @@ -646,7 +676,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand All @@ -663,6 +694,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down Expand Up @@ -696,7 +732,8 @@
"max_concurrent_listeners",
"sessions",
"total_duration_ms",
"total_transfer_bytes"
"total_transfer_bytes",
"users"
],
"properties": {
"key": {
Expand Down Expand Up @@ -724,6 +761,11 @@
"format": "uint64",
"minimum": 0.0
},
"users": {
"type": "integer",
"format": "uint64",
"minimum": 0.0
},
"total_duration_ms": {
"type": "integer",
"format": "uint64",
Expand Down
1 change: 1 addition & 0 deletions defs/app-analytics/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Analytics = {
utc_offset_minutes: number;
sessions: number;
ips: number;
users: number;
total_duration_ms: number;
max_concurrent_listeners?: number;
max_concurrent_listeners_date?: DateTime;
Expand Down
1 change: 1 addition & 0 deletions defs/app-analytics/AnalyticsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type AnalyticsItem<K> = {
key: K;
sessions: number;
ips: number;
users: number;
total_duration_ms: number;
total_transfer_bytes: number;
max_concurrent_listeners?: number;
Expand Down
1 change: 1 addition & 0 deletions defs/db/WsStatsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type WsStatsConnection = {
ip: string;
ap: string | null | undefined;
av: number | null | undefined;
us: string | null | undefined;
re: number;
ca: DateTime;
cl: DateTime | null | undefined;
Expand Down
1 change: 1 addition & 0 deletions defs/ws-stats/api/ws/stats/connection/WS/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export type Query = {
connection_id?: string;
station_id: string;
user_id?: string;
app_kind?: string;
app_version?: number;
};
10 changes: 5 additions & 5 deletions front/share/src/analytics/AnalyticsData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -1089,12 +1089,12 @@
key: item_key,
sessions: 0,
ips: 0,
users: 0,
total_duration_ms: 0,
total_transfer_bytes: 0,
// max_concurrent_listeners: undefined,
// max_concurrent_listeners_date: undefined,
total_transfer_bytes: 0
})
} else {
// @ts-expect-error
items.push(item)
}
Expand Down Expand Up @@ -1131,12 +1131,12 @@
key: item_key,
sessions: 0,
ips: 0,
users: 0,
total_duration_ms: 0,
total_transfer_bytes: 0,
// max_concurrent_listeners: undefined,
// max_concurrent_listeners_date: undefined,
})
} else {
// @ts-expect-error
items.push(item)
}
Expand Down
6 changes: 6 additions & 0 deletions rs/packages/api/src/ws_stats/routes/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub struct Query {

station_id: String,

#[ts(optional)]
#[serde(skip_serializing_if = "Option::is_none")]
user_id: Option<String>,

#[ts(optional)]
#[serde(skip_serializing_if = "Option::is_none")]
app_kind: Option<String>,
Expand Down Expand Up @@ -140,6 +144,7 @@ impl WsConnectionHandler {
let Query {
connection_id: prev_id,
station_id,
user_id,
app_kind,
app_version,
} = qs;
Expand Down Expand Up @@ -179,6 +184,7 @@ impl WsConnectionHandler {
ip,
app_kind: app_kind.clone(),
app_version,
user_id,
reconnections,
created_at,
closed_at: None,
Expand Down
Loading

0 comments on commit 49caf39

Please sign in to comment.