Skip to content
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

feat: standardize user agent value #1775

Merged
merged 18 commits into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5d5440a
fix: update default useragent string to comply metrics requirements
AllanZhengYP Nov 9, 2020
de12942
feat(util-user-agent-node): update node user agent provider to the la…
AllanZhengYP Dec 7, 2020
2d9fe9a
feat(types): add user agent type
AllanZhengYP Dec 7, 2020
4d84b99
feat(types): add useragent to handler exec context
AllanZhengYP Dec 7, 2020
33d5814
feat(util-user-agent-node): update node user agent provider to the la…
AllanZhengYP Dec 7, 2020
6cf848b
feat(util-user-agent-node): support app id and add unit tests
AllanZhengYP Dec 8, 2020
ab29da1
feat(util-user-agent-browser): detect browser UA in new format
AllanZhengYP Dec 9, 2020
addd91d
feat(util-user-agent-browser): support react native user agent
AllanZhengYP Dec 9, 2020
5cb342d
feat(middleware-user-agent): combine ua from context, default, and co…
AllanZhengYP Dec 9, 2020
c5cacd8
feat(middleware-user-agent): add injectUserAgent plugin
AllanZhengYP Dec 9, 2020
ad2215d
feat(middleware-user-agent): add retry mode metrics
AllanZhengYP Dec 11, 2020
2bb765e
feat(util-user-agent-*): support non-AWS clients
AllanZhengYP Dec 13, 2020
821ffd0
chore(codegen): consolidate user-agent customization to a codegen plugin
AllanZhengYP Dec 14, 2020
94bfa85
fix(middleware-user-agent): remove injectUAPlugin because it's not us…
AllanZhengYP Dec 15, 2020
b923d6b
fix(util-user-agent-*): not to update version to 3.x.x
AllanZhengYP Dec 15, 2020
a0390f1
feat(middleware-user-agent): lowercase service ids
AllanZhengYP Dec 18, 2020
9380285
feat: rename defaultUserAgent config to defaultUserAgentProvider
AllanZhengYP Dec 18, 2020
0d861f7
feat(client-*): update user-agent population and injecting
AllanZhengYP Dec 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 15 additions & 12 deletions clients/client-accessanalyzer/AccessAnalyzerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
} from "@aws-sdk/smithy-client";
import {
Provider,
RegionInfoProvider,
Credentials as __Credentials,
Decoder as __Decoder,
Expand All @@ -72,6 +73,7 @@ import {
Provider as __Provider,
StreamCollector as __StreamCollector,
UrlParser as __UrlParser,
UserAgent as __UserAgent,
} from "@aws-sdk/types";

export type ServiceInputTypes =
Expand Down Expand Up @@ -161,11 +163,6 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
*/
utf8Encoder?: __Encoder;

/**
* The string that will be used to populate default value in 'User-Agent' header
*/
defaultUserAgent?: string;

/**
* The runtime environment
*/
Expand Down Expand Up @@ -207,6 +204,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
* Fetch related hostname, signing name or signing region with given region.
*/
regionInfoProvider?: RegionInfoProvider;

/**
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
*/
defaultUserAgentProvider?: Provider<__UserAgent>;
}

export type AccessAnalyzerClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
Expand All @@ -215,17 +218,17 @@ export type AccessAnalyzerClientConfig = Partial<__SmithyConfiguration<__HttpHan
EndpointsInputConfig &
AwsAuthInputConfig &
RetryInputConfig &
UserAgentInputConfig &
HostHeaderInputConfig;
HostHeaderInputConfig &
UserAgentInputConfig;

export type AccessAnalyzerClientResolvedConfig = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
Required<ClientDefaults> &
RegionResolvedConfig &
EndpointsResolvedConfig &
AwsAuthResolvedConfig &
RetryResolvedConfig &
UserAgentResolvedConfig &
HostHeaderResolvedConfig;
HostHeaderResolvedConfig &
UserAgentResolvedConfig;

