| 1 | const https = require('https') |
| 2 | |
| 3 | class OwnstatsClient { |
| 4 | constructor (endpoint) { |
| 5 | this.endpoint = endpoint |
| 6 | this.reqUrl = `https://${endpoint}/hello.gif` |
| 7 | } |
| 8 | send () { |
| 9 | const qs = [] |
| 10 | // Build querystring |
| 11 | for (var property in data) { |
| 12 | if (data.hasOwnProperty(property)) { |
| 13 | qs.push(`${property}=${encodeURIComponent(data[property].toString())}`) |
| 14 | } |
| 15 | } |
| 16 | const url = `${this.reqUrl}?${qs.join('&')}` |
| 17 | // Send data |
| 18 | https.get(url, (response) => { |
| 19 | let responseData = '' |
| 20 | response.on('data', (chunk) => { |
| 21 | responseData += chunk |
| 22 | }) |
| 23 | response.on('end', () => { |
| 24 | return true |
| 25 | }) |
| 26 | }).on("error", (err) => { |
| 27 | throw new Error(err.message) |
| 28 | }) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Ownstats analytics plugin |
nothing calls this directly
no outgoing calls
no test coverage detected