Skip to content

Commit ed9e9aa

Browse files
authored
Merge pull request Azure#10743 from erich-wang/addSubId
add sub id to client telemetry for az 4.0 preview
2 parents 058ba46 + 994d43a commit ed9e9aa

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Add client-side telemetry info for Az 4.0 preview
2122

2223
## Version 1.6.5
2324
* Update references in .psd1 to use relative path

src/Accounts/Accounts/CommonModule/TelemetryProvider.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ namespace Microsoft.Azure.Commands.Common
3333
/// </summary>
3434
public class TelemetryProvider : IDictionary<string, AzurePSQoSEvent>, IDisposable
3535
{
36+
const string SubscriptionIdString = "SubscriptionId";
37+
3638
AzurePSDataCollectionProfile _dataCollectionProfile;
3739
MetricHelper _helper;
3840
Action<string> _warningLogger, _debugLogger;
@@ -144,6 +146,27 @@ public virtual AzurePSQoSEvent CreateQosEvent(InvocationInfo invocationInfo, str
144146

145147
data.CustomProperties.Add("PSPreviewVersion", "4.0.0");
146148
data.CustomProperties.Add("UserAgent", "AzurePowershell/Az4.0.0-preview");
149+
if(invocationInfo?.BoundParameters?.ContainsKey(SubscriptionIdString) == true)
150+
{
151+
object rawValue = invocationInfo.BoundParameters[SubscriptionIdString];
152+
string subscriptionId = null;
153+
if(rawValue is string)
154+
{
155+
subscriptionId = rawValue as string;
156+
}
157+
else if(rawValue is string[])
158+
{
159+
string[] rawValueArray = rawValue as string[] ;
160+
if (rawValueArray.Length > 0)
161+
{
162+
subscriptionId = string.Join(";", rawValueArray);
163+
}
164+
}
165+
if(!string.IsNullOrEmpty(subscriptionId))
166+
{
167+
data.CustomProperties.Add(SubscriptionIdString, subscriptionId);
168+
}
169+
}
147170

148171
if (invocationInfo != null)
149172
{

0 commit comments

Comments
 (0)