/**
* <p>AWS IAM Access Analyzer helps identify potential resource-access risks by enabling you to identify
Expand Down Expand Up @@ -253,16 +256,16 @@ export class AccessAnalyzerClient extends __Client<
let _config_2 = resolveEndpointsConfig(_config_1);
let _config_3 = resolveAwsAuthConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
let _config_6 = resolveHostHeaderConfig(_config_5);
let _config_5 = resolveHostHeaderConfig(_config_4);
let _config_6 = resolveUserAgentConfig(_config_5);
super(_config_6);
this.config = _config_6;
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
this.middlewareStack.use(getLoggerPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
}

destroy(): void {
Expand Down
5 changes: 4 additions & 1 deletion clients/client-accessanalyzer/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider: invalidAsyncFunction("Credentialis missing") as any,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: DEFAULT_MAX_ATTEMPTS,
region: invalidAsyncFunction("Region is missing") as any,
requestHandler: new FetchHttpHandler(),
Expand Down
3 changes: 0 additions & 3 deletions clients/client-accessanalyzer/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import packageInfo from "./package.json";

import { Sha256 } from "@aws-crypto/sha256-js";
import { parseUrl } from "@aws-sdk/url-parser-node";
import { ClientDefaults } from "./AccessAnalyzerClient";
Expand All @@ -11,7 +9,6 @@ import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"
export const ClientDefaultValues: Required<ClientDefaults> = {
...BrowserDefaults,
runtime: "react-native",
defaultUserAgent: `aws-sdk-js-v3-react-native-${packageInfo.name}/${packageInfo.version}`,
sha256: Sha256,
urlParser: parseUrl,
};
5 changes: 4 additions & 1 deletion clients/client-accessanalyzer/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: new NodeHttpHandler(),
Expand Down
27 changes: 15 additions & 12 deletions clients/client-acm-pca/ACMPCAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import {
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
} from "@aws-sdk/smithy-client";
import {
Provider,
RegionInfoProvider,
Credentials as __Credentials,
Decoder as __Decoder,
Expand All @@ -107,6 +108,7 @@ import {
Provider as __Provider,
StreamCollector as __StreamCollector,
UrlParser as __UrlParser,
UserAgent as __UserAgent,
} from "@aws-sdk/types";

export type ServiceInputTypes =
Expand Down Expand Up @@ -206,11 +208,6 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
*/
utf8Encoder?: __Encoder;

/**
* The string that will be used to populate default value in 'User-Agent' header
*/
defaultUserAgent?: string;

/**
* The runtime environment
*/
Expand Down Expand Up @@ -252,6 +249,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
* Fetch related hostname, signing name or signing region with given region.
*/
regionInfoProvider?: RegionInfoProvider;

/**
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
*/
defaultUserAgentProvider?: Provider<__UserAgent>;
}

export type ACMPCAClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
Expand All @@ -260,17 +263,17 @@ export type ACMPCAClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOpti
EndpointsInputConfig &
AwsAuthInputConfig &
RetryInputConfig &
UserAgentInputConfig &
HostHeaderInputConfig;
HostHeaderInputConfig &
UserAgentInputConfig;

export type ACMPCAClientResolvedConfig = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
Required<ClientDefaults> &
RegionResolvedConfig &
EndpointsResolvedConfig &
AwsAuthResolvedConfig &
RetryResolvedConfig &
UserAgentResolvedConfig &
HostHeaderResolvedConfig;
HostHeaderResolvedConfig &
UserAgentResolvedConfig;

/**
* <note>
Expand Down Expand Up @@ -307,16 +310,16 @@ export class ACMPCAClient extends __Client<
let _config_2 = resolveEndpointsConfig(_config_1);
let _config_3 = resolveAwsAuthConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
let _config_6 = resolveHostHeaderConfig(_config_5);
let _config_5 = resolveHostHeaderConfig(_config_4);
let _config_6 = resolveUserAgentConfig(_config_5);
super(_config_6);
this.config = _config_6;
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
this.middlewareStack.use(getLoggerPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
}

destroy(): void {
Expand Down
5 changes: 4 additions & 1 deletion clients/client-acm-pca/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider: invalidAsyncFunction("Credentialis missing") as any,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: DEFAULT_MAX_ATTEMPTS,
region: invalidAsyncFunction("Region is missing") as any,
requestHandler: new FetchHttpHandler(),
Expand Down
3 changes: 0 additions & 3 deletions clients/client-acm-pca/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import packageInfo from "./package.json";

import { Sha256 } from "@aws-crypto/sha256-js";
import { parseUrl } from "@aws-sdk/url-parser-node";
import { ClientDefaults } from "./ACMPCAClient";
Expand All @@ -11,7 +9,6 @@ import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"
export const ClientDefaultValues: Required<ClientDefaults> = {
...BrowserDefaults,
runtime: "react-native",
defaultUserAgent: `aws-sdk-js-v3-react-native-${packageInfo.name}/${packageInfo.version}`,
sha256: Sha256,
urlParser: parseUrl,
};
5 changes: 4 additions & 1 deletion clients/client-acm-pca/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: new NodeHttpHandler(),
Expand Down
27 changes: 15 additions & 12 deletions clients/client-acm/ACMClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
SmithyResolvedConfiguration as __SmithyResolvedConfiguration,
} from "@aws-sdk/smithy-client";
import {
Provider,
RegionInfoProvider,
Credentials as __Credentials,
Decoder as __Decoder,
Expand All @@ -76,6 +77,7 @@ import {
Provider as __Provider,
StreamCollector as __StreamCollector,
UrlParser as __UrlParser,
UserAgent as __UserAgent,
} from "@aws-sdk/types";

export type ServiceInputTypes =
Expand Down Expand Up @@ -155,11 +157,6 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
*/
utf8Encoder?: __Encoder;

