From 44e0e2483a6ee9ead4a143213137ad8fb0fc1d7a Mon Sep 17 00:00:00 2001
From: Daniel <mytechde@outlook.com>
Date: Wed, 4 Apr 2018 18:25:34 +0200
Subject: [PATCH] feat(plugin): add Microsoft App Center Crashes plugin

---
 .../plugins/app-center-crashes/index.ts       | 115 ++++++++++++++++++
 1 file changed, 115 insertions(+)
 create mode 100644 src/@ionic-native/plugins/app-center-crashes/index.ts

diff --git a/src/@ionic-native/plugins/app-center-crashes/index.ts b/src/@ionic-native/plugins/app-center-crashes/index.ts
new file mode 100644
index 00000000..ca4357da
--- /dev/null
+++ b/src/@ionic-native/plugins/app-center-crashes/index.ts
@@ -0,0 +1,115 @@
+import { Injectable } from '@angular/core';
+import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
+
+export interface AppCenterCrashReport {
+  id: string;
+  device: AppCenterCrashReportDevice;
+  appStartTime: number;
+  appErrorTime: number;
+  signal: string;
+  appProcessIdentifier: number;
+}
+
+export interface AppCenterCrashReportDevice {
+  oem_name: string;
+  os_name: string;
+  app_version: string;
+  time_zone_offset: number;
+  carrier_name: string;
+  screen_size: string;
+  locale: string;
+  sdk_version: string;
+  carrier_country: string;
+  os_build: string;
+  app_namespace: string;
+  os_version: string;
+  sdk_name: string;
+  model: string;
+  app_build: string;
+}
+
+/**
+ * @name App Center Crashes
+ * @description
+ * App Center Analytics helps you understand user behavior and customer engagement to improve your app.
+ * The SDK automatically captures session count and device properties like model, OS version, etc.
+ * You can define your own custom events to measure things that matter to you.
+ * All the information captured is available in the App Center portal for you to analyze the data.
+ *
+ * For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/crashes/cordova
+ *
+ * @usage
+ * ```typescript
+ * import { AppCenterCrashes } from '@ionic-native/app-center-crashes';
+ *
+ *
+ * constructor(private AppCenterCrashes: AppCenterCrashes) { }
+ *
+ * ...
+ *
+ * this.AppCenterCrashes.setEnabled(true).then(() => {
+ *    this.AppCenterCrashes.lastSessionCrashReport().then(report => {
+ *        console.log('Crash report', report);
+ *    });
+ * });
+ *
+ * ```
+ * @interfaces
+ * AppCenterCrashReport
+ * AppCenterCrashReportDevice
+ */
+@Plugin({
+  pluginName: 'AppCenterCrashes',
+  plugin: 'cordova-plugin-appcenter-crashes',
+  pluginRef: 'AppCenter.Crashes',
+  repo:
+    'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-crashes',
+  platforms: ['Android', 'iOS']
+})
+@Injectable()
+export class AppCenterCrashes extends IonicNativePlugin {
+  /**
+   * App Center Crashes provides you with an API to generate a test crash for easy testing of the SDK.
+   * This API can only be used in test/beta apps and won't do anything in production apps.
+   * @returns void
+   */
+  @Cordova()
+  generateTestCrash(): void {}
+
+  /**
+   * At any time after starting the SDK, you can check if the app crashed in the previous launch
+   * @returns {Promise<boolean>}
+   */
+  @Cordova()
+  hasCrashedInLastSession(): Promise<boolean> {
+    return;
+  }
+
+  /**
+   * Details about the last crash
+   * @returns {Promise<AppCenterCrashReport>}
+   */
+  @Cordova()
+  lastSessionCrashReport(): Promise<AppCenterCrashReport> {
+    return;
+  }
+
+  /**
+   * Check if App Center Crashes is enabled
+   * @returns {Promise<boolean>}
+   */
+  @Cordova()
+  isEnabled(): Promise<boolean> {
+    return;
+  }
+
+  /**
+   * Enable or disable App Center Crashes at runtime
+   * @param  {boolean} shouldEnable Set value
+   * @returns {Promise<void>}
+   */
+  @Cordova()
+  setEnabled(shouldEnable: boolean): Promise<void> {
+    return;
+  }
+}