mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
Merge pull request #182 from EverythingMe/feature_events_throtle
Make sure events are reported at most once per second
This commit is contained in:
commit
d26b822f6c
@ -69,6 +69,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: fire event for query view for each query
|
// TODO: fire event for query view for each query
|
||||||
|
Events.record(currentUser, "view", "widget", $scope.widget.id);
|
||||||
|
Events.record(currentUser, "view", "query", $scope.widget.visualization.query.id);
|
||||||
|
Events.record(currentUser, "view", "visualization", $scope.widget.visualization.id);
|
||||||
|
|
||||||
$scope.query = new Query($scope.widget.visualization.query);
|
$scope.query = new Query($scope.widget.visualization.query);
|
||||||
$scope.queryResult = $scope.query.getQueryResult();
|
$scope.queryResult = $scope.query.getQueryResult();
|
||||||
|
@ -20,6 +20,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Events($http) {
|
function Events($http) {
|
||||||
|
this.events = [];
|
||||||
|
|
||||||
|
this.post = _.debounce(function() {
|
||||||
|
var events = this.events;
|
||||||
|
this.events = [];
|
||||||
|
|
||||||
|
$http.post('/api/events', events);
|
||||||
|
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
this.record = function (user, action, object_type, object_id, additional_properties) {
|
this.record = function (user, action, object_type, object_id, additional_properties) {
|
||||||
|
|
||||||
var event = {
|
var event = {
|
||||||
@ -30,8 +40,9 @@
|
|||||||
"timestamp": Date.now()/1000.0
|
"timestamp": Date.now()/1000.0
|
||||||
};
|
};
|
||||||
_.extend(event, additional_properties);
|
_.extend(event, additional_properties);
|
||||||
|
this.events.push(event);
|
||||||
|
|
||||||
$http.post('/api/events', [event]);
|
this.post();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user