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

spm-metrics-js

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spm-metrics-js - npm Package Compare versions

Comparing version 1.0.7 to 1.0.9

.npmignore

33

lib/index.js

@@ -18,3 +18,7 @@ 'use strict'

function SpmCustomMetrics (token, metricsInterval, metricsApiEndpoint) {
this.metricsUrl = (metricsApiEndpoint || 'https://spm-receiver.sematext.com/receiver/custom/receive.json?token=') + token
if(process.env.SPM_URL) {
this.metricsUrl = process.env.SPM_URL.replace('_bulk', 'receiver/custom/receive.json?token=' + token)
} else {
this.metricsUrl = (metricsApiEndpoint || 'https://spm-receiver.sematext.com/receiver/custom/receive.json?token=') + token
}
this.token = token || process.env.SPM_TOKEN

@@ -84,6 +88,8 @@ this.datapoints = []

if (err) {
self.emit('error', err)
self.emit('send error', err)
} else {
self.emit('send metrics', { res: res, source: 'send' })
}
}).on('error', function (err) {
self.emit('send error', err)
})

@@ -103,3 +109,3 @@ }

var options = {
url: 'https://event-receiver.sematext.com/' + this.token + '/' + type,
url: (process.env.SPM_EVENTS_URL || 'https://event-receiver.sematext.com') + '/' + this.token + '/' + type,
headers: {

@@ -114,13 +120,12 @@ 'User-Agent': 'spm-metrics-js',

this.events = []
var self = this
request.post(options, function (err, res) {
if (err) {
self.emit('error', { err: err, source: 'sendEvent'})
} else {
self.emit('send event', { source: 'sendEvent', event: event, err: err })
}
if (callback) {
callback(err, res)
}
})
request.post(options, function (err, res) {
if (callback) {
return callback(err, res)
}
if (err) {
self.emit('send error', { err: err, source: 'sendEvent'})
} else {
self.emit('send event', { source: 'sendEvent', event: event, err: err })
}
})
}

@@ -127,0 +132,0 @@

{
"name": "spm-metrics-js",
"version": "1.0.7",
"version": "1.0.9",
"description": "Node.js client for SPM - Custom Metrics and Event API",

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

var SPM = require('../lib/index.js')
var token = process.env.SPM_TOKEN
var trace = require ('trace')
// var trace = require ('trace')
describe('spm custom metrics ', function () {

@@ -12,3 +12,3 @@ it('set metric', function (done) {

})
spmcm.once('error', done)
spmcm.once('send error', done)
var testMetric = spmcm.getCustomMetric({ name: 'test.metric', aggregation: 'avg', filter1: 'filter1', filter2: 'filter2' })

@@ -39,3 +39,3 @@ testMetric.set(42)

} else {
done()
done(err)
}

@@ -59,3 +59,2 @@ })

})
spmcm.once('error', done)
var testMetric = spmcm.getCustomMetric({ name: 'timer', aggregation: 'avg', filter1: 'filter1', filter2: 'filter2' })

@@ -90,3 +89,3 @@ var stopwatch = testMetric.timer().start()

spmcm.send()
spmcm.once('error', done)
spmcm.once('send error', done)
} catch (err) {

@@ -93,0 +92,0 @@ done(err)

Sorry, the diff of this file is not supported yet

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