-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement the new App uuid system #370
Comments
@teolemon Basically it's about adding 3 optional |
I think we can edit the UserAgent to be used for that |
|
What apps can't send a UserAgent, the current UserAgent in this sdk is pretty similar, it's only lacking the uuid and is probably send different https://github.com/openfoodfacts/openfoodfacts-dart/blob/master/lib/model/UserAgent.dart
|
New file: * `SourceConfiguration.dart`: Source Configuration for detection of apps (populates data sources on BE). Impacted file: * `openfoodfacts.dart`: added source configuration parameter to `saveProduct`
I agree with @M123-dev , the info is the same as what we have in the UserAgent class, we can reuse it, so we don't need a separate SourceConfiguration class as proposed by @monsieurtanuki in his PR. A few points:
The reason we want both is that we can see them in different places. The User-Agent header is easy to find in nginx and Apache logs, while the more structured app_name and app_version are better for the OFF API internals.
|
|
Working on 1. and 3. |
…ies (as parameters) Impacted files: * `configuration_test.dart`: added test for user agent; refactored * `HttpHelper.dart`: new method `addUserAgentParameters`, automatically used for post and multipart requests * `openfoodfacts.dart`: added `addUserAgentParameters: false` for specific `getUri` calls like post and multipart * `UriHelper.dart`: new parameter `addUserAgentParameters` for `getUri`
For the uuid, we can probably add it to the user class since it is somewhat related |
…eters) (#376) Impacted files: * `configuration_test.dart`: added test for user agent; refactored * `HttpHelper.dart`: new method `addUserAgentParameters`, automatically used for post and multipart requests * `openfoodfacts.dart`: added `addUserAgentParameters: false` for specific `getUri` calls like post and multipart * `UriHelper.dart`: new parameter `addUserAgentParameters` for `getUri`
Sounds good to me. But: how do you compute the UUID? I cannot picture the meaning of UUID compared to just the userId (e.g. |
@monsieurtanuki here's what we do in Smoothie (for Robotoff only, I believe) |
Thank you @teolemon! As off-dart is not restricted to Android and iOS, we need UUID also for MacOS, Linux, Web and Windows. Something like that: if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
deviceIdentifier = androidInfo.androidId;
} else if (Platform.isIOS) {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
deviceIdentifier = iosInfo.identifierForVendor;
} else if (kIsWeb) {
// The web doesnt have a device UID, so use a combination fingerprint as an example
WebBrowserInfo webInfo = await deviceInfo.webBrowserInfo;
deviceIdentifier = webInfo.vendor + webInfo.userAgent + webInfo.hardwareConcurrency.toString();
} else if (Platform.isLinux) {
LinuxDeviceInfo linuxInfo = await deviceInfo.linuxInfo;
deviceIdentifier = linuxInfo.machineId;
} Or using platform_device_id:
(for web we only get the user agent). Anyway the general idea is that we (as off-dart) compute the UUID and affect it automatically to the relevant requests, right? |
There is a couple of problems:
Shouldn't we create a static |
Sorry for being late to the party.
Agreed, this is not ideal.
I think the server should specifically either ask for a device-id or/and (a bunch of specific information like app-name, app-version, username etc) and the server should be responsible for generating the UUID based on that information. Reason being, if you let clients come up with their own mechanics for creating unique strings, two different clients could create the same UUID (which would be unique for them but not across devices). Clients are generally not responsible for creating their own identifiers (unless if they use something globally unique like device-id) If the server specifically asked for device-id (and app-name+version), that would make this problem much easier, each client would send the device id (and other stuff) to the dart package which would forward it to the server. |
@jasmeet0817 As I said before, I don't quite understand the purpose of the As I suggested, we can provide a dart method to generate UUID. The problem is that we cannot be sure that the user 1. uses this method 2. populates correctly the global A solution would be either to convert off-dart to a flutter project (instead of a dart project), or to create a new project called |
hmm I see. Thanks for clarifying. To be honest I would just get the @teolemon Basic question: Is this really needed in off-dart package ? Can the clients just pass |
Impacted files: * `configuration_test.dart`: added tests with "uuid" * `HttpHelper.dart`: included new static `uuid` to parameters * `OpenFoodAPIConfiguration.dart`: added `static String? uuid` * `pubspec.yaml`: unrelated upgrade
@teolemon I think we're done here; I guess the part about |
What
For further details and potential questions, see: openfoodfacts/openfoodfacts-server#6319
Part of
The text was updated successfully, but these errors were encountered: