Skip to content

Commit a79019c

Browse files
committed
Migrated to GA4
1 parent 756d9be commit a79019c

File tree

5 files changed

+18
-80
lines changed

5 files changed

+18
-80
lines changed

package-lock.json

Lines changed: 0 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"morgan": "^1.10.0",
2121
"nedb": "^1.8.0",
2222
"pug": "^3.0.2",
23-
"universal-analytics": "^0.5.3",
2423
"uuid": "^9.0.0",
2524
"validate.js": "^0.13.1",
2625
"xml2js": "^0.4.23"

public/apidoc/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<link href="css/style.css" rel="stylesheet" media="screen, print">
1111
<link href="img/favicon.ico" rel="icon" type="image/x-icon">
1212
<script src="vendor/polyfill.js"></script>
13-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118712228-2"></script>
14-
<script>
15-
window.dataLayer = window.dataLayer || [];
16-
function gtag(){dataLayer.push(arguments);}
17-
gtag('js', new Date());
18-
19-
gtag('config', 'UA-118712228-2');
20-
</script>
13+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2Q48X98CJ6"></script>
14+
<script>
15+
window.dataLayer = window.dataLayer || [];
16+
function gtag(){dataLayer.push(arguments);}
17+
gtag('js', new Date());
18+
19+
gtag('config', 'G-2Q48X98CJ6');
20+
</script>
2121
</head>
2222
<body class="container-fluid">
2323

public/index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
font-family: 'Muli', Arial, Helvetica, sans-serif;
2020
}
2121
</style>
22-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118712228-2"></script>
23-
<script>
24-
window.dataLayer = window.dataLayer || [];
25-
function gtag(){dataLayer.push(arguments);}
26-
gtag('js', new Date());
2722

28-
gtag('config', 'UA-118712228-2');
29-
</script>
23+
<!-- Google tag (gtag.js) -->
24+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2Q48X98CJ6"></script>
25+
<script>
26+
window.dataLayer = window.dataLayer || [];
27+
function gtag(){dataLayer.push(arguments);}
28+
gtag('js', new Date());
29+
30+
gtag('config', 'G-2Q48X98CJ6');
31+
</script>
32+
3033
</head>
3134
<body>
3235
<div class="jumbotron p-4">

routes/index.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const router = express.Router(),
55
Booking = require('../models/booking'),
66
validator = require('../helpers/validator'),
77
creator = require('../helpers/bookingcreator'),
8-
ua = require('universal-analytics');
98
globalLogins = {};
109

1110
const { v4: uuidv4 } = require('uuid');
@@ -27,8 +26,6 @@ if(process.env.SEED === 'true'){
2726
})()
2827
};
2928

30-
const visitor = ua('UA-118712228-2', uuidv4());
31-
3229
/**
3330
* @api {get} ping HealthCheck
3431
* @apiName Ping
@@ -45,9 +42,6 @@ const visitor = ua('UA-118712228-2', uuidv4());
4542
* HTTP/1.1 201 Created
4643
*/
4744
router.get('/ping', function(req, res, next) {
48-
visitor.set('uid', uuidv4());
49-
visitor.pageview('/ping', 'https://restful-booker.herokuapp.com/', "GET /Ping").send();
50-
5145
res.sendStatus(201);
5246
});
5347

@@ -94,9 +88,6 @@ router.get('/ping', function(req, res, next) {
9488
]
9589
*/
9690
router.get('/booking', function(req, res, next) {
97-
visitor.set('uid', uuidv4());
98-
visitor.pageview('/booking', 'https://restful-booker.herokuapp.com/', "GET /booking").send();
99-
10091
const query = {};
10192

10293
if(typeof(req.query.firstname) != 'undefined'){
@@ -184,9 +175,6 @@ router.get('/booking', function(req, res, next) {
184175
* firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
185176
*/
186177
router.get('/booking/:id',function(req, res, next){
187-
visitor.set('uid', uuidv4());
188-
visitor.pageview('/booking/:id', 'https://restful-booker.herokuapp.com/', "GET /booking/:id").send();
189-
190178
Booking.get(req.params.id, function(err, record){
191179
if(record){
192180
const booking = parse.booking(req.headers.accept, record);
@@ -309,9 +297,6 @@ router.get('/booking/:id',function(req, res, next){
309297
* bookingid=1&booking%5Bfirstname%5D=Jim&booking%5Blastname%5D=Brown&booking%5Btotalprice%5D=111&booking%5Bdepositpaid%5D=true&booking%5Bbookingdates%5D%5Bcheckin%5D=2018-01-01&booking%5Bbookingdates%5D%5Bcheckout%5D=2019-01-01
310298
*/
311299
router.post('/booking', function(req, res, next) {
312-
visitor.set('uid', uuidv4());
313-
visitor.pageview('/booking', 'https://restful-booker.herokuapp.com/', "POST /booking").send();
314-
315300
newBooking = req.body;
316301
if(req.headers['content-type'] === 'text/xml') newBooking = newBooking.booking;
317302

@@ -446,9 +431,6 @@ router.post('/booking', function(req, res, next) {
446431
* firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
447432
*/
448433
router.put('/booking/:id', function(req, res, next) {
449-
visitor.set('uid', uuidv4());
450-
visitor.pageview('/booking/:id', 'https://restful-booker.herokuapp.com/', "PUT /booking/:id").send();
451-
452434
if(globalLogins[req.cookies.token] || req.headers.authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM='){
453435
updatedBooking = req.body;
454436
if(req.headers['content-type'] === 'text/xml') updatedBooking = updatedBooking.booking;
@@ -575,9 +557,6 @@ router.put('/booking/:id', function(req, res, next) {
575557
* firstname=Jim&lastname=Brown&totalprice=111&depositpaid=true&bookingdates%5Bcheckin%5D=2018-01-01&bookingdates%5Bcheckout%5D=2019-01-01
576558
*/
577559
router.patch('/booking/:id', function(req, res) {
578-
visitor.set('uid', uuidv4());
579-
visitor.pageview('/booking/:id', 'https://restful-booker.herokuapp.com/', "DELETE /booking/:id").send();
580-
581560
if(globalLogins[req.cookies.token] || req.headers.authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM='){
582561
updatedBooking = req.body;
583562

@@ -633,9 +612,6 @@ router.patch('/booking/:id', function(req, res) {
633612
* HTTP/1.1 201 Created
634613
*/
635614
router.delete('/booking/:id', function(req, res, next) {
636-
visitor.set('uid', uuidv4());
637-
visitor.pageview('/booking/:id', 'https://restful-booker.herokuapp.com/', "DELETE /booking/:id").send();
638-
639615
if(globalLogins[req.cookies.token] || req.headers.authorization == 'Basic YWRtaW46cGFzc3dvcmQxMjM='){
640616
Booking.get(req.params.id, function(err, record){
641617
if(record){
@@ -681,9 +657,6 @@ router.delete('/booking/:id', function(req, res, next) {
681657
}
682658
*/
683659
router.post('/auth', function(req, res, next){
684-
visitor.set('uid', uuidv4());
685-
visitor.pageview('/auth', 'https://restful-booker.herokuapp.com/', "POST /auth").send();
686-
687660
if(req.body.username === "admin" && req.body.password === "password123"){
688661
const token = crypto.randomBytes(Math.ceil(15 / 2))
689662
.toString('hex')

0 commit comments

Comments
 (0)