透過 API 上傳損毀

如果您不想要使用我們的 SDK 或針對自訂平臺進行開發,您可以上傳損毀報表。 將損 錯誤或附件記錄上傳至 app Center,並查看 app center 診斷 UI 中的詳細資料。 下列各節將說明如何 上傳損毀、 錯誤附件

注意

App Center 每分鐘最多隻接受60個損毀,且每分鐘處理的錯誤為每個唯一應用程式。 我們不會內嵌超過此限制的任何損毀或錯誤。

若要上傳報表,請 https://in.appcenter.ms/logs?Api-Version=1.0.0 使用下列標頭呼叫 App Center 內嵌端點:

  • Content-Type:描述主體的格式。 App Center 目前僅支援 JSON 格式。
  • App-Secret:字串,這是每個應用程式的唯一識別碼。 您可以在應用程式的設定中找到應用程式秘密。
  • Install-ID:可以是用來追蹤計數之任何 GUID 的字串。

記錄檔屬性:

  • type:需要記錄檔類型的字串-"appleError" 代表 Apple 當機,"managedError" 代表其他損毀,"handledError" 表示錯誤,"errorAttachment" 代表錯誤附件。
  • timestamp:具有記錄時間戳記日期時間的選擇性字串,例如 "2017-03-13T18:05: 42Z"-如果設定,則在進行內嵌時,最多必須為72小時
  • appLaunchTimestamp:必要的字串,指定啟動應用程式時的時間戳記日期時間,例如 "2017-03-13T18:05: 42Z"。
  • device:具有裝置特性的必要物件
    • appVersion:需要具有應用程式版本名稱的字串,例如 "1.1.0"
    • appBuild:需要具有應用程式組建編號的字串,例如 "42"
    • sdkName:需要具有 SDK 名稱的字串。 包含 SDK 和平臺的名稱,例如 "appcenter" (適用于 Android)和 "appcenter" (自訂平臺)
    • sdkVersion:以語義版本控制格式的 SDK 版本所需的字串,例如 "1.2.0" 或 "0.12.3-Alpha. 1"
    • osName:需要 OS 名稱的字串,例如 "android"
    • osVersion:需要作業系統版本的字串,例如 "9.3.0"
    • model:具有裝置型號的選擇性字串,例如 "iPad2"
    • locale:需要語言代碼的字串,例如 "en-us"
    • timeZoneOffset:選擇性位移(以分鐘為單位) (從裝置時區的國際標準時間 (UTC) 之間的-840 和 840) 。 包括日光節約時間,例如120。
  • userId:用來將記錄與使用者建立關聯的選擇性字串
  • exception:具有例外狀況詳細資料的必要物件
    • type:需要具有例外狀況類型的字串
    • frame:具有堆疊框架的選擇性陣列
    • message:選擇性字串,但有例外狀況原因
    • stackTrace:含原始堆疊追蹤的選擇性字串
    • innerException:包含內部例外狀況的選擇性陣列

您可以在下方找到如何上傳損毀報告、錯誤報表和附件的範例。 如需更多規格,您可以在 這裡找到完整的檔案。

注意

由於保留原則的不同,在 timestamp 過去或3天內,報告必須不超過25天。

上傳損毀報告

以下是上傳損毀報告所需的屬性:

  • processId:需要具有處理序識別碼的整數
  • id:需要具有例外狀況識別碼的字串,必須是此報表的唯一識別碼
  • fatal:必要的布林值,指出例外狀況是否造成損毀
  • processName:需要具有進程名稱的字串
  • appNamespace: Android 應用程式的必要項,否則為具有套件組合識別碼、封裝識別碼或命名空間的選擇性字串,視使用的平臺而定。

