/// <summary> /// Check next frame if a new session should be captured /// </summary> private IEnumerator <UnityEngine.AsyncOperation> RunInitialSessionCheck() { yield return(null); if (Configuration.AutoCaptureSessions && SessionTracking.CurrentSession == null) { SessionTracking.StartSession(); } }
public void SetApplicationState(bool inFocus) { if (inFocus) { Stopwatch.Start(); if (Configuration.AutoCaptureSessions) { SessionTracking.StartSession(); } } else { Stopwatch.Stop(); } }
public void SetApplicationState(bool inFocus) { if (inFocus) { ForegroundStopwatch.Start(); lock (autoSessionLock) { if (Configuration.AutoCaptureSessions && BackgroundStopwatch.Elapsed.TotalSeconds > AutoCaptureSessionThresholdSeconds) { SessionTracking.StartSession(); } BackgroundStopwatch.Reset(); } } else { ForegroundStopwatch.Stop(); BackgroundStopwatch.Start(); } }
public static string GetContextSessionID() { object xLock = new object(); int? UserId = (int?)int.Parse(DataSecurityTripleDES.GetPlainText(GetContextSessionLoggedUserID())); lock (xLock) { string SessionID = HttpContext.Current.Session.SessionID, IPAddress = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? string.Empty).Trim() == string.Empty ? HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]?.Trim() : HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]?.Trim(); SessionTracking result = null; using (CraveatsDbContext craveatsDbContext = new CraveatsDbContext()) { result = craveatsDbContext.SessionTracking.FirstOrDefault(u => u.IPAddress == IPAddress && u.SessionID == SessionID && u.UserId == UserId); } return(DataSecurityTripleDES.GetEncryptedText(result?.Id ?? 0)); } }
private static SessionTracking EditSessionTracking(SessionTracking sessionTracking) { SessionTracking savedSessionTracking = null; try { using (CraveatsDbContext craveatsDbContext = new CraveatsDbContext()) { DBCommonUtility dBCommonUtility = new DBCommonUtility(); string sqlCmdParamString = ""; SqlParameter[] sqlParameters = dBCommonUtility.GetSqlParameters( new object[] { sessionTracking.SessionID, sessionTracking.IPAddress, sessionTracking.UserId, null, sessionTracking.LoggedInAt, sessionTracking.LoggedOutAt }, out sqlCmdParamString , true); StringBuilder sbRawSQL = new StringBuilder("exec EditSessionTracking"); sbRawSQL.AppendFormat(" {0}", sqlCmdParamString.Trim()); savedSessionTracking = craveatsDbContext.Database.SqlQuery <SessionTracking>( sql: sbRawSQL.ToString(), parameters: sqlParameters ).FirstOrDefault(); } } catch (Exception exception) { throw exception; } return(savedSessionTracking); }
void Notify(Exception[] exceptions, HandledState handledState, Middleware callback, LogType?logType) { if (!ShouldSendRequests()) { return; // Skip overhead of computing payload to to ultimately not be sent } var user = new User { Id = User.Id, Email = User.Email, Name = User.Name }; var app = new App(Configuration) { InForeground = InForeground, DurationInForeground = ForegroundStopwatch.Elapsed, }; NativeClient.PopulateApp(app); var device = new Device(); NativeClient.PopulateDevice(device); device.AddRuntimeVersions(Configuration); var metadata = new Metadata(); NativeClient.PopulateMetadata(metadata); foreach (var item in Metadata) { metadata.AddToPayload(item.Key, item.Value); } metadata.AddToPayload(UnityMetadataKey, UnityMetadata.WithLogType(logType)); var @event = new Payload.Event( Configuration.Context, metadata, app, device, user, exceptions, handledState, Breadcrumbs.Retrieve(), SessionTracking.CurrentSession); var report = new Report(Configuration, @event); lock (MiddlewareLock) { foreach (var middleware in Middleware) { try { middleware(report); } catch (System.Exception) { } } } try { callback?.Invoke(report); } catch (System.Exception) { } if (!report.Ignored) { Send(report); Breadcrumbs.Leave(Breadcrumb.FromReport(report)); SessionTracking.AddException(report); } }
void Notify(Exception[] exceptions, HandledState handledState, Middleware callback, LogType?logType) { var user = new User { Id = User.Id, Email = User.Email, Name = User.Name }; var app = new App(Configuration) { InForeground = InForeground, DurationInForeground = Stopwatch.Elapsed, }; NativeClient.PopulateApp(app); var device = new Device(); NativeClient.PopulateDevice(device); var metadata = new Metadata(); NativeClient.PopulateMetadata(metadata); foreach (var item in Metadata) { metadata.AddToPayload(item.Key, item.Value); } metadata.AddToPayload(UnityMetadataKey, UnityMetadata.WithLogType(logType)); var @event = new Payload.Event( Configuration.Context, metadata, app, device, user, exceptions, handledState, Breadcrumbs.Retrieve(), SessionTracking.CurrentSession); var report = new Report(Configuration, @event); if (report.Configuration.ReleaseStage != null && report.Configuration.NotifyReleaseStages != null && !report.Configuration.NotifyReleaseStages.Contains(report.Configuration.ReleaseStage)) { return; } lock (MiddlewareLock) { foreach (var middleware in Middleware) { try { middleware(report); } catch (System.Exception) { } } } try { callback?.Invoke(report); } catch (System.Exception) { } if (!report.Ignored) { Send(report); Breadcrumbs.Leave(Breadcrumb.FromReport(report)); SessionTracking.AddException(report); } }