newrelic: log screen resolution and pixel density.

Log the user's screen resolution and pixel density so we can make better
decisions about which screen sizes to support.
This commit is contained in:
evazion
2021-09-25 06:46:25 -05:00
parent 51bc953383
commit 04cd6d0d3f
2 changed files with 16 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ import Upload from "../src/javascripts/uploads.js.erb";
import UserTooltip from "../src/javascripts/user_tooltips.js";
import Utility from "../src/javascripts/utility.js";
import Ugoira from "../src/javascripts/ugoira.js"
import NewRelic from "../src/javascripts/new_relic.js";
let Danbooru = {};
Danbooru.Autocomplete = Autocomplete;
@@ -70,6 +71,7 @@ Danbooru.Upload = Upload;
Danbooru.UserTooltip = UserTooltip;
Danbooru.Utility = Utility;
Danbooru.Ugoira = Ugoira;
Danbooru.NewRelic = NewRelic;
Danbooru.notice = Utility.notice;
Danbooru.error = Utility.error;

View File

@@ -0,0 +1,14 @@
class NewRelic {
static initialize_all() {
/* https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/setcustomattribute-browser-agent-api/ */
if (typeof window.newrelic === "object") {
window.newrelic.setCustomAttribute("screenWidth", window.screen.width);
window.newrelic.setCustomAttribute("screenHeight", window.screen.height);
window.newrelic.setCustomAttribute("screenResolution", `${window.screen.width}x${window.screen.height}`);
window.newrelic.setCustomAttribute("devicePixelRatio", window.devicePixelRatio);
}
}
}
NewRelic.initialize_all();
export default NewRelic;