若要上傳 Apple 格式以外的損毀報告,請確定記錄類型已設為 "managedError"。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "timestamp": "2019-10-08T04:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "processId": "123",
      "id": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "fatal": true,
      "processName": "com.microsoft.appcenter.demo.project",
      "device": {
        "appVersion": "12.0",
        "appBuild": "1",
        "sdkName": "custom.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US",
        "appNamespace": "com.contoso.myapp"
      },
      "userId": "TestID",
      "exception": {
        "type": "java.lang.RuntimeException",
        "frames": [
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2575,
            "methodName": "performResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2603,
            "methodName": "handleResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2089,
            "methodName": "handleLaunchActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 130,
            "methodName": "access$600"
          },
          {
            "className": "android.app.ActivityThread$H",
            "fileName": "ActivityThread.java",
            "lineNumber": 1195,
            "methodName": "handleMessage"
          },
          {
            "className": "android.os.Handler",
            "fileName": "Handler.java",
            "lineNumber": 99,
            "methodName": "dispatchMessage"
          },
          {
            "className": "android.os.Looper",
            "fileName": "Looper.java",
            "lineNumber": 137,
            "methodName": "loop"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 4745,
            "methodName": "main"
          }
        ],
        "innerExceptions": [
          {
            "type": "java.lang.RuntimeException",
            "frames": [
              {
                "className": "android.app.Activity",
                "fileName": "Activity.java",
                "lineNumber": 5084,
                "methodName": "performResume"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2565,
                "methodName": "performResumeActivity"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2603,
                "methodName": "handleResumeActivity"
              }
            ]
          }
        ]
      }
    }
  ]
}'

上傳 Apple 損毀記錄

若要上傳 Apple 損毀記錄檔,請確定記錄類型已設為 "appleError"。 也需要下列屬性:

  • primaryArchitectureId:需要 CPU 主要架構的整數
  • applicationPath:需要具有應用程式路徑的字串
  • osExceptionType:需要 OS 例外狀況類型的字串
  • osExceptionCode:需要具有 OS 例外狀況代碼的字串
  • osExceptionAddress:需要 OS 例外狀況位址的字串
  • binaries:必要的陣列,其中包含與錯誤相關聯的二進位檔

例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
        "type": "appleError",
        "timestamp": "2019-10-08T02:44:55.000Z",
        "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
        "id": "70D280D4-2343-400D-BE4C-301BB2B39ECA",
        "applicationPath": "iOS/salesforce",
        "osExceptionType": "CustomerIssue (TestIssue)",
        "osExceptionCode": "0",
        "osExceptionAddress": "0x00",
        "processName": "salesforce",
        "fatal": true,
        "isTestMessage": false,
        "device": {
          "appVersion": "10.0",
          "appBuild": "1",
          "sdkName": "custom.ios",
          "sdkVersion": "1.0.0",
          "osName": "iOS",
          "osVersion": "9.3",
          "model": "iPhone9,1",
          "locale": "en-US"
        },
        "userId": "70D280D4-2343-400D-BE4C-301BB2B39ECA",
        "fatal": true,
        "threads": [
         {
          "id": 0,
          "frames": [
            {
              "address": "0x000000018ada4d70",
              "code": "0x18ad87000 + 122224"
            },
            {
              "address": "0x0000000104463884",
              "code": "0x10445c000 + 30852"
            },
            {
              "address": "0x000000010438f640",
              "code": "0x104388000 + 30272"
            },
            {
              "address": "0x00000001b859fb64",
              "code": "0x1b8229000 + 3631972"
            }
          ]
        },
        {
          "id": 1,
          "frames": [
            {
              "address": "0x000000018bb4fce0",
              "code": "0x18baa2000 + 711904"
            },
            {
              "address": "0x000000018bbf7078",
              "code": "0x18baa2000 + 1396856"
            },
            {
              "address": "0x000000018baa8258",
              "code": "0x18baa2000 + 25176"
            },
            {
              "address": "0x000000018bb1c49c",
              "code": "0x18baa2000 + 500892"
            }
          ]
        },
        {
          "id": 3,
          "frames": [
            {
              "address": "0x000000018b755b9c",
              "code": "0x18b732000 + 146332"
            },
            {
              "address": "0x000000018b7dcd00",
              "code": "0x18b7ce000 + 60672"
            }
          ]
        }
      ],
      "binaries": [
        {
          "id": "d449e33d-7e74-379d-8b79-15ee104ed1df",
          "startAddress": "0x0000000104388000",
          "endAddress": "0x0000000104413fff",
          "name": "CrashProbeiOS",
          "path": "/var/containers/Bundle/Application/023013EA-0D58-4F6D-8B98-49E1372F4044/CrashProbeiOS.app/CrashProbeiOS",
          "primaryArchitectureId": 16777228,
          "architectureVariantId": 0
        },
        {
          "id": "5da23653-d126-39f0-bdcf-994b3019f92c",
          "startAddress": "0x000000010445c000",
          "endAddress": "0x0000000104467fff",
          "name": "CrashLibiOS",
          "path": "/private/var/containers/Bundle/Application/023013EA-0D58-4F6D-8B98-49E1372F4044/CrashProbeiOS.app/Frameworks/CrashLibiOS.framework/CrashLibiOS",
          "primaryArchitectureId": 16777228,
          "architectureVariantId": 0
        }
      ]
    }
  ]
}'

