diff --git a/Packages/systems.speckle.speckle-unity/Editor/Components/StreamManagerEditor.cs b/Packages/systems.speckle.speckle-unity/Editor/Components/StreamManagerEditor.cs index 3adffa0..9040c53 100644 --- a/Packages/systems.speckle.speckle-unity/Editor/Components/StreamManagerEditor.cs +++ b/Packages/systems.speckle.speckle-unity/Editor/Components/StreamManagerEditor.cs @@ -163,9 +163,10 @@ private async Task Receive() try { + Commit selectedCommit = Branches[SelectedBranchIndex].commits.items[SelectedCommitIndex]; // Receive Speckle Objects var @base = await Operations.Receive( - Branches[SelectedBranchIndex].commits.items[SelectedCommitIndex].referencedObject, + selectedCommit.referencedObject, remoteTransport: transport, onProgressAction: dict => { @@ -179,8 +180,15 @@ private async Task Receive() ); EditorUtility.ClearProgressBar(); - - Analytics.TrackEvent(SelectedAccount, Analytics.Events.Receive); + + Analytics.TrackEvent(SelectedAccount, Analytics.Events.Receive, new Dictionary() + { + {"mode", nameof(StreamManagerEditor)}, + {"sourceHostApp", HostApplications.GetHostAppFromString(selectedCommit.sourceApplication).Slug}, + {"sourceHostAppVersion", selectedCommit.sourceApplication ?? ""}, + {"hostPlatform", Application.platform.ToString()}, + {"isMultiplayer", selectedCommit.authorId != SelectedAccount.userInfo.id}, + }); //Convert Speckle Objects int childrenConverted = 0; diff --git a/Packages/systems.speckle.speckle-unity/Runtime/Components/Deprecated/Receiver.cs b/Packages/systems.speckle.speckle-unity/Runtime/Components/Deprecated/Receiver.cs index f9fbbf6..708c036 100644 --- a/Packages/systems.speckle.speckle-unity/Runtime/Components/Deprecated/Receiver.cs +++ b/Packages/systems.speckle.speckle-unity/Runtime/Components/Deprecated/Receiver.cs @@ -5,8 +5,10 @@ using Speckle.Core.Transports; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using JetBrains.Annotations; using Sentry; using Speckle.ConnectorUnity.Components; using Speckle.Core.Kits; @@ -93,7 +95,7 @@ public void Receive() if (!mainBranch.commits.items.Any()) throw new Exception("This branch has no commits"); var commit = mainBranch.commits.items[0]; - GetAndConvertObject(commit.referencedObject, commit.id); + GetAndConvertObject(commit.referencedObject, commit.id, commit.sourceApplication, commit.authorId); } catch (Exception e) { @@ -116,12 +118,12 @@ protected virtual void Client_OnCommitCreated(object sender, CommitInfo e) if (e.branchName == BranchName) { Debug.Log("New commit created"); - GetAndConvertObject(e.objectId, e.id); + GetAndConvertObject(e.objectId, e.id, e.sourceApplication, e.authorId); } } - private async void GetAndConvertObject(string objectId, string commitId) + private async void GetAndConvertObject(string objectId, string commitId, string sourceApplication, string authorId) { try { @@ -136,7 +138,14 @@ private async void GetAndConvertObject(string objectId, string commitId) disposeTransports: true ); - Analytics.TrackEvent(Client.Account, Analytics.Events.Receive); + Analytics.TrackEvent(Client.Account, Analytics.Events.Receive, new Dictionary() + { + {"mode", nameof(Receiver)}, + {"sourceHostApp", HostApplications.GetHostAppFromString(sourceApplication).Slug}, + {"sourceHostAppVersion", sourceApplication ?? ""}, + {"hostPlatform", Application.platform.ToString()}, + {"isMultiplayer", authorId != null && authorId != Client.Account.userInfo.id}, + }); Dispatcher.Instance().Enqueue(() => { @@ -186,4 +195,4 @@ private void OnDestroy() #endregion } -} \ No newline at end of file +} diff --git a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs index 573e50d..2fc51f9 100644 --- a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs +++ b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleReceiver.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Threading; @@ -86,7 +87,7 @@ public IEnumerator ReceiveAndConvertRoutine(SpeckleReceiver speckleReceiver, str client: client, streamId: stream.id, objectId: commit.referencedObject, - commitId: commit.id, + commit: commit, onProgressAction: dict => OnReceiveProgressAction.Invoke(dict), onErrorAction: (m, e) => OnErrorAction.Invoke(m, e), onTotalChildrenCountKnown: c => OnTotalChildrenCountKnown.Invoke(c) @@ -100,7 +101,7 @@ public IEnumerator ReceiveAndConvertRoutine(SpeckleReceiver speckleReceiver, str /// /// /// - /// + /// /// /// /// @@ -109,7 +110,7 @@ public IEnumerator ReceiveAndConvertRoutine(SpeckleReceiver speckleReceiver, str Client client, string streamId, string objectId, - string? commitId, + Commit? commit, Action>? onProgressAction = null, Action? onErrorAction = null, Action? onTotalChildrenCountKnown = null) @@ -134,7 +135,14 @@ public IEnumerator ReceiveAndConvertRoutine(SpeckleReceiver speckleReceiver, str disposeTransports: false ).ConfigureAwait(false); - Analytics.TrackEvent(client.Account, Analytics.Events.Receive); + Analytics.TrackEvent(client.Account, Analytics.Events.Receive, new Dictionary() + { + {"mode", nameof(SpeckleReceiver)}, + {"sourceHostApp", HostApplications.GetHostAppFromString(commit?.sourceApplication).Slug}, + {"sourceHostAppVersion", commit?.sourceApplication ?? ""}, + {"hostPlatform", Application.platform.ToString()}, + {"isMultiplayer", commit != null && commit.authorId != client.Account.userInfo.id}, + }); token.ThrowIfCancellationRequested(); @@ -144,7 +152,7 @@ public IEnumerator ReceiveAndConvertRoutine(SpeckleReceiver speckleReceiver, str await client.CommitReceived(token, new CommitReceivedInput { streamId = streamId, - commitId = commitId, + commitId = commit?.id, message = $"received commit from {Application.unityVersion}", sourceApplication = HostApplications.Unity.GetVersion(CoreUtils.GetHostAppVersion()) }).ConfigureAwait(false); diff --git a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleSender.cs b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleSender.cs index 43867ae..18b4be2 100644 --- a/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleSender.cs +++ b/Packages/systems.speckle.speckle-unity/Runtime/Components/SpeckleSender.cs @@ -84,7 +84,11 @@ public static async Task SendDataAsync(CancellationToken cancellationTok onErrorAction: onErrorAction ); - Analytics.TrackEvent(client.Account, Analytics.Events.Send); + Analytics.TrackEvent(client.Account, Analytics.Events.Send, new Dictionary() + { + {"mode", nameof(SpeckleSender)}, + {"hostPlatform", Application.platform.ToString()}, + }); if (createCommit && !cancellationToken.IsCancellationRequested) {