Skip to content

Commit cfb8a74

Browse files
committed
[logger] guidelines changes.
- global variables declared at top of page. - duplicated variable names changed. - unused variables removed.
1 parent decbeb8 commit cfb8a74

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

plugins/logger/api/api.js

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var plugin = {},
1+
var exported = {},
22
common = require('../../../api/utils/common.js'),
33
plugins = require('../../pluginManager.js');
44

5-
(function(plugin) {
5+
(function() {
66
//write api call
77
plugins.register("/sdk", function(ob) {
88
var params = ob.params;
@@ -164,7 +164,7 @@ var plugin = {},
164164
plugins.register("/o", function(ob) {
165165
var params = ob.params;
166166
var validate = ob.validateUserForDataReadAPI;
167-
if (params.qstring.method == 'logs') {
167+
if (params.qstring.method === 'logs') {
168168
var filter = {};
169169
if (typeof params.qstring.filter !== "undefined") {
170170
try {
@@ -174,36 +174,35 @@ var plugin = {},
174174
filter = {};
175175
}
176176
}
177-
validate(params, function(params) {
178-
common.db.collection('logs' + params.app_id).find(filter).toArray(function(err, items) {
177+
validate(params, function(parameters) {
178+
common.db.collection('logs' + parameters.app_id).find(filter).toArray(function(err, items) {
179179
if (err) {
180180
console.log(err);
181181
}
182-
common.returnOutput(params, items || []);
182+
common.returnOutput(parameters, items || []);
183183
});
184184
});
185185
return true;
186186
}
187-
if (params.qstring.method == 'collection_info') {
188-
validate(params, function(params) {
189-
common.db.collection('logs' + params.app_id).stats(function(err, stats) {
187+
if (params.qstring.method === 'collection_info') {
188+
validate(params, function(parameters) {
189+
common.db.collection('logs' + parameters.app_id).stats(function(err, stats) {
190190
if (err) {
191191
console.log(err);
192192
}
193-
common.returnOutput(params, stats && {capped: stats.capped, max: stats.max} || {});
194-
});
193+
common.returnOutput(parameters, stats && {capped: stats.capped, max: stats.max} || {});
194+
});
195195
});
196196
return true;
197197
}
198198
});
199199

200200

201201
plugins.register("/i/apps/create", function(ob) {
202-
var params = ob.params;
203202
var appId = ob.appId;
204-
common.db.command({"convertToCapped": 'logs' + appId, size: 10000000, max: 1000}, function(err, data) {
203+
common.db.command({"convertToCapped": 'logs' + appId, size: 10000000, max: 1000}, function(err) {
205204
if (err) {
206-
common.db.createCollection('logs' + appId, {capped: true, size: 10000000, max: 1000}, function(err, data) {});
205+
common.db.createCollection('logs' + appId, {capped: true, size: 10000000, max: 1000}, function() {});
207206
}
208207
});
209208
});
@@ -224,6 +223,6 @@ var plugin = {},
224223
common.db.createCollection('logs' + appId, {capped: true, size: 10000000, max: 1000}, function() {});
225224
});
226225
});
227-
}(plugin));
226+
}(exported));
228227

229-
module.exports = plugin;
228+
module.exports = exported;

plugins/logger/frontend/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var plugin = {};
1+
var exported = {};
22

33
(function(plugin) {
4-
plugin.init = function(app, countlyDb) {
4+
plugin.init = function() {
55

66
};
7-
}(plugin));
7+
}(exported));
88

9-
module.exports = plugin;
9+
module.exports = exported;

plugins/logger/frontend/public/javascripts/countly.models.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
(function(countlyLogger, $, undefined) {
1+
/*global countlyCommon, countlyGlobal, jQuery, $*/
2+
(function(countlyLogger) {
23

34
//Private Properties
45
var _data = {};

plugins/logger/frontend/public/javascripts/countly.views.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global countlyView, store, $, countlyLogger, countlyGlobal, Handlebars, countlyCommon, jQuery, moment, app, LoggerView, CountlyHelpers*/
12
window.LoggerView = countlyView.extend({
23
initialize: function() {
34
this.filter = (store.get("countly_loggerfilter")) ? store.get("countly_loggerfilter") : "logger-all";
@@ -29,13 +30,13 @@ window.LoggerView = countlyView.extend({
2930

3031
this.dtable = $('#logger-table').dataTable($.extend({}, $.fn.dataTable.defaults, {
3132
"aaData": data,
32-
"fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
33+
"fnRowCallback": function(nRow, aData) {
3334
$(nRow).attr("id", aData._id);
3435
},
3536
"aoColumns": [
3637
CountlyHelpers.expandRowIconColumn(),
3738
{
38-
"mData": function(row, type) {
39+
"mData": function(row) {
3940
var ret = '';
4041
if (row.m) {
4142
ret += row.m + "<br/>";
@@ -54,7 +55,7 @@ window.LoggerView = countlyView.extend({
5455
},
5556
{
5657
"mData": function(row, type) {
57-
if (type == "display") {
58+
if (type === "display") {
5859
if ((Math.round(parseFloat(row.reqts, 10)) + "").length === 10) {
5960
return moment(row.reqts * 1000).format("MMMM Do YYYY<br/>HH:mm:ss");
6061
}
@@ -76,7 +77,7 @@ window.LoggerView = countlyView.extend({
7677
},
7778
{
7879
"mData": function(row, type) {
79-
if (type == "display") {
80+
if (type === "display") {
8081
if ((Math.round(parseFloat(row.ts, 10)) + "").length === 10) {
8182
return moment(row.ts * 1000).format("MMMM Do YYYY<br/>HH:mm:ss");
8283
}
@@ -97,7 +98,7 @@ window.LoggerView = countlyView.extend({
9798
"sTitle": jQuery.i18n.map["logger.timestamp"]
9899
},
99100
{
100-
"mData": function(row, type) {
101+
"mData": function(row) {
101102
var ret = "<b>Device ID:</b> <br/>" + row.d.id;
102103
if (row.d.d) {
103104
ret += "<br/><br/>" + row.d.d;
@@ -115,10 +116,10 @@ window.LoggerView = countlyView.extend({
115116
"sTitle": jQuery.i18n.map["logger.device"]
116117
},
117118
{
118-
"mData": function(row, type) {
119+
"mData": function(row) {
119120
if (typeof row.t === "object") {
120121
var ob = {};
121-
if (self.filter && self.filter != "logger-all") {
122+
if (self.filter && self.filter !== "logger-all") {
122123
if (typeof row.t[self.filterToQuery()] === "string") {
123124
try {
124125
ob = JSON.parse(countlyCommon.decodeHtml(row.t[self.filterToQuery()]));
@@ -159,7 +160,7 @@ window.LoggerView = countlyView.extend({
159160
"bSortable": false
160161
},
161162
{
162-
"mData": function(row, type) {
163+
"mData": function(row) {
163164

164165
var ret = "";
165166

@@ -170,7 +171,7 @@ window.LoggerView = countlyView.extend({
170171
ret += "<br/><br/>";
171172
}
172173

173-
if (row.s && (row.s.name || row.s.version)) {
174+
if (row.s && (row.s.name || row.s.version)) {
174175
ret += "<b>" + jQuery.i18n.map["logger.sdk"] + ":</b> ";
175176
ret += "<br/>";
176177
ret += (row.s.name || "") + " " + (row.s.version || "");
@@ -212,7 +213,7 @@ window.LoggerView = countlyView.extend({
212213
var self = this;
213214
if (!this.dtable.aOpen.length) {
214215
$.when(countlyLogger.initialize(this.filterToQuery())).then(function() {
215-
if (app.activeView != self) {
216+
if (app.activeView !== self) {
216217
return false;
217218
}
218219
var data = countlyLogger.getData();
@@ -230,22 +231,22 @@ window.LoggerView = countlyView.extend({
230231
},
231232
filterToQuery: function() {
232233
if (this.filter) {
233-
if (this.filter == "logger-event") {
234+
if (this.filter === "logger-event") {
234235
return "events";
235236
}
236-
if (this.filter == "logger-session") {
237+
if (this.filter === "logger-session") {
237238
return "session";
238239
}
239-
if (this.filter == "logger-metric") {
240+
if (this.filter === "logger-metric") {
240241
return "metrics";
241242
}
242-
if (this.filter == "logger-user") {
243+
if (this.filter === "logger-user") {
243244
return "user_details";
244245
}
245-
if (this.filter == "logger-crash") {
246+
if (this.filter === "logger-crash") {
246247
return "crash";
247248
}
248-
if (this.filter == "logger-consent") {
249+
if (this.filter === "logger-consent") {
249250
return "consent";
250251
}
251252
}

0 commit comments

Comments
 (0)