added google analytics
This commit is contained in:
parent
92786795d2
commit
a3f0d0f878
4 changed files with 18 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
var fs = require('fs');
|
||||
var lbryApi = require('../helpers/lbryApi.js');
|
||||
var config = require('config');
|
||||
|
||||
var walledAddress = config.get('WalletConfig.lbryAddress');
|
||||
|
||||
function handlePublishError(error) {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
"express-handlebars": "^3.0.0",
|
||||
"nodemon": "^1.11.0",
|
||||
"socket.io": "^2.0.1",
|
||||
"socketio-file-upload": "^0.6.0"
|
||||
"socketio-file-upload": "^0.6.0",
|
||||
"universal-analytics": "^0.4.13"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,11 @@ var path = require('path');
|
|||
var routeHelpers = require('../helpers/routeHelpers.js');
|
||||
var lbryApi = require('../helpers/lbryApi.js');
|
||||
|
||||
module.exports = function(app){
|
||||
// route for favicon
|
||||
// app.get("/favicon.ico", function(req, res){
|
||||
// console.log(" >> GET request on favicon.ico");
|
||||
// res.sendFile(path.join(__dirname, '../public/assets/img', 'favicon.ico'));
|
||||
// });
|
||||
// route to fetch one free public claim
|
||||
module.exports = function(app, visitor){
|
||||
// route to fetch all free public claims
|
||||
app.get("/:name/all", function(req, res){
|
||||
console.log(">> GET request on /" + req.params.name + " (all)");
|
||||
visitor.pageview(req.url).send();
|
||||
// create promise
|
||||
lbryApi.getAllClaims(req.params.name)
|
||||
.then(function(orderedFreePublicClaims){
|
||||
|
@ -25,6 +21,7 @@ module.exports = function(app){
|
|||
});
|
||||
// route to fetch one free public claim
|
||||
app.get("/:name/:claim_id", function(req, res){
|
||||
|
||||
var uri = req.params.name + "#" + req.params.claim_id;
|
||||
console.log(">> GET request on /" + uri);
|
||||
// create promise
|
||||
|
@ -40,6 +37,7 @@ module.exports = function(app){
|
|||
});
|
||||
// route to fetch one free public claim
|
||||
app.get("/:name", function(req, res){
|
||||
|
||||
console.log(">> GET request on /" + req.params.name);
|
||||
// create promise
|
||||
lbryApi.getClaimBasedOnNameOnly(req.params.name)
|
||||
|
@ -53,10 +51,12 @@ module.exports = function(app){
|
|||
});
|
||||
// route for the home page
|
||||
app.get("/", function(req, res){
|
||||
visitor.pageview(req.url).send();
|
||||
res.status(200).render('index');
|
||||
});
|
||||
// a catch-all route if someone visits a page that does not exist
|
||||
app.use("*", function(req, res){
|
||||
visitor.pageview(req.url).send();
|
||||
res.status(404).render('fourOhFour');
|
||||
});
|
||||
}
|
||||
|
|
11
server.js
11
server.js
|
@ -4,6 +4,11 @@ var bodyParser = require('body-parser');
|
|||
var path = require('path');
|
||||
var siofu = require("socketio-file-upload");
|
||||
var expressHandlebars = require("express-handlebars");
|
||||
var ua = require('universal-analytics');
|
||||
var config = require('config');
|
||||
|
||||
var googleAnalyticsId = config.get('AnalyticsConfig.googleId');
|
||||
var visitor = ua(googleAnalyticsId, {https: true});
|
||||
|
||||
// set port
|
||||
var PORT = 3000;
|
||||
|
@ -24,11 +29,11 @@ app.engine('handlebars', expressHandlebars({defaultLayout: 'main'}));
|
|||
app.set('view engine', 'handlebars');
|
||||
|
||||
// require express routes
|
||||
require("./routes/api-routes.js")(app);
|
||||
require("./routes/html-routes.js")(app);
|
||||
require("./routes/api-routes.js")(app, visitor);
|
||||
require("./routes/html-routes.js")(app, visitor);
|
||||
|
||||
// wrap the server in socket.io to intercept incoming sockets requests
|
||||
var http = require("./routes/sockets-routes.js")(app);
|
||||
var http = require("./routes/sockets-routes.js")(app, visitor);
|
||||
|
||||
// start server
|
||||
http.listen(PORT, function() {
|
||||
|
|
Loading…
Reference in a new issue