2024-04-22 16:13:14 +05:30
|
|
|
|
|
|
|
|
import { init } from "@sentry/react-native";
|
2024-03-27 20:36:03 +05:30
|
|
|
import { Component } from "react";
|
|
|
|
|
import codePush from "react-native-code-push";
|
2024-04-01 19:43:10 +05:30
|
|
|
import { SentryConstants } from "./App/common/constants/SentryConstants";
|
2024-03-29 15:33:27 +05:30
|
|
|
import { logToSentry } from "./App/common/hooks/useSentryLogging";
|
2024-03-27 20:36:03 +05:30
|
|
|
import { CtaData } from "./App/common/interface";
|
|
|
|
|
import RnApp from "./App/common/navigator/RnAppCreator";
|
2024-03-29 15:33:27 +05:30
|
|
|
import {
|
|
|
|
|
getBuildConfigDetails,
|
|
|
|
|
setBuildConfigDetails,
|
|
|
|
|
} from "./App/common/utilities/CacheUtils";
|
|
|
|
|
|
2024-04-22 16:13:14 +05:30
|
|
|
init({
|
2024-04-01 19:43:10 +05:30
|
|
|
dsn: SentryConstants.SENTRY_DSN,
|
|
|
|
|
environment: SentryConstants.SENTRY_ENVIRONMENT_PRODUCTION,
|
2024-03-29 15:33:27 +05:30
|
|
|
});
|
2024-03-27 20:36:03 +05:30
|
|
|
|
|
|
|
|
export default class App extends Component<{}> {
|
2024-04-26 20:34:37 +05:30
|
|
|
checkForUpdates = async() => {
|
2024-03-29 15:33:27 +05:30
|
|
|
let flavor: string | undefined;
|
2024-03-27 20:36:03 +05:30
|
|
|
getBuildConfigDetails().then((res) => {
|
2024-03-29 15:33:27 +05:30
|
|
|
flavor = res?.baseUrl;
|
|
|
|
|
});
|
2024-04-26 20:34:37 +05:30
|
|
|
await codePush.sync(
|
2024-04-12 17:41:45 +05:30
|
|
|
{
|
2024-04-26 23:07:17 +05:30
|
|
|
installMode: codePush.InstallMode.ON_NEXT_RESUME,
|
2024-04-12 17:41:45 +05:30
|
|
|
mandatoryInstallMode: codePush.InstallMode.IMMEDIATE,
|
|
|
|
|
},
|
|
|
|
|
(status) => {
|
|
|
|
|
this.onCodepushStatusChange(status);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onCodepushStatusChange = (status: codePush.SyncStatus) => {
|
|
|
|
|
switch (status) {
|
|
|
|
|
case codePush.SyncStatus.UPDATE_IGNORED:
|
|
|
|
|
logToSentry(
|
|
|
|
|
`Codepush Ignored | Status: ${status} | MethodName: onCodepushStatusChange`
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case codePush.SyncStatus.UNKNOWN_ERROR:
|
|
|
|
|
logToSentry(
|
|
|
|
|
`Codepush Failed | Status: ${status} | MethodName: onCodepushStatusChange`
|
|
|
|
|
);
|
2024-04-26 20:34:37 +05:30
|
|
|
break;
|
2024-04-12 17:41:45 +05:30
|
|
|
}
|
2024-03-27 20:36:03 +05:30
|
|
|
};
|
|
|
|
|
getInitialCta = (): CtaData | undefined => {
|
|
|
|
|
const { CtaData } = this.props as any;
|
|
|
|
|
|
|
|
|
|
if (!CtaData) {
|
|
|
|
|
logToSentry(
|
|
|
|
|
`CtaData is missing or invalid: ${CtaData} | MethodName: getInitialCta`
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const cta = JSON.parse(CtaData) as CtaData;
|
|
|
|
|
return cta;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
logToSentry(
|
|
|
|
|
`Error parsing CtaData: ${CtaData} | Error: ${error} | MethodName: getInitialCta`
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
override componentDidMount(): void {
|
2024-03-29 15:33:27 +05:30
|
|
|
setBuildConfigDetails();
|
2024-03-27 20:36:03 +05:30
|
|
|
this.checkForUpdates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override render() {
|
|
|
|
|
const cta = this.getInitialCta();
|
2024-04-26 20:34:37 +05:30
|
|
|
return cta ? RnApp.create(cta) : <></>;
|
2024-03-27 20:36:03 +05:30
|
|
|
}
|
2024-04-12 17:41:45 +05:30
|
|
|
}
|