2017-12-17 20:59:26 +09:00
|
|
|
import { addTrackFunction } from 'meteor/vulcan:events';
|
|
|
|
import { getRenderContext } from 'meteor/vulcan:lib';
|
|
|
|
import gql from 'graphql-tag';
|
|
|
|
|
2017-12-18 09:01:24 +09:00
|
|
|
function trackInternal(eventName, eventProperties) {
|
2018-01-25 15:03:03 -06:00
|
|
|
const { apolloClient } = getRenderContext();
|
2017-12-18 09:01:24 +09:00
|
|
|
const mutation = gql`
|
2018-01-04 11:56:50 +09:00
|
|
|
mutation AnalyticsEventsNew($document: AnalyticsEventsInput) {
|
|
|
|
AnalyticsEventsNew(document: $document) {
|
2017-12-18 09:01:24 +09:00
|
|
|
name
|
|
|
|
createdAt
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
const variables = {
|
|
|
|
document: {
|
|
|
|
name: eventName,
|
|
|
|
properties: eventProperties,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
apolloClient.mutate({ mutation, variables });
|
2017-12-17 20:59:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
addTrackFunction(trackInternal);
|