Skip to content

Commit b495969

Browse files
committed
fix formatting of telemetrty api metric params
1 parent c627b7d commit b495969

File tree

4 files changed

+2213
-514
lines changed

4 files changed

+2213
-514
lines changed

lib/monitor.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const qs = require('qs')
12
const Errors = require('./errors')
23

34
class Monitor {
@@ -82,7 +83,14 @@ class Monitor {
8283

8384
async ping(params={}) {
8485
try {
85-
await this._api.axios.get(this._api.pingUrl(this.key), {params: this._cleanParams(params)})
86+
let resp = await this._api.axios.get(
87+
this._api.pingUrl(this.key), {
88+
params,
89+
paramsSerializer: (params) => {
90+
return qs.stringify(this._cleanParams(params), { arrayFormat: 'repeat', encode: false})
91+
}
92+
})
93+
8694
return true
8795
} catch(e) {
8896
console.error(e)
@@ -93,7 +101,10 @@ class Monitor {
93101
_cleanParams(params={}) {
94102
let allowedParams = {
95103
state: params.state || null,
96-
message: typeof params === 'string' ? params : params.message ? params.message : null,
104+
message: typeof params === 'string'
105+
? encodeURIComponent(params)
106+
: params.message
107+
? encodeURIComponent(params.message) : null,
97108
metric: null,
98109
series: params.series || null,
99110
host: params.host || process.env.HOSTNAME || null,

0 commit comments

Comments
 (0)