replaced fxa-geodb with load balancer header

This commit is contained in:
Danny Coates
2020-07-28 09:31:09 -07:00
parent 7d35e8f61f
commit 8ad4597114
9 changed files with 43 additions and 98 deletions

View File

@@ -11,6 +11,8 @@ module.exports = async function(req, res) {
statDeleteEvent({
id,
ip: req.ip,
country: req.geo.country,
state: req.geo.state,
owner: meta.owner,
download_count: meta.dl,
ttl,

View File

@@ -31,6 +31,8 @@ module.exports = async function(req, res) {
statDownloadEvent({
id,
ip: req.ip,
country: req.geo.country,
state: req.geo.state,
owner: meta.owner,
download_count: dl,
ttl,

View File

@@ -93,6 +93,19 @@ module.exports = function(app) {
);
next();
});
app.use(function(req, res, next) {
try {
// set by the load balancer
const [country, state] = req.header('X-Client-Geo-Location').split(',');
req.geo = {
country,
state
};
} catch (e) {
req.geo = {};
}
next();
});
app.use(bodyParser.json());
app.use(bodyParser.text());
app.get('/', language, pages.index);

View File

@@ -12,7 +12,8 @@ module.exports = async function(req, res) {
data.session_id + deltaT,
deltaT,
data.platform,
req.ip
req.geo.country,
req.geo.state
)
);
const status = await sendBatch(events);

View File

@@ -9,6 +9,8 @@ module.exports = async function(req, res) {
statReportEvent({
id,
ip: req.ip,
country: req.geo.country,
state: req.geo.state,
owner: meta.owner,
reason: req.body.reason,
download_limit: meta.dlimit,

View File

@@ -111,6 +111,8 @@ module.exports = function(ws, req) {
statUploadEvent({
id: newId,
ip: req.ip,
country: req.geo.country,
state: req.geo.state,
owner,
dlimit,
timeLimit,