2017-12-17 17:42:06 +09:00
|
|
|
import { addCallback } from 'meteor/vulcan:core';
|
|
|
|
|
|
|
|
export const initFunctions = [];
|
|
|
|
|
|
|
|
export const trackFunctions = [];
|
|
|
|
|
|
|
|
export const addInitFunction = func => {
|
|
|
|
initFunctions.push(func);
|
|
|
|
// execute init function as soon as possible
|
|
|
|
func();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const addTrackFunction = func => {
|
|
|
|
trackFunctions.push(func);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const track = (eventName, eventProperties) => {
|
|
|
|
trackFunctions.forEach(f => {
|
|
|
|
f(eventName, eventProperties);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export const addIdentifyFunction = func => {
|
|
|
|
addCallback('events.identify', func);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const addPageFunction = func => {
|
2017-12-17 18:00:48 +09:00
|
|
|
addCallback('router.onUpdate', (empty, route) => func(route));
|
2017-12-17 17:42:06 +09:00
|
|
|
};
|