Skip to content

Commit 1a11fbb

Browse files
author
Samson
committed
A
1 parent 4cff13a commit 1a11fbb

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

Diff for: js/libs/events/event_bus.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
define([
2+
'backbone',
3+
'underscore'
4+
], function(Backbone, _) {
5+
var EventBus = _.clone(Backbone.Events);
6+
return EventBus;
7+
});

Diff for: js/libs/events/events.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
define({
2+
NEW_USER: 'new-user'
3+
});

Diff for: js/views/app.js

+17-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ define([
55
'extensions',
66
'vm',
77
'events',
8+
'libs/events/event_bus',
9+
'libs/events/events',
810
'models/session',
911
'models/error',
1012
'text!templates/layout.html',
@@ -13,14 +15,19 @@ define([
1315
'views/footer/footer',
1416
'views/feedback/feedback',
1517
'views/notifications/main'
16-
], function($, _, Backbone, extensions, Vm, Events, Session, ErrorModel, layoutTemplate, AccountMenu, HeaderView, FooterView, FeedbackView, Notifications){
18+
], function($, _, Backbone, extensions, Vm, Eventsa, EventBus, Events, Session, ErrorModel, layoutTemplate, AccountMenu, HeaderView, FooterView, FeedbackView, Notifications){
1719
var AppView = Backbone.View.extend({
1820
el: 'body',
1921
initialize: function () {
2022
// log all 500 error codes with the server. We may also log others - this is done in libs/form/form.js
2123
// when no UI elements are found for handling a valid server error condition.
24+
EventBus.on('all', function (event) {
25+
_gaq.push(['_trackEvent', 'app', event])
26+
_gaq.push(['_trackEvent', 'Videos', 'Stop', 'Gone With the Wind']);
27+
});
28+
EventBus.trigger(Events.NEW_USER);
2229
$("body").ajaxError(function(ev, res, req) {
23-
if(res.status >= 500 && res.status <= 600) {
30+
if(res.status >= 500 && res.status <= 600) {
2431
var responseJSON = xhr.responseText;
2532
try {
2633
responseJSON = JSON.parse(xhr.responseText);
@@ -29,15 +36,15 @@ define([
2936
var error = new ErrorModel();
3037
error.save({
3138
"page": window.location.href,
32-
"context": req.type + ' ' + req.url,
33-
"code": res.status,
34-
"error": "Internal API error",
35-
"payload": {
36-
sent : req.data,
37-
received : responseJSON
38-
}
39+
"context": req.type + ' ' + req.url,
40+
"code": res.status,
41+
"error": "Internal API error",
42+
"payload": {
43+
sent : req.data,
44+
received : responseJSON
45+
}
3946
}, {});
40-
}
47+
}
4148
console.log(arguments);
4249
});
4350

0 commit comments

Comments
 (0)