Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
7d377e31c2 | |||
fcb12d5734 | |||
febf6c1911 | |||
457ac52a14 | |||
495a3ffafd | |||
ffd1274f21 | |||
8e4ad6159a | |||
c5a2383fd3 | |||
2c25cd0655 | |||
370caae226 | |||
75c3979120 | |||
b5d792d58c | |||
05b80b618b | |||
511b7ee143 | |||
08d37dc037 |
@ -15,7 +15,9 @@ stages:
|
|||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -24,7 +26,9 @@ testLEGACY:
|
|||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -32,7 +36,9 @@ testLTS:
|
|||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -40,7 +46,8 @@ testSTABLE:
|
|||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci npm prepare
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
27
README.md
27
README.md
@ -22,23 +22,36 @@ Google Analytics everywhere
|
|||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
### Why does this package exist?
|
### Why does this package exist?
|
||||||
Tracking users in webapps is common. We use Google Analytics to gain insight in who is using what
|
Tracking users in webapps is common, often to gain insight in who is using what and where to spend dev resources for best efficiency.
|
||||||
and where to spend resources for best efficiency.
|
|
||||||
|
|
||||||
Doing the same stuff in apps can be a bit of a hassle.
|
Doing the same stuff in apps can be a bit of a hassle.
|
||||||
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
||||||
just to gain a little usage info.
|
just to gain a little usage info.
|
||||||
Say hello to smartanalytics.
|
|
||||||
It features a very slim dependency tree using the native node request module to send posts to Google Analytics.
|
**Say hello to smartanalytics. :)**
|
||||||
|
It features a very slim dependency tree using the native node request module to send posts to a tracking API of your choice.
|
||||||
|
|
||||||
### How do I use this package?
|
### How do I use this package?
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import {AnalyticsAccount} from 'smartanalytics'
|
import { Analytics } from 'smartanalytics'
|
||||||
let myAnalyticsAccount = new AnalyticsAccount('My App Name', 'UA-XXXXXX-Y')
|
let myAnalytics = new plugins.smartanalytics.Analytics({
|
||||||
myAnalyticsAccount.sendEvent('npmtool', 'install', 'somelabel')
|
apiEndPoint: 'https://somepubapi.endpoint.com',
|
||||||
|
projectId: 'gitzone',
|
||||||
|
appName: 'npmts'
|
||||||
|
})
|
||||||
|
|
||||||
|
myAnalytics.recordEvent('someEvent', {
|
||||||
|
myKey1: 'myValue1',
|
||||||
|
myKey2: 'myValue2',
|
||||||
|
myDataKey3: 3
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
10
dist/smartanalytics.classes.analytics.d.ts
vendored
10
dist/smartanalytics.classes.analytics.d.ts
vendored
@ -4,10 +4,10 @@ export declare class Analytics {
|
|||||||
apiEndPoint: string;
|
apiEndPoint: string;
|
||||||
secretKey: string;
|
secretKey: string;
|
||||||
constructor(optionsArg: {
|
constructor(optionsArg: {
|
||||||
projectIdArg: string;
|
projectId: string;
|
||||||
appNameArg: string;
|
appName: string;
|
||||||
apiEndPointArg: string;
|
apiEndPoint: string;
|
||||||
secretKeyArg?: string;
|
secretKey?: string;
|
||||||
});
|
});
|
||||||
recordEvent(identifierArg: string, analyticsDataArg: any): Promise<void>;
|
recordEvent(eventIdArg: string, analyticsDataArg: any): Promise<void>;
|
||||||
}
|
}
|
||||||
|
16
dist/smartanalytics.classes.analytics.js
vendored
16
dist/smartanalytics.classes.analytics.js
vendored
@ -12,19 +12,19 @@ const plugins = require("./smartanalytics.plugins");
|
|||||||
class Analytics {
|
class Analytics {
|
||||||
constructor(optionsArg) {
|
constructor(optionsArg) {
|
||||||
this.secretKey = '';
|
this.secretKey = '';
|
||||||
this.projectId = optionsArg.projectIdArg;
|
this.projectId = optionsArg.projectId;
|
||||||
this.appName = optionsArg.appNameArg;
|
this.appName = optionsArg.appName;
|
||||||
this.apiEndPoint = optionsArg.apiEndPointArg;
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
||||||
if (optionsArg.secretKeyArg) {
|
if (optionsArg.secretKey) {
|
||||||
this.secretKey = optionsArg.secretKeyArg;
|
this.secretKey = optionsArg.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recordEvent(identifierArg, analyticsDataArg) {
|
recordEvent(eventIdArg, analyticsDataArg) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let dataToSend = {
|
let dataToSend = {
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
appName: this.appName,
|
appName: this.appName,
|
||||||
identifier: identifierArg,
|
eventId: eventIdArg,
|
||||||
analyticsData: analyticsDataArg
|
analyticsData: analyticsDataArg
|
||||||
};
|
};
|
||||||
yield plugins.smartrequest.post(this.apiEndPoint, {
|
yield plugins.smartrequest.post(this.apiEndPoint, {
|
||||||
@ -40,4 +40,4 @@ class Analytics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Analytics = Analytics;
|
exports.Analytics = Analytics;
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuYWx5dGljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsb0RBQW1EO0FBRW5EO0lBS0UsWUFBYSxVQUtaO1FBTkQsY0FBUyxHQUFXLEVBQUUsQ0FBQTtRQU9wQixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxZQUFZLENBQUE7UUFDeEMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDLGNBQWMsQ0FBQTtRQUM1QyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUM1QixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxZQUFZLENBQUE7UUFDMUMsQ0FBQztJQUNILENBQUM7SUFFSyxXQUFXLENBQUUsYUFBcUIsRUFBRSxnQkFBcUI7O1lBQzdELElBQUksVUFBVSxHQUFHO2dCQUNmLFNBQVMsRUFBRSxJQUFJLENBQUMsU0FBUztnQkFDekIsT0FBTyxFQUFFLElBQUksQ0FBQyxPQUFPO2dCQUNyQixVQUFVLEVBQUUsYUFBYTtnQkFDekIsYUFBYSxFQUFFLGdCQUFnQjthQUNoQyxDQUFBO1lBQ0QsTUFBTSxPQUFPLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFO2dCQUNoRCxPQUFPLEVBQUU7b0JBQ1AsY0FBYyxFQUFFLElBQUksQ0FBQyxTQUFTO29CQUM5QixjQUFjLEVBQUUsa0JBQWtCO2lCQUNuQztnQkFDRCxXQUFXLEVBQUUsVUFBVTthQUN4QixDQUFDLENBQUMsS0FBSyxDQUFDLEdBQUc7Z0JBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtZQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNKLENBQUM7S0FBQTtDQUNGO0FBcENELDhCQW9DQyJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuYWx5dGljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsb0RBQW1EO0FBRW5EO0lBS0UsWUFBYSxVQUtaO1FBTkQsY0FBUyxHQUFXLEVBQUUsQ0FBQTtRQU9wQixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxTQUFTLENBQUE7UUFDckMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFBO1FBQ2pDLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDLFdBQVcsQ0FBQTtRQUN6QyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxTQUFTLENBQUE7UUFDdkMsQ0FBQztJQUNILENBQUM7SUFFSyxXQUFXLENBQUUsVUFBa0IsRUFBRSxnQkFBcUI7O1lBQzFELElBQUksVUFBVSxHQUFHO2dCQUNmLFNBQVMsRUFBRSxJQUFJLENBQUMsU0FBUztnQkFDekIsT0FBTyxFQUFFLElBQUksQ0FBQyxPQUFPO2dCQUNyQixPQUFPLEVBQUUsVUFBVTtnQkFDbkIsYUFBYSxFQUFFLGdCQUFnQjthQUNoQyxDQUFBO1lBQ0QsTUFBTSxPQUFPLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFO2dCQUNoRCxPQUFPLEVBQUU7b0JBQ1AsY0FBYyxFQUFFLElBQUksQ0FBQyxTQUFTO29CQUM5QixjQUFjLEVBQUUsa0JBQWtCO2lCQUNuQztnQkFDRCxXQUFXLEVBQUUsVUFBVTthQUN4QixDQUFDLENBQUMsS0FBSyxDQUFDLEdBQUc7Z0JBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtZQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNKLENBQUM7S0FBQTtDQUNGO0FBcENELDhCQW9DQyJ9
|
59
docs/index.md
Normal file
59
docs/index.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# smartanalytics
|
||||||
|
Google Analytics everywhere
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/smartanalytics)
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics)
|
||||||
|
[](https://github.com/pushrocks/smartanalytics)
|
||||||
|
[](https://pushrocks.gitlab.io/smartanalytics/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/smartanalytics/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/smartanalytics)
|
||||||
|
[](https://david-dm.org/pushrocks/smartanalytics)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartanalytics/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/smartanalytics)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
### Why does this package exist?
|
||||||
|
Tracking users in webapps is common, often to gain insight in who is using what and where to spend dev resources for best efficiency.
|
||||||
|
|
||||||
|
Doing the same stuff in apps can be a bit of a hassle.
|
||||||
|
Unnecessary dependencies used by many existing analytics tools make the whole app slow
|
||||||
|
just to gain a little usage info.
|
||||||
|
|
||||||
|
**Say hello to smartanalytics. :)**
|
||||||
|
It features a very slim dependency tree using the native node request module to send posts to a tracking API of your choice.
|
||||||
|
|
||||||
|
### How do I use this package?
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Analytics } from 'smartanalytics'
|
||||||
|
let myAnalytics = new plugins.smartanalytics.Analytics({
|
||||||
|
apiEndPoint: 'https://somepubapi.endpoint.com',
|
||||||
|
projectId: 'gitzone',
|
||||||
|
appName: 'npmts'
|
||||||
|
})
|
||||||
|
|
||||||
|
myAnalytics.recordEvent('someEvent', {
|
||||||
|
myKey1: 'myValue1',
|
||||||
|
myKey2: 'myValue2',
|
||||||
|
myDataKey3: 3
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
|
||||||
|
[](https://push.rocks)
|
19
license
Normal file
19
license
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2018 Lossless GmbH (hello@lossless.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"npmts": {
|
"npmts": {
|
||||||
"coverageTreshold": 40
|
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
1046
package-lock.json
generated
Normal file
1046
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -1,20 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "smartanalytics",
|
"name": "@pushrocks/smartanalytics",
|
||||||
"version": "2.0.4",
|
"version": "2.0.11",
|
||||||
"description": "Google Analytics everywhere",
|
"description": "Google Analytics everywhere",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"smartq": "^1.1.1",
|
"@pushrocks/smartpromise": "^2.0.5",
|
||||||
"smartrequest": "^1.0.4",
|
"@pushrocks/smartrequest": "^1.1.14"
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.1.1"
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
|
"@gitzone/tstest": "^1.0.15",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
|
"@types/node": "^10.12.0",
|
||||||
|
"tslint": "^5.11.0",
|
||||||
|
"tslint-config-prettier": "^1.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
28
test/test.ts
28
test/test.ts
@ -1,27 +1,27 @@
|
|||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import * as smartanalytics from '../ts/index'
|
import * as smartanalytics from '../ts/index';
|
||||||
|
|
||||||
let testAnalytics: smartanalytics.Analytics
|
let testAnalytics: smartanalytics.Analytics;
|
||||||
|
|
||||||
tap.test('should create a valid AnalyticsAccount', async () => {
|
tap.test('should create a valid AnalyticsAccount', async () => {
|
||||||
testAnalytics = new smartanalytics.Analytics({
|
testAnalytics = new smartanalytics.Analytics({
|
||||||
projectIdArg: 'sandbox',
|
projectId: 'sandbox',
|
||||||
appNameArg: 'smartanalytics',
|
appName: 'smartanalytics',
|
||||||
apiEndPointArg: 'https://pubapi-1.lossless.one/analytics'
|
apiEndPoint: 'https://pubapi.lossless.one/analytics'
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should send a request to Lossless API endpoint', async () => {
|
tap.test('should send a request to Lossless API endpoint', async () => {
|
||||||
let doit = async () => {
|
let doit = async () => {
|
||||||
await testAnalytics.recordEvent('sandbox', {
|
await testAnalytics.recordEvent('sandbox', {
|
||||||
trackingPurpose: 'test'
|
trackingPurpose: 'test'
|
||||||
})
|
});
|
||||||
await testAnalytics.recordEvent('sandbox', {
|
await testAnalytics.recordEvent('sandbox', {
|
||||||
someValue: 'someData'
|
someValue: 'someData'
|
||||||
})
|
});
|
||||||
}
|
};
|
||||||
doit()
|
doit();
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@ -1 +1 @@
|
|||||||
export { Analytics } from './smartanalytics.classes.analytics'
|
export { Analytics } from './smartanalytics.classes.analytics';
|
||||||
|
@ -1,39 +1,41 @@
|
|||||||
import * as plugins from './smartanalytics.plugins'
|
import * as plugins from './smartanalytics.plugins';
|
||||||
|
|
||||||
export class Analytics {
|
export class Analytics {
|
||||||
projectId: string
|
public projectId: string;
|
||||||
appName: string
|
public appName: string;
|
||||||
apiEndPoint: string
|
public apiEndPoint: string;
|
||||||
secretKey: string = ''
|
public secretKey: string = '';
|
||||||
constructor(optionsArg: {
|
constructor(optionsArg: {
|
||||||
projectIdArg: string
|
projectId: string;
|
||||||
appNameArg: string
|
appName: string;
|
||||||
apiEndPointArg: string
|
apiEndPoint: string;
|
||||||
secretKeyArg?: string
|
secretKey?: string;
|
||||||
}) {
|
}) {
|
||||||
this.projectId = optionsArg.projectIdArg
|
this.projectId = optionsArg.projectId;
|
||||||
this.appName = optionsArg.appNameArg
|
this.appName = optionsArg.appName;
|
||||||
this.apiEndPoint = optionsArg.apiEndPointArg
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
||||||
if (optionsArg.secretKeyArg) {
|
if (optionsArg.secretKey) {
|
||||||
this.secretKey = optionsArg.secretKeyArg
|
this.secretKey = optionsArg.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async recordEvent (identifierArg: string, analyticsDataArg: any) {
|
async recordEvent(eventIdArg: string, analyticsDataArg: any) {
|
||||||
let dataToSend = {
|
let dataToSend = {
|
||||||
projectId: this.projectId,
|
projectId: this.projectId,
|
||||||
appName: this.appName,
|
appName: this.appName,
|
||||||
identifier: identifierArg,
|
eventId: eventIdArg,
|
||||||
analyticsData: analyticsDataArg
|
analyticsData: analyticsDataArg
|
||||||
}
|
};
|
||||||
await plugins.smartrequest.post(this.apiEndPoint, {
|
await plugins.smartrequest
|
||||||
|
.postJson(this.apiEndPoint, {
|
||||||
headers: {
|
headers: {
|
||||||
'authenticate': this.secretKey,
|
authenticate: this.secretKey,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
requestBody: dataToSend
|
requestBody: dataToSend
|
||||||
}).catch(err => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import 'typings-global'
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
import * as smartrequest from 'smartrequest'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartq from 'smartq'
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartrequest,
|
smartrequest,
|
||||||
smartq
|
smartpromise
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user