Files
redash/client/app/services/recordEvent.js
Arik Fraimovich 56d3be2248 Prettier all the Javascript code & GitHub Action (#4433)
* Prettier all the JS files

* Add GitHub Action to autoformat code pushed to master

* Fix eslint violation due to formatting.

* Remove GitHub actions for styling

* Add restyled.io config
2019-12-11 17:05:38 +02:00

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();
}