Skip to content

Commit b47d0cb

Browse files
committed
chore(Analytics): Revised User-Agent format
1 parent e2aa503 commit b47d0cb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/IBM.WatsonDeveloperCloud/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Constants
2626
/// The version number for this SDK build. Added to the header in
2727
/// each request as `User-Agent`.
2828
/// </summary>
29-
public static readonly string SDK_VERSION = "watson-apis-dotnet-sdk/2.13.0";
29+
public static readonly string SDK_VERSION = "watson-apis-dotnet-sdk-2.13.0";
3030
/// <summary>
3131
/// A constant used to access custom request headers in the dynamic
3232
/// customData object.

src/IBM.WatsonDeveloperCloud/Http/HttpFactory.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ public static HttpRequestMessage GetRequestMessage(HttpMethod method, Uri resour
4545

4646
// add default headers
4747
request.Headers.Add("accept", formatters.SelectMany(p => p.SupportedMediaTypes).Select(p => p.MediaType));
48+
string osInfo = System.Runtime.InteropServices.RuntimeInformation.OSDescription;
49+
int versionIndex = osInfo.IndexOfAny("0123456789".ToCharArray());
50+
string os = osInfo.Substring(0, versionIndex).Replace(" ", "");
51+
string osVersion = osInfo.Substring(versionIndex).Replace(" ", "");
4852
request.Headers.Add("User-Agent",
4953
string.Format(
50-
"{0} {1} {2}",
54+
"{0} {1} {2} {3}",
5155
Constants.SDK_VERSION,
52-
System.Runtime.InteropServices.RuntimeInformation.OSDescription,
53-
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription
56+
os,
57+
osVersion,
58+
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription.Replace(" ", "-")
5459
));
5560

5661
return request;

0 commit comments

Comments
 (0)