34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getEnv = getEnv;
|
|
const react_native_1 = require("react-native");
|
|
const react_native_localize_1 = require("react-native-localize");
|
|
const react_native_device_info_1 = require("react-native-device-info");
|
|
const isRemoteDebugging = () => {
|
|
if (!__DEV__) {
|
|
return false;
|
|
}
|
|
const debuggerModule = react_native_1.NativeModules?.Debugger;
|
|
return typeof debuggerModule !== 'undefined';
|
|
};
|
|
async function getEnv() {
|
|
const isDebuggingEnabled = isRemoteDebugging();
|
|
const language = isDebuggingEnabled ? navigator.language : (0, react_native_localize_1.getLocales)()[0].languageTag;
|
|
const deviceId = (0, react_native_device_info_1.getDeviceId)();
|
|
const fullEnv = {
|
|
...react_native_1.Platform,
|
|
visitorId: deviceId,
|
|
language,
|
|
type: 'native',
|
|
};
|
|
const briefEnv = {
|
|
brand: fullEnv.constants.Brand,
|
|
model: fullEnv.constants.Model,
|
|
system: `${fullEnv.OS}/${fullEnv.constants.Version || fullEnv.constants.osVersion}/${language}`,
|
|
};
|
|
return {
|
|
fullEnv,
|
|
briefEnv,
|
|
};
|
|
}
|