Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions admin/base/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,6 @@
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = ['--verbosity=2']

# Keen.io settings in local.py
KEEN_PROJECT_ID = osf_settings.KEEN['private']['project_id']
KEEN_READ_KEY = osf_settings.KEEN['private']['read_key']
KEEN_WRITE_KEY = osf_settings.KEEN['private']['write_key']

KEEN_CREDENTIALS = {
'keen_ready': False
}

if KEEN_CREDENTIALS['keen_ready']:
KEEN_CREDENTIALS.update({
'keen_project_id': KEEN_PROJECT_ID,
'keen_read_key': KEEN_READ_KEY,
'keen_write_key': KEEN_WRITE_KEY
})


# Set in local.py
DESK_KEY = ''
Expand Down
2 changes: 0 additions & 2 deletions admin/metrics/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.contrib.auth.mixins import PermissionRequiredMixin

from admin.base import settings
from admin.base.settings import KEEN_CREDENTIALS


class MetricsView(PermissionRequiredMixin, TemplateView):
Expand All @@ -11,7 +10,6 @@ class MetricsView(PermissionRequiredMixin, TemplateView):
raise_exception = True

def get_context_data(self, **kwargs):
kwargs.update(KEEN_CREDENTIALS.copy())
api_report_url = f'{settings.API_DOMAIN}_/metrics/reports/'
kwargs.update({'metrics_url': api_report_url})
return super().get_context_data(**kwargs)
1 change: 0 additions & 1 deletion admin/nodes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ def post(self, request, *args, **kwargs):
node = self.get_object()

node.is_public = False
node.keenio_read_key = ''

# After set permissions callback
for addon in node.get_addons():
Expand Down
6 changes: 1 addition & 5 deletions admin/static/css/keen-dashboards.css
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,4 @@ body.application .return-link:hover,
.hr-menu {
background-color: lightgray;
height: 1px;
}

#reload-node-logs {
margin-left: 20px;
}
}
145 changes: 0 additions & 145 deletions admin/static/js/metrics/metrics.es6.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file you should also be able to remove client, publicClient, renderKeenClient, and anything involving keen-analysis. keen-dataviz is still used to render charts from our internal metrics, so that should be left alone. Removing keen-analysis from here should allow you to remove it from admin's package.json / yarn.lock too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and I guess axing keen-analysis means NodeLogsByUser can go as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also be good to delete the commented-out code. If we decide to reimplement these later, we can always dig into the git history.

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@ require('keen-dataviz/dist/keen-dataviz.min.css');


var c3 = require('c3/c3.js');
var keen = require('keen-js');
var keenDataviz = require('keen-dataviz');
var keenAnalysis = require('keen-analysis');
var $ = require('jquery');

var client = new keenAnalysis({
projectId: keenProjectId,
readKey: keenReadKey
});

var publicClient = new keenAnalysis({
projectId: keenPublicProjectId,
readKey: keenPublicReadKey
});

// Heights and Colors for the below rendered
// Keen and c3 Data visualizations
Expand Down Expand Up @@ -423,67 +412,6 @@ var getMetricTitle = function(metric, type) {
return title;
};

var renderKeenMetric = function(element, type, query, height, colors, keenClient) {
if (!keenClient) {
keenClient = client;
}

var chart = new keenDataviz()
.el(element)
.height(height)
.title(' ')
.type(type)
.prepare();

if (colors) {
chart.colors([colors]);
}

keenClient
.run(query)
.then(function(res){
var metricChart = chart.data(res);
metricChart.dataset.sortRows("desc", function(row) {
return row[1]
});
metricChart.render();
})
.catch(function(err){
chart.message(err.message);
});
};

var renderNodeLogsForOneUserChart = function(user_id) {
var chart = new keenDataviz()
.el('#yesterdays-node-logs-by-user')
.height(bigMetricHeight)
.title('Individual Logs for ' + '<a href=../users/' + user_id + '>' + user_id + '</a>')
.type('line')
.prepare();

client
.query('count', {
event_collection: "node_log_events",
interval: "hourly",
group_by: "action",
filters: [{
property_name: 'user_id',
operator: 'eq',
property_value: user_id
}],
timeframe: "previous_1_days",
timezone: "UTC"
})
.then(function(res){
chart
.data(res)
.render();
})
.catch(function(err){
chart.message(err.message);
});
};

