-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathenv.ts
More file actions
49 lines (43 loc) · 1.18 KB
/
env.ts
File metadata and controls
49 lines (43 loc) · 1.18 KB
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
import { Platform } from "react-native";
import version from "./version";
// env.PKG_VERSION is replaced by Vite during build phase
const sdkVersion = `aptabase-reactnative@${process.env.PKG_VERSION}`;
export interface EnvironmentInfo {
isDebug: boolean;
locale: string;
appVersion: string;
appBuildNumber: string;
sdkVersion: string;
osName: string;
osVersion: string;
}
export function getEnvironmentInfo(): EnvironmentInfo {
const [osName, osVersion] = getOperatingSystem();
const locale = "en-US";
return {
appVersion: version.appVersion,
appBuildNumber: version.appBuildNumber,
isDebug: __DEV__,
locale,
osName,
osVersion,
sdkVersion,
};
}
function getOperatingSystem(): [string, string] {
switch (Platform.OS) {
case "android":
return ["Android", Platform.constants.Release];
case "ios":
if (Platform.isPad) {
if (version.isiOSAppOnMac) {
// Version represents the emulated iPadOS version and not the MacOS version
return ["MacOS", Platform.Version];
}
return ["iPadOS", Platform.Version];
}
return ["iOS", Platform.Version];
default:
return ["", ""];
}
}