Vulcan/packages/nova-events/lib/collection.js
Xavier Cazalot 7f99b48953 devel - revert commits related to simpl-schema (#1537)
* Revert "add note link to issue in collection2 on mutation insert, remove debug console logs on mutation edit"

This reverts commit 7a15103de7.

* Revert "node simpl-schema + collection2-core: fix vote by specifying the right type of the array (dont use blackbox in the end!)"

This reverts commit e894c3224c.

* Revert "add graphql date type (fix problem with node simple schema), fix an update bug on date picker,  add edit check on custom post item, add `blackbox: true` for arrays field (validation problem with simple-schema)"

This reverts commit 9d84fbec98.

* Revert "use node `simpl-schema` by aldeed to replace `meteor/aldeed:simple-schema` ; use the meteor collection2 core package as recommended"

This reverts commit 016935f4fa.

* revert before node-simple-schema, fix obj.hasOwnProperty undefined error thrown by simple-schema & collection2

* CustomPostsItem: check on renderActions; withDocument/List: pollInterval 20seconds by default; DateTime form component enhancement + GraphQLDate type
2017-01-11 18:02:12 +01:00

68 lines
1.5 KiB
JavaScript

import { SimpleSchema } from 'meteor/aldeed:simple-schema';
const Events = new Mongo.Collection('events');
Events.schema = new SimpleSchema({
createdAt: {
type: Date
},
name: {
type: String
},
description: {
type: String,
optional: true
},
unique: {
type: Boolean,
optional: true
},
important: { // marking an event as important means it should never be erased
type: Boolean,
optional: true
},
properties: {
type: Object,
optional: true,
blackbox: true
}
});
// Meteor.startup(function(){
// // needs to happen after every fields are added
// Events.internationalize();
// });
Events.attachSchema(Events.schema);
if (Meteor.isServer) {
Events.log = function (event) {
// if event is supposed to be unique, check if it has already been logged
if (!!event.unique && !!Events.findOne({name: event.name})) {
return;
}
event.createdAt = new Date();
Events.insert(event);
};
}
Events.track = function(event, properties){
// console.log('trackevent: ', event, properties);
properties = properties || {};
//TODO
// add event to an Events collection for logging and buffering purposes
// if(Meteor.isClient){
// if(typeof mixpanel !== 'undefined' && typeof mixpanel.track !== 'undefined'){
// mixpanel.track(event, properties);
// }
// if(typeof GoSquared !== 'undefined' && typeof GoSquared.DefaultTracker !== 'undefined'){
// GoSquared.DefaultTracker.TrackEvent(event, JSON.stringify(properties));
// }
// }
};
export default Events;