< Summary

Class:DCL.Social.Friends.ReportFriendRequestToAnalyticsExtensions
Assembly:FriendsController
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/FriendsController/ReportFriendRequestToAnalyticsExtensions.cs
Covered lines:0
Uncovered lines:12
Coverable lines:12
Total lines:63
Line coverage:0% (0 of 12)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ReportFriendRequestErrorToAnalyticsByRequestId(...)0%12300%
ReportFriendRequestErrorToAnalyticsByUserId(...)0%72800%
ReportFriendRequestErrorToAnalyticsAsSender(...)0%20400%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/FriendsController/ReportFriendRequestToAnalyticsExtensions.cs

#LineLine coverage
 1using SocialFeaturesAnalytics;
 2using System;
 3using UnityEngine;
 4
 5namespace 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
 015            var description = e is FriendshipException fe
 16                ? fe.ErrorCode.ToString()
 17                : FriendRequestErrorCodes.Unknown.ToString();
 18
 019            if (!friendsController.TryGetAllocatedFriendRequest(friendRequestId, out FriendRequest request))
 20            {
 021                Debug.LogError($"Cannot display friend request {friendRequestId}, is not allocated");
 22
 023                socialAnalytics.SendFriendRequestError(null, null,
 24                    source,
 25                    description,
 26                    request.FriendRequestId);
 27
 028                return;
 29            }
 30
 031            socialAnalytics.SendFriendRequestError(request.From, request.To,
 32                source,
 33                description,
 34                "");
 035        }
 36
 37        public static void ReportFriendRequestErrorToAnalyticsByUserId(this Exception e, string userId,
 38            string source,
 39            IFriendsController friendsController, ISocialAnalytics socialAnalytics)
 40        {
 041            FriendRequest request = friendsController.GetAllocatedFriendRequestByUser(userId);
 42
 043            socialAnalytics.SendFriendRequestError(request?.From, request?.To,
 44                source,
 45                e is FriendshipException fe
 46                    ? fe.ErrorCode.ToString()
 47                    : FriendRequestErrorCodes.Unknown.ToString(),
 48                request?.FriendRequestId);
 049        }
 50
 51        public static void ReportFriendRequestErrorToAnalyticsAsSender(this Exception e, string recipientId,
 52            string source,
 53            IUserProfileBridge userProfileBridge, ISocialAnalytics socialAnalytics)
 54        {
 055            socialAnalytics.SendFriendRequestError(userProfileBridge.GetOwn()?.userId, recipientId,
 56                source,
 57                e is FriendshipException fe
 58                    ? fe.ErrorCode.ToString()
 59                    : FriendRequestErrorCodes.Unknown.ToString(),
 60                "");
 061        }
 62    }
 63}