diff --git a/lib/api/quizRelase.ts b/lib/api/quizRelase.ts index 16c5543..f6d8150 100644 --- a/lib/api/quizRelase.ts +++ b/lib/api/quizRelase.ts @@ -6,18 +6,33 @@ import device from "current-device"; import type { AxiosError } from "axios"; import { replaceSpacesToEmptyLines } from "../components/ViewPublicationPage/tools/replaceSpacesToEmptyLines"; import { QuizSettings } from "@model/settingsData"; - +import * as Bowser from "bowser"; let SESSIONS = ""; const domain = location.hostname === "hbpn.link" ? "" : "https://s.hbpn.link"; const md = new MobileDetect(window.navigator.userAgent); - const userAgent = navigator.userAgent -let OSDevice = md.os() -if (OSDevice === null) {OSDevice = userAgent} +//операционная система +let OSDevice:string | undefined +if (userAgent.toLowerCase().includes("linux")) {OSDevice = "Linux"} +if (userAgent.toLowerCase().includes("windows")) {OSDevice = "Windows"} +if (/iPad|iPhone|iPod/.test(userAgent)){OSDevice = "IOS"} +if (userAgent.toLowerCase().includes("macintosh")) {OSDevice = "Mac OS"} +if (OSDevice === undefined) {OSDevice = userAgent} + +//браузер +let browserUser:string +if(Bowser.name === "Chrome") { + browserUser = "Chrome" +} else if(Bowser.name === "Firefox") { + browserUser = "Firefox" +}else if(Bowser.name === "Safari") { + browserUser = "Safari" +}else{browserUser = userAgent} const DeviceType = device.type + let Device = md.mobile() if (Device === null) {Device = userAgent} @@ -30,7 +45,7 @@ export const publicationMakeRequest = ({ url, body }: any) => { "DeviceType" : DeviceType, "Device" : Device, "OS": OSDevice, - "Browser" : userAgent + "Browser" : browserUser }, method: "POST", }); diff --git a/package.json b/package.json index 72c29b7..d27df76 100755 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "zustand": "^4.3.8" }, "dependencies": { + "bowser": "1.9.4", "country-flag-emoji-polyfill": "^0.1.8", "current-device": "^0.10.2", "hex-rgb": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 44316e8..68f63c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1337,6 +1337,11 @@ bluebird@^3.7.2: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== +bowser@1.9.4: + version "1.9.4" + resolved "https://registry.yarnpkg.com/bowser/-/bowser-1.9.4.tgz#890c58a2813a9d3243704334fa81b96a5c150c9a" + integrity sha512-9IdMmj2KjigRq6oWhmwv1W36pDuA4STQZ8q6YO9um+x07xgYNCD3Oou+WP/3L1HNz7iqythGet3/p4wvc8AAwQ== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"