From ab8ef34ca00a1d9da2e6dd967b84643f2adf0770 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Wed, 15 Mar 2023 14:18:29 -0500 Subject: [PATCH] refactor(updater): remove client_id (#78) --- dart_bindings/lib/src/bindings.dart | 22 +++++++++------------- dart_bindings/lib/updater.dart | 6 ++---- dart_cli/bin/dart_cli.dart | 1 - library/src/cache.rs | 13 ------------- library/src/network.rs | 1 - 5 files changed, 11 insertions(+), 32 deletions(-) diff --git a/dart_bindings/lib/src/bindings.dart b/dart_bindings/lib/src/bindings.dart index d8590b4..b0e6a5a 100644 --- a/dart_bindings/lib/src/bindings.dart +++ b/dart_bindings/lib/src/bindings.dart @@ -10,8 +10,6 @@ import 'package:ffi/ffi.dart'; class AppParameters extends ffi.Struct { external ffi.Pointer channel; // ignore: non_constant_identifier_names - external ffi.Pointer client_id; - // ignore: non_constant_identifier_names external ffi.Pointer app_id; // ignore: non_constant_identifier_names external ffi.Pointer base_version; @@ -24,17 +22,16 @@ class AppParameters extends ffi.Struct { // ignore: non_constant_identifier_names external ffi.Pointer cache_dir; - static ffi.Pointer allocate( - {required String clientId, - required String appId, - required String version, - required String channel, - required String? updateUrl, - required String libappPath, - required String libflutterPath, - required String cacheDir}) { + static ffi.Pointer allocate({ + required String appId, + required String version, + required String channel, + required String? updateUrl, + required String libappPath, + required String libflutterPath, + required String cacheDir, + }) { var config = calloc(); - config.ref.client_id = clientId.toNativeUtf8(); config.ref.app_id = appId.toNativeUtf8(); config.ref.base_version = version.toNativeUtf8(); config.ref.channel = channel.toNativeUtf8(); @@ -48,7 +45,6 @@ class AppParameters extends ffi.Struct { } static void free(ffi.Pointer config) { - calloc.free(config.ref.client_id); calloc.free(config.ref.app_id); calloc.free(config.ref.base_version); calloc.free(config.ref.channel); diff --git a/dart_bindings/lib/updater.dart b/dart_bindings/lib/updater.dart index 2653144..7ddb0b0 100644 --- a/dart_bindings/lib/updater.dart +++ b/dart_bindings/lib/updater.dart @@ -49,8 +49,7 @@ class Updater { // This is only used when called from a Dart command line. // Shorebird will have initialized the library already for you when // inside a Flutter app. - static void initUpdaterLibrary({ - required String clientId, + static void initUpdaterLibrary({ required String appId, required String version, required String channel, @@ -65,8 +64,7 @@ class Updater { channel: channel, updateUrl: updateUrl, libappPath: baseLibraryPath, - libflutterPath: vmPath, - clientId: clientId, + libflutterPath: vmPath, cacheDir: cacheDir, ); try { diff --git a/dart_cli/bin/dart_cli.dart b/dart_cli/bin/dart_cli.dart index 631646d..e0c5346 100644 --- a/dart_cli/bin/dart_cli.dart +++ b/dart_cli/bin/dart_cli.dart @@ -10,7 +10,6 @@ void main(List args) async { Updater.loadLibrary(directory: directory, name: "updater"); Updater.initUpdaterLibrary( - clientId: 'my-client-id', appId: 'demo', version: '1.0.0', channel: 'stable', diff --git a/library/src/cache.rs b/library/src/cache.rs index 2cd544b..3f3ba52 100644 --- a/library/src/cache.rs +++ b/library/src/cache.rs @@ -3,7 +3,6 @@ use std::fs::File; use std::io::{BufReader, BufWriter}; use std::path::Path; -use uuid::Uuid; use serde::{Deserialize, Serialize}; @@ -26,13 +25,6 @@ struct Slot { // anything inside should be done via the functions below. #[derive(Deserialize, Serialize)] pub struct UpdaterState { - // The purpose of the client_id is to allow for staged rollouts - // the server needs some sort of per-client number, so that it can bucket - // and say "this client is in the 10% bucket, so it gets the new version". - // It might be better for this to just be a number 0-100? - #[serde(default = "Uuid::new_v4")] - /// ID generated for this device/client used for staged rollouts. - client_id: Uuid, /// List of patches that failed to boot. We will never attempt these again. failed_patches: Vec, /// List of patches that successfully booted. We will never rollback past @@ -48,7 +40,6 @@ pub struct UpdaterState { impl Default for UpdaterState { fn default() -> Self { Self { - client_id: Uuid::new_v4(), current_slot_index: 0, failed_patches: Vec::new(), successful_patches: Vec::new(), @@ -111,10 +102,6 @@ impl UpdaterState { Ok(()) } - pub fn client_id(&self) -> String { - self.client_id.to_string() - } - pub fn current_patch(&self) -> Option { // If there is no state, return None. if self.slots.is_empty() { diff --git a/library/src/network.rs b/library/src/network.rs index c1d6871..8322844 100644 --- a/library/src/network.rs +++ b/library/src/network.rs @@ -38,7 +38,6 @@ pub fn send_patch_check_request( // Send the request to the server. let client = reqwest::blocking::Client::new(); let mut body = HashMap::new(); - body.insert("client_id", state.client_id()); body.insert("app_id", config.app_id.clone()); body.insert("channel", config.channel.clone()); body.insert("base_version", config.base_version.clone());