Refactor platform properties loading
This commit is contained in:
parent
585b702652
commit
c34afdb4bd
3 changed files with 36 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue