UNPKG

nativescript-fabric

Version:
93 lines 3.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var application = require("application"); var fabric_common_1 = require("./fabric-common"); var fabric_appdelegate_1 = require("./fabric.appdelegate"); var CrashlyticsIOSPlugin = (function () { function CrashlyticsIOSPlugin() { this.initDone = false; } CrashlyticsIOSPlugin.prototype.getErrorDetails = function (args) { var error = args.ios; return error; }; CrashlyticsIOSPlugin.prototype.init = function () { var _this = this; if (application.ios) { application.ios.delegate = fabric_appdelegate_1.FabricAppDelegate; this.initDone = true; } application.on('uncaughtError', function (args) { if (application.ios) { _this.logError(args); } }); }; CrashlyticsIOSPlugin.prototype.logSignUp = function (method, success) { if (this.initDone) { try { Answers.logSignUpWithMethodSuccessCustomAttributes(method, success, null); } catch (e) { console.error('Unknown logging signup in Fabric', e); } } }; CrashlyticsIOSPlugin.prototype.logLogin = function (method, success) { if (this.initDone) { try { Answers.logLoginWithMethodSuccessCustomAttributes(method, success, null); } catch (e) { console.error('Unknown logging login in Fabric', e); } } }; CrashlyticsIOSPlugin.prototype.logContentView = function (id, name, type) { if (this.initDone) { try { Answers.logContentViewWithNameContentTypeContentIdCustomAttributes(name, type, id, null); } catch (e) { console.error('Unknown logging content view in Fabric', e); } } }; CrashlyticsIOSPlugin.prototype.logCustomEvent = function (withName, customAttributes) { if (this.initDone) { try { var attributes_1 = {}; if (!!customAttributes) { customAttributes.forEach(function (value, key) { attributes_1[key] = value; }); } Answers.logCustomEventWithNameCustomAttributes(withName, attributes_1); } catch (e) { console.error('Unknown logging custom event in Fabric', e); } } }; CrashlyticsIOSPlugin.prototype.logError = function (error, msg) { if (this.initDone) { try { if (!!msg) { Crashlytics.sharedInstance().setObjectValueForKey('' + msg, "msg"); } if (!error.ios) { Crashlytics.sharedInstance().recordError({ domain: msg ? msg : 'error', code: 0, userInfo: null }); } else { Crashlytics.sharedInstance().recordError(this.getErrorDetails(error)); } } catch (e) { console.error('Unknown logging error in Fabric', e); } } }; return CrashlyticsIOSPlugin; }()); exports.Fabric = fabric_common_1.getInstance(CrashlyticsIOSPlugin); //# sourceMappingURL=fabric.ios.js.map