/**
* The string that will be used to populate default value in 'User-Agent' header
*/
defaultUserAgent?: string;

/**
* The runtime environment
*/
Expand Down Expand Up @@ -201,6 +198,12 @@ export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__
* Fetch related hostname, signing name or signing region with given region.
*/
regionInfoProvider?: RegionInfoProvider;

/**
* The provider populating default tracking information to be sent with `user-agent`, `x-amz-user-agent` header
* @internal
*/
defaultUserAgentProvider?: Provider<__UserAgent>;
}

export type ACMClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOptions>> &
Expand All @@ -209,17 +212,17 @@ export type ACMClientConfig = Partial<__SmithyConfiguration<__HttpHandlerOptions
EndpointsInputConfig &
AwsAuthInputConfig &
RetryInputConfig &
UserAgentInputConfig &
HostHeaderInputConfig;
HostHeaderInputConfig &
UserAgentInputConfig;

export type ACMClientResolvedConfig = __SmithyResolvedConfiguration<__HttpHandlerOptions> &
Required<ClientDefaults> &
RegionResolvedConfig &
EndpointsResolvedConfig &
AwsAuthResolvedConfig &
RetryResolvedConfig &
UserAgentResolvedConfig &
HostHeaderResolvedConfig;
HostHeaderResolvedConfig &
UserAgentResolvedConfig;

/**
* <fullname>AWS Certificate Manager</fullname>
Expand All @@ -246,16 +249,16 @@ export class ACMClient extends __Client<
let _config_2 = resolveEndpointsConfig(_config_1);
let _config_3 = resolveAwsAuthConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
let _config_6 = resolveHostHeaderConfig(_config_5);
let _config_5 = resolveHostHeaderConfig(_config_4);
let _config_6 = resolveUserAgentConfig(_config_5);
super(_config_6);
this.config = _config_6;
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
this.middlewareStack.use(getLoggerPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
}

destroy(): void {
Expand Down
5 changes: 4 additions & 1 deletion clients/client-acm/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider: invalidAsyncFunction("Credentialis missing") as any,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: DEFAULT_MAX_ATTEMPTS,
region: invalidAsyncFunction("Region is missing") as any,
requestHandler: new FetchHttpHandler(),
Expand Down
3 changes: 0 additions & 3 deletions clients/client-acm/runtimeConfig.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import packageInfo from "./package.json";

import { Sha256 } from "@aws-crypto/sha256-js";
import { parseUrl } from "@aws-sdk/url-parser-node";
import { ClientDefaults } from "./ACMClient";
Expand All @@ -11,7 +9,6 @@ import { ClientDefaultValues as BrowserDefaults } from "./runtimeConfig.browser"
export const ClientDefaultValues: Required<ClientDefaults> = {
...BrowserDefaults,
runtime: "react-native",
defaultUserAgent: `aws-sdk-js-v3-react-native-${packageInfo.name}/${packageInfo.version}`,
sha256: Sha256,
urlParser: parseUrl,
};
5 changes: 4 additions & 1 deletion clients/client-acm/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const ClientDefaultValues: Required<ClientDefaults> = {
base64Encoder: toBase64,
bodyLengthChecker: calculateBodyLength,
credentialDefaultProvider,
defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),
defaultUserAgentProvider: defaultUserAgent({
serviceId: ClientSharedValues.serviceId,
clientVersion: packageInfo.version,
}),
maxAttempts: loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: new NodeHttpHandler(),
Expand Down
Loading