Skip to content

Commit 89fef83

Browse files
authored
DataDog RUM + Events (#225)
* DataDog RUM + Events * THE RIGHT INFORMATION ON THE FILE * Fix: Travis Build * Fix: Travis Build * Added all of the ga events + some more other ones that weren't just inside scheduleActionsDirective.js * Few more events + linter * Took out some unnececarry events
1 parent c08f5d2 commit 89fef83

File tree

7 files changed

+85
-11
lines changed

7 files changed

+85
-11
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@ Available at [schedule.csh.rit.edu](https://schedule.csh.rit.edu)
1717
## Dev Environment
1818

1919
### Setup
20-
- Fork and clone the repository
21-
- Copy the `config.example.php` file to `config.php` in `/inc/` or set environment variables as defined in `config.env.php`
22-
- Contact a current maintainer for server/database configs
23-
- If you wish to see images locally, you will also need S3 credentials, either supply your own or reach out
20+
- Fork and clone the repository.
21+
- Copy the `config.example.php` file to `config.php` in `/inc/` or set environment variables as defined in `config.env.php`.
22+
- Contact a current maintainer for server/database configs.
23+
- If you wish to see images locally, you will also need S3 credentials, either supply your own or reach out.
2424

2525
### Run Locally
26-
In order to run locally youre going to need [docker](https://www.docker.com/)
26+
In order to run locally youre going to need [docker](https://www.docker.com/).
2727

2828
```
2929
docker build -t schedulemaker .
3030
docker run --rm -i -t -p 5000:8080 --name=schedulemaker schedulemaker
3131
```
3232

33-
You can replace `5000` with whatever port you wish to connect locally to. Then visit `http://localhost:5000` in a browser
33+
You can replace `5000` with whatever port you wish to connect locally to. Then visit `http://localhost:5000` in a browser.
3434

3535
### Development
36-
- To build js files run `npm run-script build`
37-
- Increment the version number in `package.json` after updating js/css files or ensure all cache cleared
38-
- Make sure you increment at least the patch number in any PRs that touch Javascript/CSS
36+
- To build js files run `npm run-script build`.
37+
- Increment the version number in `package.json` after updating js/css files or ensure all cache cleared.
38+
- Make sure you increment at least the patch number in any PRs that touch Javascript/CSS.
39+
- If you get an error with JS/CSS not loading, check your config file.
3940

4041
## Maintainers
4142

assets/src/modules/sm/Generate/controllers/GenerateController.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ angular.module('sm').controller('GenerateController', function ($scope, globalKb
160160
$http.post('/generate/getMatchingSchedules', $.param(requestData))
161161
.success(function (data, status, headers, config) {
162162
ga('send', 'event', 'generate', 'schedule')
163+
window.DD_RUM &&
164+
DD_RUM.addUserAction('Generate', {
165+
type: 'Schedule',
166+
data: data
167+
})
163168
$scope.generationStatus = 'D'
164169

165170
// If no errors happened

assets/src/modules/sm/Schedule/directives/scheduleActionsDirective.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
5151
save: function (saveType) {
5252
if (saveType === 'create') {
5353
ga('send', 'event', 'schedule', 'save')
54+
window.DD_RUM &&
55+
DD_RUM.addUserAction('Schedule', {
56+
type: 'Save'
57+
})
5458
getSavedInfo().then(function (data) {
5559
scope.notification = 'This schedule can be accessed at ' +
5660
'<a href="' + data.url + '" target="_blank">' +
@@ -62,14 +66,23 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
6266
})
6367
} else {
6468
ga('send', 'event', 'schedule', 'fork')
65-
localStorage.setItem('forkSchedule', scope.schedule)
69+
window.DD_RUM &&
70+
DD_RUM.addUserAction('Schedule', {
71+
type: 'Fork'
72+
})
6673

74+
localStorage.setItem('forkSchedule', scope.schedule)
6775
$state.go('generate')
6876
}
6977
},
7078

7179
shareToService: function ($event, serviceName, newWindow) {
7280
ga('send', 'event', 'schedule', 'share', serviceName)
81+
window.DD_RUM &&
82+
DD_RUM.addUserAction('Schedule', {
83+
type: 'Share',
84+
serviceName: serviceName
85+
})
7386
$event.preventDefault()
7487
scope.status = 'L'
7588
if (serviceName && serviceName in shareServiceInfo) {
@@ -87,6 +100,11 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
87100

88101
shareToEmail: function ($event) {
89102
ga('send', 'event', 'schedule', 'share', 'email')
103+
window.DD_RUM &&
104+
DD_RUM.addUserAction('Schedule', {
105+
type: 'Share',
106+
subtype: 'Email'
107+
})
90108
$event.preventDefault()
91109

92110
getSavedInfo().then(function (data) {
@@ -100,13 +118,23 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
100118

101119
shareToDirectLink: function ($event) {
102120
ga('send', 'event', 'schedule', 'share', 'link')
121+
window.DD_RUM &&
122+
DD_RUM.addUserAction('Schedule', {
123+
type: 'Share',
124+
subtype: 'Link'
125+
})
103126
$event.preventDefault()
104127

105128
scope.scheduleActions.save('create')
106129
},
107130

108131
downloadiCal: function ($event) {
109132
ga('send', 'event', 'schedule', 'download', 'iCal')
133+
window.DD_RUM &&
134+
DD_RUM.addUserAction('Schedule', {
135+
type: 'Download',
136+
subtype: 'iCal'
137+
})
110138
$event.preventDefault()
111139

112140
getSavedInfo().then(function (data) {
@@ -116,6 +144,11 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
116144

117145
downloadImage: function ($event) {
118146
ga('send', 'event', 'schedule', 'download', 'image')
147+
window.DD_RUM &&
148+
DD_RUM.addUserAction('Schedule', {
149+
type: 'Download',
150+
subtype: 'Image'
151+
})
119152
$event.preventDefault()
120153

121154
var popup = openPopup(true)
@@ -128,6 +161,10 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
128161

129162
print: function () {
130163
ga('send', 'event', 'schedule', 'print')
164+
window.DD_RUM &&
165+
DD_RUM.addUserAction('Schedule', {
166+
type: 'Print'
167+
})
131168

132169
var reloadSchedule = angular.copy(scope.state.drawOptions)
133170
reloadSchedule.term = scope.state.requestOptions.term
@@ -142,6 +179,10 @@ angular.module('sm').directive('scheduleActions', function ($http, $q, shareServ
142179

143180
hide: function () {
144181
ga('send', 'event', 'schedule', 'hide')
182+
window.DD_RUM &&
183+
DD_RUM.addUserAction('Schedule', {
184+
type: 'Hide'
185+
})
145186
const appstate = scope.$parent.$parent.state
146187
const pageStartIndex = appstate.displayOptions.currentPage * appstate.displayOptions.pageSize
147188

assets/src/modules/sm/Search/controllers/SearchController.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ angular.module('sm').controller('SearchController', function ($scope, $http, ent
138138
// 'D'one loading
139139
$scope.searchStatus = 'D'
140140

141+
ga('send', 'event', 'search', 'find')
142+
window.DD_RUM &&
143+
DD_RUM.addUserAction('Search', {
144+
type: 'Find',
145+
data: data
146+
})
147+
141148
if (status === 200 && typeof data.error === 'undefined') {
142149
// Set the results
143150
$scope.searchResults = data

assets/src/modules/sm/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ angular.module('sm', ['ngAnimate', 'ngSanitize', 'ui.router'])
7676
.run(function ($rootScope, $window) {
7777
$rootScope.$on('$stateChangeSuccess', function (evt) {
7878
ga('send', 'pageview')
79+
window.DD_RUM &&
80+
DD_RUM.addUserAction('Pageview', {
81+
type: 'On Load'
82+
})
7983
$($window).scrollTop(0)
8084
})
8185

inc/config.env.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@
4141
$GOOGLEANALYTICS = ($SERVER_TYPE == 'production')?
4242
$get_env(getenv("GOOGLEANALYTICS1"), ''):
4343
$get_env(getenv("GOOGLEANALYTICS2"), '');
44-
//
44+
45+
////////////////////////////////////////////////////////////////////////////
46+
////// DATADOG RUM ANALYTICS
47+
////
48+
49+
$RUM_CLIENT_TOKEN = $get_env(getenv("RUM_CLIENT_TOKEN"), '');
50+
$RUM_APPLICATION_ID = $get_env(getenv("RUM_APPLICATION_ID"), '');
4551

4652
////////////////////////////////////////////////////////////////////////////
4753
// WORK AROUNDS

index.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@
126126

127127
ga('create', '<?= $GOOGLEANALYTICS ?>', 'rit.edu');
128128
</script>
129+
<script
130+
src="https://www.datadoghq-browser-agent.com/datadog-rum-us.js"
131+
type="text/javascript">
132+
</script>
133+
<script>
134+
window.DD_RUM && window.DD_RUM.init({
135+
clientToken: '<?= $RUM_CLIENT_TOKEN ?>',
136+
applicationId: '<?= $RUM_APPLICATION_ID ?>',
137+
});
138+
</script>
129139
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
130140
<script src="//cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js"></script>
131141
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

0 commit comments

Comments
 (0)