Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds tracking for visualization interactions #685

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions assets/js/visualize/contributors/pack_hierarchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ function draw_pack_hierarchy(areaID) {
parentCircles.on('click', clicked);

function clicked(o) {
if (typeof _paq !== 'undefined') {
var actionName = o.depth > focus.depth ? 'Drilldown' : 'Drillup';
_paq.push(['trackEvent', 'Contributions - Projects', actionName, o.data.name]);
}
d3.select('#zoomTitle').text(() => {
while (o.depth > focus.depth + 1) {
o = o.parent;
Expand Down
23 changes: 19 additions & 4 deletions assets/js/visualize/dependencies/force_dependencyGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ function draw_force_graph(areaID, adjacentAreaID) {
.ticks(optionsArray.length - 1)
.height(10 * optionsArray.length - 1)
.on('onchange', val => {
if (typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Dependency Graph', 'Dimension Change', optionsArray[val].text]);
}
optionChanged(optionsArray[Math.round(val)]);
d3.select('.' + adjacentAreaID).select('g').remove();
});
Expand Down Expand Up @@ -545,6 +548,9 @@ function draw_force_graph(areaID, adjacentAreaID) {
nodeTip.hide(d);
})
.on('click', d => {
if (d && typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Dependency Graph', 'Repository - Click', d.id]);
}
node.selectAll('circle').each(d => {
d['focused'] = false;
document.getElementById(d['id']).removeAttribute('searched');
Expand Down Expand Up @@ -910,6 +916,9 @@ function draw_force_graph(areaID, adjacentAreaID) {
nodeTip.hide(d)
})
.on('click', d => {
if (d && typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Dependency Graph', 'Repository - Click', d.data.id]);
}
nodeTip.hide(d);
d = nodes[nodes.findIndex(o => o.id == d.data.id)];
const data = { name: d.name, package: d.package, id: d.id, notPackage: d.notPackage, children: getCurrentNeighbors(d) };
Expand Down Expand Up @@ -1023,19 +1032,25 @@ function draw_force_graph(areaID, adjacentAreaID) {

function searchForm(event) {
event.preventDefault();
var searchQueryElement = document.getElementById('search').value.toUpperCase(),
rawSearchQueryValue = searchQueryElement.value,
searchQueryValue = rawSearchQueryValue.toUpperCase();
if (typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Dependency Graph', 'Search', searchQueryValue]);
}
$('.inGraph').attr('fill-opacity', function(i, d) {
return $(this).attr('id').toUpperCase().includes(document.getElementById('search').value.toUpperCase()) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 1 : 0.2;
return $(this).attr('id').toUpperCase().includes(searchQueryValue) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 1 : 0.2;
});

$('.inGraph').attr('stroke-opacity', function(i, d) {
return $(this).attr('id').toUpperCase().includes(document.getElementById('search').value.toUpperCase()) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 1 : 0.2;
return $(this).attr('id').toUpperCase().includes(searchQueryValue) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 1 : 0.2;
});

$('.inGraph').attr('r', function(i, d) {
return $(this).attr('id').toUpperCase().includes(document.getElementById('search').value.toUpperCase()) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 6.5 : 5;
return $(this).attr('id').toUpperCase().includes(searchQueryValue) || ($(this).attr('language') && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase())) ? 6.5 : 5;
});

$('.inGraph').attr('searched', function(i, d) {
return $(this).attr('id').toUpperCase().includes(document.getElementById('search').value.toUpperCase()) || (($(this).attr('language') != null) && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase()));
return $(this).attr('id').toUpperCase().includes(searchQueryValue) || (($(this).attr('language') != null) && $(this).attr('language').toUpperCase().includes(document.getElementById('search').value.toUpperCase()));
});
}
6 changes: 6 additions & 0 deletions assets/js/visualize/largeRepos/pie_activityCommits.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ function draw_pie_commits(areaID) {
.on('click', clicked);

function clicked(d) {
if (typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Commits', 'Drill Down', d.label]);
}
const pieData = pie(decompress(data));
const scaleCoeff = 2 * Math.PI / (2 * Math.PI - (pieData[pieData.length - 1].endAngle - pieData[pieData.length - 1].startAngle));
let shift = 0;
Expand Down Expand Up @@ -157,6 +160,9 @@ function draw_pie_commits(areaID) {
}

function unclicked(d) {
if (typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Commits', 'Drillup', d.label]);
}
const dur = 1000;

const t = chart.transition().duration(dur);
Expand Down
8 changes: 8 additions & 0 deletions assets/js/visualize/largeRepos/sunburst_licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ function draw_sunburst_licenses(areaID) {
let lastClickedObject = root;

function clicked(o) {
if (o.data.name && typeof _paq !== 'undefined') {
var actionName = o.depth > lastClickedObject.depth ? 'Drilldown' : 'Drillup';
_paq.push(['trackEvent', 'Popular Licenses - Sunburst', actionName, o.data.name]);
}
lastClickedObject = o;

let newLabel = label.filter(d => labelEverVisible(d));
Expand Down Expand Up @@ -222,6 +226,10 @@ function draw_sunburst_licenses(areaID) {
})
.ticks(3)
.on('onchange', val => {
if (typeof _paq !== 'undefined') {
var humanReadableValue = options[val];
_paq.push(['trackEvent', 'Popular Licenses - Sunburst', 'Dimension Change', humanReadableValue]);
}
data = reformatData(obj, val);
root = partition(data);
root.each(d => d.current = d);
Expand Down
4 changes: 4 additions & 0 deletions assets/js/visualize/line_repoActivityExplore.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
.on('mouseover', tip.show)
.on('mouseout', tip.hide)
.on('click', d => {
if (d && typeof _paq !== 'undefined') {
var value = d.date.getFullYear() + '-' + d.date.getMonth() + '-' + d.date.getDate();
_paq.push(['trackEvent', 'Line Chart', 'Click', value]);
}
tip.hide(d);
update(smallX,y);
d3.select('#Thanksgiving').attr('y', d => {
Expand Down
3 changes: 3 additions & 0 deletions assets/js/visualize/line_repoStarHistoryExplore.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function draw_line_repoStarHistory(areaID) {
.tickFormat(d3.format('d'))
.default([1, d3.max(flattenedData.map(d => d.value))])
.on('end', val => {
if (val && typeof _paq !== 'undefined') {
_paq.push(['trackEvent', 'Star Chart', 'Filter - Stars', val.join(' - ')]);
}
chart.selectAll('g').remove();
var reposInRange = [];
for (var repo in data) {
Expand Down
8 changes: 8 additions & 0 deletions assets/js/visualize/sunburst_licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ function draw_sunburst_licenses(areaID) {
let lastClickedObject = root;

function clicked(o) {
if (o.data.name && typeof _paq !== 'undefined') {
var actionName = o.depth > lastClickedObject.depth ? 'Drilldown' : 'Drillup';
_paq.push(['trackEvent', 'Licenses - Sunburst', actionName, o.data.name]);
}
lastClickedObject = o;

let newLabel = label.filter(d => labelEverVisible(d));
Expand Down Expand Up @@ -215,6 +219,10 @@ function draw_sunburst_licenses(areaID) {
})
.ticks(3)
.on('onchange', val => {
if (typeof _paq !== 'undefined') {
var humanReadableValue = options[val];
_paq.push(['trackEvent', 'Licenses - Sunburst', 'Dimension Change', humanReadableValue]);
}
data = reformatData(obj, val);
root = partition(data);
root.each(d => d.current = d);
Expand Down