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

Add Header Tracking Id #172

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/MercadoPago/Client/MercadoPagoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public abstract class MercadoPagoClient<TResource>
[Headers.ACCEPT] = ACCEPT_VALUE,
[Headers.PRODUCT_ID] = MercadoPagoConfig.ProductId,
[Headers.USER_AGENT] = $"MercadoPago DotNet SDK/{MercadoPagoConfig.Version}",
[Headers.TRACKING_ID] = MercadoPagoConfig.TrackingId,
};

/// <summary>
Expand Down
11 changes: 10 additions & 1 deletion src/MercadoPago/Config/MercadoPagoConfig.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace MercadoPago.Config
{
using System;
using System.Configuration;
using System.Reflection;
using MercadoPago.Http;
Expand All @@ -23,14 +24,22 @@ public static class MercadoPagoConfig
private static ISerializer serializer;
private static IRetryStrategy retryStrategy;

static MercadoPagoConfig() =>
static MercadoPagoConfig()
{
Version = new AssemblyName(typeof(MercadoPagoConfig).GetTypeInfo().Assembly.FullName).Version.ToString(3);
TrackingId = $"platform:{Environment.Version.Major}|{Environment.Version},type:SDK{Version},so;";
}

/// <summary>
/// Actual SDK version.
/// </summary>
public static string Version { get; }

/// <summary>
/// SDK Tracking Id.
/// </summary>
public static string TrackingId { get; }

/// <summary>
/// Base URL of MercadoPago's APIs.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/MercadoPago/Http/Headers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ public static class Headers
/// Platform ID header name.
/// </summary>
public const string PLATFORM_ID = "X-Platform-Id";

/// <summary>
/// Tracking ID header name.
/// </summary>
public const string TRACKING_ID = "X-Tracking-Id";
}
}
4 changes: 2 additions & 2 deletions src/MercadoPago/MercadoPago.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<SignAssembly>True</SignAssembly>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TargetFrameworks>net5.0;netstandard2.0;net461</TargetFrameworks>
<Version>2.3.3</Version>
<VersionPrefix>2.3.3</VersionPrefix>
<Version>2.3.4</Version>
<VersionPrefix>2.3.4</VersionPrefix>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
Expand Down