上傳自訂損毀記錄

若要上傳自訂平臺的損毀,請確定記錄類型設定為 "managedError",而且 sdkName 設定為 "appcenter"。 例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "id": "a7bea41b-1e4d-4e42-ae76-1025f4fdfc4f",
      "userId": "TestID",
      "timestamp": "2019-11-26T02:00:04Z",
      "appLaunchTimestamp": "2019-11-26T02:00:04Z",
      "architecture": "armeabi-v7a",
      "fatal": true,
      "processId": 4871,
      "processName": "com.microsoft.appcenter.sasquatch.project",
      "sid": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "errorThreadId": 1,
      "errorThreadName": "main",
      "device": {
        "appBuild": "1337",
        "appVersion": "7.1.0",
        "appNamespace": "com.microsoft.appcenter.sasquatch.project",
        "carrierCountry": "us",
        "locale": "en_US",
        "model": "Galaxy Nexus",
        "oemName": "samsung",
        "osApiLevel": 16,
        "osBuild": "JRO03O",
        "osName": "Android",
        "osVersion": "5.0.0",
        "screenSize": "720x1184",
        "sdkName": "appcenter.custom",
        "sdkVersion": "1.9.1",
        "timeZoneOffset": -480
      },
       "exception": {
        "frames": [
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2575,
            "methodName": "performResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2603,
            "methodName": "handleResumeActivity"
          },
          {
            "className": "android.app.ActivityThread",
            "fileName": "ActivityThread.java",
            "lineNumber": 2089,
            "methodName": "handleLaunchActivity"
          }
        ],
        "innerExceptions": [
          {
            "frames": [
              {
                "className": "android.app.CustomActivity",
                "fileName": "CustomActivity.java",
                "lineNumber": 8673,
                "methodName": "performCustomResume"
              },
              {
                "className": "android.app.ActivityThread",
                "fileName": "ActivityThread.java",
                "lineNumber": 2565,
                "methodName": "performResumeActivity"
              }
            ],
            "message": "Activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2} did not call through to super.onResume()",
            "type": "android.app.CustomNotCalledException"
          }
        ],
        "message": "Unable to resume activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2}: android.app.SuperNotCalledException: Activity {com.microsoft.appcenter.sasquatch.project/com.microsoft.appcenter.sasquatch.activities.CrashSubActivity2} did not call through to super.onResume()",
        "type": "java.lang.RuntimeException"
      },
      "threads": [
        {
          "frames": [
            {
              "className": "dalvik.system.NativeStart",
              "fileName": "NativeStart.java",
              "lineNumber": -2,
              "methodName": "run"
            }
          ],
          "id": 369,
          "name": "Binder_3"
        },
        {
          "frames": [
            {
              "className": "dalvik.system.NativeStart",
              "fileName": "NativeStart.java",
              "lineNumber": -2,
              "methodName": "run"
            }
          ],
          "id": 345,
          "name": "Compiler"
        }
      ]

    }
  ]
}'

