1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
7 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
8 | };
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | const insight_1 = __importDefault(require("insight"));
|
11 | const path_1 = __importDefault(require("path"));
|
12 | const read_json_sync_1 = __importDefault(require("read-json-sync"));
|
13 | const GA_TOKEN = 'UA-37033501-13';
|
14 | let insight;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | function init() {
|
20 | return new Promise(resolve => {
|
21 | try {
|
22 | const projectPkgJson = read_json_sync_1.default(path_1.default.join(process.cwd(), 'package.json'));
|
23 | exports.PROJECT_NAME = projectPkgJson.name;
|
24 | exports.PROJECT_VERSION = projectPkgJson.version;
|
25 | insight = new insight_1.default({
|
26 | trackingCode: GA_TOKEN,
|
27 | pkg: require('../package.json'),
|
28 | });
|
29 | }
|
30 | catch (err) {
|
31 |
|
32 | }
|
33 | if (insight && insight.optOut === undefined) {
|
34 | insight.askPermission(undefined, resolve);
|
35 | }
|
36 | else {
|
37 | resolve();
|
38 | }
|
39 | });
|
40 | }
|
41 | exports.init = init;
|
42 | exports.track = (...args) => {
|
43 | if (insight) {
|
44 | insight.track(insight.config.get('clientId'), insight.PROJECT_NAME, ...args);
|
45 | }
|
46 | };
|