Vulcan/packages/vulcan-events-internal/lib/client/internal-client.js

26 lines
677 B
JavaScript
Raw Normal View History

import { addTrackFunction } from 'meteor/vulcan:events';
import { ApolloClient } from 'apollo-client';
import { getRenderContext } from 'meteor/vulcan:lib';
import gql from 'graphql-tag';
function trackInternal(eventName, eventProperties) {
const { apolloClient, store } = getRenderContext();
const mutation = gql`
2018-01-04 11:56:50 +09:00
mutation AnalyticsEventsNew($document: AnalyticsEventsInput) {
AnalyticsEventsNew(document: $document) {
name
createdAt
}
}
`;
const variables = {
document: {
name: eventName,
properties: eventProperties,
},
};
apolloClient.mutate({ mutation, variables });
}
addTrackFunction(trackInternal);