上傳 Breakpad 損毀記錄和小型傾印

您可以上傳適用于 Android 和 Windows 的自訂 Breakpad 損毀。 例如:

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
      "type": "managedError",
      "id": "70D280D4-2343-400D-BE4C-301BB2B39ECA",
      "userId": "TestID",
      "processId": 9448,
      "processName": "Contoso.UWP.Puppet.exe",
      "fatal": true,
      "timestamp": "2019-10-08T06:22:23.530Z",
      "architecture": "X64",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "sid": "d4608adf-83b9-4f69-90ad-8bb0234080a7",
      "device": {
        "sdkName": "appcenter.custom",
        "sdkVersion": "2.4.1-SNAPSHOT",
        "model": "Parallels Virtual Platform",
        "oemName": "Parallels Software International Inc.",
        "osName": "WINDOWS",
        "osVersion": "10.0.18363",
        "osBuild": "10.0.18363.418",
        "locale": "en-US",
        "timeZoneOffset": -300,
        "screenSize": "4608x2470",
        "appVersion": "1.0",
        "appBuild": "1.0",
        "appNamespace": "10805zumoTestUser.AppCenter-Contoso.UWP.Puppet",
        "carrierCountry": "us",
        "wrapperSdkName": "custom.ndk"
      },
      "exception": {
        "type": "minidump",
        "wrapperSdkName": "custom.ndk"
      }
    },
    {
      "contentType": "application/octet-stream",
      "errorId": "70D280D4-2343-400D-BE4C-301BB2B39ECA",
      "fileName": "minidump.dmp",
      "id": "7b975468-5656-40a5-8242-c1907b26fc31",
      "sid": "03693776-cdd4-46b8-bbda-12af457f1732",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "type": "errorAttachment",
       "device": {
        "sdkName": "appcenter.custom",
        "sdkVersion": "2.4.1-SNAPSHOT",
        "model": "Parallels Virtual Platform",
        "oemName": "Parallels Software International Inc.",
        "osName": "WINDOWS",
        "osVersion": "10.0.18363",
        "osBuild": "10.0.18363.418",
        "locale": "en-US",
        "timeZoneOffset": -300,
        "screenSize": "4608x2470",
        "appVersion": "1.0",
        "appBuild": "1.0",
        "appNamespace": "10805zumoTestUser.AppCenter-Contoso.UWP.Puppet",
        "carrierCountry": "us",
        "wrapperSdkName": "custom.ndk"
      },
      "data": "<base64 encoded minidump>"
    }
  ]
}'

警示

若要上傳 Breakpad 損毀, wrapperSdkName 欄位必須設為 "custom",而且您必須將小型傾印檔案附加至損毀報告的附件。 瞭解如何在此頁面的 [附件] 區段 中傳送附件。

若要將您的損毀,您必須根據我們的 api檔,透過 CLI 或 api 來上傳您的符號。如果您是使用 Breakpad 搭配 Android,則支援在 ANDROID NDK 檔中指定的兩個選項;如果您搭配使用 Breakpad 與 Windows,則僅支援選項2:「上傳 Breakpad 符號」。

注意

如果您要從 macOS 上傳符號,則必須清除任何無關資料夾的符號,例如,產生 __MACOS,並刪除您可以使用的符號 zip -d <symbols.zip> __MACOSX/\*

上傳錯誤報表