// called from pageview collection
var differenceGrowthBetweenMetrics = function(query1, query2, totalQuery, element, colors) {

Expand Down Expand Up @@ -837,46 +765,6 @@ var renderEmailDomainsChart = function() {
});
};

var NodeLogsPerUser = function() {
var chart = new keenDataviz()
.el('#yesterdays-node-logs-by-user')
.title(' ')
.height(bigMetricHeight)
.chartOptions({
data: {
onclick: function (d, element) {
renderNodeLogsForOneUserChart(d.name);
}
}
})

.type('line')
.prepare();

client
.query('count', {
event_collection: 'node_log_events',
group_by: "user_id",
timeframe: 'previous_1_days',
interval: 'hourly'
})
.then(function (res) {
var chartWithData = chart.data(res);
chartWithData.dataset.filterColumns(function (column, index) {
var logThreshhold = 25;
for (var i = 0; i < column.length; i++) {
if (column[i] > logThreshhold && column[0] != 'null' && column[0] != 'uj57r') {
return column;
}
}
});

chartWithData.render();
})
.catch(function (err) {
chart.message(err.message);
});
};

var renderRawNodeMetrics = function() {
var propertiesAndElements = [
Expand Down Expand Up @@ -966,7 +854,6 @@ var UserGainMetrics = function() {
renderMainCounts();
renderWeeklyUserGainMetrics();
renderEmailDomainsChart();
NodeLogsPerUser();
};


Expand Down Expand Up @@ -1084,36 +971,6 @@ function renderPreprintMetrics(timeframe) {
// ><+><+><+<+><+

var DownloadMetrics = function() {

// ********** legacy keen **********
var totalDownloadsQuery = new keenAnalysis.Query("count", {
eventCollection: "file_stats",
timeframe: 'previous_1_days',
filters: [{
property_name: 'action.type',
operator: 'eq',
property_value: 'download_file',
timezone: "UTC"
}]
});
renderKeenMetric("#number-of-downloads", "metric", totalDownloadsQuery,
defaultHeight, defaultColor, publicClient);

// ********** legacy keen **********
var uniqueDownloadsQuery = new keenAnalysis.Query("count_unique", {
eventCollection: "file_stats",
timeframe: 'previous_1_days',
target_property: 'file.resource',
filters: [{
property_name: 'action.type',
operator: 'eq',
property_value: 'download_file',
timezone: "UTC"
}]
});
renderKeenMetric("#number-of-unique-downloads", "metric", uniqueDownloadsQuery,
defaultHeight, defaultColor, publicClient);

renderDownloadMetrics();
};

Expand All @@ -1138,13 +995,11 @@ function renderDownloadMetrics(timeframe) {

module.exports = {
UserGainMetrics: UserGainMetrics,
NodeLogsPerUser: NodeLogsPerUser,
InstitutionMetrics: InstitutionMetrics,
RawNumberMetrics: RawNumberMetrics,
AddonMetrics: AddonMetrics,
PreprintMetrics: PreprintMetrics,
DownloadMetrics: DownloadMetrics,
KeenRenderMetrics: renderKeenMetric,
RenderPreprintMetrics: renderPreprintMetrics,
RenderDownloadMetrics: renderDownloadMetrics,
};
8 changes: 1 addition & 7 deletions admin/static/js/pages/metrics-page.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove keenAnalysis from this file and move the initializers out of the keenAnalysis.ready()

Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
'use strict';

var $ = require('jquery');
var keenAnalysis = require('keen-analysis');
var Metrics = require('js/metrics/metrics');



keenAnalysis.ready(function() {

$( document ).ready(function() {
Metrics.UserGainMetrics();

$('#reload-node-logs')[0].onclick = function() {
Metrics.NodeLogsPerUser();
};

$('#institution-tab')[0].onclick = function() {
Metrics.InstitutionMetrics();
};
Expand Down
Loading
Loading