@@ -3,6 +3,7 @@ import { useLogout } from "@/features/authentication/use-logout.hook";
3
3
import { translate } from "@/i18n" ;
4
4
import { navigate } from "@/navigation/navigation.utils" ;
5
5
import { $globalStyles } from "@/theme/styles" ;
6
+ import { getEnv } from "@/utils/getEnv" ;
6
7
import { getNativeLogFile } from "@/utils/xmtpRN/logs" ;
7
8
import * as Sentry from "@sentry/react-native" ;
8
9
import {
@@ -23,6 +24,8 @@ export function DebugProvider(props: { children: React.ReactNode }) {
23
24
24
25
const { logout } = useLogout ( ) ;
25
26
27
+ const { currentlyRunning } = Updates . useUpdates ( ) ;
28
+
26
29
const methods = useMemo ( ( ) => {
27
30
// Debug menu options and their corresponding actions
28
31
const debugMethods = {
@@ -65,6 +68,70 @@ export function DebugProvider(props: { children: React.ReactNode }) {
65
68
) ;
66
69
alert ( "Done!" ) ;
67
70
} ,
71
+ "Show App Info" : ( ) => {
72
+ const appVersion = Constants . expoConfig ?. version ;
73
+ const buildNumber =
74
+ Platform . OS === "ios"
75
+ ? Constants . expoConfig ?. ios ?. buildNumber
76
+ : Constants . expoConfig ?. android ?. versionCode ;
77
+ const environment = getEnv ( ) ;
78
+
79
+ Alert . alert (
80
+ "App Information" ,
81
+ [
82
+ `Version: ${ appVersion } ` ,
83
+ `Build: ${ buildNumber } ` ,
84
+ `Environment: ${ environment } ` ,
85
+ `Update ID: ${ currentlyRunning . updateId || "embedded" } ` ,
86
+ `Created At: ${
87
+ currentlyRunning . createdAt ?. toLocaleString ( ) || "N/A"
88
+ } `,
89
+ `Runtime Version: ${ currentlyRunning . runtimeVersion } ` ,
90
+ `Channel: ${ currentlyRunning . channel || "N/A" } ` ,
91
+ `Is Embedded: ${ currentlyRunning . isEmbeddedLaunch } ` ,
92
+ currentlyRunning . isEmergencyLaunch ? `Emergency Launch: Yes` : "" ,
93
+ currentlyRunning . emergencyLaunchReason
94
+ ? `Emergency Reason: ${ currentlyRunning . emergencyLaunchReason } `
95
+ : "" ,
96
+ ]
97
+ . filter ( Boolean )
98
+ . join ( "\n" )
99
+ ) ;
100
+ } ,
101
+ "Check for Updates" : async ( ) => {
102
+ try {
103
+ const update = await Updates . checkForUpdateAsync ( ) ;
104
+ if ( update . isAvailable ) {
105
+ Alert . alert (
106
+ "Update Available" ,
107
+ "Would you like to download and install the update?" ,
108
+ [
109
+ {
110
+ text : "Cancel" ,
111
+ style : "cancel" ,
112
+ } ,
113
+ {
114
+ text : "Update" ,
115
+ onPress : async ( ) => {
116
+ try {
117
+ const fetchedUpdate = await Updates . fetchUpdateAsync ( ) ;
118
+ if ( fetchedUpdate . isNew ) {
119
+ await Updates . reloadAsync ( ) ;
120
+ }
121
+ } catch ( error ) {
122
+ Alert . alert ( "Error" , JSON . stringify ( error ) ) ;
123
+ }
124
+ } ,
125
+ } ,
126
+ ]
127
+ ) ;
128
+ } else {
129
+ Alert . alert ( "No Updates" , "You are running the latest version" ) ;
130
+ }
131
+ } catch ( error ) {
132
+ Alert . alert ( "Error" , JSON . stringify ( error ) ) ;
133
+ }
134
+ } ,
68
135
} ;
69
136
70
137
return {
@@ -112,7 +179,7 @@ export function DebugProvider(props: { children: React.ReactNode }) {
112
179
} ,
113
180
Cancel : undefined ,
114
181
} ;
115
- } , [ logout ] ) ;
182
+ } , [ logout , currentlyRunning ] ) ;
116
183
117
184
const showDebugMenu = useCallback ( ( ) => {
118
185
const options = Object . keys ( methods ) ;
@@ -151,13 +218,13 @@ export function DebugProvider(props: { children: React.ReactNode }) {
151
218
clearTimeout ( tapTimeoutRef . current ) ;
152
219
}
153
220
154
- // Set new timeout to reset count after 2 seconds
221
+ // Set new timeout to reset count after 500ms
155
222
tapTimeoutRef . current = setTimeout ( ( ) => {
156
223
tapCountRef . current = 0 ;
157
- } , 2000 ) ;
224
+ } , 500 ) ;
158
225
159
- // Show debug menu after 4 taps
160
- if ( tapCountRef . current >= 4 ) {
226
+ // Show debug menu after 5 taps
227
+ if ( tapCountRef . current >= 5 ) {
161
228
showDebugMenu ( ) ;
162
229
tapCountRef . current = 0 ;
163
230
}
0 commit comments