Chatwoot/app/javascript/widget/api/events.js

20 lines
497 B
JavaScript
Raw Normal View History

import { API } from 'widget/helpers/axios';
import { buildSearchParamsWithLocale } from '../helpers/urlParamsHelper';
export const generateEventParams = () => ({
initiated_at: {
timestamp: new Date().toString(),
},
referer: window.referrerURL || '',
});
export default {
create(name) {
const search = buildSearchParamsWithLocale(window.location.search);
return API.post(`/api/v1/widget/events${search}`, {
name,
event_info: generateEventParams(),
});
},
};