mirror of
https://github.com/getredash/redash.git
synced 2026-05-09 03:03:08 -04:00
* Refine Auth service: remove dead code and fix race condition * Export services in CommonJS style * Refine Users, Events and OfflineListener services * Refactor Notifications service - rewrite to CommonJS * Replace Angular service injection with imports in React components * Fix Footer tests * Events service -> recordEvent function * CR1
26 lines
593 B
JavaScript
26 lines
593 B
JavaScript
import { debounce, extend } from 'lodash';
|
|
import { $http } from '@/services/ng';
|
|
|
|
let events = [];
|
|
|
|
const post = debounce(() => {
|
|
const eventsToSend = events;
|
|
events = [];
|
|
|
|
$http.post('api/events', eventsToSend);
|
|
}, 1000);
|
|
|
|
export default function recordEvent(action, objectType, objectId, additionalProperties) {
|
|
const event = {
|
|
action,
|
|
object_type: objectType,
|
|
object_id: objectId,
|
|
timestamp: Date.now() / 1000.0,
|
|
screen_resolution: `${window.screen.width}x${window.screen.height}`,
|
|
};
|
|
extend(event, additionalProperties);
|
|
events.push(event);
|
|
|
|
post();
|
|
}
|