diff --git a/README.md b/README.md
index 10bfc21..0d66b18 100644
--- a/README.md
+++ b/README.md
@@ -43,21 +43,21 @@ Example:
-
+
AppSecret
{APP_SECRET_VALUE}
LogLevel
- 2
- AnalyticsEnableInJs
-
+ 2
+ AnalyticsEnableInJs
+
AnalyticsTransmissionInterval
- 3
+ 3
CrashesEnableInJs
-
+
CrashesAlwaysSend
-
-
+
+
```
diff --git a/appcenter-crashes/CHANGELOG.md b/appcenter-crashes/CHANGELOG.md
new file mode 100644
index 0000000..326b499
--- /dev/null
+++ b/appcenter-crashes/CHANGELOG.md
@@ -0,0 +1,8 @@
+# Change Log
+
+## 0.3.0
+
+### Features
+
+* Add hasCrashedInLastSession api
+* Add lastSessionCrashReport api
diff --git a/appcenter-crashes/LICENSE b/appcenter-crashes/LICENSE
new file mode 100644
index 0000000..9c5a1fa
--- /dev/null
+++ b/appcenter-crashes/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) COPYRIGHT_YEAR COPYRIGHT_HOLDER
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/appcenter-crashes/README.md b/appcenter-crashes/README.md
index 3fc9179..cc5e34e 100644
--- a/appcenter-crashes/README.md
+++ b/appcenter-crashes/README.md
@@ -1,6 +1,35 @@
-# @capacitor-community/appcenter-crashes
-
-App Center Crashes will automatically generate a crash log every time your app crashes. The log is first written to the device's storage and when the user starts the app again, the crash report will be sent to App Center. Collecting crashes works for both beta and live apps, i.e. those submitted to the App Store. Crash logs contain valuable information for you to help fix the crash.
+
+
+App Center Crashes
+@capacitor-community/appcenter-crashes
+
+ App Center Crashes will automatically generate a crash log every time your app crashes. The log is first written to the device's storage and when the user starts the app again, the crash report will be sent to App Center. Collecting crashes works for both beta and live apps, i.e. those submitted to the App Store. Crash logs contain valuable information for you to help fix the crash.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Maintainers
+
+| Maintainer | GitHub | Social |
+| -----------| -------| -------|
+| John Borges | [johnborges](https://github.com/johnborges) | [@johnborges](https://twitter.com/johnborges) |
+
+## Features
+
+- Generate test crashes
+- Get more information about a previous crash
+- Customize how crashes are processed
+- Enable or disable App Center Crashes at runtime
## Install
@@ -17,6 +46,9 @@ npx cap sync
* [`setEnabled(...)`](#setenabled)
* [`generateTestCrash()`](#generatetestcrash)
* [`hasReceivedMemoryWarningInLastSession()`](#hasreceivedmemorywarninginlastsession)
+* [`hasCrashedInLastSession()`](#hascrashedinlastsession)
+* [`lastSessionCrashReport()`](#lastsessioncrashreport)
+* [Interfaces](#interfaces)
@@ -87,4 +119,74 @@ Check if app recieved memory warning in the last session.
--------------------
+
+### hasCrashedInLastSession()
+
+```typescript
+hasCrashedInLastSession() => any
+```
+
+Check if the app has crashed in the last session.
+
+**Returns:** any
+
+**Since:** 0.3.0
+
+--------------------
+
+
+### lastSessionCrashReport()
+
+```typescript
+lastSessionCrashReport() => any
+```
+
+Provides details about the crash that occurred in the last app session.
+
+**Returns:** any
+
+**Since:** 0.3.0
+
+--------------------
+
+
+### Interfaces
+
+
+#### ErrorReport
+
+| Prop | Type |
+| -------------------------- | ----------------------------------------- |
+| **`id`** | string
|
+| **`threadName`** | string
|
+| **`appErrorTime`** | string \| number
|
+| **`appStartTime`** | string \| number
|
+| **`exceptionName`** | string
|
+| **`exceptionReason`** | string
|
+| **`device`** | Device
|
+| **`signal`** | string
|
+| **`appProcessIdentifier`** | number
|
+
+
+#### Device
+
+| Prop | Type |
+| -------------------- | ------------------- |
+| **`sdkName`** | string
|
+| **`sdkVersion`** | string
|
+| **`model`** | string
|
+| **`oemName`** | string
|
+| **`osName`** | string
|
+| **`osVersion`** | string
|
+| **`osBuild`** | string
|
+| **`osApiLevel`** | number
|
+| **`locale`** | string
|
+| **`timeZoneOffset`** | number
|
+| **`screenSize`** | string
|
+| **`appVersion`** | string
|
+| **`carrierName`** | string
|
+| **`carrierCountry`** | string
|
+| **`appBuild`** | string
|
+| **`appNamespace`** | string
|
+
diff --git a/appcenter-crashes/ios/Plugin/AppCenterCrashesBase.swift b/appcenter-crashes/ios/Plugin/AppCenterCrashesBase.swift
index 634d426..6b87df4 100644
--- a/appcenter-crashes/ios/Plugin/AppCenterCrashesBase.swift
+++ b/appcenter-crashes/ios/Plugin/AppCenterCrashesBase.swift
@@ -24,4 +24,12 @@ import AppCenterCrashes
public func hasReceivedMemoryWarningInLastSession() -> Bool {
return Crashes.hasReceivedMemoryWarningInLastSession
}
+
+ public func hasCrashedInLastSession() -> Bool {
+ return Crashes.hasCrashedInLastSession
+ }
+
+ public func lastSessionCrashReport() -> Dictionary? {
+ return CrashesUtil.convertReportToJs(report: Crashes.lastSessionCrashReport)
+ }
}
diff --git a/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.m b/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.m
index a6d75c6..afdc5dd 100644
--- a/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.m
+++ b/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.m
@@ -6,6 +6,9 @@
CAP_PLUGIN(CrashesPlugin, "Crashes",
CAP_PLUGIN_METHOD(setEnabled, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(isEnabled, CAPPluginReturnPromise);
- CAP_PLUGIN_METHOD(generateTestCrash, CAPPluginReturnPromise);
+ CAP_PLUGIN_METHOD(generateTestCrash, CAPPluginReturnNone);
CAP_PLUGIN_METHOD(hasReceivedMemoryWarningInLastSession, CAPPluginReturnPromise);
+ CAP_PLUGIN_METHOD(hasCrashedInLastSession, CAPPluginReturnPromise);
+ CAP_PLUGIN_METHOD(lastSessionCrashReport, CAPPluginReturnPromise);
+
)
diff --git a/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.swift b/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.swift
index c7a57b0..1ee60c0 100644
--- a/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.swift
+++ b/appcenter-crashes/ios/Plugin/AppCenterCrashesPlugin.swift
@@ -19,6 +19,7 @@ public class CrashesPlugin: CAPPlugin {
let alwaysSendCrashes = config["CrashesAlwaysSend"] as? Bool
if AppCenterCapacitorShared.isSdkConfigured() {
+ print("[CrashesPlugin] starting")
implementation.start()
}
}
@@ -38,6 +39,26 @@ public class CrashesPlugin: CAPPlugin {
}
@objc func hasReceivedMemoryWarningInLastSession(_ call: CAPPluginCall) {
- call.resolve(["value": implementation.hasReceivedMemoryWarningInLastSession()])
+ DispatchQueue.main.async {
+ call.resolve(["value": self.implementation.hasReceivedMemoryWarningInLastSession()])
+ }
}
+
+ @objc func hasCrashedInLastSession(_ call: CAPPluginCall) {
+ DispatchQueue.main.async {
+ call.resolve(["value": self.implementation.hasCrashedInLastSession()])
+ }
+ }
+
+ @objc func lastSessionCrashReport(_ call: CAPPluginCall) {
+ DispatchQueue.main.async {
+ guard let report = self.implementation.lastSessionCrashReport() else {
+ call.reject("No crash report available")
+ return
+ }
+
+ call.resolve(["value": report])
+ }
+ }
+
}
diff --git a/appcenter-crashes/ios/Plugin/AppCenterCrashesUtil.swift b/appcenter-crashes/ios/Plugin/AppCenterCrashesUtil.swift
index 7f8bee7..e0e49db 100644
--- a/appcenter-crashes/ios/Plugin/AppCenterCrashesUtil.swift
+++ b/appcenter-crashes/ios/Plugin/AppCenterCrashesUtil.swift
@@ -2,142 +2,108 @@ import Foundation
import AppCenterCrashes
/**
- Utility class containing helpers for converting App Center objects.
+ Utility class containing helpers for converting App Center objects.
*/
public class CrashesUtil {
- static let kMSSdkName: String = "sdkName";
- static let kMSSdkVersion: String = "sdkVersion";
- static let kMSModel: String = "model";
- static let kMSOemName: String = "oemName";
- static let kMSOsName: String = "osName";
- static let kMSOsVersion: String = "osVersion";
- static let kMSOsBuild: String = "osBuild";
- static let kMSOsApiLevel: String = "osApiLevel";
- static let kMSLocale: String = "locale";
- static let kMSTimeZoneOffset: String = "timeZoneOffset";
- static let kMSScreenSize: String = "screenSize";
- static let kMSAppVersion: String = "appVersion";
- static let kMSCarrierName: String = "carrierName";
- static let kMSCarrierCountry: String = "carrierCountry";
- static let kMSAppBuild: String = "appBuild";
- static let kMSAppNamespace: String = "appNamespace";
+ static let kMSSdkName: String = "sdkName";
+ static let kMSSdkVersion: String = "sdkVersion";
+ static let kMSModel: String = "model";
+ static let kMSOemName: String = "oemName";
+ static let kMSOsName: String = "osName";
+ static let kMSOsVersion: String = "osVersion";
+ static let kMSOsBuild: String = "osBuild";
+ static let kMSOsApiLevel: String = "osApiLevel";
+ static let kMSLocale: String = "locale";
+ static let kMSTimeZoneOffset: String = "timeZoneOffset";
+ static let kMSScreenSize: String = "screenSize";
+ static let kMSAppVersion: String = "appVersion";
+ static let kMSCarrierName: String = "carrierName";
+ static let kMSCarrierCountry: String = "carrierCountry";
+ static let kMSAppBuild: String = "appBuild";
+ static let kMSAppNamespace: String = "appNamespace";
- /**
- Serializes App Center Device properties to Dictionary
- - Parameter device: App Center Device
- - Returns Device Dictionary
+ /**
+ Serializes App Center Device properties to Dictionary
+ - Parameter device: App Center Device
+ - Returns Device Dictionary
*/
- public func serializeDeviceToDictionary(device: Device) -> Dictionary {
- var dict = [String: Any]()
+ public static func serializeDeviceToDictionary(device: Device) -> Dictionary {
+ var dict = [String: Any]()
- if !device.sdkName.isEmpty {
- dict[CrashesUtil.kMSSdkName] = device.sdkName;
- }
- if !device.sdkName.isEmpty {
- dict[CrashesUtil.kMSSdkVersion] = device.sdkVersion;
- }
- if !device.model.isEmpty {
- dict[CrashesUtil.kMSModel] = device.model;
- }
- if !device.oemName.isEmpty {
- dict[CrashesUtil.kMSOemName] = device.oemName;
- }
- if !device.osName.isEmpty {
- dict[CrashesUtil.kMSOsName] = device.osName;
- }
- if !device.osVersion.isEmpty {
- dict[CrashesUtil.kMSOsVersion] = device.osVersion;
- }
- if !device.osBuild.isEmpty {
- dict[CrashesUtil.kMSOsBuild] = device.osBuild;
- }
- if device.osApiLevel != nil {
- dict[CrashesUtil.kMSOsApiLevel] = device.osApiLevel!;
- }
- if !device.locale.isEmpty {
- dict[CrashesUtil.kMSLocale] = device.locale;
- }
- if device.timeZoneOffset != nil {
- dict[CrashesUtil.kMSTimeZoneOffset] = device.timeZoneOffset!;
- }
- if !device.screenSize.isEmpty {
- dict[CrashesUtil.kMSScreenSize] = device.screenSize;
- }
- if !device.appVersion.isEmpty {
- dict[CrashesUtil.kMSAppVersion] = device.appVersion;
- }
- if !device.carrierName.isEmpty {
- dict[CrashesUtil.kMSCarrierName] = device.carrierName;
- }
- if !device.carrierCountry.isEmpty {
- dict[CrashesUtil.kMSCarrierCountry] = device.carrierCountry;
- }
- if !device.appBuild.isEmpty {
- dict[CrashesUtil.kMSAppBuild] = device.appBuild;
- }
- if !device.appNamespace.isEmpty {
- dict[CrashesUtil.kMSAppNamespace] = device.appNamespace;
- }
- return dict;
- }
+ dict[CrashesUtil.kMSSdkName] = device.sdkName;
+ dict[CrashesUtil.kMSSdkVersion] = device.sdkVersion;
+ dict[CrashesUtil.kMSModel] = device.model;
+ dict[CrashesUtil.kMSOemName] = device.oemName;
+ dict[CrashesUtil.kMSOsName] = device.osName;
+ dict[CrashesUtil.kMSOsVersion] = device.osVersion;
+
+ if device.osBuild != nil {
+ dict[CrashesUtil.kMSOsBuild] = device.osBuild!;
+ }
+ if device.osApiLevel != nil {
+ dict[CrashesUtil.kMSOsApiLevel] = device.osApiLevel!;
+ }
+
+ dict[CrashesUtil.kMSLocale] = device.locale;
+ dict[CrashesUtil.kMSTimeZoneOffset] = device.timeZoneOffset;
+ dict[CrashesUtil.kMSScreenSize] = device.screenSize;
+ dict[CrashesUtil.kMSAppVersion] = device.appVersion;
+
+ if device.carrierName != nil {
+ dict[CrashesUtil.kMSCarrierName] = device.carrierName!;
+ }
+ if device.carrierCountry != nil {
+ dict[CrashesUtil.kMSCarrierCountry] = device.carrierCountry!;
+ }
+
+ dict[CrashesUtil.kMSAppBuild] = device.appBuild;
+
+ if device.appNamespace != nil {
+ dict[CrashesUtil.kMSAppNamespace] = device.appNamespace!;
+ }
+
+ return dict;
+ }
/**
Converts App Center ErrorReport to Dictionary
- Parameter report: App Center ErrorReport
- Returns JS optional Dictionary
*/
- public func convertReportToJs(report: ErrorReport?) -> Dictionary? {
+ public static func convertReportToJs(report: ErrorReport?) -> Dictionary? {
- guard let actualReport = report else {
- return nil
- }
+ guard let actualReport = report else {
+ return nil
+ }
- var dict = [String: Any]()
-
- let identifier: String = actualReport.incidentIdentifier
- if !identifier.isEmpty {
- dict["id"] = identifier
- }
-
- let processIdentifier: UInt = actualReport.appProcessIdentifier
- dict["appProcessIdentifier"] = String(processIdentifier)
-
- let startTime: Date? = actualReport.appStartTime
- if startTime != nil {
- dict["appStartTime"] = String(startTime!.timeIntervalSince1970)
- }
-
- let errTime: Date? = actualReport.appErrorTime
- if errTime != nil {
- dict["appErrorTime"] = errTime!.timeIntervalSince1970
- }
-
- let exceptionName: String = actualReport.exceptionName
- if !exceptionName.isEmpty {
- dict["exceptionName"] = exceptionName
- }
-
- let exceptionReason: String = actualReport.exceptionReason
- if !exceptionReason.isEmpty {
- dict["exceptionReason"] = exceptionReason
- }
-
- let signal: String = actualReport.signal
- if !signal.isEmpty {
- dict["signal"] = signal
- }
-
- dict["device"] = serializeDeviceToDictionary(device: actualReport.device)
+ var dict = [String: Any]()
- return dict
+ dict["id"] = actualReport.incidentIdentifier
+ dict["signal"] = actualReport.signal
+ if let exceptionName = actualReport.exceptionName {
+ dict["exceptionName"] = exceptionName
+ }
+ if let exceptionReason = actualReport.exceptionReason {
+ dict["exceptionReason"] = exceptionReason
+ }
+ if let startTime = actualReport.appStartTime {
+ dict["appStartTime"] = String(startTime.timeIntervalSince1970)
+ }
+ if let errTime = actualReport.appErrorTime {
+ dict["appErrorTime"] = String(errTime.timeIntervalSince1970)
+ }
+ dict["device"] = serializeDeviceToDictionary(device: actualReport.device)
+ dict["appProcessIdentifier"] = actualReport.appProcessIdentifier
+
+ return dict
}
/**
- Converts arrat of App Center ErrorReports to a Dictionary
+ Converts array of App Center ErrorReports to a Dictionary
- Parameter reports: App Center ErrorReport
- Returns Array of Dictionaries
*/
- public func convertReportsToJS (reports: [ErrorReport]) -> [[String: Any]] {
+ public static func convertReportsToJS (reports: [ErrorReport]) -> [[String: Any]] {
var jsReadyReports = [[String: Any]]()
for (index, value) in reports.enumerated() {
guard let convertedReport = convertReportToJs(report: value) else {
diff --git a/appcenter-crashes/package.json b/appcenter-crashes/package.json
index 2753f60..90f2154 100644
--- a/appcenter-crashes/package.json
+++ b/appcenter-crashes/package.json
@@ -1,6 +1,6 @@
{
"name": "@capacitor-community/appcenter-crashes",
- "version": "0.2.0",
+ "version": "0.3.0",
"description": "Capacitor plugin for Microsoft AppCenter Crashes.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
diff --git a/appcenter-crashes/src/definitions.ts b/appcenter-crashes/src/definitions.ts
index 6272369..d4b064e 100644
--- a/appcenter-crashes/src/definitions.ts
+++ b/appcenter-crashes/src/definitions.ts
@@ -5,34 +5,58 @@ export enum UserConfirmation {
}
export interface Device {
+ /* Name of the SDK. Consists of the name of the SDK and the platform, e.g. "appcenter.ios", "appcenter.android" */
sdkName: string;
+ /* Version of the SDK in semver format, e.g. "1.2.0" or "0.12.3-alpha.1". */
sdkVersion: string;
+ /* Device model (example: iPad2,3). */
model: string;
+ /* Device manufacturer (example: HTC). */
oemName: string;
+ /* OS name (example: iOS). */
osName: string;
+ /* OS version (example: 9.3.0). */
osVersion: string;
- osBuild: string;
+ /* OS build code (example: LMY47X). */
+ osBuild?: string;
+ /* API level when applicable like in Android (example: 15). */
osApiLevel?: number;
+ /* Language code (example: en_US). */
locale: string;
+ /* The offset in minutes from UTC for the device time zone, including daylight savings time. */
timeZoneOffset: number;
- screenSize?: string;
+ /* Screen size of the device in pixels (example: 640x480). */
+ screenSize: string;
+ /* Application version name, e.g. 1.1.0 */
appVersion: string;
+ /* Carrier name (for mobile devices). */
carrierName?: string;
+ /* Carrier country code (for mobile devices). */
carrierCountry?: string;
+ /* The app's build number, e.g. 42. */
appBuild: string;
- appNamespace: string;
+ /* The bundle identifier, package identifier, or namespace, depending on what the individual plattforms use, .e.g com.microsoft.example. */
+ appNamespace?: string;
}
export interface ErrorReport {
+ /* UUID for the crash report. */
id: string;
threadName?: string;
- appErrorTime: string | number;
- appStartTime: string | number;
- exception?: string;
+ /* Date and time the error occurred. */
+ appErrorTime?: string | number;
+ /* Date and time the app started. */
+ appStartTime?: string | number;
+ /* Exception name that triggered the crash. */
+ exceptionName?: string;
+ /* Exception reason. */
exceptionReason?: string;
+ /* Device information of the app when it crashed. */
device: Device;
- signal?: string;
- appProcessIdentifier?: number;
+ /* Signal that caused the crash. */
+ signal: string;
+ /* Identifier of the app process that crashed. */
+ appProcessIdentifier: number;
}
export interface CrashesListener {
@@ -103,10 +127,30 @@ export interface CrashesPlugin {
* const { value: gotMemWarning } = await Crashes.hasReceivedMemoryWarningInLastSession();
*/
hasReceivedMemoryWarningInLastSession(): Promise<{value: boolean}>;
+
+ /**
+ * Check if the app has crashed in the last session.
+ * @returns {Promise<{value: boolean}>}
+ * @since 0.3.0
+ * @example
+ * import Crashes from '@capacitor-community/appcenter-crashes';
+ *
+ * const { value: hasCrashed } = await Crashes.hasCrashedInLastSession();
+ */
+ hasCrashedInLastSession(): Promise<{ value: boolean}>;
+
+ /**
+ * Provides details about the crash that occurred in the last app session.
+ * @returns {Promise<{value: ErrorReport}>}
+ * @since 0.3.0
+ * @example
+ * import Crashes from '@capacitor-community/appcenter-crashes';
+ *
+ * const { value: crashReport } = await Crashes.lastSessionCrashReport();
+ */
+ lastSessionCrashReport(): Promise<{value: ErrorReport}>;
}
// convert
-// export function hasCrashedInLastSession(): Promise;
-// export function lastSessionCrashReport(): Promise;
// export function notifyUserConfirmation(userConfirmation: UserConfirmation): void;
// export function setListener(crashesListener: CrashesListener): Promise;
diff --git a/appcenter-crashes/src/web.ts b/appcenter-crashes/src/web.ts
index e810c76..ed0cce5 100644
--- a/appcenter-crashes/src/web.ts
+++ b/appcenter-crashes/src/web.ts
@@ -1,10 +1,16 @@
import { WebPlugin } from '@capacitor/core';
-import type { CrashesPlugin } from './definitions';
+import { CrashesPlugin, ErrorReport } from './definitions';
export class CrashesWeb
extends WebPlugin
implements CrashesPlugin {
+ lastSessionCrashReport(): Promise<{ value: ErrorReport; }> {
+ throw new Error('Method not implemented.');
+ }
+ hasCrashedInLastSession(): Promise<{ value: boolean; }> {
+ throw this.unimplemented('Not supported on web.');
+ }
hasReceivedMemoryWarningInLastSession(): Promise<{ value: boolean; }> {
throw this.unimplemented('Not supported on web.');
}
diff --git a/example/ios/App/App/AppCenter-Config.plist b/example/ios/App/App/AppCenter-Config.plist
index 236aaa8..e6f5a4f 100644
--- a/example/ios/App/App/AppCenter-Config.plist
+++ b/example/ios/App/App/AppCenter-Config.plist
@@ -5,7 +5,7 @@
AnalyticsTransmissionInterval
10
AnalyticsEnableInJs
-
+
AppSecret
fb3a28d5-1ed9-401c-b06a-0379f66c8650
LogLevel
diff --git a/example/src/components/app-crashes/app-crashes.tsx b/example/src/components/app-crashes/app-crashes.tsx
index 206d87f..0ff5608 100644
--- a/example/src/components/app-crashes/app-crashes.tsx
+++ b/example/src/components/app-crashes/app-crashes.tsx
@@ -1,6 +1,6 @@
import { Component, State, h } from '@stencil/core';
import { ToggleChangeEventDetail } from '@ionic/core';
-import Crashes from '@capacitor-community/appcenter-crashes';
+import Crashes, { ErrorReport } from '@capacitor-community/appcenter-crashes';
@Component({
tag: 'app-crashes',
@@ -10,6 +10,8 @@ export class AppCrashes {
/* Flag to toggle entire Crashes service */
@State() enabled: boolean = false
@State() memoryWarning: boolean = false
+ @State() hasCrashed: boolean = false
+ @State() crashReport: ErrorReport
constructor() {
this.toggleCrashes = this.toggleCrashes.bind(this);
@@ -20,10 +22,14 @@ export class AppCrashes {
try {
const { value: crashesEnabled } = await Crashes.isEnabled();
const { value: memoryWarning } = await Crashes.hasReceivedMemoryWarningInLastSession();
+ const { value: hasCrashed } = await Crashes.hasCrashedInLastSession();
+ const { value: crashReport } = await Crashes.lastSessionCrashReport();
this.enabled = crashesEnabled
this.memoryWarning = memoryWarning
- console.debug(`got mem warning: ${this.memoryWarning}`)
+ this.hasCrashed = hasCrashed
+ console.debug(crashReport)
+
} catch (error) {
console.error(error)
}
@@ -54,29 +60,46 @@ export class AppCrashes {
- Crashes
,
+ App Center Crashes
+ App Center Crashes will automatically generate a crash log every time your app crashes.
+
- Enable Analytics
+ Enable Crashes
this.toggleCrashes(e)} />
-
- Previous Crash Info
-
Memory Warning
{this.memoryWarning.toString()}
+
+ Crashed Prior
+ {this.hasCrashed.toString()}
+
-
+
+
+
+
+ Crash Report
+
+
+ { this.crashReport ? Object.keys(this.crashReport).map(key => {
+
+ {key}
+
+ }) : null}
+
+
+
,
];
}