Skip to content
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
188 changes: 101 additions & 87 deletions CHANGELOG.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/Sentry/Protocol/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public sealed class App : ISentryJsonSerializable, ICloneable<App>, IUpdatable<A
/// </summary>
public string? Build { get; set; }

/// <summary>
/// Amount of memory used by the application in bytes.
/// </summary>
public long? Memory { get; set; }

/// <summary>
/// A flag indicating whether the app is in foreground or not. An app is in foreground when it's visible to the user.
/// </summary>
Expand All @@ -74,6 +79,7 @@ App ICloneable<App>.Clone()
Name = Name,
Version = Version,
Build = Build,
Memory = Memory,
InForeground = InForeground
};

Expand All @@ -100,6 +106,7 @@ void IUpdatable<App>.UpdateFrom(App source)
Name ??= source.Name;
Version ??= source.Version;
Build ??= source.Build;
Memory ??= source.Memory;
InForeground ??= source.InForeground;
}

Expand All @@ -116,6 +123,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? _)
writer.WriteStringIfNotWhiteSpace("app_name", Name);
writer.WriteStringIfNotWhiteSpace("app_version", Version);
writer.WriteStringIfNotWhiteSpace("app_build", Build);
writer.WriteNumberIfNotNull("app_memory", Memory);
writer.WriteBooleanIfNotNull("in_foreground", InForeground);

writer.WriteEndObject();
Expand All @@ -133,6 +141,7 @@ public static App FromJson(JsonElement json)
var name = json.GetPropertyOrNull("app_name")?.GetString();
var version = json.GetPropertyOrNull("app_version")?.GetString();
var build = json.GetPropertyOrNull("app_build")?.GetString();
var memory = json.GetPropertyOrNull("app_memory")?.GetInt64();
var inForeground = json.GetPropertyOrNull("in_foreground")?.GetBoolean();

return new App
Expand All @@ -144,6 +153,7 @@ public static App FromJson(JsonElement json)
Name = name,
Version = version,
Build = build,
Memory = memory,
InForeground = inForeground
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ namespace Sentry.Protocol
public string? Hash { get; set; }
public string? Identifier { get; set; }
public bool? InForeground { get; set; }
public long? Memory { get; set; }
public string? Name { get; set; }
public System.DateTimeOffset? StartTime { get; set; }
public string? Version { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ namespace Sentry.Protocol
public string? Hash { get; set; }
public string? Identifier { get; set; }
public bool? InForeground { get; set; }
public long? Memory { get; set; }
public string? Name { get; set; }
public System.DateTimeOffset? StartTime { get; set; }
public string? Version { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ namespace Sentry.Protocol
public string? Hash { get; set; }
public string? Identifier { get; set; }
public bool? InForeground { get; set; }
public long? Memory { get; set; }
public string? Name { get; set; }
public System.DateTimeOffset? StartTime { get; set; }
public string? Version { get; set; }
Expand Down
1 change: 1 addition & 0 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,7 @@ namespace Sentry.Protocol
public string? Hash { get; set; }
public string? Identifier { get; set; }
public bool? InForeground { get; set; }
public long? Memory { get; set; }
public string? Name { get; set; }
public System.DateTimeOffset? StartTime { get; set; }
public string? Version { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions test/Sentry.Tests/Protocol/Context/AppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
Hash = "93fd0e9a",
Name = "Sentry.Test.App",
StartTime = DateTimeOffset.MaxValue,
Memory = 123456789,
InForeground = true
};

Expand All @@ -41,6 +42,7 @@ public void Clone_CopyValues()
Name = "name",
StartTime = DateTimeOffset.UtcNow,
Version = "version",
Memory = 987654321,
InForeground = false
};

Expand All @@ -53,6 +55,7 @@ public void Clone_CopyValues()
Assert.Equal(sut.Name, clone.Name);
Assert.Equal(sut.StartTime, clone.StartTime);
Assert.Equal(sut.Version, clone.Version);
Assert.Equal(sut.Memory, clone.Memory);
Assert.Equal(sut.InForeground, clone.InForeground);
}

Expand All @@ -75,6 +78,7 @@ public static IEnumerable<object[]> TestCases()
yield return new object[] { (new App { StartTime = DateTimeOffset.MaxValue }, """{"type":"app","app_start_time":"9999-12-31T23:59:59.9999999+00:00"}""") };
yield return new object[] { (new App { Version = "some version" }, """{"type":"app","app_version":"some version"}""") };
yield return new object[] { (new App { Identifier = "some identifier" }, """{"type":"app","app_identifier":"some identifier"}""") };
yield return new object[] { (new App { Memory = 12345 }, """{"type":"app","app_memory":12345}""") };
yield return new object[] { (new App { InForeground = true }, """{"type":"app","in_foreground":true}""") };
}
}
Loading