You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Refactor platform properties loading
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import posthog, { PostHog } from 'posthog-js';
|
||||
import PlatformPeg from './PlatformPeg';
|
||||
import SdkConfig from './SdkConfig';
|
||||
|
||||
interface IEvent {
|
||||
@@ -226,6 +227,22 @@ export class PosthogAnalytics {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPlatformProperties() {
|
||||
const platform = PlatformPeg.get();
|
||||
let appVersion;
|
||||
try {
|
||||
appVersion = await platform.getAppVersion();
|
||||
} catch (e) {
|
||||
// this happens if no version is set i.e. in dev
|
||||
appVersion = "unknown";
|
||||
}
|
||||
|
||||
return {
|
||||
appVersion,
|
||||
appPlatform: platform.getHumanReadableName(),
|
||||
};
|
||||
}
|
||||
|
||||
export function getAnalytics(): PosthogAnalytics {
|
||||
return PosthogAnalytics.instance();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user