Skip to content

Commit

Permalink
Merge pull request #358 from VirtualFlyBrain/vfb_geppetto_application
Browse files Browse the repository at this point in the history
Improving GA tracking of issues
  • Loading branch information
Robbie1977 authored Aug 1, 2019
2 parents 536ff98 + 8bfa5e3 commit 0be8cff
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
20 changes: 15 additions & 5 deletions components/VFBMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export default class VFBMain extends React.Component {
if (window.history.state != null && window.history.state.s == 1 && window.location.search.indexOf("i=") > -1) {
window.history.replaceState({ s:0, n:window.history.state.n, b:window.history.state.b, f:window.history.state.f, u:window.location.search }, "Loading", location.pathname + location.search.replace(/id=.*\&/gi,"id=" + idsList[0] + "&") + "," + idsList.join(','));
}
window.ga('send', 'event', 'request', 'addvfbid', idsList.join(','));
window.ga('vfb.send', 'event', 'request', 'addvfbid', idsList.join(','));
if (idsList != null && idsList.length > 0) {
for (var singleId = 0; idsList.length > singleId; singleId++) {
if ($.inArray(idsList[singleId], this.vfbLoadBuffer) == -1) {
Expand Down Expand Up @@ -478,14 +478,14 @@ export default class VFBMain extends React.Component {
}
if (templateID != window.templateID) {
// open new window with the new template and the instance ID
window.ga('send', 'event', 'request', 'newtemplate', templateID);
window.ga('vfb.send', 'event', 'request', 'newtemplate', templateID);
var targetWindow = '_blank';
var newUrl = window.redirectURL.replace(/\$VFB_ID\$/gi, rootInstance.getId()).replace(/\$TEMPLATE\$/gi, templateID).replace(/\$HOST\$/gi, curHost).replace(/\$PROTOCOL\$/gi, curProto);
if (confirm("The image you requested is aligned to another template. \nClick OK to open in a new tab or Cancel to just view the image metadata.")) {
window.open(newUrl, targetWindow);
window.ga('send', 'event', 'opening', 'newtemplate', templateID);
window.ga('vfb.send', 'event', 'opening', 'newtemplate', templateID);
} else {
window.ga('send', 'event', 'cancelled', 'newtemplate', templateID);
window.ga('vfb.send', 'event', 'cancelled', 'newtemplate', templateID);
}
// stop flow here, we don't want to add to scene something with a different template
return;
Expand Down Expand Up @@ -1084,6 +1084,16 @@ export default class VFBMain extends React.Component {
}
}

// google analytics vfb specific tracker
ga('create', 'UA-18509775-2', 'auto', 'vfb');
window.console.stdlog = console.log.bind(console);
window.console.logs = [];
console.log = function () {
window.ga('vfb.send', 'event', 'log', Array.from(arguments).join("\n"));
window.console.logs.push(Array.from(arguments));
window.console.stdlog.apply(console, arguments);
}

// Selection listener
GEPPETTO.on(GEPPETTO.Events.Select, function (instance) {
var selection = GEPPETTO.SceneController.getSelection();
Expand Down Expand Up @@ -1122,7 +1132,7 @@ export default class VFBMain extends React.Component {
}.bind(this));

GEPPETTO.on(GEPPETTO.Events.Websocket_disconnected, function () {
window.ga('send', 'event', 'reload', 'websocket-disconnect', (window.location.origin + window.location.pathname + window.location.search));
window.ga('vfb.send', 'event', 'reload', 'websocket-disconnect', (window.location.pathname + window.location.search));
console.log("Reloading websocket connection by reloading page");
window.location.reload(true);
});
Expand Down
8 changes: 6 additions & 2 deletions components/interface/ErrorCatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,20 @@ class ErrorCatcher extends React.Component {

handleClose = () => {
var customMessage = "Steps to reproduce the problem: \n\nPlease fill the below with the necessary steps to reproduce the problem\n\n\n\nError Information:\n\n"
var url = "https://github.com/VirtualFlyBrain/VFB2/issues/new?body=" + customMessage + this.state.error.message + "\n\n" + this.state.error.stack.replace("#",escape("#"));
var url = "https://github.com/VirtualFlyBrain/VFB2/issues/new?body=" + customMessage + this.state.error.message + "\n\n" + this.state.error.stack.replace("#",escape("#")) + "\n\n" + window.console.logs.join('\n').replace("#",escape("#"));
var win = window.open(encodeURI(url), '_blank');
win.focus();
};

componentDidCatch (error, info) {
// Report error to GA
window.ga('send', 'event', 'error', 'react', error.message + " - " + error.stack.replace("#",escape("#")));
window.ga('vfb.send', 'event', 'error', 'react', error.message + " - " + error.stack.replace("#",escape("#")));
// Display fallback UI
this.setState({ hasError: true, error: error });
// add clinet data to console
$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function (data) {
console.log(JSON.stringify(data, null, 2));
});
}

render () {
Expand Down
4 changes: 2 additions & 2 deletions components/interface/VFBTermInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ export default class VFBTermInfoWidget extends React.Component {
try {
items = 'id=' + this.refs.termInfoRef.state.termInfoId.replace('_meta','') + '&' + items;
title = title || this.refs.termInfoRef.state.termInfoName ;
window.ga('send', 'pageview', (window.location.origin + window.location.pathname + '?id=' + this.refs.termInfoRef.state.termInfoId.replace('_meta','')));
window.ga('vfb.send', 'pageview', (window.location.pathname + '?id=' + this.refs.termInfoRef.state.termInfoId.replace('_meta','')));
} catch (ignore) { }
if (items != "i=") {
if (window.history.state == null) {
Expand All @@ -750,7 +750,7 @@ export default class VFBTermInfoWidget extends React.Component {
}
}
}
window.ga('send', 'pageview', (window.location.origin + window.location.pathname + window.location.search));
window.ga('vfb.send', 'pageview', (window.location.pathname + window.location.search));
window.vfbUpdatingHistory = false;
}
} catch (ignore) {
Expand Down
15 changes: 14 additions & 1 deletion components/interface/VFBToolBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ var menuConfiguration = {
list: [
{
label: "Adult",
icon: "",
position: "right-start",
action: {
handlerAction: "submenu",
Expand Down Expand Up @@ -365,7 +366,8 @@ export default class VFBToolBar extends React.Component {
+ "you can engage directly with our developer community on GitHub"
+ "[<a href='https://github.com/VirtualFlyBrain/VFB2' target='_blank'>VirtualFlyBrain/VFB2</a>].</p>"
+ "<p>If you have a GitHub account you can easily raise a new issue:"
+ "<a id='feedback_githubissue' href='https://github.com/VirtualFlyBrain/VFB2/issues/new?body=%0A%0A%0A%0A%0A%0ASupport%20info%3A%0A'"
+ "<a id='feedback_githubissue' href='https://github.com/VirtualFlyBrain/VFB2/issues/new?body=%0A%0A%0A%0A%0A%0ASupport%20info%3A%0A"
+ window.location.href + "\n\n" + window.console.logs.join('\n').replace("#",escape("#")) + "'"
+ "title='Report an issue via GitHub' target='_blank'>"
+ "Create GitHub Issue</a>"
+ "</p>"
Expand All @@ -381,6 +383,14 @@ export default class VFBToolBar extends React.Component {
+ " </div>";

this.props.htmlOutputHandler(htmlContent);
window.ga('vfb.send', 'pageview', (window.location.pathname + '?page=Feedback'));
// add clinet data to console
$.getJSON('http://gd.geobytes.com/GetCityDetails?callback=?', function (data) {
console.log(JSON.stringify(data, null, 2));
});
// report console log for agrigated analysis
window.ga('vfb.send', 'feedback', window.location.href, window.console.logs.join('\n').replace("#",escape("#")), );

}

clickAbout () {
Expand Down Expand Up @@ -663,6 +673,7 @@ export default class VFBToolBar extends React.Component {
+ " </div>";

this.props.htmlOutputHandler(htmlContent);
window.ga('vfb.send', 'pageview', (window.location.pathname + '?page=About'));
}

clickContribute () {
Expand Down Expand Up @@ -712,12 +723,14 @@ export default class VFBToolBar extends React.Component {
+ " </div>";

this.props.htmlOutputHandler(htmlContent);
window.ga('vfb.send', 'pageview', (window.location.pathname + '?page=Contribute'));
}

menuHandler (click) {
switch (click.handlerAction) {
case 'openNewTab':
click.parameters.map((item, index) => {
window.ga('vfb.send', 'pageview', item);
window.open(item, '_blank');
})
break;
Expand Down
8 changes: 1 addition & 7 deletions dockerFiles/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ grep -rls http://r.virtualflybrain.org/ocpu/library/vfbr/R/vfb_nblast $HOME/work
echo $SOLR_SERVER
grep -rls https://solr.virtualflybrain.org/solr/ontology/select $HOME/workspace/org.geppetto.frontend | xargs sed -i "s@https://solr.virtualflybrain.org/solr/ontology/select@$SOLR_SERVER@g"
echo "Google Analytics code: ${googleAnalyticsSiteCode}"
grep -rls UA-45841517-1 $HOME/workspace/org.geppetto.frontend | xargs sed -i "s@UA-45841517-1@${googleAnalyticsSiteCode}@g"
grep -rls "ga('create', 'UA-" $HOME/workspace/org.geppetto.frontend/src/main/webapp | xargs sed -i "s@ga('create', 'UA-[0-9]*-[0-9]'@ga('create', '${googleAnalyticsSiteCode}'@g"

# Frontend final build
cd $HOME/workspace/org.geppetto.frontend
/bin/echo -e "\e[96mMaven install org.geppetto.frontend\e[0m"
mvn -Dhttps.protocols=TLSv1.2 -DcontextPath=org.geppetto.frontend -DuseSsl=false -DskipTests install
rm -rf src

echo "Google Analytics code: ${googleAnalyticsSiteCode}"
grep -rls UA-45841517-1 $HOME/ | xargs sed -i "s@UA-45841517-1@${googleAnalyticsSiteCode}@g"

# Start a logfile
mkdir -p $SERVER_HOME/serviceability/logs
echo 'Start of log...' > $SERVER_HOME/serviceability/logs/log.log
Expand All @@ -30,9 +27,6 @@ echo 'Start of log...' > $SERVER_HOME/serviceability/logs/log.log
rm $SERVER_HOME/./repository/usr/* || true
cd $HOME/workspace/org.geppetto/utilities/source_setup && python update_server.py

echo "Google Analytics code: ${googleAnalyticsSiteCode}"
grep -rls UA-45841517-1 $HOME/ | xargs sed -i "s@UA-45841517-1@${googleAnalyticsSiteCode}@g"

# set java memory maximum
sed 's/XX:MaxPermSize=512m/XX:MaxPermSize=$MAXSIZE/g' -i $SERVER_HOME/bin/dmk.sh
sed 's/Xmx512m/Xmx$MAXSIZE/' -i $SERVER_HOME/bin/dmk.sh
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"jest-puppeteer": "^3.9.0",
"puppeteer": "^1.17.0",
"url-join": "^4.0.0",
"@geppettoengine/geppetto-client": "openworm/geppetto-client#vfb_ga_code"
"@geppettoengine/geppetto-client": "openworm/geppetto-client#fix_linting"
},
"buildOptions": {
"emitEntryPoint": true,
Expand Down

0 comments on commit 0be8cff

Please sign in to comment.