@@ -23,95 +23,96 @@ import io.sentry.SentryOptions.BeforeBreadcrumbCallback
2323import io.sentry.SentryOptions.BeforeSendCallback
2424import io.sentry.android.core.SentryAndroid
2525
26- class MainApplication : Application (), ReactApplication {
27-
28- override val reactNativeHost: ReactNativeHost =
29- ReactNativeHostWrapper (
30- this ,
31- object : DefaultReactNativeHost (this ) {
26+ class MainApplication :
27+ Application (),
28+ ReactApplication {
29+ override val reactNativeHost: ReactNativeHost =
30+ ReactNativeHostWrapper (
31+ this ,
32+ object : DefaultReactNativeHost (this ) {
33+ override fun getPackages (): List <ReactPackage > {
34+ // Packages that cannot be autolinked yet can be added manually here, for
35+ // example:
36+ // packages.add(new MyReactNativePackage());
37+ return PackageList (this ).packages
38+ }
3239
33- override fun getPackages (): List <ReactPackage > {
34- // Packages that cannot be autolinked yet can be added manually here, for
35- // example:
36- // packages.add(new MyReactNativePackage());
37- return PackageList (this ).packages
38- }
40+ override fun getJSMainModuleName (): String = " index"
3941
40- override fun getJSMainModuleName (): String = " index "
42+ override fun getUseDeveloperSupport (): Boolean = BuildConfig . DEBUG
4143
42- override fun getUseDeveloperSupport (): Boolean = BuildConfig .DEBUG
44+ override val isNewArchEnabled: Boolean = BuildConfig .IS_NEW_ARCHITECTURE_ENABLED
45+ override val isHermesEnabled: Boolean = BuildConfig .IS_HERMES_ENABLED
46+ },
47+ )
4348
44- override val isNewArchEnabled: Boolean = BuildConfig .IS_NEW_ARCHITECTURE_ENABLED
45- override val isHermesEnabled: Boolean = BuildConfig .IS_HERMES_ENABLED
46- }
47- )
49+ override val reactHost: ReactHost
50+ get() = getDefaultReactHost(applicationContext, reactNativeHost)
4851
49- override val reactHost: ReactHost
50- get() = getDefaultReactHost(applicationContext, reactNativeHost)
52+ override fun onCreate () {
53+ super .onCreate()
54+ val context = applicationContext
5155
52- override fun onCreate () {
53- super .onCreate()
54- val context = applicationContext
56+ // Retrieve the version string from the app's BuildConfig
57+ val versionString = BuildConfig .VERSION_NAME
5558
56- // Retrieve the version string from the app's BuildConfig
57- val versionString = BuildConfig .VERSION_NAME
59+ if (" SENTRY_DSN_URL" .contains(" SENTRY_DSN" )) {
60+ // Sentry disabled. Need to add sentry keys to env.json
61+ } else {
62+ SentryAndroid .init (this ) { options ->
63+ options.dsn = " SENTRY_DSN_URL"
5864
59- if (" SENTRY_DSN_URL" .contains(" SENTRY_DSN" )) {
60- // Sentry disabled. Need to add sentry keys to env.json
65+ if (versionString == " 99.99.99" ) {
66+ options.environment = " development"
67+ } else if (versionString.contains(" -" )) {
68+ options.environment = " testing"
6169 } else {
62- SentryAndroid .init (this ) { options ->
63- options.dsn = " SENTRY_DSN_URL"
64-
65- if (versionString == " 99.99.99" ) {
66- options.environment = " development"
67- } else if (versionString.contains(" -" )) {
68- options.environment = " testing"
69- } else {
70- options.environment = " production"
71- }
72-
73- options.beforeBreadcrumb =
74- BeforeBreadcrumbCallback { breadcrumb, hint ->
75- if (" network.event" == breadcrumb.category ||
76- " http" == breadcrumb.category || " console" == breadcrumb.category
77- ) {
78- null
79- } else {
80- breadcrumb
81- }
82- }
83- // Add a callback that will be used before the event is sent to Sentry.
84- // With this callback, you can modify the event or, when returning null, also
85- // discard the event.
86- options.beforeSend =
87- BeforeSendCallback { event: SentryEvent , hint: Hint ->
88- if (SentryLevel .DEBUG == event.level) {
89- null
90- } else {
91- event
92- }
93- }
94- }
70+ options.environment = " production"
9571 }
9672
97- // Disable RTL
98- val sharedI18nUtilInstance = I18nUtil .getInstance()
99- sharedI18nUtilInstance.allowRTL(context, false )
100-
101- // Background task:
102- MessagesWorker .ensureScheduled(context)
103- // MessagesWorker.testRun(context);
104- SoLoader .init (this , OpenSourceMergedSoMapping )
105- if (BuildConfig .IS_NEW_ARCHITECTURE_ENABLED ) {
106- // If you opted-in for the New Architecture, we load the native entry point for this
107- // app.
108- load()
109- }
110- onApplicationCreate(this )
73+ options.beforeBreadcrumb =
74+ BeforeBreadcrumbCallback { breadcrumb, hint ->
75+ if (" network.event" == breadcrumb.category ||
76+ " http" == breadcrumb.category ||
77+ " console" == breadcrumb.category
78+ ) {
79+ null
80+ } else {
81+ breadcrumb
82+ }
83+ }
84+ // Add a callback that will be used before the event is sent to Sentry.
85+ // With this callback, you can modify the event or, when returning null, also
86+ // discard the event.
87+ options.beforeSend =
88+ BeforeSendCallback { event: SentryEvent , hint: Hint ->
89+ if (SentryLevel .DEBUG == event.level) {
90+ null
91+ } else {
92+ event
93+ }
94+ }
95+ }
11196 }
11297
113- override fun onConfigurationChanged (newConfig : Configuration ) {
114- super .onConfigurationChanged(newConfig)
115- onConfigurationChanged(this , newConfig)
98+ // Disable RTL
99+ val sharedI18nUtilInstance = I18nUtil .getInstance()
100+ sharedI18nUtilInstance.allowRTL(context, false )
101+
102+ // Background task:
103+ MessagesWorker .ensureScheduled(context)
104+ // MessagesWorker.testRun(context);
105+ SoLoader .init (this , OpenSourceMergedSoMapping )
106+ if (BuildConfig .IS_NEW_ARCHITECTURE_ENABLED ) {
107+ // If you opted-in for the New Architecture, we load the native entry point for this
108+ // app.
109+ load()
116110 }
111+ onApplicationCreate(this )
112+ }
113+
114+ override fun onConfigurationChanged (newConfig : Configuration ) {
115+ super .onConfigurationChanged(newConfig)
116+ onConfigurationChanged(this , newConfig)
117+ }
117118}
0 commit comments