Skip to content

Commit 99d8de0

Browse files
author
Bret Ambrose
committed
Update
1 parent dc3547f commit 99d8de0

4 files changed

Lines changed: 21 additions & 15 deletions

File tree

lib/browser/mqtt.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ export interface MqttConnectionConfig extends mqtt_shared.MqttConnectionConfigBa
130130

131131
/** Options for the underlying credentials provider */
132132
credentials_provider?: auth.CredentialsProvider;
133-
134-
/** Optional metrics configuration to be applied to the username and sent with the CONNECT packet */
135-
sdkMetrics?: mqtt_shared.AwsIoTDeviceSDKMetrics;
136133
}
137134

138135
/**
@@ -247,7 +244,13 @@ export class MqttClientConnection extends BufferedEventEmitter {
247244
internalConnectOptions.clientId = this.config.client_id;
248245
}
249246

250-
internalConnectOptions.username = mqtt_shared_browser.buildFinalUsernameFromMetrics(this.config.sdkMetrics ?? new mqtt_shared.AwsIoTDeviceSDKMetrics(), this.config.username);
247+
if (this.config.disable_metrics) {
248+
if (this.config.username) {
249+
internalConnectOptions.username = this.config.username;
250+
}
251+
} else {
252+
internalConnectOptions.username = mqtt_shared_browser.buildFinalUsernameFromMetrics(new mqtt_shared.AwsIoTDeviceSDKMetrics(), this.config.username);
253+
}
251254

252255
if (this.config.password) {
253256
internalConnectOptions.password = mqtt_shared_browser.normalize_payload_to_buffer(this.config.password);

lib/browser/mqtt5.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ export interface Mqtt5ClientConfig extends mqtt_shared.Mqtt5ClientConfigBase {
144144
* @group Browser-only
145145
*/
146146
websocketOptions?: Mqtt5WebsocketConfig;
147-
148-
/** Optional metrics configuration to be applied to the username and sent with the CONNECT packet */
149-
sdkMetrics?: mqtt_shared.AwsIoTDeviceSDKMetrics;
150147
}
151148

152149
function convertSessionBehaviorToSessionPolicy(behavior?: mqtt5.ClientSessionBehavior) : internal_mqtt_client.ResumeSessionPolicyType {
@@ -167,7 +164,15 @@ function convertSessionBehaviorToSessionPolicy(behavior?: mqtt5.ClientSessionBeh
167164
}
168165

169166
function buildInternalConnectOptions(internalConnectOptions : internal_mqtt_client.ConnectOptions, clientConfig: Mqtt5ClientConfig, connectProperties?: mqtt5_packet.ConnectPacket) {
170-
internalConnectOptions.username = mqtt_shared_browser.buildFinalUsernameFromMetrics(clientConfig.sdkMetrics ?? new mqtt_shared.AwsIoTDeviceSDKMetrics(), connectProperties?.username);
167+
if (clientConfig.disableMetrics) {
168+
if (connectProperties?.username) {
169+
internalConnectOptions.username = connectProperties.username;
170+
}
171+
} else {
172+
internalConnectOptions.username = mqtt_shared_browser.buildFinalUsernameFromMetrics(new mqtt_shared.AwsIoTDeviceSDKMetrics(), connectProperties?.username);
173+
}
174+
175+
internalConnectOptions.username = mqtt_shared_browser.buildFinalUsernameFromMetrics(new mqtt_shared.AwsIoTDeviceSDKMetrics(), connectProperties?.username);
171176

172177
if (!connectProperties) {
173178
return;

lib/common/mqtt_shared.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,10 @@ export interface Mqtt5ClientConfigBase {
343343
* If this setting is left undefined, then topic aliasing behavior will be disabled.
344344
*/
345345
topicAliasingOptions? : mqtt5.TopicAliasingOptions;
346+
347+
/**
348+
* Options for disable Aws IoT Metrics. The metrics includes SDK name, version, and platform.
349+
*/
350+
disableMetrics? : boolean;
346351
}
347352

lib/native/mqtt5.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ export interface Mqtt5ClientConfig extends mqtt_shared.Mqtt5ClientConfigBase {
206206
* @group Node-only
207207
*/
208208
extendedValidationAndFlowControlOptions? : ClientExtendedValidationAndFlowControl;
209-
210-
/**
211-
* Options for disable Aws IoT Metrics. The metrics includes SDK name, version, and platform.
212-
*
213-
* @group Node-only
214-
*/
215-
disableMetrics? : boolean;
216209
}
217210

218211
/**

0 commit comments

Comments
 (0)