diff --git a/src/app/apiInterceptor.js b/src/app/apiInterceptor.js
index 573f58199c..f6f7d1c81b 100644
--- a/src/app/apiInterceptor.js
+++ b/src/app/apiInterceptor.js
@@ -1,9 +1,13 @@
angular
.module('bit')
- .factory('apiInterceptor', function ($injector, $q, toastr) {
+ .factory('apiInterceptor', function ($injector, $q, toastr, appSettings, utilsService) {
return {
request: function (config) {
+ if (config.url.indexOf(appSettings.apiUri + '/') > -1) {
+ config.headers['Device-Type'] = utilsService.getDeviceType();
+ }
+
return config;
},
response: function (response) {
diff --git a/src/app/constants.js b/src/app/constants.js
index 2e86011aac..45a7d06ad1 100644
--- a/src/app/constants.js
+++ b/src/app/constants.js
@@ -39,6 +39,16 @@ angular.module('bit')
hidden: 1,
boolean: 2
},
+ deviceType: {
+ chrome: 9,
+ firefox: 10,
+ opera: 11,
+ edge: 12,
+ ie: 13,
+ unknown: 14,
+ safari: 17,
+ vivaldi: 18
+ },
eventType: {
User_LoggedIn: 1000,
User_ChangedPassword: 1001,
diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js
index 00d59c46dd..330e0209a2 100644
--- a/src/app/services/apiService.js
+++ b/src/app/services/apiService.js
@@ -1,7 +1,7 @@
angular
.module('bit.services')
- .factory('apiService', function ($resource, tokenService, appSettings, $httpParamSerializer) {
+ .factory('apiService', function ($resource, tokenService, appSettings, $httpParamSerializer, utilsService) {
var _service = {},
_apiUri = appSettings.apiUri,
_identityUri = appSettings.identityUri;
@@ -190,7 +190,10 @@
token: {
url: _identityUri + '/connect/token',
method: 'POST',
- headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' },
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
+ 'Device-Type': utilsService.getDeviceType()
+ },
transformRequest: transformUrlEncoded,
skipAuthorization: true,
params: {}
diff --git a/src/app/services/utilsService.js b/src/app/services/utilsService.js
new file mode 100644
index 0000000000..688c04be6e
--- /dev/null
+++ b/src/app/services/utilsService.js
@@ -0,0 +1,47 @@
+angular
+ .module('bit.services')
+
+ .factory('utilsService', function (constants) {
+ var _service = {};
+ var _browserCache;
+
+ _service.getDeviceType = function (token) {
+ if (_browserCache) {
+ return _browserCache;
+ }
+
+ if (navigator.userAgent.indexOf(' Vivaldi/') >= 0) {
+ _browserCache = constants.deviceType.vivaldi;
+ }
+ else if (!!window.chrome && !!window.chrome.webstore) {
+ _browserCache = constants.deviceType.chrome;
+ }
+ else if (typeof InstallTrigger !== 'undefined') {
+ _browserCache = constants.deviceType.firefox;
+ }
+ else if ((!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0) {
+ _browserCache = constants.deviceType.firefox;
+ }
+ else if (/constructor/i.test(window.HTMLElement) ||
+ safariCheck(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification))) {
+ _browserCache = constants.deviceType.opera;
+ }
+ else if (!!document.documentMode) {
+ _browserCache = constants.deviceType.ie;
+ }
+ else if (!!window.StyleMedia) {
+ _browserCache = constants.deviceType.edge;
+ }
+ else {
+ _browserCache = constants.deviceType.unknown;
+ }
+
+ return _browserCache;
+ };
+
+ function safariCheck(p) {
+ return p.toString() === '[object SafariRemoteNotification]';
+ }
+
+ return _service;
+ });
diff --git a/src/index.html b/src/index.html
index 270e8918ef..77cb625bb5 100644
--- a/src/index.html
+++ b/src/index.html
@@ -147,6 +147,7 @@
+