Skip to content

Commit d576213

Browse files
committed
[sources] add source character limitation config & process
1 parent ac6d667 commit d576213

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

plugins/sources/api/api.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ var utmTags = ["_ga", "_gac", "utm_source", "utm_medium", "utm_campaign", "utm_t
101101
var predefinedMetrics = ob.predefinedMetrics;
102102
var params = ob.params;
103103
var user = ob.user;
104+
104105
if (params.qstring.metrics && (!user || typeof user[common.dbUserMap.source] === "undefined")) {
105106
if (typeof params.qstring.metrics._store === "undefined" && params.qstring.metrics._os) {
106107
params.qstring.metrics._store = params.qstring.metrics._os;
@@ -113,7 +114,9 @@ var utmTags = ["_ga", "_gac", "utm_source", "utm_medium", "utm_campaign", "utm_t
113114
}
114115
params.qstring.metrics._store = common.db.encode(params.qstring.metrics._store);
115116
}
116-
117+
var sourcesConfig = plugins.getConfig("sources", params.app && params.app.plugins, true) || {};
118+
var sources_length_limit = (sourcesConfig.sources_length_limit && parseInt(sourcesConfig.sources_length_limit)) || 1000;
119+
params.qstring.metrics._store = params.qstring.metrics._store.substring(0, sources_length_limit);
117120
predefinedMetrics.push({
118121
db: "sources",
119122
metrics: [

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

+38
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,44 @@ window.KeywordsView = countlyView.extend({
226226
}
227227
});
228228

229+
app.addAppManagementView('sources', jQuery.i18n.map['sources.title'], window.countlyManagementView.extend({
230+
initialize: function() {
231+
this.plugin = 'sources';
232+
this.template = window.Handlebars.compile('<div class="mgmt-plugins-row">' +
233+
' <div>' +
234+
' <label for="bundle" data-localize="sources.length_limit" /> ' +
235+
' <span data-localize="sources.length_limit_explain" />' +
236+
' </div>' +
237+
' <div>' +
238+
' <br />' +
239+
' <input type="number" name="sources_length_limit" value="" />' +
240+
' </div>' +
241+
'</div>');
242+
this.resetTemplateData();
243+
},
244+
245+
beforeRender: function() {
246+
},
247+
248+
afterRender: function() {
249+
this.el.find('input')[0].value = this.templateData.sources_length_limit;
250+
},
251+
252+
resetTemplateData: function() {
253+
this.templateData = {
254+
sources_length_limit: this.config().sources_length_limit || 1000
255+
};
256+
},
257+
258+
prepare: function() {
259+
return $.when({
260+
sources: {
261+
sources_length_limit: this.templateData.sources_length_limit || []
262+
}
263+
});
264+
}
265+
}));
266+
229267
//register views
230268
app.sourcesView = new SourcesView();
231269
app.keywordsView = new KeywordsView();

plugins/sources/frontend/public/localization/sources.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ sources.description = Display sources (appstores or referring pages) of your use
44
sources.source = Source
55
sources.direct = Direct
66
sources.organic = Organic
7+
sources.length_limit = Characters length limitation for sources
8+
sources.length_limit_explain = The characters beyond the limitation value will be ignored
79
help.sources.chart = Pie chart on the left shows total visitors from each source (referral URL). Pie chart on the right shows new visitors from each source. The table below shows a breakdown of this data for each source. Click on each line on a table to see a list of paths.
8-
910
#keywords
1011
keywords.title = Search terms

0 commit comments

Comments
 (0)