From 3a819a29b7c0b3e1e9348e5a9baa0c766fb15f07 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 12 Aug 2016 11:01:01 +0100 Subject: [PATCH] Make up a device display name Pass a default device name into react-sdk --- package.json | 4 +++- src/vector/index.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3863cd14..d95348ee 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,9 @@ "react-dnd-html5-backend": "^2.1.2", "react-dom": "^15.2.1", "react-gemini-scrollbar": "matrix-org/react-gemini-scrollbar#5e97aef", - "sanitize-html": "^1.11.1" + "sanitize-html": "^1.11.1", + "ua-parser-js": "^0.7.10", + "url": "^0.11.0" }, "devDependencies": { "babel": "^5.8.23", diff --git a/src/vector/index.js b/src/vector/index.js index 07501094..6264f744 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -44,6 +44,8 @@ var VectorConferenceHandler = require('../VectorConferenceHandler'); var UpdateChecker = require("./updater"); var q = require('q'); var request = require('browser-request'); + +import UAParser from 'ua-parser-js'; import url from 'url'; import {parseQs, parseQsFromFragment} from './url_utils'; @@ -134,6 +136,19 @@ var makeRegistrationUrl = function() { '#/register'; } + +function getDefaultDeviceName() { + // strip query-string and fragment from uri + let u = url.parse(window.location.href); + u.search = ""; + u.hash = ""; + let app_name = u.format(); + + let ua = new UAParser(); + return app_name + " via " + ua.getBrowser().name + + " on " + ua.getOS().name; +} + window.addEventListener('hashchange', onHashChange); window.onload = function() { console.log("window.onload"); @@ -238,6 +253,7 @@ async function loadApp() { startingFragmentQueryParams={fragparts.params} enableGuest={true} onLoadCompleted={onLoadCompleted} + default_device_name={getDefaultDeviceName()} />, document.getElementById('matrixchat') );