-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
595 lines (556 loc) · 23.6 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
<!DOCTYPE html>
<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>
<style>
.big {
font-size: 150%;
text-align: center;
}
input {
font-family: system, -apple-system, ".SFNSDisplay-Regular", "Helvetica Neue", sans-serif;
font-weight: normal;
letter-spacing: 0.03em;
font-size: 13px;
color: #747d94;
width: 455px;
margin: 0 0 10px 0;
padding: 5px;
border: 1px solid #bdc7d2;
-webkit-border-radius: 3px;
border-radius: 3px;
position: relative;
-webkit-appearance: textfield;
background-color: white;
}
input:focus, input:hover {
outline: 0;
border-color: #5ba7e1;
}
input.operandText {
height: 20px;
}
#runQueryError {
color: red;
font-weight: bold;
padding: 5px;
}
</style>
</head>
<body class="mixpanel-platform-body">
<div class="mixpanel-platform-section">
<h1 class="big">Launch Analysis</h1>
<h1>How did a new launch event (cause):</h1>
<div id="causeEventSelect" style="float: left;"></div>
<button id="causeFilter" class="mixpanel-platform-label" style="width: 80px; margin-left: 10px; display: none;">+ Filter</button>
<div style="clear: both; padding: 10px"></div>
<h1 id="causeFilteredBy" style="float:left; margin-left: 50px; display:none;">Filtered by:</h1>
<div id="causePropSelect" style="float: left; margin-left: 10px"></div>
<div id="causeOperatorSelect" style="float: left; margin-left: 10px; display: none;"></div>
<div id="causeOperandSelect" style="float: left; margin-left: 10px; display: none;"></div>
<input id="causeOperandTextBox" class="operandText" style="float: left; margin-left: 10px; display: none;">
<div style="clear: both; padding: 10px;"></div>
<h1>impact my KPI metric (effect):</h1>
<div id="effectEventSelect" style="float: left;"></div>
<button id="effectFilter" class="mixpanel-platform-label" style="width: 80px; margin-left: 10px; display: none;">+ Filter</button>
<div style="clear: both; padding: 10px"></div>
<h1 id="effectFilteredBy" style="float:left; margin-left: 50px; display:none;">Filtered by:</h1>
<div id="effectPropSelect" style="float: left; margin-left: 10px;"></div>
<div id="effectOperatorSelect" style="float: left; margin-left: 10px; display: none;"></div>
<div id="effectOperandSelect" style="float: left; margin-left: 10px; display: none;"></div>
<input id="effectOperandTextBox" class="operandText" style="float: left; margin-left: 10px; display: none;">
<div style="clear: both; padding: 10px;"></div>
<h1>in this date range (launch event must be introduced within this range):</h1>
<div id="dateSelect" style="float: left;"></div>
<div style="clear: both; padding: 10px;"></div>
<button id="runQuery" class="mixpanel-platform-label" style="width: 100px;">Run Query</button>
<div id="runQueryError" style="float: left; margin-left: 10px; display: none;">Please choose 2 events!</div>
<div style="clear: both; padding:10px;"></div>
<div id="activityLevel"></div>
<div style="clear: both;"></div>
<div id="relativeScale"></div>
<div style="clear: both;"></div>
<div id="absoluteScale"></div>
<div style="clear: both;"></div>
<div id="graph"></div>
</div>
<div id="table"></div>
<script>
// Questions
// 1. why don't all the events show up in the dropdown e.g. [Flows] Change flow direction
// https://mixpanel.com/report/3/jql-console#edit/5814893
var activityLevelJQL =`
function main() {
return Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: [
...params.effect_selectors
]
})
.groupByUser(mixpanel.reducer.count())
.reduce(mixpanel.reducer.numeric_percentiles("value", params.activity_percentiles || [25, 75, 90, 95, 99]))
;}
`;
// https://mixpanel.com/report/3/jql-console#edit/5645877
var relativeScaleJQL =`
var PROJECT_TIME_OFFSET = 7 * 60 * 60 * 1000;
function timestampToDaysSinceEpoch(ts) {
return Math.floor(ts / (1000 * 3600 * 24));
}
function dateToDaysSinceEpoch(date) {
return timestampToDaysSinceEpoch(date.getTime());
}
function emptyTimeseries(length) {
return (new Array(length)).fill(0);
}
var from = dateToDaysSinceEpoch(new Date(Date.parse(params.from_date)));
var to = dateToDaysSinceEpoch(new Date(Date.parse(params.to_date)));
var timeseriesLength = (to - from + 1);
var subquery = Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: params.effect_selectors
}).groupByUser(mixpanel.reducer.count());
function main() {
return join(Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: [
...params.effect_selectors,
...params.cause_selectors
]
}), subquery, {behavior_name: "activity_level", type: "left", selectors:[{selector: '(not "mixpanel.com" in user["$email"])'}]})
// For each user, return an object {treatmentTime: int, effectCounts: int[]}
// treatmentTime is the timestamp of the first time the user did the treatment or null if they never did.
// effectCounts is a list of counts of the effect event for each day after the treatment event was performed.
// /*
.groupByUser((state, events) => {
state = state || {treatmentTime: null, effectCounts: emptyTimeseries(timeseriesLength), firstEffectTime: null};
for(var i = 0; i< events.length; i++) {
if (events[i].behaviors && events[i].behaviors.activity_level) {
state.activity_level = events[i].behaviors.activity_level;
}
var event = events[i].event;
if (event.labels && event.labels.includes("$cause") && state.treatmentTime === null) {
state.treatmentTime = event.time + PROJECT_TIME_OFFSET;
}
if (event.labels && event.labels.includes("$effect")) {
var index = timestampToDaysSinceEpoch(event.time + PROJECT_TIME_OFFSET) - from;
state.effectCounts[index] += 1;
if (index >= params.window && index < state.effectCounts.length - params.window && state.firstEffectTime === null) {
state.firstEffectTime = event.time + PROJECT_TIME_OFFSET;
}
}
}
return state;
})
.groupBy([mixpanel.numeric_bucket("value.activity_level", params.activity_level_bounds)],
function(countAccumulators, countObjects) {
// accume holds the number of treatment users, and a time series with the average events per day for some period
// before and after the treatment event is first performed.
var accume = {
treatment: {
userCount: 0,
effectTimeseries: emptyTimeseries(2 * params.window + 1)
},
control: {
userCount: 0,
effectTimeseries: emptyTimeseries(2 * params.window + 1)
}
};
// Add all the accumulators
for(var i = 0; i < countAccumulators.length; i++) {
currentAccume = countAccumulators[i];
accume.treatment.userCount += currentAccume.treatment.userCount;
accume.control.userCount += currentAccume.control.userCount;
for(var j = 0; j < currentAccume.treatment.effectTimeseries.length; j++) {
if (currentAccume.treatment.effectTimeseries[j]) {
accume.treatment.effectTimeseries[j] += (currentAccume.treatment.effectTimeseries[j] *
currentAccume.treatment.userCount);
}
if (currentAccume.control.effectTimeseries[j]) {
accume.control.effectTimeseries[j] += (currentAccume.control.effectTimeseries[j] *
currentAccume.control.userCount);
}
}
}
// Add all the individual counts
for(i = 0; i < countObjects.length; i++) {
var currentCount = countObjects[i].value;
if (!currentCount.treatmentTime) { // temporarily only look at people who've had the treatment
// This group never did the treatment event
var index = timestampToDaysSinceEpoch(currentCount.firstEffectTime) - from;
if (index >= params.window && index < currentCount.effectCounts.length - params.window) {
accume.control.userCount += 1;
for(var j = index - params.window; j < index + params.window; j++) {
accume.control.effectTimeseries[j - (index - params.window)] += currentCount.effectCounts[j];
}
}
} else {
// This group did the treatment event
var index = timestampToDaysSinceEpoch(currentCount.treatmentTime) - from;
if (index >= params.window && index < currentCount.effectCounts.length - params.window) {
accume.treatment.userCount += 1;
for(var j = index - params.window; j < index + params.window; j++) {
accume.treatment.effectTimeseries[j - (index - params.window)] += currentCount.effectCounts[j];
}
}
}
}
// Normalize to get the average effectEvents per day
for (var relativeDay = 0; relativeDay < accume.treatment.effectTimeseries.length; relativeDay++) {
if (accume.treatment.userCount && accume.treatment.effectTimeseries[relativeDay]) {
accume.treatment.effectTimeseries[relativeDay] = (1.0 * accume.treatment.effectTimeseries[relativeDay]) / accume.treatment.userCount;
}
if (accume.control.userCount && accume.control.effectTimeseries[relativeDay]) {
accume.control.effectTimeseries[relativeDay] = (1.0 * accume.control.effectTimeseries[relativeDay]) / accume.control.userCount;
}
}
return accume;
}
)
.filter(function(item) {
return item.value.control.userCount > 0 && item.value.treatment.userCount > 0;
})
;}
`;
// https://mixpanel.com/report/3/jql-console#edit/5751773
var cumulativeAdoptersJQL =`
function timestampToDaysSinceEpoch(ts) {
return Math.floor(ts / (1000 * 3600 * 24));
}
function dateToDaysSinceEpoch(date) {
return timestampToDaysSinceEpoch(date.getTime());
}
function emptyTimeseries(length) {
var ar = new Array(length);
for(var i = 0; i < ar.length; i++) {
ar[i] = {adopters: [], non_adopters: []}; //[];
}
return ar
}
var from = dateToDaysSinceEpoch(new Date(Date.parse(params.from_date)));
var to = dateToDaysSinceEpoch(new Date(Date.parse(params.to_date)));
var timeseriesLength = (to - from + 1);
function main() {
return join(
Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: [...params.cause_selectors, ...params.effect_selectors],
}), People(), {type: "inner", selectors:[{selector: '(not "mixpanel.com" in user["$email"])'}]})
.reduce(function(accumulators, items) {
var accum = emptyTimeseries(timeseriesLength);
for (var i = 0; i < accum.length; i++) {
for (var j = 0; j < accumulators.length; j++) {
accum[i].adopters.push(...(accumulators[j][i].adopters));
accum[i].non_adopters.push(...(accumulators[j][i].non_adopters));
}
}
var all_users = [];
for (var k = 0; k < items.length; k++) {
var ev = items[k].event;
var index = timestampToDaysSinceEpoch(ev.time) - from;
for (var l = index; l < accum.length; l++) {
if (ev.labels && ev.labels.includes("$cause")) {
accum[l].adopters.push(ev.distinct_id);
}
}
all_users.push(ev.distinct_id);
}
for (var m = 0; m < accum.length; m++) {
var xa = new Set(accum[m].adopters);
accum[m].adopters = Array.from(xa);
var xna = new Set([...(accum[m]).non_adopters, ...all_users]);
accum[m].non_adopters = Array.from(xna);
}
return accum;
})
.flatten()
.map(function(x) {
var a = new Set(x.adopters);
var na = new Set(x.non_adopters.filter(x => !a.has(x)));
delete x.non_adopters;
x.num_non_adopters = Array.from(na).length;
return x;
})
;}
`;
// https://mixpanel.com/report/3/jql-console#edit/5746545
var absoluteScaleJQL = `
function timestampToDaysSinceEpoch(ts) {
return Math.floor(ts / (1000 * 3600 * 24));
}
function timestampToDateString(ts) {
return (new Date(ts)).toISOString().slice(0,10);
}
function safeDiv(num, denom) {
if (denom === 0) {
return 0;
} else {
return num / denom;
}
}
function dateToDaysSinceEpoch(date) {
return timestampToDaysSinceEpoch(date.getTime());
}
var from = dateToDaysSinceEpoch(new Date(Date.parse(params.from_date)));
var to = dateToDaysSinceEpoch(new Date(Date.parse(params.to_date)));
var subquery = Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: params.effect_selectors
}).groupByUser(mixpanel.reducer.count());
function main() {
return join(
join( // add this line if excluding mixpanelers
Events({
from_date: params.from_date,
to_date: params.to_date,
event_selectors: params.effect_selectors}),
People(), {type: "inner", selectors:[{selector: '(not "mixpanel.com" in user["$email"])'}]}), // add this line if excluding mixpanelers
subquery, {behavior_name: "activity_level", type: "left"})
.groupBy([mixpanel.numeric_bucket("behaviors.activity_level", params.activity_level_bounds), function(ev) {return timestampToDateString(ev.event.time);}],
function(accums, its) {
var accum = {adopter_effect_counts: 0,
num_adopters: 0,
non_adopter_effect_counts: 0,
num_non_adopters: 0};
_.each(accums, function (acc) {
accum.adopter_effect_counts += acc.adopter_effect_counts;
accum.num_adopters = Math.max(accum.num_adopters, acc.num_adopters);
accum.non_adopter_effect_counts += acc.non_adopter_effect_counts;
accum.num_non_adopters = Math.max(accum.num_non_adopters, acc.num_non_adopters);
});
var index = null;
var adopters = [];
if (its.length > 0) {
index = timestampToDaysSinceEpoch(its[0].event.time) - from;
adopters = params.cumulative_adopters[index].adopters;
accum.num_adopters = adopters.length;
accum.num_non_adopters = params.cumulative_adopters[index].num_non_adopters;
}
_.each(its, function (it) {
var event = it.event;
if (adopters.includes(event.distinct_id)) {
accum.adopter_effect_counts += 1;
} else {
accum.non_adopter_effect_counts += 1;
}
});
return accum;
})
.reduce(function(accumulators, items){
var a = {};
for (var i = 0; i < accumulators.length; i++) {
for (var activity_level in accumulators[i]) {
a[activity_level] = Object.assign({}, a[activity_level] || {}, accumulators[i][activity_level]);
}
}
_.each(items, function (item) {
var avgmap = {"adopter_avg": safeDiv(item.value.adopter_effect_counts, item.value.num_adopters),
"non_adopter_avg": safeDiv(item.value.non_adopter_effect_counts, item.value.num_non_adopters)}
a[item.key[0]] = a[item.key[0]] || {};
a[item.key[0]][item.key[1]] = avgmap;
});
return a;
})
;}
`;
// var userCohort = ''; TODO user group
var causeEventSelect = $('#causeEventSelect').MPEventSelect();
var causePropSelect = $('#causePropSelect').MPPropertySelect();
var causeOperatorSelect = $('#causeOperatorSelect').MPSelect({items: [{label: '==', value: '=='},
{label: '!=', value: '!='},
{label: '>', value: '>'},
{label: '<', value: '<'},
{label: 'contains', value: 'contains'},
{label: 'does not contain', value: 'does not contain'},
{label: 'set', value: 'set'},
{label: 'not set', value: 'not set'},]});
causeOperatorSelect.val('==');
var causeOperandSelect = '';
var effectEventSelect = $('#effectEventSelect').MPEventSelect();
var effectPropSelect = $('#effectPropSelect').MPPropertySelect();
var effectOperatorSelect = $('#effectOperatorSelect').MPSelect({items: [{label: '==', value: '=='},
{label: '!=', value: '!='},
{label: '>', value: '>'},
{label: '<', value: '<'},
{label: 'contains', value: 'contains'},
{label: 'does not contain', value: 'does not contain'},
{label: 'set', value: 'set'},
{label: 'not set', value: 'not set'},]});
effectOperatorSelect.val('==');
var effectOperandSelect = '';
var dateSelect = $('#dateSelect').MPDatepicker();
// var unit = ''; TODO
var formatSelector = function(propName, operator, operand) {
var selector = '';
if (operand && typeof propName == 'string') {
switch (operator) {
case '==':
case '!=':
case '>':
case '<':
selector = `string(properties["${propName}"]) ${operator} "${operand}"`;
break;
case 'contains':
selector = `"${operand}" in string(properties["${propName}"])`;
break;
case 'does not contain':
selector = `not "${operand}" in string(properties["${propName}"])`;
break;
case 'set':
selector = `defined (properties["${propName}"])`;
break;
case 'not set':
selector = `not defined (properties["${propName}"])`;
break;
}
}
return selector;
};
var runQuery = function() {
$('#runQueryError').hide();
$('#activityLevel').empty();
$('#relativeScale').empty();
$('#absoluteScale').empty();
var causeEventName = causeEventSelect.MPEventSelect('value'),
causePropName = causePropSelect.MPPropertySelect('value'),
causeOperator = causeOperatorSelect.MPSelect('value'),
causeOperand = (typeof causeOperandSelect === 'string' ? '' : causeOperandSelect.MPSelect('value')),
causeOperandText = $('#causeOperandTextBox').val(),
effectEventName = effectEventSelect.MPEventSelect('value'),
effectPropName = effectPropSelect.MPPropertySelect('value'),
effectOperator = effectOperatorSelect.MPSelect('value'),
effectOperand = (typeof effectOperandSelect === 'string' ? '' : effectOperandSelect.MPSelect('value')),
effectOperandText = $('#effectOperandTextBox').val(),
dateRange = dateSelect.MPDatepicker('value');
console.log("causePropName:", typeof causePropName, causePropName);
console.log("causeOperator:", typeof causeOperator, causeOperator);
console.log("causeOperand:", typeof causeOperand, causeOperand);
var causeSelector = formatSelector(causePropName, causeOperator, (['<','>','contains', 'does not contain'].indexOf(causeOperator) ? causeOperandText : causeOperand));
var effectSelector = formatSelector(effectPropName, effectOperator, (['<','>','contains', 'does not contain'].indexOf(effectOperator) ? effectOperandText : effectOperand));
var params = {
from_date: dateRange.from.toISOString().slice(0,10),
to_date: dateRange.to.toISOString().slice(0,10),
cause_selectors: [{event: causeEventName,
selector: causeSelector,
label: '$cause'}],
effect_selectors: [{event: effectEventName,
selector: effectSelector,
label: '$effect'}],
activity_percentiles: [25, 75, 90, 95, 99],
window: 30
};
if (causeEventName && effectEventName) {
console.log("Running activity level with params:", params);
// activity level
MP.api.jql(activityLevelJQL, params).done(function(alresults) {
console.log("Activity level results:", alresults);
$('#activityLevel').append($('<h1>').append('<br><br>Activity level: <br>'));
$('#activityLevel').append(alresults[0].toString());
var activity_level_bounds = [...new Set(alresults[0].map(x => x["value"]))].sort(function(a, b){return a - b});
params['activity_level_bounds'] = activity_level_bounds;
// relative scale
console.log("Running relative scale with params:", params);
MP.api.jql(relativeScaleJQL, params).done(function(rsresults) {
console.log("Relative scale results:", rsresults);
$('#relativeScale').append($('<h1>').append('<br><br>Relative scale: <br>'));
$('#relativeScale').append(rsresults.toString());
});
// absolute scale
console.log("Running absolute scale with params:", params);
MP.api.jql(cumulativeAdoptersJQL, params).done(function(curesults) {
console.log("Cumulative adopters results:", curesults);
params['cumulative_adopters'] = curesults;
MP.api.jql(absoluteScaleJQL, params).done(function(asresults) {
console.log("Absolute scale results:", asresults);
$('#absoluteScale').append($('<h1>').append('<br><br>Absolute scale: <br>'));
$('#absoluteScale').append(asresults.toString());
});
});
});
} else {
$('#runQueryError').show();
}
};
// cause selection
causeEventSelect.on('change', function(e, eventName) {
$("#causeFilter").show();
});
$('#causeFilter').on('click', function() {
$("#causeFilter").hide();
$("#causeFilteredBy").show();
var eventName = causeEventSelect.MPEventSelect('value');
causePropSelect.MPPropertySelect('setEvent', eventName);
});
causePropSelect.on('change', function(e, propName) {
causeOperatorSelect.show();
$("#causeOperandSelect").empty();
var eventName = causeEventSelect.MPEventSelect('value');
var propName = causePropSelect.MPPropertySelect('value');
var op = causeOperatorSelect.MPSelect('value');
MP.api.propertyValues(eventName, propName, {limit: 255}).done(function(properties) {
//console.log(properties.values());
var props = _.map(properties.values(), function(item, key) {return {label: item, value: item};});
causeOperandSelect = $("<div></div>").MPSelect({items: props});
$("#causeOperandSelect").append(causeOperandSelect);
$("#causeOperandSelect").show();
});
});
causeOperatorSelect.on('change', function(e, op) {
if (['==','!='].indexOf(op) > -1) {
$("#causeOperandTextBox").hide();
$("#causeOperandSelect").show();
} else if (['>', '<','contains', 'does not contain'].indexOf(op) > -1) {
$("#causeOperandSelect").hide();
$("#causeOperandTextBox").show();
} else if (['set','not set'].indexOf(op) > -1) {
$("#causeOperandTextBox").hide();
$("#causeOperandSelect").hide();
}
});
// effect selection
effectEventSelect.on('change', function(e, eventName) {
$("#effectFilter").show();
});
$('#effectFilter').on('click', function() {
$("#effectFilter").hide();
$("#effectFilteredBy").show();
var eventName = effectEventSelect.MPEventSelect('value');
effectPropSelect.MPPropertySelect('setEvent', eventName);
});
effectPropSelect.on('change', function(e, propName) {
effectOperatorSelect.show();
$("#effectOperandSelect").empty();
var eventName = effectEventSelect.MPEventSelect('value');
var propName = effectPropSelect.MPPropertySelect('value');
MP.api.propertyValues(eventName, propName, {limit: 255}).done(function(properties) {
//console.log(properties.values());
var props = _.map(properties.values(), function(item, key) {return {label: item, value: item};});
effectOperandSelect = $("<div></div>").MPSelect({items: props});
$("#effectOperandSelect").append(effectOperandSelect);
$("#effectOperandSelect").show();
});
});
effectOperatorSelect.on('change', function(e, op) {
if (['==','!='].indexOf(op) > -1) {
$("#effectOperandTextBox").hide();
$("#effectOperandSelect").show();
} else if (['>','<','contains', 'does not contain'].indexOf(op) > -1) {
$("#effectOperandSelect").hide();
$("#effectOperandTextBox").show();
} else if (['set','not set'].indexOf(op) > -1) {
$("#effectOperandTextBox").hide();
$("#effectOperandSelect").hide();
}
});
$('#runQuery').on('click', runQuery);
</script>
</body>
</html>