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

fix: Renamed ISession to ISentrySession #3110

Merged
merged 6 commits into from
Feb 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### Fixes

- To resolve conflicting types due to the SDK adding itself to the global usings:
- The interface `Sentry.ISession` has been renamed to `Sentry.ISentrySession`
- The class `Sentry.Session` has been renamed to `Sentry.SentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))

### Dependencies

- Bump Cocoa SDK from v8.19.0 to v8.20.0 ([#3107](https://github.com/getsentry/sentry-dotnet/pull/3107))
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/GlobalSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ internal class GlobalSessionManager : ISessionManager
private readonly string? _persistenceDirectoryPath;

private string? _resolvedInstallationId;
private Session? _currentSession;
private SentrySession? _currentSession;
private DateTimeOffset? _lastPauseTimestamp;

// Internal for testing
internal Session? CurrentSession => _currentSession;
internal SentrySession? CurrentSession => _currentSession;

public bool IsSessionActive => _currentSession is not null;

Expand Down Expand Up @@ -308,7 +308,7 @@ private void DeletePersistedSession()
var distinctId = TryGetInstallationId();

// Create new session
var session = new Session(distinctId, release, environment);
var session = new SentrySession(distinctId, release, environment);

// Set new session and check whether we ended up overwriting an active one in the process
var previousSession = Interlocked.Exchange(ref _currentSession, session);
Expand All @@ -329,7 +329,7 @@ private void DeletePersistedSession()
return update;
}

private SessionUpdate EndSession(Session session, DateTimeOffset timestamp, SessionEndStatus status)
private SessionUpdate EndSession(SentrySession session, DateTimeOffset timestamp, SessionEndStatus status)
{
if (status == SessionEndStatus.Crashed)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/ISession.cs → src/Sentry/ISentrySession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Sentry;
/// <summary>
/// Session metadata.
/// </summary>
public interface ISession
public interface ISentrySession
{
/// <summary>
/// Session auto-generated ID.
Expand Down
8 changes: 4 additions & 4 deletions src/Sentry/Session.cs → src/Sentry/SentrySession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Sentry;
/// Sentry session.
/// </summary>
// https://develop.sentry.dev/sdk/sessions
public class Session : ISession
public class SentrySession : ISentrySession
{
/// <inheritdoc />
public SentryId Id { get; }
Expand Down Expand Up @@ -36,7 +36,7 @@ public class Session : ISession
// Start at -1 so that the first increment puts it at 0
private int _sequenceNumber = -1;

internal Session(
internal SentrySession(
SentryId id,
string? distinctId,
DateTimeOffset startTimestamp,
Expand All @@ -55,9 +55,9 @@ internal Session(
}

/// <summary>
/// Initializes a new instance of <see cref="Session"/>.
/// Initializes a new instance of <see cref="SentrySession"/>.
/// </summary>
public Session(string? distinctId, string release, string? environment)
public SentrySession(string? distinctId, string release, string? environment)
: this(
SentryId.Create(),
distinctId,
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/SessionUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Sentry;
/// Session update.
/// </summary>
// https://develop.sentry.dev/sdk/sessions/#session-update-payload
public class SessionUpdate : ISession, IJsonSerializable
public class SessionUpdate : ISentrySession, IJsonSerializable
{
/// <inheritdoc />
public SentryId Id { get; }
Expand Down Expand Up @@ -93,7 +93,7 @@ public SessionUpdate(
/// Initializes a new instance of <see cref="SessionUpdate"/>.
/// </summary>
public SessionUpdate(
ISession session,
ISentrySession session,
bool isInitial,
DateTimeOffset timestamp,
int sequenceNumber,
Expand Down
40 changes: 20 additions & 20 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ namespace Sentry
{
void Apply(Sentry.Scope scope, object state);
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISession
public interface ISentrySession
{
string? DistinctId { get; }
string? Environment { get; }
Expand All @@ -317,6 +313,10 @@ namespace Sentry
System.DateTimeOffset StartTimestamp { get; }
string? UserAgent { get; }
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
new string? Description { get; set; }
Expand Down Expand Up @@ -792,6 +792,19 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySession : Sentry.ISentrySession
{
public SentrySession(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
Expand Down Expand Up @@ -928,30 +941,17 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { }
}
public class Session : Sentry.ISession
{
public Session(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public enum SessionEndStatus
{
Exited = 0,
Crashed = 1,
Abnormal = 2,
}
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISession
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISentrySession
{
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial) { }
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISentrySession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.SentryId id, string? distinctId, System.DateTimeOffset startTimestamp, string release, string? environment, string? ipAddress, string? userAgent, int errorCount, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public string? DistinctId { get; }
public System.TimeSpan Duration { get; }
Expand Down
40 changes: 20 additions & 20 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ namespace Sentry
{
void Apply(Sentry.Scope scope, object state);
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISession
public interface ISentrySession
{
string? DistinctId { get; }
string? Environment { get; }
Expand All @@ -317,6 +313,10 @@ namespace Sentry
System.DateTimeOffset StartTimestamp { get; }
string? UserAgent { get; }
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
new string? Description { get; set; }
Expand Down Expand Up @@ -792,6 +792,19 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySession : Sentry.ISentrySession
{
public SentrySession(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
Expand Down Expand Up @@ -928,30 +941,17 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { }
}
public class Session : Sentry.ISession
{
public Session(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public enum SessionEndStatus
{
Exited = 0,
Crashed = 1,
Abnormal = 2,
}
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISession
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISentrySession
{
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial) { }
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISentrySession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.SentryId id, string? distinctId, System.DateTimeOffset startTimestamp, string release, string? environment, string? ipAddress, string? userAgent, int errorCount, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public string? DistinctId { get; }
public System.TimeSpan Duration { get; }
Expand Down
40 changes: 20 additions & 20 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,7 @@ namespace Sentry
{
void Apply(Sentry.Scope scope, object state);
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISession
public interface ISentrySession
{
string? DistinctId { get; }
string? Environment { get; }
Expand All @@ -318,6 +314,10 @@ namespace Sentry
System.DateTimeOffset StartTimestamp { get; }
string? UserAgent { get; }
}
public interface ISentryUserFactory
{
Sentry.SentryUser? Create();
}
public interface ISpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
new string? Description { get; set; }
Expand Down Expand Up @@ -794,6 +794,19 @@ namespace Sentry
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, Sentry.SentryTraceHeader traceHeader) { }
public static Sentry.ITransactionTracer StartTransaction(string name, string operation, string? description) { }
}
public class SentrySession : Sentry.ISentrySession
{
public SentrySession(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public class SentrySpan : Sentry.IHasExtra, Sentry.IHasTags, Sentry.IJsonSerializable, Sentry.ISpanData, Sentry.Protocol.ITraceContext
{
public SentrySpan(Sentry.ISpan tracer) { }
Expand Down Expand Up @@ -930,30 +943,17 @@ namespace Sentry
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
public static Sentry.SentryUser FromJson(System.Text.Json.JsonElement json) { }
}
public class Session : Sentry.ISession
{
public Session(string? distinctId, string release, string? environment) { }
public string? DistinctId { get; }
public string? Environment { get; }
public int ErrorCount { get; }
public Sentry.SentryId Id { get; }
public string? IpAddress { get; }
public string Release { get; }
public System.DateTimeOffset StartTimestamp { get; }
public string? UserAgent { get; }
public void ReportError() { }
}
public enum SessionEndStatus
{
Exited = 0,
Crashed = 1,
Abnormal = 2,
}
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISession
public class SessionUpdate : Sentry.IJsonSerializable, Sentry.ISentrySession
{
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial) { }
public SessionUpdate(Sentry.SessionUpdate sessionUpdate, bool isInitial, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.ISentrySession session, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public SessionUpdate(Sentry.SentryId id, string? distinctId, System.DateTimeOffset startTimestamp, string release, string? environment, string? ipAddress, string? userAgent, int errorCount, bool isInitial, System.DateTimeOffset timestamp, int sequenceNumber, Sentry.SessionEndStatus? endStatus) { }
public string? DistinctId { get; }
public System.TimeSpan Duration { get; }
Expand Down
Loading
Loading