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 User Agent Header #83

Open
Cliftonz opened this issue Dec 4, 2023 · 1 comment · May be fixed by #94
Open

Add User Agent Header #83

Cliftonz opened this issue Dec 4, 2023 · 1 comment · May be fixed by #94
Assignees
Milestone

Comments

@Cliftonz
Copy link

Cliftonz commented Dec 4, 2023

Add the user-agent request header to every call in this sdk.

Example:

headers: {
Authorization: Bearer ${ApiKey},
"User-Agent": novu/${sdk}@${version},
},

Why? (Context)

Having request headers in the SDKs will help us in monitoring which SDK is mostly used by the community and customers. It will help us make the decisions in the future on which SDKs to officially support in the future.

@wh1337 wh1337 self-assigned this Dec 11, 2023
@toddb toddb added this to the 0.4.1 milestone Feb 9, 2025
@toddb toddb assigned toddb and unassigned wh1337 Feb 9, 2025
@toddb
Copy link
Collaborator

toddb commented Feb 9, 2025

Issue with the User-Agent Instruction

The current ticket provides incorrect instructions for setting the User-Agent header in HTTP requests that won't work for the Http

System.AggregateException
One or more errors occurred. (The format of value 'novu/novu-dotnet@0.0.0' is invalid.) (The format of value 'novu/novu-dotnet@0.0.0' is invalid.)
  Exception doesn't have a stacktrace

System.FormatException
The format of value 'novu/novu-dotnet@0.0.0' is invalid.
   at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index)
   at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(HeaderDescriptor descriptor, String value)

Why the Instruction is Wrong

  1. Invalid User-Agent Format: The User-Agent header should follow a standard format. Using novu/[email protected] is invalid due to the @ symbol and four-segment version, which do not comply with HTTP standards.

Correct Solution

This will work:

novu-dotnet/{nuget file version}

Implementation Steps

To correctly retrieve the version:

using System.Reflection;

var version = Assembly
    .GetExecutingAssembly()
    .GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
    .InformationalVersion ?? "0.0.0"; // allow for detection of developers

var userAgent = $"novu-dotnet/{version}";

toddb pushed a commit that referenced this issue Feb 9, 2025
@toddb toddb linked a pull request Feb 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants