2017-12-17 20:59:26 +09:00
|
|
|
import { addTrackFunction } from 'meteor/vulcan:events';
|
2018-06-28 08:37:04 +02:00
|
|
|
import { getRenderContext, getFragment, createClientTemplate } from 'meteor/vulcan:lib';
|
2017-12-17 20:59:26 +09:00
|
|
|
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();
|
2018-06-28 08:37:04 +02:00
|
|
|
|
|
|
|
const fragmentName = 'AnalyticsEventFragment';
|
|
|
|
const fragment = getFragment(fragmentName);
|
|
|
|
|
|
|
|
const mutation = gql`${createClientTemplate({ typeName: 'AnalyticsEvent', fragmentName })}${fragment}`;
|
|
|
|
|
2017-12-18 09:01:24 +09:00
|
|
|
const variables = {
|
|
|
|
document: {
|
|
|
|
name: eventName,
|
|
|
|
properties: eventProperties,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
apolloClient.mutate({ mutation, variables });
|
2017-12-17 20:59:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
addTrackFunction(trackInternal);
|