MCPcopy Create free account
hub / github.com/DavidWells/analytics / OwnstatsClient

Class OwnstatsClient

packages/analytics-plugin-ownstats/src/node.js:3–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1const https = require('https')
2
3class 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected