-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (52 loc) · 2.12 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/css/reset.css">
<link rel="stylesheet" type="text/css" href="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.css">
<script src="https://cdn.mxpnl.com/libs/mixpanel-platform/build/mixpanel-platform.v0.latest.min.js"></script>
</head>
<body class="mixpanel-platform-body">
<script id='query'>
var eventSubstr = 'Browse_Classes.Impression.';
function main() {
return Events({
from_date: '2018-03-04',
to_date: '2018-04-03'
})
.filter(event => event.name.indexOf(eventSubstr) !== -1)
.groupBy(['name'], mixpanel.reducer.noop())
.map(res => res.key[0]);
}
</script>
Date: <br>
<div id="dateSelect"></div>
Event: <br>
<div id='events'></div>
Property <br>
<div id='properties'></div>
<div id="table" style='width:943px'></div><br>
<script>
var script = document.getElementById('query').innerHTML;
var dateSelect = $('#dateSelect').MPDatepicker();
var eventSelect = $('#events').MPEventSelect();
var propSelect = $('#properties').MPPropertySelect();
propSelect.MPPropertySelect('setEvent');
var eventTable = $('#table').MPTable({showPercentages: false, firstColHeader: 'Frequency'});
function runQuery() {
var params = {
'from_date': dateSelect.MPDatepicker('value').from.toISOString().slice(0, -14),
'to_date': dateSelect.MPDatepicker('value').to.toISOString().slice(0, -14),
'event': eventSelect.MPEventSelect('value'),
'property': propSelect.MPPropertySelect('value')
};
MP.api.custom_query(script, {}).done(function(results) {
debugger;
var res = _.chain(results).map(function(item) {var obj = {}; obj.Property = item.key[0]? item.key[0]: 'No Property'; obj.Count = item.value; return obj;}).sortBy(item => -1 * item.Count).value();res.unshift(''); delete res[0];
eventTable.MPTable('setData', res);
});
}
eventSelect.on('change', function() {runQuery();});
propSelect.on('change', function() {runQuery();});
</script>
</body>
</html>