
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
node-ga-plus
Advanced tools
Logging middleware for express: translate your API calls to visit to your website by using Google Analytics.
This module uses the Google Analytics for mobile websites API. Thus, your account ID must start with 'MO' instead of 'UA'. You can just give your usual account ID, this module will do the translation.
var express = require('express');
var ga = require('node-ga');
var app = express();
app.use(express.cookieParser());
app.use(ga('UA-XXXXXXXX-Y', {
safe: true
}));
app.get('/', function (req, res, next) {
return res.end('Hello world!');
});
safe: {Boolean}
If set to false, the log will be wrapped in a function to be called later by process.nextTick(). Defaults to true, in which case the request will be logged before being passed to next().
cookie_name: {String}
Custom cookie name to log the visitor ID. Defaults to "__utmnodejs".
custom: {Object}
Dictionary of functions to use on req and res to retrieve some custom values asynchronously. See next section for examples.
You can use asynchronous functions to assign custom key/values to the Google Analytics request. Give each of key a function that will take three parameters: ServerRequest, ServerObject and a callback function (with error and result) to be called once you're done.
NOTE: Returning a null value instead of a string will NOT log the data. In the following example, the value for "key_three" is NEVER sent to the Google Analytics server.
var express = require('express');
var ga = require('node-ga');
var app = express();
function func_key_one (req, res, next) {
return asynchronous_mongodb_call(function (err, result) {
if (err) return next(err);
var data = result.process();
return next(null, data);
});
};
app.use(express.cookieParser());
app.use(ga('UA-XXXXXXXX-Y', {
custom: {
key_one: func_key_one,
key_two: function (req, res, next) {
return next(null, 'hello');
},
key_three: function (req, res, next) { return next(null, null); }
}
}));
app.get('/', function (req, res, next) {
return res.end('Hello world!');
});
This middleware can be used without express. The cookie is automatically added with res.setHeader(). You should however parse req.headers['cookie'] to an object in req.cookies to avoid an unique being seen as multiple visits. The module will still work fine otherwise.
var http = require('http');
var ga = require('node-ga')('UA-XXXXXXXX-Y', { safe: true});
http.createServer(function (req, res) {
return ga(req, res, function () {
res.end('Hello world!');
});
}).listen(80);
FAQs
Log server calls using Google Analytics
The npm package node-ga-plus receives a total of 0 weekly downloads. As such, node-ga-plus popularity was classified as not popular.
We found that node-ga-plus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.