-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDP-6981_GoogleAnalyticsFrontend_prod (#327)
* * Added endpoint for the GoogleAnalytics to send analytics from frontend in FrontendAnalyticsRoute *changed the way we calculate the time difference to get the ceiling *corrected old ways of getting GA * * Added calculation for empty list
- Loading branch information
Showing
7 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/broadinstitute/dsm/route/FrontendAnalyticsRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.broadinstitute.dsm.route; | ||
|
||
import org.broadinstitute.ddp.handlers.util.Result; | ||
import org.broadinstitute.dsm.analytics.GoogleAnalyticsMetrics; | ||
import org.broadinstitute.dsm.analytics.GoogleAnalyticsMetricsTracker; | ||
import org.broadinstitute.dsm.security.RequestHandler; | ||
import org.broadinstitute.dsm.statics.RoutePath; | ||
import spark.QueryParamsMap; | ||
import spark.Request; | ||
import spark.Response; | ||
|
||
public class FrontendAnalyticsRoute extends RequestHandler { | ||
|
||
@Override | ||
protected Object processRequest(Request request, Response response, String userId) throws Exception { | ||
QueryParamsMap queryParams = request.queryMap(); | ||
|
||
String realm = null; | ||
int timer = 0; | ||
if (queryParams.value(RoutePath.REALM) != null) { | ||
realm = queryParams.get(RoutePath.REALM).value(); | ||
if(queryParams.value("timer") != null){ | ||
timer = (int) Math.ceil(Double.parseDouble(queryParams.get("timer").value())/1000); | ||
GoogleAnalyticsMetricsTracker.getInstance().sendAnalyticsMetrics(realm, GoogleAnalyticsMetrics.EVENT_CATEGORY_PARTICIPANT_LIST, | ||
GoogleAnalyticsMetrics.EVENT_PARTICIPANT_LIST_FRONTEND_LOAD_TIME, GoogleAnalyticsMetrics.EVENT_PARTICIPANT_LIST_FRONTEND_LOAD_TIME, timer); | ||
return new Result(200); | ||
}else{ | ||
throw new RuntimeException("timer should not be empty"); | ||
} | ||
} | ||
else{ | ||
throw new RuntimeException("Realm should not be empty"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters