public void LogFeatureUsage(FeatureTraceCategory category, HttpContextBase context, string action, string message, int itemCount, string entity, string cRED) { try { var userId = HashPii.GetHashedUserId(context); var sessionId = context != null && context.Session != null ? context.Session.SessionID : string.Empty; bool isPortalEntityAllowed = EntityNamePrivacy.IsPortalEntityAllowed(entity); cRED = string.IsNullOrEmpty(cRED) ? "UnknownPortalAction" : cRED; entity = EntityNamePrivacy.GetEntityName(entity); action = cRED + (!isPortalEntityAllowed ? "__CustomEntityHashedName:" : "__") + entity; // message = EntityGUID this.LogFeatureUsage( category, userId, sessionId, action, message, itemCount, entity, this.Lcid, this.CrmLcid, this.PortalUrl, this.PortalVersion, this.ProductionOrTrial, cRED, this.ElapsedTime()); } catch (Exception ex) { ADXTrace.Instance.TraceError(TraceCategory.Exception, "LogFeatureUsage: received unexpected exception. Message: " + ex.Message); } }
public object BeforeSendRequest(ref Message request, IClientChannel channel) { var site = HashPii.ComputeHashPiiSha256(WebAppSettings.Instance.SiteName); var instance = HashPii.ComputeHashPiiSha256(WebAppSettings.Instance.InstanceId); var userAgent = $"Portals (Site={site}; Instance={instance}; ActivityId={EventSource.CurrentThreadActivityId})"; var property = new HttpRequestMessageProperty { Headers = { { HttpRequestHeader.UserAgent, userAgent } } }; request.Properties.Add(HttpRequestMessageProperty.Name, property); return(null); }
private static void LogAuthentication(TUser user, string authenticationType) { try { if (FeatureCheckHelper.IsFeatureEnabled(FeatureNames.TelemetryFeatureUsage)) { var userId = HashPii.ComputeHashPiiSha256(user.Id); PortalFeatureTrace.TraceInstance.LogAuthentication(FeatureTraceCategory.Authentication, userId, HttpContext.Current.Session.SessionID, "logIn", "authentication", authenticationType); } } catch (Exception e) { WebEventSource.Log.GenericErrorException(e); } }
public void LogAuthentication(FeatureTraceCategory category, HttpContextBase context, string action, string entity = "", string authenticationType = "") { try { var userId = HashPii.GetHashedUserId(context); var sessionId = context.Session.SessionID; this.LogAuthentication( category, userId, sessionId, action, entity, authenticationType); } catch (Exception ex) { ADXTrace.Instance.TraceError(TraceCategory.Exception, "LogAuthentication: received unexpected exception. Message: " + ex.Message); } }
public void LogSessionInfo(FeatureTraceCategory category) { var userId = string.Empty; var authenticated = false; var userAgent = string.Empty; var ipAddress = string.Empty; var context = this.HttpContextBase; if (context != null) { try { authenticated = context.User.Identity.IsAuthenticated; userId = HashPii.GetHashedUserId(context); userAgent = context.Request.UserAgent; ipAddress = HashPii.GetHashedIpAddress(context); } catch { } } this.LogSessionInfo(category, userId, authenticated ? "authenticated" : "nonauthenticated", this.SessionId, this.Lcid, this.CrmLcid, this.PortalUrl, this.PortalVersion, this.ProductionOrTrial, userAgent, ipAddress, this.ElapsedTime(), this.PersistentCookie); }