zulip/zephyr/static/js/metrics.js

53 lines
1.9 KiB
JavaScript

var metrics = (function () {
var exports = {};
function enable_metrics() {
return page_params.domain === "humbughq.com";
}
if (! enable_metrics()) {
mixpanel.disable();
}
$(function () {
$(document).on('compose_started.zephyr', function (event) {
mixpanel.track('compose started', {user: page_params.email,
realm: page_params.domain,
type: event.message_type,
trigger: event.trigger},
function (arg) {
if (arg !== undefined && arg.status !== 1) {
blueslip.warn(arg);
}
});
});
$(document).on('narrow_activated.zephyr', function (event) {
var operators = event.filter.operators();
var stream_operands = event.filter.operands('stream');
var subject_operands = event.filter.operands('subject');
var reported_operators;
if (operators.length === 1) {
reported_operators = operators[0][0];
} else if (operators.length === 2
&& stream_operands.length !== 0 && subject_operands.length !== 0) {
reported_operators = 'stream and subject';
} else {
reported_operators = 'multiple';
}
mixpanel.track('narrow activated', {user: page_params.email,
realm: page_params.domain,
operators: reported_operators,
trigger: event.trigger},
function (arg) {
if (arg !== undefined && arg.status !== 1) {
blueslip.warn(arg);
}
});
});
});
return exports;
}());