CINXE.COM

BugSnag docs › Platforms › Unity

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <!-- Always force latest IE rendering engine or request Chrome Frame --> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="Add BugSnag to your Unity games and applications for iOS, Android, macOS, Windows, Nintendo Switch and WebGL."> <title>BugSnag docs &rsaquo; Platforms &rsaquo; Unity</title> <link rel="icon" type="image/png" href="/assets/images/favicon3-96.png" sizes="96x96"> <link href="/assets/stylesheets/all.css" rel="stylesheet" /> <link rel="canonical" href="https://docs.bugsnag.com/platforms/unity/"> <!-- BugSnag --> <script src="//d2wy8f7a9ursnm.cloudfront.net/v7/bugsnag.min.js"></script> <script> Bugsnag.start({ apiKey: '1adb72945c3fe4df9da3638ec54c5e4f', enabledReleaseStages: ['preview', 'production'], releaseStage: 'production' }) </script> <!-- CookieHub --> <script type="text/javascript"> var cpm = {}; (function(h,u,b){ var d=h.getElementsByTagName("script")[0],e=h.createElement("script"); e.async=true;e.src='https://cookiehub.net/c2/93363859.js'; e.onload=function(){u.cookiehub.load(b);} d.parentNode.insertBefore(e,d); })(document,window,cpm); </script> <!-- Segment --> <script type="text/plain" data-consent="analytics"> !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="3.1.0"; // Track page views in Segment unless PetalBot is the source of the request. // PetalBot requests translate to a lot of MTUs (unique monthly users) in Segment which are billable. if (!/PetalBot/i.test(window.navigator.userAgent)) { analytics.load("68nit8nqeCaJTiD3u6961Prq8ZrNFMSF"); analytics.page() }}}(); </script> <!-- Global site tag (gtag.js) - Google Ads: 987941250 --> <script type="text/plain" data-consent="marketing" async src="https://www.googletagmanager.com/gtag/js?id=AW-987941250"></script> <script type="text/plain" data-consent="marketing"> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-987941250'); </script> <!-- Event snippet for Sign-up 2020-04-30 conversion page In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. --> <script type="text/plain" data-consent="marketing"> function gtag_report_conversion(url) { var callback = function () { if (typeof(url) != 'undefined') { window.location = url; } }; gtag('event', 'conversion', { 'send_to': 'AW-987941250/AllYCPWI684BEIKTi9cD', 'event_callback': callback }); return false; } </script> <!-- 6sense --> <script type="text/plain" data-consent="marketing"> window._6si = window._6si || []; window._6si.push(['enableEventTracking', true]); window._6si.push(['setToken', '8e0ea75c2ca92b31dec5baa7e7cf66be']); window._6si.push(['setEndpoint', 'b.6sc.co']); (function() { var gd = document.createElement('script'); gd.type = 'text/javascript'; gd.async = true; gd.src = '//j.6sc.co/6si.min.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gd, s); })(); </script> </head> <body class="platforms platforms_unity platforms_unity_index"> <div class="SmartBear-banner"></div> <div class="Main"> <nav class="Sidebar"> <button class="Sidebar-toggle" onclick="document.body.classList.toggle('show-sidebar')"> <img class="Sidebar-icon Sidebar-icon-menu no-open" src="/assets/images/icons/menu.svg" /> <img class="Sidebar-icon Sidebar-icon-close no-open" src="/assets/images/icons/close.svg" /> </button> <div class="Sidebar-content"> <a class="Sidebar-logo" href="/"></a> <div class="Sidebar-search"> <input class="Sidebar-searchInput js-searchInput" type="search" placeholder="Search docs..."/> </div> <div class="Sidebar-sectionsScrollbarHider "> <div class="Sidebar-sections"> <div class="Sidebar-section"> <div class="Sidebar-sectionHeader">Unity integration guide</div> <a href="#installation" class="Sidebar-navLink"> Installation </a><a href="#basic-configuration" class="Sidebar-navLink"> Basic configuration </a><a href="#showing-full-stacktraces" class="Sidebar-navLink"> Showing full stacktraces </a><a href="#reporting-unhandled-errors" class="Sidebar-navLink"> Reporting unhandled errors </a><a href="#reporting-out-of-memory-terminations" class="Sidebar-navLink"> Reporting out-of-memory terminations </a><a href="#reporting-anrs-and-fatal-app-hangs" class="Sidebar-navLink"> Reporting ANRs and fatal app hangs </a><a href="#reporting-thermal-kills" class="Sidebar-navLink"> Reporting thermal kills </a><a href="#reporting-handled-errors" class="Sidebar-navLink"> Reporting handled errors </a><a href="#sending-diagnostic-data" class="Sidebar-navLink"> Sending diagnostic data </a><a href="#identifying-users" class="Sidebar-navLink"> Identifying users </a><a href="#logging-breadcrumbs" class="Sidebar-navLink"> Logging breadcrumbs </a><a href="#session-tracking" class="Sidebar-navLink"> Session tracking </a><a href="#declaring-feature-flags-and-experiments" class="Sidebar-navLink"> Declaring feature flags and experiments </a><a href="#identifying-crashes-at-launch" class="Sidebar-navLink"> Identifying crashes at launch </a><a href="#next-steps" class="Sidebar-navLink"> Next steps </a> </div> <div class="Sidebar-section"> <div class="Sidebar-sectionHeader">Library reference</div> <div class="Sidebar-nestedNavLinks"> <div class="Sidebar-navLink js-nestedListToggle "> <a href="/platforms/unity/configuration-options/">Configuration options</a> </div> <div class="Sidebar-nestedList js-nestedList "> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#api-key"> API Key </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#app-hang-threshold"> App Hang Threshold </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#app-type"> App Type </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#app-version"> App Version </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#auto-detect-errors"> Auto Detect Errors </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#auto-track-sessions"> Auto Track Sessions </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#breadcrumb-log-level"> Breadcrumb Log Level </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#bundle-version"> Bundle Version </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#context"> Context </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#discard-classes"> Discard Classes </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#enabled-breadcrumb-types"> Enabled Breadcrumb Types </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#enabled-error-types"> Enabled Error Types </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#enabled-release-stages"> Enabled Release Stages </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#endpoints"> Endpoints </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#feature-flags"> Feature Flags </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#generate-anonymous-id"> Generate Anonymous ID </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#launch-duration"> Launch Duration </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#max-breadcrumbs"> Max Breadcrumbs </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#max-persisted-events"> Max Persisted Events </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#max-persisted-sessions"> Max Persisted Sessions </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#max-reported-threads"> Max Reported Threads </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#max-string-value-length"> Max String Value Length </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#metadata"> Metadata </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#notify-log-level"> Notify Log Level </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#on-error-callbacks"> On Error Callbacks </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#on-send-error-callbacks"> On Send Error Callbacks </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#on-session-callbacks"> On Session Callbacks </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#persistence-directory"> Persistence Directory </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#persist-user"> Persist User </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#project-packages"> Project Packages </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#redacted-keys"> Redacted Keys </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#release-stage"> Release Stage </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#report-exception-logs-as-handled"> Report Exception Logs As Handled </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#seconds-per-unique-log"> Seconds Per Unique Log </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#send-launch-crashes-synchronously"> Send Launch Crashes Synchronously </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#send-threads"> Send Threads </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#start-automatically"> Start Automatically </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#user"> User </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#telemetry"> Telemetry </a> <a class="Sidebar-navLink" href="/platforms/unity/configuration-options/#version-code"> Version Code </a> </div> </div> <a href="/platforms/unity/reporting-app-hangs/" class="Sidebar-navLink"> Reporting app hangs </a><a href="/platforms/unity/reporting-handled-errors/" class="Sidebar-navLink"> Reporting handled errors </a><a href="/platforms/unity/customizing-error-reports/" class="Sidebar-navLink"> Customizing error reports </a><a href="/platforms/unity/customizing-breadcrumbs/" class="Sidebar-navLink"> Customizing breadcrumbs </a><a href="/platforms/unity/features-experiments/" class="Sidebar-navLink"> Feature flags & experiments </a><a href="/platforms/unity/capturing-sessions/" class="Sidebar-navLink"> Capturing sessions </a><a href="/platforms/unity/showing-full-stacktraces/" class="Sidebar-navLink"> Showing full stacktraces </a><a href="/platforms/unity/identifying-crashes-at-launch/" class="Sidebar-navLink"> Identifying crashes at launch </a><a href="/platforms/unity/automatically-captured-data/" class="Sidebar-navLink"> Automatically captured data </a><a href="/platforms/unity/platform-support/" class="Sidebar-navLink"> Platform support </a> </div> <div class="Sidebar-section"> <div class="Sidebar-sectionHeader">Further reading</div> <a href="https://github.com/bugsnag/bugsnag-unity/" class="Sidebar-navLink"> View on GitHub </a><a href="https://github.com/bugsnag/bugsnag-unity/tree/master/example" class="Sidebar-navLink"> Unity demo app </a><a href="https://github.com/bugsnag/bugsnag-unity/blob/master/CHANGELOG.md" class="Sidebar-navLink"> Changelog </a><a href="https://github.com/bugsnag/bugsnag-unity/blob/master/UPGRADING.md" class="Sidebar-navLink"> Upgrade guide </a><a href="/platforms/ios/appstore-privacy/" class="Sidebar-navLink"> App Store privacy details </a><a href="/platforms/android/playstore-privacy/" class="Sidebar-navLink"> Play Store privacy details </a><a href="/platforms/unity/support/" class="Sidebar-navLink"> Support </a> </div> </div> </div> </div> </nav> <div class="Content"> <div class="TopBar"> <div class="TopBar-content Grid"> <div class="TopBar-breadcrumbs"> <a href="/" class="TopBar-breadcrumb"> Docs </a><a href="/platforms/" class="TopBar-breadcrumb"> Platforms </a><a href="/platforms/unity/" class="TopBar-breadcrumb"> Unity </a> </div> <div class="TopBar-buttons"> <a class="TopBar-button" href="https://smartbear.com/insight-hub">Smartbear.com</a> <a class="TopBar-button is-primary" href="https://app.bugsnag.com/user/new/" onclick="gtag_report_conversion();">Start Free Trial</a> </div> </div> </div> <div class="Typography Grid"> <div id="BugSnag-is-now-Insight-Hub"> <img class="no-open" src="/assets/images/bugsnag-is-now-insight-hub.svg" /> <span><strong>BugSnag is now Insight Hub</strong> - we&apos;re making some changes to how the product looks, but this won&apos;t impact the way you use BugSnag or any of your integrations.</span> </div> <h1>Unity integration guide</h1> <p>Add BugSnag to your <a href="http://unity3d.com">Unity</a> games and applications for iOS, Android, macOS, Windows, Nintendo Switch and WebGL.</p> <p>After completing this guide, exceptions and crashes from <a href="platform-support/">supported platforms</a> are automatically detected and sent to BugSnag.</p> <div class="AlertBox AlertBox--tip"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="tip-icon" stroke="none" stroke-width="1"> <g> <rect id="container" x="0" y="0"></rect> <path d="M2.97045455,14.0138425 L4.06,15.0906921 L5.44318182,13.7159905 L4.35363636,12.6391408 L2.97045455,14.0138425 Z M8.72727273,17 L10.2727273,17 L10.2727273,14.7470167 L8.72727273,14.7470167 L8.72727273,17 Z M3.31818182,7.87350835 L1,7.87350835 L1,9.40095465 L3.31818182,9.40095465 L3.31818182,7.87350835 Z M11.8181818,4.67350835 L11.8181818,1 L7.18181818,1 L7.18181818,4.67350835 C5.79863636,5.46778043 4.86363636,6.94176611 4.86363636,8.6372315 C4.86363636,11.1651551 6.94227273,13.2195704 9.5,13.2195704 C12.0577273,13.2195704 14.1363636,11.1651551 14.1363636,8.6372315 C14.1363636,6.94176611 13.2013636,5.46778043 11.8181818,4.67350835 Z M15.6818182,7.87350835 L15.6818182,9.40095465 L18,9.40095465 L18,7.87350835 L15.6818182,7.87350835 Z M13.5490909,13.7236277 L14.9322727,15.0983294 L16.0218182,14.0214797 L14.6309091,12.6544153 L13.5490909,13.7236277 Z" id="Shape"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>New to BugSnag? <a href="https://app.bugsnag.com/user/new">Create an account</a></p> </div> <p></div> </div> <div class="AlertBox AlertBox--performance"> <div class="AlertBox-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <g id="performance-icon" stroke="none" stroke-width="1"> <path d="m15.4417 16.4396-1.341-1.3553c.4278-.9198.239-2.0118-.472-2.7304-.7109-.7187-1.7913-.9095-2.7012-.4771L4.4655 5.345a.8038.8038 0 0 0-1.133.0124c-.3115.3149-.317.8236-.0123 1.1452l6.4621 6.5317c-.4277.9197-.239 2.0118.472 2.7304.711.7186 1.7914.9095 2.7013.4771l1.3409 1.3543a.8038.8038 0 0 0 1.133-.0124c.3114-.3148.3169-.8235.0122-1.1451M2.48 14.3041c-.0042-2.1047.579-4.1548 1.6629-5.8457L3.085 7.2353C.4936 11.1176.3004 16.4675 2.6029 20.5862c.1399.2676.3947.426.665.413.2701-.0128.5129-.1947.6333-.4747.1204-.28.0995-.6136-.0547-.8705-.8928-1.5932-1.3668-3.4515-1.3646-5.3499" /> <path d="M22.139 9.9474c-1.3338-3.2502-4.0602-5.6794-7.3793-6.575-3.319-.8955-6.8546-.156-9.5692 2.0019L6.36 6.5766c3.6658-2.7699 8.7334-2.4514 12.0437.7569s3.9176 8.39 1.4434 12.3148a.8622.8622 0 0 0-.0863.8723c.1322.2844.4078.4693.7143.479.3066.0097.5928-.1573.7418-.4328 1.996-3.1643 2.3385-7.1393.9146-10.615" /> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>Looking for performance monitoring? See our <a href="/performance/integration-guides/unity/">performance guide</a></p></p> <p></div> </div> </div></p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>This documentation is for version 6+ of the BugSnag Unity notifier. If you are using older versions, we recommend upgrading to the latest release using our <a href="https://github.com/bugsnag/bugsnag-unity/tree/master/UPGRADING.md">Upgrade guide</a>. Documentation for the previous release can be found on our <a href="/platforms/unity/legacy/">legacy pages</a>.</p> </div> <p></div> </div></p> <h2 id="installation">Installation</h2> <h3 id="upm">UPM</h3> <p>If you are using Unity 2019 or higher, the simplest way to install BugSnag is through the <a href="https://docs.unity3d.com/Manual/upm-ui-giturl.html">Unity Package Manager</a>.</p> <p>Go to Window &#8594; Package Manager and add the package from the following git URL:</p> <div class="highlight"><pre class="highlight shell"><code>https://github.com/bugsnag/bugsnag-unity-upm.git </code></pre></div> <p>This will fetch the latest release available when the URL is added. To get a newer version in future builds, re-add the package. You can also specify an exact version using the git tag for the release after the URL:</p> <div class="highlight"><pre class="highlight shell"><code>https://github.com/bugsnag/bugsnag-unity-upm.git#v8.5.0 </code></pre></div> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>The latest available version of <code>bugsnag-unity-upm</code> is <a href="https://github.com/bugsnag/bugsnag-unity/releases/v8.5.0"><code>v8.5.0</code></a>.</p> </div> <p></div> </div></p> <h3 id="openupm">OpenUPM</h3> <p>The main release of the BugSnag Unity SDK is also installable via OpenUPM:</p> <div class="highlight"><pre class="highlight shell"><code>openupm add com.bugsnag.unitynotifier </code></pre></div> <p>You can find the installation instructions and package information <a href="https://openupm.com/packages/com.bugsnag.unitynotifier/">here</a>.</p> <h3 id="manual-download">Manual download</h3> <p>You can also download the latest package (v8.5.0) from our <a href="https://github.com/bugsnag/bugsnag-unity/releases/latest">GitHub releases page</a>.</p> <p>Download the <code>Bugsnag.unitypackage</code> file and double-click it to import into your Unity project.</p> <h3 id="edm4u-support">EDM4U Support</h3> <p>If you are using the <a href="https://github.com/googlesamples/unity-jar-resolver">External Dependency Manager for Unity (EDM4U)</a> to manage Android dependencies, the above installation steps can lead to conflicts between your app dependencies and the external libraries used by BugSnag Unity.</p> <p>To avoid this, either use the alternative UPM package at <code>https://github.com/bugsnag/bugsnag-unity-upm-edm4u.git</code> or, if you are installing the BugSnag Unity package manually, enable support in the Editor via Window &#8594; Bugsnag &#8594; Enable EDM4U Support or via the script:</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">BugsnagEditor</span><span class="p">.</span><span class="nf">EnableEDM</span><span class="p">();</span> </code></pre></div> <h3 id="nintendo-switch">Nintendo Switch</h3> <p>An additional package is required to detect and report errors from the C# layer of a Unity Nintendo Switch game. Please <a href="mailto:support@bugsnag.com">contact us</a> to request access. To report <em>native</em> Nintendo Switch crashes, follow the instructions in the <a href="/platforms/nintendo-switch/">Nintendo Switch integration guide</a>.</p> <h2 id="basic-configuration">Basic configuration</h2> <p>BugSnag will start automatically in your app once you have configured your <em>API key</em> through Window &#8594; Bugsnag &#8594; Configuration:</p> <p><img src="/assets/images/platforms/unity_settings.png" alt="Import Package" /></p> <p>You can find your API key in <em>Project Settings</em> from your BugSnag dashboard.</p> <h3 id="starting-bugsnag-manually">Starting BugSnag manually</h3> <p>If you&rsquo;d like control over when BugSnag starts, uncheck &ldquo;Start Automatically&rdquo; in the <em>Bugsnag Configuration</em> window. Then create a <code>Configuration</code> object by loading the configuration from the Unity Editor, which can then be overridden in code:</p> <div class="highlight"><pre class="highlight csharp"><code><span class="kt">var</span> <span class="n">config</span> <span class="p">=</span> <span class="n">BugsnagSettingsObject</span><span class="p">.</span><span class="nf">LoadConfiguration</span><span class="p">();</span> <span class="n">config</span><span class="p">.</span><span class="n">AppVersion</span> <span class="p">=</span> <span class="s">"1.2.3-alpha"</span><span class="p">;</span> <span class="n">Bugsnag</span><span class="p">.</span><span class="nf">Start</span><span class="p">(</span><span class="n">config</span><span class="p">);</span> </code></pre></div> <div class="AlertBox AlertBox--warning"> <div class="AlertBox-icon"> <svg viewBox="0 0 20 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="warning-icon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g> <rect id="Rectangle" x="0" y="0" width="20" height="18"></rect> <polygon id="Path" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" points="10 1 1 17 19 17"></polygon> <path d="M11.012785,6.20882916 L10.6223219,11.1540073 C10.6044407,11.6901822 10.2751586,12.1125415 9.87502402,12.1125415 C9.47488947,12.1125415 9.14560733,11.6901822 9.12772618,11.1540073 L8.73726305,6.20882916 C8.70745924,5.36612821 11.0976624,5.36612821 11.012785,6.20882916 Z" id="Path"></path> <path d="M10.5127821,15.0392061 C10.244371,15.3419133 9.84153915,15.4322672 9.49146042,15.2682851 C9.14138168,15.1043029 8.912695,14.7181364 8.9116585,14.2892158 C8.9116585,13.9100206 9.09034497,13.5596297 9.38040849,13.3700321 C9.670472,13.1804345 10.027845,13.1804345 10.3179085,13.3700321 C10.607972,13.5596297 10.7866585,13.9100206 10.7866585,14.2892158 C10.7852866,14.5700905 10.6870024,14.8392345 10.5127821,15.0392061 Z" id="Path"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>No errors will be captured until BugSnag has been started. It should therefore be initialized as early as possible during your app&rsquo;s startup to avoid missing any crashes. <br/><br/> <code>Bugsnag.Start</code> must be called from the main thread – e.g. from the <code>Start</code> lifecycle function of a <code>MonoBehaviour</code>.</p> </div> <p></div> </div></p> <p>If you&rsquo;d like to configure BugSnag further, check out the <a href="./configuration-options/">Configuration options</a> reference.</p> <h2 id="showing-full-stacktraces">Showing full stacktraces</h2> <p>For Android or iOS projects in Unity follow the <a href="showing-full-stacktraces/">showing full stacktraces guide</a> to set up ProGuard mapping, NDK symbols, and debug symbol maps (dSYMs) so you can see the original method names, file paths, and line numbers in stack traces.</p> <h2 id="reporting-unhandled-errors">Reporting unhandled errors</h2> <p>After completing <a href="#installation">installation</a> and <a href="#basic-configuration">basic configuration</a>, <a href="/product/severity-indicator/#handled-vs-unhandled">unhandled</a> exceptions will be reported and automatically appear on your BugSnag dashboard.</p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>Unhandled errors that occur outside of your app&rsquo;s C# code are sent to your BugSnag dashboard when the app next launches. On iOS, they will <em>not</em> be reported when the debugger is attached.</p> </div> <p></div> </div></p> <h2 id="reporting-out-of-memory-terminations">Reporting out-of-memory terminations</h2> <p>On iOS platforms, BugSnag automatically detects terminations of your app caused by the operating system due to high memory usage.</p> <p>OOM detection is enabled by default as part of the <a href="#basic-configuration">basic configuration</a> steps. If you wish to disable it, see the <a href="configuration-options/#enablederrortypes"><code>EnabledErrorTypes</code></a> configuration option.</p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>OOMs are sent to your BugSnag dashboard when the app next launches. OOMs will <em>not</em> be reported when the debugger is attached.</p> </div> <p></div> </div></p> <h2 id="reporting-anrs-and-fatal-app-hangs">Reporting ANRs and fatal app hangs</h2> <p>When your app fails to respond to interactions in real time it causes user frustration and can lead them to abandon your app altogether.</p> <h3 id="android">Android <span id="android-anrs" /></h3> <p>When the main thread of an Android app is blocked for too long, it appears unresponsive and the Android OS creates an <a href="https://developer.android.com/topic/performance/vitals/anr">Application Not Responding (ANR)</a> error, presenting the user with a dialog option to force quit the app.</p> <p>ANR detection is enabled by default as part of the <a href="#basic-configuration">basic configuration</a> steps. If you wish to disable it, see the <a href="./configuration-options/#enablederrortypes"><code>EnabledErrorTypes</code></a> configuration option.</p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>ANRs are sent to your BugSnag dashboard when the app next launches. ANRs will <em>not</em> be reported when the debugger is attached.</p> </div> <p></div> </div></p> <h3 id="ios-and-macos">iOS and macOS</h3> <p>When the main thread of an app is unresponsive for a period of time it will appear to have frozen and may be terminated by the system watchdog as described in <a href="https://developer.apple.com/documentation/xcode/diagnosing_issues_using_crash_reports_and_device_logs/identifying_the_cause_of_common_crashes/addressing_watchdog_terminations">Apple&rsquo;s documentation</a>.</p> <p>Detection of these &ldquo;fatal&rdquo; app hangs is enabled by default as part of the <a href="#basic-configuration">basic configuration</a> steps. If you wish to disable it, see the <a href="configuration-options/#enablederrortypes"><code>EnabledErrorTypes</code></a> configuration option. By default fatal app hangs are reported when the app is terminated after the main thread has been unresponsive for 2000ms.</p> <p>You can also report non-fatal app hangs (i.e. hangs that did not result in the app being killed) by configuring a minimum <a href="configuration-options/#apphangthresholdmillis">app hang threshold duration</a>. This threshold applies to both fatal and non-fatal app hangs and is used by BugSnag to prepare an app hang event report when it is exceeded; if the app subsequently recovers from the hang, a non-fatal hang is reported otherwise a fatal hang will be reported if the app is terminated.</p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>Fatal app hangs are sent to your BugSnag dashboard when the app next launches.</p> </div> <p></div> </div></p> <p>See the <a href="./reporting-app-hangs/">Reporting app hangs</a> guide for more information.</p> <h2 id="reporting-thermal-kills">Reporting thermal kills</h2> <p>On iOS platforms, BugSnag detects terminations of your app by the operating system due to the device overheating.</p> <p>Thermal kill detection is enabled by default as part of the <a href="#basic-configuration">basic configuration</a> steps. If you wish to disable it, see the <a href="configuration-options/#enablederrortypes"><code>EnabledErrorTypes</code></a> configuration option.</p> <div class="AlertBox AlertBox--note"> <div class="AlertBox-icon"> <svg viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="note-icon" stroke="none" stroke-width="1"> <g transform="translate(2.000000, 2.000000)" id="Shape"> <path d="M0,11.0837384 L0,14 L2.91626163,14 L11.5172893,5.39897236 L8.60102764,2.48271073 L0,11.0837384 Z M13.7725316,3.14373004 C14.0758228,2.84043883 14.0758228,2.35050687 13.7725316,2.04721566 L11.9527843,0.227468407 C11.6494931,-0.0758228024 11.1595612,-0.0758228024 10.85627,0.227468407 L9.43313429,1.65060408 L12.3493959,4.56686571 L13.7725316,3.14373004 Z"></path> </g> </g> </svg> </div> <div class="AlertBox-content"> <div class="AlertBox-text"> <p>Thermal kill events are sent to your BugSnag dashboard when the app next launches. They will <em>not</em> be reported when the debugger is attached.</p> </div> <p></div> </div></p> <h2 id="reporting-handled-errors">Reporting handled errors</h2> <p>If you would like to send non-fatal or handled exceptions to BugSnag, you can pass any <code>Exception</code> object to BugSnag&rsquo;s <code>Notify</code> method in your Unity scripts:</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">Bugsnag</span><span class="p">.</span><span class="nf">Notify</span><span class="p">(</span><span class="k">new</span> <span class="n">System</span><span class="p">.</span><span class="nf">Exception</span><span class="p">(</span><span class="s">"Non-fatal"</span><span class="p">));</span> </code></pre></div> <p>BugSnag subscribes to the <a href="https://docs.unity3d.com/ScriptReference/Application-logMessageReceivedThreaded.html">Unity logging framework</a> messages. By default Unity log messages of type <code>Exception</code> will be sent as BugSnag errors.</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">Debug</span><span class="p">.</span><span class="nf">LogException</span><span class="p">(</span><span class="k">new</span> <span class="n">System</span><span class="p">.</span><span class="nf">Exception</span><span class="p">(</span><span class="s">"Non-fatal"</span><span class="p">));</span> </code></pre></div> <p>To configure which log levels will be reported as errors, see the <a href="configuration-options/#notify-log-level">Notify Log Level configuration option</a>.</p> <h3 id="adding-diagnostics-or-adjusting-severity">Adding diagnostics or adjusting severity</h3> <p>It can often be helpful to adjust the severity or attach custom diagnostics to handled exceptions. For more information, see <a href="./reporting-handled-errors/">Reporting handled errors</a>.</p> <h2 id="sending-diagnostic-data">Sending diagnostic data</h2> <h3 id="automatically-captured-diagnostics">Automatically captured diagnostics</h3> <p>BugSnag will automatically capture and attach the following diagnostic data to every exception report:</p> <ul> <li>Full <strong>stack traces</strong> for all threads.</li> <li><strong>App state</strong> including running time and time in foreground.</li> <li><strong>Build information</strong> including name, version/build and <a href="./configuration-options/#releasestage">release stage</a>.</li> <li><strong>Device specification</strong> including model, OS version and total memory.</li> <li><strong>System state</strong> including orientation, free memory, available disk space and battery level.</li> </ul> <p>For more information see <a href="automatically-captured-data/">Automatically captured data</a>.</p> <h3 id="attaching-custom-diagnostics">Attaching custom diagnostics</h3> <p>It can often be helpful to attach application-specific diagnostic data to error reports. This can be accomplished by setting a callback which will be invoked before any reports are sent to BugSnag:</p> <div class="highlight"><pre class="highlight csharp"><code><span class="kt">var</span> <span class="n">config</span> <span class="p">=</span> <span class="n">BugsnagSettingsObject</span><span class="p">.</span><span class="nf">LoadConfiguration</span><span class="p">();</span> <span class="n">config</span><span class="p">.</span><span class="nf">AddOnSendError</span><span class="p">(</span><span class="n">@event</span> <span class="p">=&gt;</span> <span class="p">{</span> <span class="n">@event</span><span class="p">.</span><span class="nf">AddMetadata</span><span class="p">(</span><span class="s">"account"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">,</span> <span class="s">"Acme Co."</span><span class="p">);</span> <span class="n">@event</span><span class="p">.</span><span class="nf">AddMetadata</span><span class="p">(</span><span class="s">"account"</span><span class="p">,</span> <span class="s">"paying_customer"</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span> <span class="c1">// Return `false` if you'd like to stop this error being reported</span> <span class="k">return</span> <span class="k">true</span><span class="p">;</span> <span class="p">});</span> <span class="n">Bugsnag</span><span class="p">.</span><span class="nf">Start</span><span class="p">(</span><span class="n">config</span><span class="p">);</span> </code></pre></div> <p>For more information, see <a href="./customizing-error-reports/">Customizing error reports</a>.</p> <h2 id="identifying-users">Identifying users</h2> <p>In order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information. BugSnag includes helpers for attaching an identifier, email address and name to reports that will be <a href="/product/searching-dashboard/">searchable in the dashboard</a>.</p> <p>By default we will generate a unique ID and send this ID along with every error report from an individual device. If you would like to override this identifier you can set the user ID property.</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">Bugsnag</span><span class="p">.</span><span class="nf">SetUser</span><span class="p">(</span><span class="s">"userId"</span><span class="p">,</span> <span class="s">"user@example.com"</span><span class="p">,</span> <span class="s">"User Name"</span><span class="p">);</span> </code></pre></div> <h2 id="logging-breadcrumbs">Logging breadcrumbs</h2> <p>In order to understand what happened in your application before each error, it can be helpful to leave short log statements that we call <em>breadcrumbs</em>. A configurable number of breadcrumbs are attached to each error report to help diagnose what events led to the error.</p> <h3 id="automatically-captured-breadcrumbs">Automatically captured breadcrumbs</h3> <p>By default, BugSnag captures common events including:</p> <ul> <li>Unity scene changes</li> <li>Low memory warnings, network connectivity changes, and other device metrics on <a href="/platforms/android/#automatically-captured-breadcrumbs">Android</a> and <a href="/platforms/ios/#automatically-captured-breadcrumbs">iOS</a></li> <li>Low-severity messages logged using <code>Debug.Log</code></li> <li>Prior non-fatal error events</li> </ul> <h3 id="capturing-unitywebrequest-breadcrumbs">Capturing <code>UnityWebRequest</code> breadcrumbs</h3> <p>If you use the built-in <a href="https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html">UnityWebRequest</a> class for network requests in your app, you can use the <code>BugnsagUnityWebRequest</code> wrapper to capture network requests as breadcrumbs in your error reports. For usage instructions, see our <a href="./customizing-breadcrumbs/#network-request-breadcrumbs">Customizing breadcrumbs</a> guide.</p> <h3 id="leaving-custom-breadcrumbs">Leaving custom breadcrumbs</h3> <p>Leaving breadcrumbs with a short message can be accomplished as follows:</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">Bugsnag</span><span class="p">.</span><span class="nf">LeaveBreadcrumb</span><span class="p">(</span><span class="s">"Player won"</span><span class="p">);</span> </code></pre></div> <p>When logging breadcrumbs, we’ll keep track of the timestamp, and show both the message and timestamp on your dashboard.</p> <p>BugSnag will keep track of the time and order of the breadcrumbs and show them on your dashboard.</p> <p>Additional data can also be attached to breadcrumbs by providing the optional <code>type</code> and <code>metadata</code> parameters. For more information and examples for how custom breadcrumbs can be integrated, see <a href="customizing-breadcrumbs/">Customizing breadcrumbs</a>.</p> <h2 id="session-tracking">Session tracking</h2> <p>BugSnag tracks the number of &ldquo;sessions&rdquo; that happen within your application. This allows you to <a href="/product/releases/releases-dashboard/">compare stability scores between releases</a> and helps you to understand the quality of your releases.</p> <p>Sessions are captured and reported by default. This behavior can be disabled using the <a href="./configuration-options/#autotracksessions"><code>AutoTrackSessions</code> configuration option</a>.</p> <p>BugSnag will automatically report a session each time the app is launched or enters the foreground after being in the background for at least 30 seconds.</p> <p>For more information about controlling session tracking, see <a href="capturing-sessions/">Capturing sessions</a>.</p> <h2 id="declaring-feature-flags-and-experiments">Declaring feature flags and experiments</h2> <p>Monitor errors as you roll out features or run experiments and A/B tests by declaring your feature flag and experiment usage in the BugSnag client. You can use the <a href="/product/features-experiments/#features-dashboard">Features dashboard</a> to identify whether these features have introduced errors into your app.</p> <div class="highlight"><pre class="highlight csharp"><code><span class="n">Bugsnag</span><span class="p">.</span><span class="nf">AddFeatureFlag</span><span class="p">(</span><span class="s">"Checkout button color"</span><span class="p">,</span> <span class="s">"Blue"</span><span class="p">);</span> <span class="n">Bugsnag</span><span class="p">.</span><span class="nf">AddFeatureFlag</span><span class="p">(</span><span class="s">"New checkout flow"</span><span class="p">);</span> </code></pre></div> <p>For more information, see <a href="features-experiments/">Feature flags &amp; experiments</a>.</p> <h2 id="identifying-crashes-at-launch">Identifying crashes at launch</h2> <p>By default BugSnag will identify crashes that occur whilst your app is launching, allowing you to prioritize fixing high-impact launch crashes.</p> <p>Additionally you can use BugSnag to detect recurrent launch crashes: allowing you to take evasive action in your app, such as resetting data or turning off application features.</p> <p>Follow the <a href="./identifying-crashes-at-launch/">Identifying crashes at launch</a> guide to configure this functionality.</p> <h2 id="next-steps">Next steps</h2> <ul> <li>Explore a <a href="https://github.com/bugsnag/bugsnag-unity/tree/master/example">demo app</a></li> <li>Get <a href="support/">support</a> for your questions and feature requests</li> <li>View <a href="https://github.com/bugsnag/bugsnag-unity"><code>bugsnag-unity</code></a>, the library powering this integration, on GitHub</li> </ul> </div> </div> </div> <div class="Background"> <div class="Background-left"></div> <div class="Background-right"></div> </div> <!-- Docs search --> <script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script><script src="/assets/javascripts/all.js"></script> <script type="text/javascript"> docsearch({ apiKey: '95e256f960a70c3f7fa9c722dbe28130', appId: 'F9ABIKS431', indexName: 'bugsnag', inputSelector: '.js-searchInput', debug: true, algoliaOptions: { hitsPerPage: 20 } }); </script> <!-- Zendesk Widget --> <script> // Standard Zendesk snippet window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(e){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_framework/main.js","bugsnag.zendesk.com"); // Don't allow the widget to set cookies: https://developer.zendesk.com/embeddables/docs/widget/settings#cookies window.zESettings = { cookies: false }; // Force the widget locale to be en-US to encourage customers to send in support queries in English zE('webWidget', 'setLocale', 'en-US'); // Some custom code to turn support@bugsnag.com links into Zendesk triggers $('[href="mailto:support@bugsnag.com"], [href="mailto:enterprise@bugsnag.com"], [href="mailto:notifiers@bugsnag.com"]').on('click', function(e) { // Only do this if Zendesk has loaded. Otherwise, fall back to mailto behavior if (window.zEmbed.activate) { window.zEmbed.activate(); e.preventDefault(); } }); </script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10