diff --git a/src/index.test.ts b/src/index.test.ts index da2b39e6..a63faff3 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -45,8 +45,8 @@ test.each([ "https://example.com/js?callback=__googleMapsCallback", ], [ - { channel: "foo" }, - "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&channel=foo", + { client: "bar", channel: "foo" }, + "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&channel=foo&client=bar", ], ])("createUrl is correct", (options: LoaderOptions, expected: string) => { const loader = new Loader(options); diff --git a/src/index.ts b/src/index.ts index 59f31373..7407b5bf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,32 +42,13 @@ export interface LoaderOptions { */ apiKey: string; /** - * To track usage across different applications using the same client ID, - * you may provide an optional channel parameter with your requests. By - * specifying different channel values for different aspects of your - * application, you can determine precisely how your application is used. - * - * For example, your externally-facing website may access the API using a - * channel set to customer while your internal marketing department may use - * a channel set to mkting. Your reports will break down usage by those - * channel values. - * - * Channel reporting is available for applications using the Maps JavaScript - * API, the image APIs or any of the Google Maps Platform web services. - * - * The channel parameter must use the following format: - * - * - Must be an ASCII alphanumeric string. - * - Period (.), underscore (_) and hyphen (-) characters are allowed. - * - The channel parameter is case-insensitive; upper-case, mixed-case, and - * lower-cased channel parameters will be merged into their lower-case - * equivalent. For example, usage on the `CUSTOMER` channel will be combined - * with the usage on the `customer` channel. - * - The channel value must be a static value assigned per application - * instance, and must not be generated dynamically. You may not use - * channel values to track individual users, for example. + * @deprecated See https://developers.google.com/maps/premium/overview. */ channel?: string; + /** + * @deprecated See https://developers.google.com/maps/premium/overview, use `apiKey` instead. + */ + client?: string; /** * In your application you can specify release channels or version numbers: * @@ -205,11 +186,15 @@ export class Loader { */ apiKey: string; /** - * See [[LoaderOptions.id]] + * See [[LoaderOptions.channel]] */ channel: string; /** - * See [[LoaderOptions.channel]] + * See [[LoaderOptions.client]] + */ + client: string; + /** + * See [[LoaderOptions.id]] */ id: string; /** @@ -259,6 +244,7 @@ export class Loader { constructor({ apiKey, channel, + client, id = "__googleMapsScriptId", libraries = [], language, @@ -271,6 +257,7 @@ export class Loader { this.version = version; this.apiKey = apiKey; this.channel = channel; + this.client = client; this.id = id; this.libraries = libraries; this.language = language; @@ -297,6 +284,10 @@ export class Loader { url += `&channel=${this.channel}`; } + if (this.client) { + url += `&client=${this.client}`; + } + if (this.libraries.length > 0) { url += `&libraries=${this.libraries.join(",")}`; }