mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-02-08 13:40:58 -05:00
* Enable CA2000 in editorconfig * Remove unused CaptureStdOut class * Add missing dispose calls in Sandbox.Tools * Add missing dispose calls in tests * Add missing dispose calls in launchers * Add missing dispose calls in Topten.RichtTextKit * Add missing dispose calls in Engine * Add missing dispose calls in SboxBuild * Add nullchecks to a few dispose calls * Fix more missing disposal calls and leaks * Disable CA2000 for Textures * Fix disposing too early in ImageFileTextureGenerator * Fix disposing codec, ownership is transferred to animation * Add missing using in ByteStream benchmark
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
namespace CrashReporter;
|
|
|
|
public class SentryClient
|
|
{
|
|
public static async Task SubmitEnvelopeAsync( string dsn, Envelope envelope, CancellationToken cancellationToken = default )
|
|
{
|
|
// <scheme>://<key>@<host>:<port>/<project-id> ->
|
|
// <scheme>://<host>:<port>/api/<project-id>/envelope
|
|
var uri = new Uri( dsn );
|
|
var projectId = uri.LocalPath.Trim( '/' );
|
|
var uriBuilder = new UriBuilder()
|
|
{
|
|
Scheme = uri.Scheme,
|
|
Host = uri.Host,
|
|
Port = uri.Port,
|
|
Path = $"/api/{projectId}/envelope/"
|
|
};
|
|
|
|
var stream = new MemoryStream();
|
|
await envelope.SerializeAsync( stream, cancellationToken ).ConfigureAwait( false );
|
|
await stream.FlushAsync( cancellationToken ).ConfigureAwait( false );
|
|
stream.Seek( 0, SeekOrigin.Begin );
|
|
|
|
using var request = new HttpRequestMessage( HttpMethod.Post, uriBuilder.Uri )
|
|
{
|
|
Content = new StreamContent( stream )
|
|
};
|
|
|
|
using var httpClient = new HttpClient();
|
|
using var response = await httpClient.SendAsync( request, cancellationToken ).ConfigureAwait( false );
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
var content = await response.Content.ReadAsStringAsync( cancellationToken ).ConfigureAwait( false );
|
|
|
|
Console.WriteLine( $"content: {content}" );
|
|
|
|
}
|
|
}
|