Skip to content

Commit 7370f87

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Add swift and kotlin and python client metrics logging (#30561)
Add logging to set up swift/kotlin GitOrigin-RevId: 6559efa77fac190cbeffa00a2049a9c7cfdd7ff5
1 parent 9a936da commit 7370f87

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

crates/common/src/version.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ pub enum ClientType {
185185
// For HTTP requests from the dashboard. Requests from the dashboard via a
186186
// Convex client will have an `NPM` version
187187
Dashboard,
188+
Swift,
189+
Kotlin,
188190
// We convert to lower case when we parse, so lets just generate lowercase strings.
189191
#[cfg_attr(
190192
any(test, feature = "testing"),
@@ -200,6 +202,7 @@ impl FromStr for ClientType {
200202
fn from_str(s: &str) -> Result<Self, Self::Err> {
201203
let client_type = match &*s.to_ascii_lowercase() {
202204
"python-convex" => Self::Python,
205+
"python" => Self::Python,
203206
"npm-cli" => Self::CLI,
204207
"npm" => Self::NPM,
205208
"actions" => Self::Actions,
@@ -209,6 +212,8 @@ impl FromStr for ClientType {
209212
"fivetran-import" => Self::FivetranImport,
210213
"fivetran-export" => Self::FivetranExport,
211214
"dashboard" => Self::Dashboard,
215+
"swift" => Self::Swift,
216+
"kotlin" => Self::Kotlin,
212217
unrecognized => Self::Unrecognized(unrecognized.to_string()),
213218
};
214219
Ok(client_type)
@@ -218,7 +223,7 @@ impl FromStr for ClientType {
218223
impl Display for ClientType {
219224
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
220225
match self {
221-
Self::Python => write!(f, "python-convex"),
226+
Self::Python => write!(f, "python"),
222227
Self::CLI => write!(f, "npm-cli"),
223228
Self::NPM => write!(f, "npm"),
224229
Self::Actions => write!(f, "actions"),
@@ -228,6 +233,8 @@ impl Display for ClientType {
228233
Self::FivetranImport => write!(f, "fivetran-import"),
229234
Self::FivetranExport => write!(f, "fivetran-export"),
230235
Self::Dashboard => write!(f, "dashboard"),
236+
Self::Swift => write!(f, "swift"),
237+
Self::Kotlin => write!(f, "kotlin"),
231238
Self::Unrecognized(other_client) => write!(f, "{other_client}"),
232239
}
233240
}
@@ -245,6 +252,8 @@ impl ClientType {
245252
| Self::FivetranImport
246253
| Self::FivetranExport
247254
| Self::Dashboard
255+
| Self::Swift
256+
| Self::Kotlin
248257
| Self::Unrecognized(_) => None,
249258
}
250259
}
@@ -260,6 +269,8 @@ impl ClientType {
260269
| Self::FivetranImport
261270
| Self::FivetranExport
262271
| Self::Dashboard
272+
| Self::Swift
273+
| Self::Kotlin
263274
| Self::Unrecognized(_) => None,
264275
}
265276
}
@@ -281,6 +292,8 @@ impl ClientType {
281292
| Self::FivetranImport
282293
| Self::FivetranExport
283294
| Self::Dashboard
295+
| Self::Swift
296+
| Self::Kotlin
284297
| Self::Unrecognized(_) => "",
285298
}
286299
}
@@ -397,6 +410,8 @@ impl ClientVersion {
397410
| ClientType::FivetranImport
398411
| ClientType::FivetranExport
399412
| ClientType::Dashboard
413+
| ClientType::Swift
414+
| ClientType::Kotlin
400415
| ClientType::Unrecognized(_) => true,
401416
};
402417

@@ -484,9 +499,7 @@ mod tests {
484499

485500
// Versions higher than what we know about are also considered latest.
486501
assert_eq!(
487-
"python-convex-1000.0.0"
488-
.parse::<ClientVersion>()?
489-
.current_state(),
502+
"python-1000.0.0".parse::<ClientVersion>()?.current_state(),
490503
ClientVersionState::Supported
491504
);
492505
assert_eq!(
@@ -554,9 +567,9 @@ mod tests {
554567
"npm-2.0.0",
555568
"actions-1.4.1",
556569
"npm-cli-1.4.1",
557-
"python-convex-0.5.0",
558-
"python-convex-0.6.0",
559-
"python-convex-1.6.0",
570+
"python-0.5.0",
571+
"python-0.6.0",
572+
"python-1.6.0",
560573
"asdf-0.0.0", // unknown
561574
];
562575
for r in require {
@@ -571,8 +584,8 @@ mod tests {
571584
"npm-0.19.0",
572585
"actions-1.3.0",
573586
"npm-cli-1.3.0",
574-
"python-convex-0.4.0",
575-
"python-convex-0.3.0",
587+
"python-0.4.0",
588+
"python-0.3.0",
576589
];
577590
for r in not_require {
578591
assert_eq!(

crates/local_backend/src/logs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ pub async fn stream_function_logs(
163163
| ClientType::AirbyteExport
164164
| ClientType::FivetranImport
165165
| ClientType::FivetranExport
166+
| ClientType::Swift
167+
| ClientType::Kotlin
166168
| ClientType::Unrecognized(_) => false,
167169
};
168170
futures::select_biased! {

crates/local_backend/src/subs/mod.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ use common::{
3232
ResolvedHostname,
3333
},
3434
runtime::Runtime,
35-
version::{
36-
ClientType,
37-
ClientVersion,
38-
},
35+
version::ClientVersion,
3936
ws::is_connection_closed_error,
4037
};
4138
use futures::{
@@ -329,21 +326,7 @@ async fn run_sync_socket(
329326
}
330327

331328
fn new_sync_worker_config(client_version: ClientVersion) -> anyhow::Result<SyncWorkerConfig> {
332-
match client_version.client() {
333-
ClientType::NPM => Ok(SyncWorkerConfig { client_version }),
334-
ClientType::Rust | ClientType::Unrecognized(_) => Ok(SyncWorkerConfig::default()),
335-
ClientType::CLI
336-
| ClientType::Python
337-
| ClientType::StreamingImport
338-
| ClientType::AirbyteExport
339-
| ClientType::FivetranImport
340-
| ClientType::FivetranExport
341-
| ClientType::Dashboard
342-
| ClientType::Actions => Err(anyhow::anyhow!(
343-
"No websocket support for client: {}",
344-
client_version.client()
345-
)),
346-
}
329+
Ok(SyncWorkerConfig { client_version })
347330
}
348331

349332
pub async fn sync_client_version_url(

0 commit comments

Comments
 (0)