Skip to content
Open
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
5 changes: 5 additions & 0 deletions Packages/StreamVideo/Runtime/Core/IStreamVideoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public interface IStreamVideoClient : IStreamVideoClientEventsListener, IDisposa
/// </summary>
event CallHandler CallStarted;

/// <summary>
/// Event fired when a call is about to be left. You can still access full call data because the leaving process is just starting.
/// </summary>
event CallHandler CallLeaving;

/// <summary>
/// Event fired when a call ended
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
using System;
using StreamVideo.Libs.Logs;
using StreamVideo.Libs.Serialization;

namespace StreamVideo.Core.IssueReporters
{
#if STREAM_DEBUG_ENABLED
internal class FeedbackReporterFactory
{
public FeedbackReporterFactory(ILogsCollector logsCollector, ISerializer serializer)
public FeedbackReporterFactory(ILogsCollector logsCollector, ISerializer serializer, ILogs logs)
{
_logsCollector = logsCollector ?? throw new ArgumentNullException(nameof(logsCollector));
_serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
_logs = logs ?? throw new ArgumentNullException(nameof(logs));
}

public IFeedbackReporter CreateTrelloReporter()
{
var logsProvider = CreateLogsProvider();
return new TrelloFeedbackReporter(logsProvider);
return new TrelloFeedbackReporter(logsProvider, _logs);
}

private readonly ILogsCollector _logsCollector;
private readonly ISerializer _serializer;
private readonly ILogs _logs;

private ILogsProvider CreateLogsProvider()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.IO;
using System;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using StreamVideo.Libs.Logs;
using UnityEngine.Device;

namespace StreamVideo.Core.IssueReporters
Expand All @@ -13,27 +14,38 @@ internal class TrelloFeedbackReporter : IFeedbackReporter
// StreamTODO: Move to local config
public const string SendReportEndpoint = "http://194.59.158.13:3000/send-logs";

public TrelloFeedbackReporter(ILogsProvider logsProvider)
public TrelloFeedbackReporter(ILogsProvider logsProvider, ILogs logs)
{
_logsProvider = logsProvider;
_logs = logs;
}

public async Task SendCallReport(string callId, string participantId)
{
using var client = new HttpClient();

var deviceLogs = _logsProvider.GetLogs();
var logsFileName = GetLogsFileName(participantId);
var zippedLogs = CreateZipArchive(deviceLogs, logsFileName);
try
{
_logs.Warning("Send call report to Trello");
using var client = new HttpClient();

var content = new MultipartFormDataContent();
content.Add(new ByteArrayContent(zippedLogs), "file", $"{logsFileName}.zip");
content.Add(new StringContent(callId), "callId");
var deviceLogs = _logsProvider.GetLogs();
var logsFileName = GetLogsFileName(participantId);
var zippedLogs = CreateZipArchive(deviceLogs, logsFileName);

var response = await client.PostAsync(SendReportEndpoint, content);
var content = new MultipartFormDataContent();
content.Add(new ByteArrayContent(zippedLogs), "file", $"{logsFileName}.zip");
content.Add(new StringContent(callId), "callId");

var response = await client.PostAsync(SendReportEndpoint, content);
}
catch (Exception e)
{
_logs.Error("Failed to send call report to Trello: " + e.Message);
_logs.Exception(e);
}
}

private readonly ILogsProvider _logsProvider;
private readonly ILogs _logs;

private string GetLogsFileName(string participantId)
{
Expand Down
7 changes: 6 additions & 1 deletion Packages/StreamVideo/Runtime/Core/StreamVideoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class StreamVideoClient : IStreamVideoClient, IInternalStreamVideoClient
public event DisconnectedHandler Disconnected;

public event CallHandler CallStarted;
public event CallHandler CallLeaving;

//StreamTodo: not sure if this should pass instance because we want to destroy call instance when the call is over??
public event CallHandler CallEnded;
Expand Down Expand Up @@ -497,7 +498,7 @@ private StreamVideoClient(IWebsocketClient coordinatorWebSocket, Func<IWebsocket
#if UNITY_IOS || UNITY_ANDROID
_logsCollector.Enable();
#endif
_feedbackReporter = new StreamVideo.Core.IssueReporters.FeedbackReporterFactory(_logsCollector, serializer)
_feedbackReporter = new StreamVideo.Core.IssueReporters.FeedbackReporterFactory(_logsCollector, serializer, _logs)
.CreateTrelloReporter();
#endif
}
Expand Down Expand Up @@ -837,6 +838,10 @@ private void OnRtcPeerConnectionDisconnectedDuringSession()

private void OnRtcCallStateChanged(CallingState previousState, CallingState newState)
{
if (newState == CallingState.Leaving)
{
CallLeaving?.Invoke(ActiveCall);
}
if (newState == CallingState.Left)
{
CallEnded?.Invoke(ActiveCall);
Expand Down
Loading