-
Notifications
You must be signed in to change notification settings - Fork 0
/
analytics-utils.ts
85 lines (74 loc) · 1.93 KB
/
analytics-utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Method check if app is running inside Internet explorer
*/
export function isIE(): boolean {
return navigator.userAgent.indexOf("MSIE") >= 0;
}
/**
* Method check if app is running inside Internet explorer 6
*/
export function isIE6(): boolean {
return navigator.userAgent.indexOf("MSIE 6") >= 0;
}
/**
* Method check if app is running inside Internet explorer 11
*/
export function isIE11(): boolean {
return !!(/Trident\/7\./.exec(navigator.userAgent));
}
/**
* Method check if app is running inside Edge
*/
export function isEdge(): boolean {
return !!(/Edge\//.exec(navigator.userAgent));
}
/**
* Method check if app is running inside Safary
*/
export function isSafari(): boolean {
return navigator.userAgent.indexOf("AppleWebKit/") >= 0 &&
navigator.userAgent.indexOf("Chrome/") < 0 &&
navigator.userAgent.indexOf("Edge/") < 0;
}
/**
* Method check if app is running inside IOS
*/
export function isIOS(): boolean {
return !!navigator.userAgent.match(/(iPad|iPhone|iPod)/g);
}
/**
* Method check if app is running inside Chrome
*/
export function isChromeApp(): boolean {
return !!(window as { chrome?: { app?: { runtime: boolean } } })?.chrome?.app?.runtime;
}
/**
* Method check if app is running onMessage Windows
*/
export function isWin(): boolean {
return navigator.appVersion.indexOf("Win") > 0;
}
/**
* Method check if app is running onMessage Mac OS
*/
export function isMac(): boolean {
return navigator.appVersion.indexOf("Mac") > 0;
}
/**
* Method check if app is running Chrome OS
*/
export function isChromeOs(): boolean {
return /\bCrOS\b/.test(navigator.userAgent);
}
/**
* Method check if device support touch events
*/
export function isTouch(): boolean {
return "ontouchstart" in document.documentElement;
}
/**
* Method check if device support mouse events
*/
export function hasMouse(): boolean {
return "onmousemove" in document.documentElement;
}