cartodb-4.42/lib/assets/javascripts/builder/components/metrics/metrics-model.js
2024-04-06 05:25:13 +00:00

37 lines
756 B
JavaScript
Executable File

var Backbone = require('backbone');
var _ = require('underscore');
module.exports = Backbone.Model.extend({
defaults: {
eventName: '',
eventProperties: {}
},
url: function () {
return this._configModel.get('base_url') + '/api/v3/metrics';
},
initialize: function (attrs, opts) {
if (!opts.configModel) { throw new Error('configModel is required'); }
this._userId = opts.userId;
this._visId = opts.visId;
this._configModel = opts.configModel;
},
toJSON: function () {
return {
name: this.get('eventName'),
properties: _.extend(
{},
this.get('eventProperties'),
{
visualization_id: this._visId,
user_id: this._userId
}
)
};
}
});