diff --git a/src/components/__tests__/api-provider.test.tsx b/src/components/__tests__/api-provider.test.tsx index da8f535..39870e0 100644 --- a/src/components/__tests__/api-provider.test.tsx +++ b/src/components/__tests__/api-provider.test.tsx @@ -67,6 +67,7 @@ test('passes parameters to GoogleMapsAPILoader', () => { version={'beta'} language={'en'} region={'us'} + solutionChannel={'test-channel_value'} authReferrerPolicy={'origin'}> ); @@ -76,6 +77,7 @@ test('passes parameters to GoogleMapsAPILoader', () => { v: 'beta', language: 'en', region: 'us', + solutionChannel: 'test-channel_value', authReferrerPolicy: 'origin' }); }); diff --git a/src/components/api-provider.tsx b/src/components/api-provider.tsx index c004a27..d3d9082 100644 --- a/src/components/api-provider.tsx +++ b/src/components/api-provider.tsx @@ -65,6 +65,14 @@ export type APIProviderProps = { * Part of: https://developers.google.com/maps/documentation/javascript/url-params */ authReferrerPolicy?: string; + /** + * To understand usage and ways to improve our solutions, Google includes the + * `solution_channel` query parameter in API calls to gather information about + * code usage. You may opt out at any time by setting this attribute to an + * empty string. Read more in the + * [documentation](https://developers.google.com/maps/reporting-and-monitoring/reporting#solutions-usage). + */ + solutionChannel?: string; /** * A function that can be used to execute code after the Google Maps JavaScript API has been loaded. */ @@ -101,6 +109,7 @@ function useMapInstances() { */ function useGoogleMapsApiLoader(props: APIProviderProps) { const {onLoad, apiKey, version, libraries = [], ...otherApiParams} = props; + const solutionChannel = props.solutionChannel || 'GMP_VISGL_react'; const [status, setStatus] = useState( GoogleMapsApiLoader.loadingStatus @@ -117,8 +126,8 @@ function useGoogleMapsApiLoader(props: APIProviderProps) { const librariesString = useMemo(() => libraries?.join(','), [libraries]); const serializedParams = useMemo( - () => JSON.stringify({apiKey, version, ...otherApiParams}), - [apiKey, version, otherApiParams] + () => JSON.stringify({apiKey, version, solutionChannel, ...otherApiParams}), + [apiKey, version, solutionChannel, otherApiParams] ); const importLibrary: typeof google.maps.importLibrary = useCallback(