1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 | var Core = (function () {
|
6 | function Core(deps) {
|
7 | |
8 |
|
9 |
|
10 | this._version = '0.11.0';
|
11 | this.config = deps.config;
|
12 | this.logger = deps.logger;
|
13 | this.emitter = deps.emitter;
|
14 | this.insights = deps.insights;
|
15 | if (!this.config.settings || !this.config.settings.core || !this.config.settings.core.app_id) {
|
16 | throw new Error('Missing app_id in cloud settings. Have you configured your app properly?');
|
17 | }
|
18 | }
|
19 | Core.prototype.init = function () {
|
20 | this.registerEventHandlers();
|
21 | this.onResume();
|
22 | };
|
23 | Object.defineProperty(Core.prototype, "version", {
|
24 | get: function () {
|
25 | return this._version;
|
26 | },
|
27 | enumerable: true,
|
28 | configurable: true
|
29 | });
|
30 | |
31 |
|
32 |
|
33 | Core.prototype.onResume = function () {
|
34 | this.insights.track('mobileapp.opened');
|
35 | };
|
36 | |
37 |
|
38 |
|
39 | Core.prototype.registerEventHandlers = function () {
|
40 | var _this = this;
|
41 | this.emitter.on('cordova:resume', function () {
|
42 | _this.onResume();
|
43 | });
|
44 | this.emitter.on('push:notification', function (data) {
|
45 | if (data.message.app.asleep || data.message.app.closed) {
|
46 | _this.insights.track('mobileapp.opened.push');
|
47 | }
|
48 | });
|
49 | };
|
50 | return Core;
|
51 | }());
|
52 | exports.Core = Core;
|
53 |
|
\ | No newline at end of file |