Closed WesleyHovick closed 3 years ago
I'm not sure the rules on your PR validation, so I'm not sure why checks are failing - I didn't change any lock files or anything.
Closing PR due to inactivity on this repo - Forking instead.
Re-opening - After thinking about this I decided to leave this open despite forking, as I think it's a very worthwhile change.
This change looks awesome! This would be a massive help in reducing some costs! I'd like to have this change as well for my team, ASAP!
@cedricdelpoux - Thoughts on this PR?
Sorry for the delay. Thank you very much for your great work. I will publish asap
Sorry for the delay. Thank you very much for your great work. I will publish asap
Awesome, thank you! We were still working on integrating the fork into our systems - so we will wait for your publish and use that instead.
Published in v3.12.0
The Problem
The current implementation has two flaws:
The Solution to 1
This PR implements session based autocomplete. The AutocompletionRequest allows us to pass in a sessionToken.
I believe this would be a significant win for the google billing portion for consumers of this component.
As I understand it, a session begins with a user typing, and ends with the auto complete being selected from the list. Upon typing again, a new session token is generated. The advantages and benefits here should be quite clear: a potential significant reduction in API calls and billing from Google.
Additionally, consumers of this component no longer have to implement their own debouncing for user input, since it will all be billed together on one session token.
The Solution to 2
This PR implements session based Places Details retrieval, through the PlacesService. We can utilize our existing
sessionToken
with agetDetails
request through this service, and specify thefields
that we want to retrieve. In the case of the existing functionality, the Geocoding appeared to be returning the following fields on the payload:address_components
,geometry
,types
. By specifying those fields to thegetDetails
we can return a payload that looks identical to the current functionality, so there shouldn't be a large breaking change here. One caveat however, isformatted_address
. This field appears to exist on the Geocoding result underaddress_components
but no longer appears as a field from thegetDetails
. We can include theformatted_address
in thegetDetails
by specifying it on thefields
, however I don't believe it would live underaddress_components
any longer and would technically be a breaking change to anyone usingformatted_address
from theaddress_components
property.This
fields
data falls under the Basic Data SKU for a Places request and do not result in any additional charge.This would also allow the component to easily accept a
fields
prop to address #46