mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Update events tracking
This commit is contained in:
parent
4f80444743
commit
d0832c3c20
3 changed files with 19 additions and 10 deletions
|
@ -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,
|
||||||
|
|
9
packages/vulcan-events-internal/lib/modules/fragments.js
Normal file
9
packages/vulcan-events-internal/lib/modules/fragments.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { registerFragment } from 'meteor/vulcan:core';
|
||||||
|
|
||||||
|
registerFragment(/* GraphQL */`
|
||||||
|
fragment AnalyticsEventFragment on AnalyticsEvent {
|
||||||
|
__typename
|
||||||
|
name
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
`);
|
|
@ -1 +1,3 @@
|
||||||
export * from './collection.js';
|
export * from './collection.js';
|
||||||
|
|
||||||
|
import './fragments';
|
Loading…
Add table
Reference in a new issue