UNPKG

1.35 kBJavaScriptView Raw
1/**
2 * @hidden
3 */
4var Core = (function () {
5 function Core(deps) {
6 /**
7 * @private
8 */
9 this._version = '0.16.2';
10 this.config = deps.config;
11 this.logger = deps.logger;
12 this.emitter = deps.emitter;
13 this.insights = deps.insights;
14 }
15 Core.prototype.init = function () {
16 this.registerEventHandlers();
17 this.onResume();
18 };
19 Object.defineProperty(Core.prototype, "version", {
20 get: function () {
21 return this._version;
22 },
23 enumerable: true,
24 configurable: true
25 });
26 /**
27 * @private
28 */
29 Core.prototype.onResume = function () {
30 if (this.insights.options.enabled) {
31 this.insights.track('mobileapp.opened');
32 }
33 };
34 /**
35 * @private
36 */
37 Core.prototype.registerEventHandlers = function () {
38 var _this = this;
39 this.emitter.on('cordova:resume', function () {
40 _this.onResume();
41 });
42 this.emitter.on('push:notification', function (data) {
43 if (data.message.app.asleep || data.message.app.closed) {
44 if (_this.insights.options.enabled) {
45 _this.insights.track('mobileapp.opened.push');
46 }
47 }
48 });
49 };
50 return Core;
51}());
52export { Core };