2020-04-10 11:12:37 +00:00
|
|
|
import { API } from 'widget/helpers/axios';
|
2020-06-12 18:49:43 +00:00
|
|
|
import { buildSearchParamsWithLocale } from '../helpers/urlParamsHelper';
|
2020-04-10 11:12:37 +00:00
|
|
|
|
2021-08-31 06:16:15 +00:00
|
|
|
export const generateEventParams = () => ({
|
|
|
|
initiated_at: {
|
|
|
|
timestamp: new Date().toString(),
|
|
|
|
},
|
|
|
|
referer: window.referrerURL || '',
|
|
|
|
});
|
|
|
|
|
2020-04-10 11:12:37 +00:00
|
|
|
export default {
|
|
|
|
create(name) {
|
2020-06-12 18:49:43 +00:00
|
|
|
const search = buildSearchParamsWithLocale(window.location.search);
|
2021-08-31 06:16:15 +00:00
|
|
|
return API.post(`/api/v1/widget/events${search}`, {
|
|
|
|
name,
|
|
|
|
event_info: generateEventParams(),
|
|
|
|
});
|
2020-04-10 11:12:37 +00:00
|
|
|
},
|
|
|
|
};
|