Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tng/gta

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tng/gta - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

10

lib/gta.js

@@ -7,2 +7,3 @@ const request = require('request-promise')

this.url = options.url
this.token = options.token
}

@@ -34,4 +35,13 @@

}
send (event, data, options) {
data.token = this.token
const obj = {
event,
properties: data
}
return this.get(obj, options)
}
}
module.exports = GTA

2

package.json
{
"name": "@tng/gta",
"version": "1.0.3",
"version": "1.0.4",
"description": "TNG GTA ==============",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,19 +12,20 @@ TNG GTA

const GTA = require('@tng/gta')
const gta = new GTA({url:'https://gta.teambition.net/v1/track/'})
const gta = new GTA({url:'https://gta.teambition.net/v1/track/', token: '1234567890'})
// get方法
// send方法 (get)
// @return promise
console.log(yield gta.get({ param: 'abc' }))
console.log(yield gta.send('event', { param: 'abc' }))
// {event: 1}
// post方法
// @return promise
console.log(yield gta.post({ param: 'abc' }))
// {event: 1}
// 指定 options
const gta = new GTA()
const options = { url: 'https://gta.teambition.net/v1/track/' }
console.log(yield gta.get({ param: 'abc' }, options))
const options = { url: 'https://gta.teambition.net/v1/track/', token: '1234567890'})
console.log(yield gta.send('event', { param: 'abc' }, options))
// get/post方法
const gta = new GTA()
const options = { url: 'https://gta.teambition.net/v1/track/'})
yield gta.get('event', { token: '1234567890', params: 'abc' }, options)
yield gta.post('event', { token: '1234567890', params: 'abc' }, options)
```

@@ -5,7 +5,6 @@ 'use strict'

const GTA = rewire('../lib/gta')
const gta = new GTA({url: 'http://gaohuifeng.cn/api'})
const gta = new GTA({url: 'http://gaohuifeng.cn/api', token: '1234567890'})
describe('gta', () => {
const params = {
user: 'abc',
token: '1234567890'
user: 'abc'
}

@@ -50,2 +49,24 @@ const options = {

})
describe('gta send', () => {
before(() => {
GTA.__set__('request', function (options) {
expect(options).properties('method', 'url')
expect(options.url).match(/\?data=/)
expect(options.url).not.match(/undefined/)
const base64Data = options.url.split('?data=')[1]
// eslint-disable-next-line
let obj = new Buffer.from(base64Data, 'base64').toString()
obj = JSON.parse(obj)
expect(obj).properties('event', 'properties')
expect(obj.properties).deepEqual({'user': 'abc', 'token': '1234567890'})
return 'Hello World'
})
})
it('gta send should ok', function * () {
const data = yield gta.send('event', params)
expect(data).eql('Hello World')
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc