added agent to server metrics (#1321)
This commit is contained in:
parent
19ac0480ee
commit
f603f40f43
|
@ -68,6 +68,7 @@ Server events allow us to aggregate data about file lifecycle without collecting
|
|||
* `event_properties`
|
||||
* `download_count` downloads completed
|
||||
* `ttl` time remaining before expiry truncated to hour
|
||||
* `agent` the browser name or first 6 characters of the user agent that made the request
|
||||
|
||||
### Client Events
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ function statUploadEvent(data) {
|
|||
size: orderOfMagnitude(data.size),
|
||||
anonymous: data.anonymous
|
||||
},
|
||||
event_properties: {
|
||||
agent: data.agent
|
||||
},
|
||||
event_id: 0
|
||||
};
|
||||
return sendBatch([event]);
|
||||
|
@ -61,6 +64,7 @@ function statDownloadEvent(data) {
|
|||
time: truncateToHour(Date.now()),
|
||||
event_type: 'server_download',
|
||||
event_properties: {
|
||||
agent: data.agent,
|
||||
download_count: data.download_count,
|
||||
ttl: data.ttl
|
||||
},
|
||||
|
@ -80,6 +84,7 @@ function statDeleteEvent(data) {
|
|||
time: truncateToHour(Date.now()),
|
||||
event_type: 'server_delete',
|
||||
event_properties: {
|
||||
agent: data.agent,
|
||||
download_count: data.download_count,
|
||||
ttl: data.ttl
|
||||
},
|
||||
|
|
|
@ -12,6 +12,7 @@ const ID_REGEX = '([0-9a-fA-F]{10, 16})';
|
|||
module.exports = function(app, devServer) {
|
||||
const wsapp = express();
|
||||
expressWs(wsapp, null, { perMessageDeflate: false });
|
||||
routes(wsapp);
|
||||
wsapp.ws('/api/ws', require('../routes/ws'));
|
||||
wsapp.listen(8081, config.listen_address);
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ if (config.sentry_dsn) {
|
|||
const app = express();
|
||||
|
||||
expressWs(app, null, { perMessageDeflate: false });
|
||||
app.ws('/api/ws', require('../routes/ws'));
|
||||
routes(app);
|
||||
app.ws('/api/ws', require('../routes/ws'));
|
||||
|
||||
app.use(
|
||||
express.static(path.resolve(__dirname, '../../dist/'), {
|
||||
|
|
|
@ -7,8 +7,8 @@ const expressWs = require('express-ws');
|
|||
module.exports = function(app, devServer) {
|
||||
assets.setMiddleware(devServer.middleware);
|
||||
expressWs(app, null, { perMessageDeflate: false });
|
||||
app.ws('/api/ws', require('../routes/ws'));
|
||||
routes(app);
|
||||
app.ws('/api/ws', require('../routes/ws'));
|
||||
tests(app);
|
||||
// webpack-dev-server routes haven't been added yet
|
||||
// so wait for next tick to add 404 handler
|
||||
|
|
|
@ -13,7 +13,8 @@ module.exports = async function(req, res) {
|
|||
ip: req.ip,
|
||||
owner: meta.owner,
|
||||
download_count: meta.dl,
|
||||
ttl
|
||||
ttl,
|
||||
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
|
||||
});
|
||||
} catch (e) {
|
||||
res.sendStatus(404);
|
||||
|
|
|
@ -28,7 +28,8 @@ module.exports = async function(req, res) {
|
|||
ip: req.ip,
|
||||
owner: meta.owner,
|
||||
download_count: dl,
|
||||
ttl
|
||||
ttl,
|
||||
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
|
||||
});
|
||||
try {
|
||||
if (dl >= dlimit) {
|
||||
|
|
|
@ -114,7 +114,8 @@ module.exports = function(ws, req) {
|
|||
dlimit,
|
||||
timeLimit,
|
||||
anonymous: !user,
|
||||
size: limiter.length
|
||||
size: limiter.length,
|
||||
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue