/// <summary>Tags that might change during runtime.</summary> public static Dictionary <string, Tag> dynamicTags() => new Dictionary <string, Tag> { { "App:LoadedLevelNames", new Tag( Enumerable2.fromImperative(SceneManager.sceneCount, SceneManager.GetSceneAt). Select(_ => $"{_.name}({_.buildIndex})").OrderBy(_ => _).mkString(", ") ) }, { "App:InternetReachability", Tag.a(Application.internetReachability) }, { "App:TargetFrameRate", Tag.a(Application.targetFrameRate) }, };
public void Sqrt() { var x = 5.0; var r = x; Enumerable2.Repeat(false) .Select(_ => (r + x / r) / 2) .TakeWhile(a => r != a) .Execute(a => r = a); AssertNearlyEqual(Math.Sqrt(x), r); }
public static SentryMessage message( string loggerName, ApiKeys keys, ErrorReporter.AppInfo appInfo, ErrorReporter.ErrorData data, ExtraData addExtraData ) { var timestamp = DateTime.UtcNow; // The list of frames should be ordered by the oldest call first. // ReSharper disable once ConvertClosureToMethodGroup - MCS bug var stacktraceFrames = data.backtrace.Select(a => backtraceElemToJson(a)).Reverse().ToList(); // Tags are properties that can be filtered/grouped by. var tags = new Dictionary <string, object> { // max tag name length = 32 { "ProductName", tag(appInfo.productName) }, { "BundleIdentifier", tag(appInfo.bundleIdentifier) }, { "App:LoadedLevelNames", tag( Enumerable2.fromImperative(SceneManager.sceneCount, SceneManager.GetSceneAt). Select(_ => $"{_.name}({_.buildIndex})").OrderBy(_ => _).mkString(", ") ) }, { "App:LevelCount", tag(SceneManager.sceneCountInBuildSettings) }, { "App:Platform", tag(Application.platform) }, { "App:UnityVersion", tag(Application.unityVersion) }, { "App:Version", tag(Application.version) }, { "App:BundleIdentifier", tag(Application.bundleIdentifier) }, { "App:InstallMode", tag(Application.installMode) }, { "App:SandboxType", tag(Application.sandboxType) }, { "App:ProductName", tag(Application.productName) }, { "App:CompanyName", tag(Application.companyName) }, { "App:CloudProjectId", tag(Application.cloudProjectId) }, { "App:WebSecurityEnabled", tag(Application.webSecurityEnabled) }, { "App:WebSecurityHostUrl", tag(Application.webSecurityHostUrl) }, { "App:TargetFrameRate", tag(Application.targetFrameRate) }, { "App:SystemLanguage", tag(Application.systemLanguage) }, { "App:BackgroundLoadingPriority", tag(Application.backgroundLoadingPriority) }, { "App:InternetReachability", tag(Application.internetReachability) }, { "App:GenuineCheckAvailable", tag(Application.genuineCheckAvailable) }, { "App:Genuine", tag(Application.genuineCheckAvailable && Application.genuine) }, { "SI:OperatingSystem", tag(SystemInfo.operatingSystem) }, { "SI:ProcessorType", tag(SystemInfo.processorType) }, { "SI:ProcessorCount", tag(SystemInfo.processorCount) }, { "SI:SystemMemorySize", tag(SystemInfo.systemMemorySize) }, { "SI:GraphicsMemorySize", tag(SystemInfo.graphicsMemorySize) }, { "SI:GraphicsDeviceName", tag(SystemInfo.graphicsDeviceName) }, { "SI:GraphicsDeviceVendor", tag(SystemInfo.graphicsDeviceVendor) }, { "SI:GraphicsDeviceID", tag(SystemInfo.graphicsDeviceID) }, { "SI:GraphicsDeviceVendorID", tag(SystemInfo.graphicsDeviceVendorID) }, { "SI:GraphicsDeviceType", tag(SystemInfo.graphicsDeviceType) }, { "SI:GraphicsDeviceVersion", tag(SystemInfo.graphicsDeviceVersion) }, { "SI:GraphicsShaderLevel", tag(SystemInfo.graphicsShaderLevel) }, { "SI:GraphicsMultiThreaded", tag(SystemInfo.graphicsMultiThreaded) }, { "SI:SupportsShadows", tag(SystemInfo.supportsShadows) }, { "SI:SupportsRenderTextures", tag(SystemInfo.supportsRenderTextures) }, { "SI:SupportsRenderToCubemap", tag(SystemInfo.supportsRenderToCubemap) }, { "SI:SupportsImageEffects", tag(SystemInfo.supportsImageEffects) }, { "SI:Supports3DTextures", tag(SystemInfo.supports3DTextures) }, { "SI:SupportsComputeShaders", tag(SystemInfo.supportsComputeShaders) }, { "SI:SupportsInstancing", tag(SystemInfo.supportsInstancing) }, { "SI:SupportsSparseTextures", tag(SystemInfo.supportsSparseTextures) }, { "SI:SupportedRenderTargetCount", tag(SystemInfo.supportedRenderTargetCount) }, { "SI:SupportsStencil", tag(SystemInfo.supportsStencil) }, { "SI:NPOTsupport", tag(SystemInfo.npotSupport) }, { "SI:DeviceName", tag(SystemInfo.deviceName) }, { "SI:DeviceModel", tag(SystemInfo.deviceModel) }, { "SI:SupportsAccelerometer", tag(SystemInfo.supportsAccelerometer) }, { "SI:SupportsGyroscope", tag(SystemInfo.supportsGyroscope) }, { "SI:SupportsLocationService", tag(SystemInfo.supportsLocationService) }, { "SI:SupportsVibration", tag(SystemInfo.supportsVibration) }, { "SI:DeviceType", tag(SystemInfo.deviceType) }, { "SI:MaxTextureSize", tag(SystemInfo.maxTextureSize) }, }; addExtraData.addTags((name, value) => tags[name] = tag(value)); // Extra contextual data is limited to 4096 characters. var extras = new Dictionary <string, object> { { "App:StreamedBytes", Application.streamedBytes }, }; addExtraData.addExtras((name, value) => extras[name] = value); var json = new Dictionary <string, object> { { "event_id", Guid.NewGuid().ToString("N") }, // max length - 1000 chars { "message", data.message.trimTo(1000) }, { "timestamp", timestamp.ToString("yyyy-MM-ddTHH:mm:ss") }, { "level", logTypeToSentryLevel(data.errorType) }, { "logger", loggerName }, { "platform", Application.platform.ToString() }, { "release", appInfo.bundleVersion }, { "tags", tags }, { "extra", extras }, { "stacktrace", new Dictionary <string, object> { { "frames", stacktraceFrames } } } }; if (!data.backtrace.isEmpty()) { json.Add("culprit", data.backtrace[0].method); } var serialized = Formats.MiniJSON.Json.Serialize(json); return(new SentryMessage(keys, timestamp, serialized)); }