mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 12:16:37 -04:00
24 lines
624 B
JavaScript
24 lines
624 B
JavaScript
import { addTrackFunction } from 'meteor/vulcan:events';
|
|
import { getRenderContext } from 'meteor/vulcan:lib';
|
|
import gql from 'graphql-tag';
|
|
|
|
function trackInternal(eventName, eventProperties) {
|
|
const { apolloClient } = getRenderContext();
|
|
const mutation = gql`
|
|
mutation AnalyticsEventsNew($document: AnalyticsEventsInput) {
|
|
AnalyticsEventsNew(document: $document) {
|
|
name
|
|
createdAt
|
|
}
|
|
}
|
|
`;
|
|
const variables = {
|
|
document: {
|
|
name: eventName,
|
|
properties: eventProperties,
|
|
},
|
|
};
|
|
apolloClient.mutate({ mutation, variables });
|
|
}
|
|
|
|
addTrackFunction(trackInternal);
|