Update events tracking

This commit is contained in:
SachaG 2018-06-28 08:37:04 +02:00
parent 4f80444743
commit d0832c3c20
3 changed files with 19 additions and 10 deletions

View file

@ -1,17 +1,15 @@
import { addTrackFunction } from 'meteor/vulcan:events'; import { addTrackFunction } from 'meteor/vulcan:events';
import { getRenderContext } from 'meteor/vulcan:lib'; import { getRenderContext, getFragment, createClientTemplate } from 'meteor/vulcan:lib';
import gql from 'graphql-tag'; import gql from 'graphql-tag';
function trackInternal(eventName, eventProperties) { function trackInternal(eventName, eventProperties) {
const { apolloClient } = getRenderContext(); const { apolloClient } = getRenderContext();
const mutation = gql`
mutation AnalyticsEventsNew($document: AnalyticsEventsInput) { const fragmentName = 'AnalyticsEventFragment';
AnalyticsEventsNew(document: $document) { const fragment = getFragment(fragmentName);
name
createdAt const mutation = gql`${createClientTemplate({ typeName: 'AnalyticsEvent', fragmentName })}${fragment}`;
}
}
`;
const variables = { const variables = {
document: { document: {
name: eventName, name: eventName,

View file

@ -0,0 +1,9 @@
import { registerFragment } from 'meteor/vulcan:core';
registerFragment(/* GraphQL */`
fragment AnalyticsEventFragment on AnalyticsEvent {
__typename
name
createdAt
}
`);

View file

@ -1 +1,3 @@
export * from './collection.js'; export * from './collection.js';
import './fragments';