| | 1 | | using SocialFeaturesAnalytics; |
| | 2 | | using System; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.Social.Friends |
| | 6 | | { |
| | 7 | | public static class ReportFriendRequestToAnalyticsExtensions |
| | 8 | | { |
| | 9 | | public static void ReportFriendRequestErrorToAnalyticsByRequestId(this Exception e, string friendRequestId, |
| | 10 | | string source, |
| | 11 | | IFriendsController friendsController, ISocialAnalytics socialAnalytics) |
| | 12 | | { |
| | 13 | |
|
| | 14 | |
|
| 0 | 15 | | var description = e is FriendshipException fe |
| | 16 | | ? fe.ErrorCode.ToString() |
| | 17 | | : FriendRequestErrorCodes.Unknown.ToString(); |
| | 18 | |
|
| 0 | 19 | | if (!friendsController.TryGetAllocatedFriendRequest(friendRequestId, out FriendRequest request)) |
| | 20 | | { |
| 0 | 21 | | Debug.LogError($"Cannot display friend request {friendRequestId}, is not allocated"); |
| | 22 | |
|
| 0 | 23 | | socialAnalytics.SendFriendRequestError(null, null, |
| | 24 | | source, |
| | 25 | | description, |
| | 26 | | request.FriendRequestId); |
| | 27 | |
|
| 0 | 28 | | return; |
| | 29 | | } |
| | 30 | |
|
| 0 | 31 | | socialAnalytics.SendFriendRequestError(request.From, request.To, |
| | 32 | | source, |
| | 33 | | description, |
| | 34 | | ""); |
| 0 | 35 | | } |
| | 36 | |
|
| | 37 | | public static void ReportFriendRequestErrorToAnalyticsByUserId(this Exception e, string userId, |
| | 38 | | string source, |
| | 39 | | IFriendsController friendsController, ISocialAnalytics socialAnalytics) |
| | 40 | | { |
| 0 | 41 | | FriendRequest request = friendsController.GetAllocatedFriendRequestByUser(userId); |
| | 42 | |
|
| 0 | 43 | | socialAnalytics.SendFriendRequestError(request?.From, request?.To, |
| | 44 | | source, |
| | 45 | | e is FriendshipException fe |
| | 46 | | ? fe.ErrorCode.ToString() |
| | 47 | | : FriendRequestErrorCodes.Unknown.ToString(), |
| | 48 | | request?.FriendRequestId); |
| 0 | 49 | | } |
| | 50 | |
|
| | 51 | | public static void ReportFriendRequestErrorToAnalyticsAsSender(this Exception e, string recipientId, |
| | 52 | | string source, |
| | 53 | | IUserProfileBridge userProfileBridge, ISocialAnalytics socialAnalytics) |
| | 54 | | { |
| 0 | 55 | | socialAnalytics.SendFriendRequestError(userProfileBridge.GetOwn()?.userId, recipientId, |
| | 56 | | source, |
| | 57 | | e is FriendshipException fe |
| | 58 | | ? fe.ErrorCode.ToString() |
| | 59 | | : FriendRequestErrorCodes.Unknown.ToString(), |
| | 60 | | ""); |
| 0 | 61 | | } |
| | 62 | | } |
| | 63 | | } |