目前只支援 Android、Xamarin、Unity、UWP、WPF 和 WinForms apps 的處理錯誤。 若要上傳錯誤報表,請確定記錄類型已設為 "handledError"。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs":
  [
    {
      "type": "handledError",
      "timestamp": "2019-10-08T06:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "id": "118dee14-9193-4ac3-9ef0-f6c11b43f2c4",
      "device": {
        "appVersion": "11.0",
        "appBuild": "1",
        "sdkName": "custom.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      },
      "userId": "TestID",
      "exception": {
        "type": "System.IO.IOException",
        "message": "Server did not respond",
        "stackTrace": "  at Contoso.Forms.Puppet.FakeService+<>c.<DoStuffInBackground>b__0_0 () [0x00000] in <7ad93f134a5d4c00a8db8be9aa9c0f76>:0 \n  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Threading.Tasks.Task.Execute () [0x00010] in <b38d4262627948c1b945a72f56ce6466>:0 \n--- End of stack trace from previous location where exception was thrown ---\n  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <b38d4262627948c1b945a72f56ce6466>:0 \n  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <b38d4262627948c1b945a72f56ce6466>:0",
        "innerExceptions": [
          {
            "type": "System.IO.IOException",
            "message": "Network down",
            "stackTrace": "  at Contoso.Forms.Demo.CrashesContentPage.SendHttp () [0x00002] in <4fd9174f6e18457b9721bfba2cd78098>:0 ",
            "wrapperSdkName": "appcenter.xamarin"
          },
          {
            "type": "System.ArgumentException",
            "message": "Invalid parameter",
            "innerExceptions": [
              {
                "type": "System.ArgumentOutOfRangeException",
                "message": "It is over 9000!",
                "stackTrace": "  at Contoso.Forms.Demo.CrashesContentPage.ValidateLength () [0x00002] in <4fd9174f6e18457b9721bfba2cd78098>:0 ",
              }
            ],
          }
        ],
      }
    }
  ]
}'

上傳附件

所有的附件都必須與損毀報告相關聯。 您可以在單一呼叫中或在兩個不同的呼叫中,上傳具有損毀報告的附件。

附加元件的特定屬性:

  • contentType:需要內容類型的字串,例如文字的 "text/純文字"。 您可以在這裡找到所支援類型的範例
  • data:需要的字串,其資料編碼為 base 64
  • errorId:必要字串,其中包含附件相關錯誤報表的唯一識別碼
  • fileName:設定為 "小型傾印" 的 NDK 損毀所需的字串

注意

附件的大小限制目前為 7 MB。 嘗試傳送較大的附件將會觸發錯誤。

以下是在一個呼叫中上傳損毀報表和附件的範例。

curl -X POST \
  'https://in.appcenter.ms/logs?Api-Version=1.0.0' \
  -H 'Content-Type: application/json' \
  -H 'app-secret: 8e14e67c-7c91-40ac-8517-c62ece8424a6' \
  -H 'install-id: 00000000-0000-0000-0000-000000000001' \
  -d '{
  "logs": [
    {
      "type": "managedError",
      "timestamp": "2019-10-01T02:22:23.516Z",
      "appLaunchTimestamp": "2019-09-29T22:22:23.516Z",
      "id": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "fatal": true,
      "processName": "com.microsoft.appcenter.sasquatch.project",
      "device": {
        "appVersion": "13.0",
        "appBuild": "1",
        "sdkName": "appcenter.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      },
      "userId": "118dee14",
      "fatal": true,
      "exception": {
          "type": "CustomerIssue",
          "frames": []
      }
    },
    {
      "type": "errorAttachment",
      "contentType": "text/plain",
      "timestamp": "2019-10-01T02:22:23.516Z",
      "data": "aGVsbG8=",
      "errorId": "bca65f46-46ee-451b-83bb-2e358c3f45bf",
      "id": "7caaea8e-dab1-4588-993c-95de2d9a4fd1",
      "device": {
        "appVersion": "13.0",
        "appBuild": "1",
        "sdkName": "appcenter.android",
        "sdkVersion": "1.0.0",
        "osName": "android",
        "osVersion": "9.3",
        "model": "Pixel",
        "locale": "en-US"
      }
    }
  ]
}'