Skip to content

Commit

Permalink
some nice mixpanel stuff as well as tracking of JS errors with Except…
Browse files Browse the repository at this point in the history
…ional (issue #4)
  • Loading branch information
lightbody committed Sep 16, 2013
1 parent edb4e62 commit 6334b97
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
11 changes: 10 additions & 1 deletion app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<!DOCTYPE html>
<html ng-app="roadmapper">
<head>
<script type="text/javascript" src="http://js.exceptional.io/exceptional.js"></script>
<script type="text/javascript">
Exceptional.setKey('@Play.current.configuration.getString("exceptional.key")');
</script>

<title>Roadmapper</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="@routes.VersionedAssets.at("css/bootstrap.css")" rel="stylesheet" media="screen">
Expand Down Expand Up @@ -67,8 +72,12 @@ <h4 ng-show="errors.length > 1">Error</h4>
</script>
<script type="text/javascript">
var heap = heap||[];heap.load=function(a){window._heapid=a;var b=document.createElement("script");b.type="text/javascript",b.async=!0,b.src=("https:"===document.location.protocol?"https:":"http:")+"//cdn.heapanalytics.com/js/heap.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c);var d=function(a){return function(){heap.push([a].concat(Array.prototype.slice.call(arguments,0)))}},e=["identify","track"];for(var f=0;f<e.length;f++)heap[e[f]]=d(e[f])};
heap.load("1171482633");
heap.load("@Play.current.configuration.getString("heap.projectId")");
</script>
<!-- start Mixpanel --><script type="text/javascript">(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==
typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g<i.length;g++)f(c,i[g]);
b._i.push([a,e,d])};b.__SV=1.2}})(document,window.mixpanel||[]);
mixpanel.init("@Play.current.configuration.getString("mixpanel.projectId")");</script><!-- end Mixpanel -->
</head>
<body>

Expand Down
14 changes: 12 additions & 2 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ application.langs="en"
# Default to Global in the root package.
global=Global

# OAuth configuration
include "overrides.conf"

# OAuth configuration
oauth.rootUrl : ${?OAUTH_ROOT_URL}
oauth.clientId : ${?OAUTH_CLIENT_ID}
oauth.clientSecret : ${?OAUTH_CLIENT_SECRET}
Expand Down Expand Up @@ -74,4 +75,13 @@ mail.smtp.user=secret
mail.smtp.pass=secret

# Intercom
intercom.app_id=${?INTERCOM_APP_ID}
intercom.app_id=${?INTERCOM_APP_ID}

# Mixpanel
mixpanel.projectId=${?MIXPANEL_PROJECT_ID}

# Heap
heap.projectId=${?HEAP_PROJECT_ID}

# Exceptional
exceptional.key=${?EXCEPTIONAL_KEY}
3 changes: 3 additions & 0 deletions public/js/problems.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ function ProblemsCtrl($scope, $http, $routeParams, $location, $route, $rootScope

$http.post('/problems', copy)
.success(function (returnedProblem) {
mixpanel.people.increment("Problems Recorded");
mixpanel.track("Record Problem", returnedProblem);

$scope.problems.push(returnedProblem);
$scope.closeNewProblem();
}).error(FormErrorHandler($scope));
Expand Down
14 changes: 14 additions & 0 deletions public/js/roadmapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ angular.module('roadmapper', ["ngCookies", "ui.bootstrap", "ui.select2"]).
$rootScope.i18n = i18n;

$rootScope.user = user;

// mixpanel stuff
mixpanel.set_config({track_pageview: false});
mixpanel.identify(user.email);
mixpanel.register({
"User Email": user.email,
"User Name": user.name
});
mixpanel.people.set("$email", user.email);
mixpanel.people.set("$username", user.email);
mixpanel.people.set("$name", user.name);
mixpanel.people.set("$created", new Date(user.firstLogin));
mixpanel.people.increment("Sessions");
mixpanel.name_tag(user.name);
});

function FormErrorHandler($scope) {
Expand Down

0 comments on commit 6334b97

Please sign in to comment.