Skip to content

Commit

Permalink
Merge pull request #172 from mercadopago/feature/add-tracking-id
Browse files Browse the repository at this point in the history
Add Header Tracking Id
  • Loading branch information
brunacamposxx authored Oct 31, 2023
2 parents 95dc650 + 30611c4 commit 1d7b8b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
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 @@ protected MercadoPagoClient(
[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

0 comments on commit 1d7b8b3

Please sign in to comment.