-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathenv.ts
47 lines (40 loc) · 1.12 KB
/
env.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
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 | undefined;
osVersion: string | undefined;
}
export function getEnvironmentInfo(): EnvironmentInfo {
const [osName, osVersion] = getOperatingSystem();
const locale = "en-US";
const envInfo: EnvironmentInfo = {
appVersion: version.appVersion,
appBuildNumber: version.appBuildNumber,
isDebug: __DEV__,
locale,
osName: osName,
osVersion: osVersion,
sdkVersion,
};
return envInfo;
function getOperatingSystem(): [string, string] {
switch (Platform.OS) {
case "android":
return ["Android", Platform.constants.Release];
case "ios":
if (Platform.isPad) {
return ["iPadOS", Platform.Version];
}
return ["iOS", Platform.Version];
default:
return ["", ""];
}
}
}