openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
162 stars 67 forks source link

fix: added "app_name" parameter for prices methods uploadProof and createPrice #938

Closed monsieurtanuki closed 3 months ago

monsieurtanuki commented 3 months ago

What

Impacted files

monsieurtanuki commented 3 months ago

cc @raphodn @raphael0202

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 83.72093% with 7 lines in your changes missing coverage. Please review.

Project coverage is 75.20%. Comparing base (820d145) to head (641d195). Report is 34 commits behind head on master.

Files Patch % Lines
lib/src/prices/currency.dart 0.00% 3 Missing :warning:
lib/src/prices/proof_type.dart 0.00% 2 Missing :warning:
test/api_search_products_test.dart 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #938 +/- ## ========================================== - Coverage 76.34% 75.20% -1.15% ========================================== Files 239 247 +8 Lines 8494 8881 +387 ========================================== + Hits 6485 6679 +194 - Misses 2009 2202 +193 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

raphodn commented 3 months ago

Fyi in the prices web app I opted to pass the app_name in the URL of every request (so not only POST, but also GET).

I guess in Sentry if there are any errors, the User Agent is sent and available in any case. But i realised that some browsers do not allow to edit the UA (for instance Chrome).

monsieurtanuki commented 3 months ago

Fyi in the prices web app I opted to pass the app_name in the URL of every request (so not only POST, but also GET).

DELETE and PATCH too?

raphodn commented 3 months ago

Yes every call to the API 👌

And you can send extra info like the app_version and any other relevant data as extra url params if you want.

I need to document at least the app_name in the API documentation

monsieurtanuki commented 3 months ago

@raphodn I've just pushed a change where all prices URLs will include "user agent" fields (when populated):

With the exception of the proof file URL where we don't add those parameters, e.g. https://prices.openfoodfacts.net/img/0002/yRw3zcph08.jpg

monsieurtanuki commented 3 months ago

Thank you @M123-dev for your reviews!