fix(core): update
This commit is contained in:
parent
febf6c1911
commit
fcb12d5734
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.
|
@ -2,8 +2,7 @@
|
|||||||
"npmts": {
|
"npmts": {
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"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
18
package.json
18
package.json
@ -1,20 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "smartanalytics",
|
"name": "@pushrocks/smartanalytics",
|
||||||
"version": "2.0.10",
|
"version": "2.0.10",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
test/test.ts
24
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({
|
||||||
projectId: 'sandbox',
|
projectId: 'sandbox',
|
||||||
appName: 'smartanalytics',
|
appName: 'smartanalytics',
|
||||||
apiEndPoint: '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: {
|
||||||
projectId: string
|
projectId: string;
|
||||||
appName: string
|
appName: string;
|
||||||
apiEndPoint: string
|
apiEndPoint: string;
|
||||||
secretKey?: string
|
secretKey?: string;
|
||||||
}) {
|
}) {
|
||||||
this.projectId = optionsArg.projectId
|
this.projectId = optionsArg.projectId;
|
||||||
this.appName = optionsArg.appName
|
this.appName = optionsArg.appName;
|
||||||
this.apiEndPoint = optionsArg.apiEndPoint
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
||||||
if (optionsArg.secretKey) {
|
if (optionsArg.secretKey) {
|
||||||
this.secretKey = optionsArg.secretKey
|
this.secretKey = optionsArg.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async recordEvent (eventIdArg: 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,
|
||||||
eventId: eventIdArg,
|
eventId: eventIdArg,
|
||||||
analyticsData: analyticsDataArg
|
analyticsData: analyticsDataArg
|
||||||
}
|
};
|
||||||
await plugins.smartrequest.post(this.apiEndPoint, {
|
await plugins.smartrequest
|
||||||
headers: {
|
.postJson(this.apiEndPoint, {
|
||||||
'authenticate': this.secretKey,
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
authenticate: this.secretKey,
|
||||||
},
|
'Content-Type': 'application/json'
|
||||||
requestBody: dataToSend
|
},
|
||||||
}).catch(err => {
|
requestBody: dataToSend
|
||||||
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"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user