Skip to content

Commit

Permalink
Merge pull request #137 from Countly/glue_crash
Browse files Browse the repository at this point in the history
fix: add missing encodings
  • Loading branch information
turtledreams authored Jun 25, 2024
2 parents c1d6b45 + 4317767 commit 9969246
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## 24.1.0
## XX.XX.XX
* Fixed an issue where some requests are not url encoded.

## 24.1.0
* New BackendMode features added and accesible through "Countly.Instance.BackendMode()" interface:
* "ChangeDeviceIdWithMerge"
* "RecordUserProperties"
Expand Down
6 changes: 3 additions & 3 deletions countlyCommon/countlyCommon/Server/ApiBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<RequestResult> SendEvents(string serverUrl, RequestHelper requ

public async Task<RequestResult> SendException(string serverUrl, RequestHelper requestHelper, int rr, ExceptionEvent exception)
{
string exceptionJson = RequestHelper.Json(exception);
string exceptionJson = UtilityHelper.EncodeDataForURL(RequestHelper.Json(exception));
return await Call(string.Format("{0}{1}&crash={2}&rr={3}", serverUrl, await requestHelper.BuildRequest(), exceptionJson, rr));
}

Expand All @@ -52,7 +52,7 @@ public async Task<RequestResult> UploadUserDetails(string serverUrl, RequestHelp
string userDetailsJson = string.Empty;

if (userDetails != null) {
userDetailsJson = RequestHelper.Json(userDetails);
userDetailsJson = UtilityHelper.EncodeDataForURL(RequestHelper.Json(userDetails));
}

return await Call(string.Format("{0}{1}&user_details={2}&rr={3}", serverUrl, await requestHelper.BuildRequest(), userDetailsJson, rr));
Expand All @@ -63,7 +63,7 @@ public async Task<RequestResult> UploadUserPicture(string serverUrl, RequestHelp
string userDetailsJson = string.Empty;

if (userDetails != null) {
userDetailsJson = "=" + RequestHelper.Json(userDetails);
userDetailsJson = "=" + UtilityHelper.EncodeDataForURL(RequestHelper.Json(userDetails));
}

return await Call(string.Format("{0}{1}&user_details{2}&rr={3}", serverUrl, await requestHelper.BuildRequest(), userDetailsJson, rr), imageStream);
Expand Down
2 changes: 1 addition & 1 deletion netstd/Countly/Countly.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
Expand Down
18 changes: 13 additions & 5 deletions netstd/MauiSampleApp/MauiExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ static MauiExceptions()
// It will fire for exceptions from iOS and Mac Catalyst,
// and for exceptions on background threads from WinUI 3.

AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
{
UnhandledException?.Invoke(sender, args);
};

// Events fired by the TaskScheduler. That is calls like Task.Run(...)
TaskScheduler.UnobservedTaskException += (sender, args) =>
{
UnhandledException?.Invoke(sender, new UnhandledExceptionEventArgs(args.Exception, false));
};

#if IOS || MACCATALYST

// For iOS and Mac Catalyst
Expand All @@ -35,10 +42,11 @@ static MauiExceptions()
// All exceptions will flow through Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser,
// and NOT through AppDomain.CurrentDomain.UnhandledException

//Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
//{
// UnhandledException?.Invoke(sender, new UnhandledExceptionEventArgs(args.Exception, true));
//};
Android.Runtime.AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) =>
{
args.Handled = true;
UnhandledException?.Invoke(sender, new UnhandledExceptionEventArgs(args.Exception, true));
};

#elif WINDOWS

Expand Down
2 changes: 1 addition & 1 deletion netstd/MauiSampleApp/Platforms/iOS/CrashTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class CrashTester : ICrashTester
{
public void Test()
{

throw new InvalidOperationException("This is a test unhandled exception.");
}
}

0 comments on commit 9969246

Please sign in to comment.