shakebug-react-native 2.2.9 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/APIs/AddIssue.js +7 -10
- package/src/APIs/MatchKey.js +2 -1
- package/src/APIs/StartSession.js +4 -2
- package/src/Componanats/ErrorHandler.js +8 -7
- package/src/Componanats/ShakeFunction.js +30 -14
- package/src/Screens/Shakebug.js +98 -70
- package/src/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shakebug-react-native",
|
|
3
3
|
"title": "shakebug-react-native",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"description": "Shakebug allows users to report the bug from your mobile phone for your application. Here users just need to shake their mobile and all the data regarding bugs & crashes can be seen by developers through their log in panel easily",
|
|
6
6
|
"main": "src/index.tsx",
|
|
7
7
|
"scripts": {
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"readmeFilename": "README.md",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@react-navigation/native": "^6.1.9",
|
|
32
|
-
"html2canvas": "^1.4.1",
|
|
33
32
|
"react-native-logs": "^5.1.0",
|
|
34
33
|
"rxjs": "^7.8.1",
|
|
35
34
|
"typescript": "^5.3.3"
|
|
@@ -42,4 +41,4 @@
|
|
|
42
41
|
"flow-bin": "^0.170.0",
|
|
43
42
|
"html-webpack-plugin": "^5.5.1"
|
|
44
43
|
}
|
|
45
|
-
}
|
|
44
|
+
}
|
package/src/APIs/AddIssue.js
CHANGED
|
@@ -12,14 +12,11 @@ async function AddIssueApi(session_id, application_id, path, isVideo, desc, emai
|
|
|
12
12
|
|
|
13
13
|
const Custom_User_Id = await ShakebugSDKSharedPreferencesModule.getString('custom_user_id')
|
|
14
14
|
|
|
15
|
-
let i = 0;
|
|
16
15
|
let internetType = "";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
i++
|
|
22
|
-
})
|
|
16
|
+
try {
|
|
17
|
+
const stat = await NetInfo.fetch();
|
|
18
|
+
internetType = stat.type;
|
|
19
|
+
} catch(e) {}
|
|
23
20
|
|
|
24
21
|
let batteryLevel = parseFloat(await DeviceInfo.getBatteryLevel() * 100).toFixed(0);
|
|
25
22
|
let architecture = await DeviceInfo.supportedAbis();
|
|
@@ -29,8 +26,8 @@ async function AddIssueApi(session_id, application_id, path, isVideo, desc, emai
|
|
|
29
26
|
let appversion = DeviceInfo.getVersion();
|
|
30
27
|
let memory = await DeviceInfo.getTotalMemory() - await DeviceInfo.getUsedMemory()
|
|
31
28
|
let osversion = await DeviceInfo.getSystemVersion()
|
|
32
|
-
const type = isVideo ? 'video/mp4' : 'image/
|
|
33
|
-
const name = isVideo ? 'video' : 'photo.
|
|
29
|
+
const type = isVideo ? 'video/mp4' : 'image/jpg';
|
|
30
|
+
const name = isVideo ? 'video.mp4' : 'photo.jpg';
|
|
34
31
|
const media = isVideo ? `file://'${path}` : path;
|
|
35
32
|
|
|
36
33
|
|
|
@@ -40,7 +37,7 @@ async function AddIssueApi(session_id, application_id, path, isVideo, desc, emai
|
|
|
40
37
|
formData.append("applicationsid", application_id);
|
|
41
38
|
formData.append("session_id", session_id);
|
|
42
39
|
formData.append("batteryLevel", batteryLevel);
|
|
43
|
-
formData.append("image", media);
|
|
40
|
+
formData.append("image", {uri: media, name: name, type: type});
|
|
44
41
|
formData.append("memory", memory);
|
|
45
42
|
formData.append("email", email);
|
|
46
43
|
formData.append("devicemodel", `${architecture[0]} -- ${model}`);
|
package/src/APIs/MatchKey.js
CHANGED
|
@@ -27,7 +27,8 @@ async function MatchKeyApi(appkey, BundleId) {
|
|
|
27
27
|
const total_video = data.response_data.total_video;
|
|
28
28
|
const used_video = data.response_data.used_video;
|
|
29
29
|
const video_duration = data.response_data.video_duration;
|
|
30
|
-
|
|
30
|
+
const shakebug_type = data.response_data.shakebug_type;
|
|
31
|
+
return { success: true, application_id, total_mau, used_mau, total_video, used_video, video_duration, shakebug_type, message: data.msg };
|
|
31
32
|
} else {
|
|
32
33
|
return { success: false, message: data.msg };
|
|
33
34
|
}
|
package/src/APIs/StartSession.js
CHANGED
|
@@ -14,8 +14,11 @@ async function SessionStartApi(latitude, longitude, application_id) {
|
|
|
14
14
|
|
|
15
15
|
if (latitude != "" && latitude != undefined && longitude != "" && longitude != undefined) {
|
|
16
16
|
try {
|
|
17
|
+
let BundleId = DeviceInfo.getBundleId ? DeviceInfo.getBundleId() : "UnknownApp";
|
|
18
|
+
|
|
17
19
|
await fetch(
|
|
18
20
|
`https://nominatim.openstreetmap.org/reverse?format=json&lat=${latitude}&lon=${longitude}`,
|
|
21
|
+
{ headers: { 'User-Agent': `Shakebug-SDK-Mobile-${BundleId}` } }
|
|
19
22
|
)
|
|
20
23
|
.then(response => response.json())
|
|
21
24
|
.then(async data => {
|
|
@@ -93,8 +96,7 @@ async function SessionStartApi(latitude, longitude, application_id) {
|
|
|
93
96
|
return { success: false, message: data.msg };
|
|
94
97
|
}
|
|
95
98
|
} catch (error) {
|
|
96
|
-
|
|
97
|
-
// throw error;
|
|
99
|
+
return { success: false, message: "Network request failed. Please check your connection." };
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
|
|
@@ -15,14 +15,11 @@ const AddCrashApi = async (desc) => {
|
|
|
15
15
|
let memory = await DeviceInfo.getTotalMemory() - await DeviceInfo.getUsedMemory()
|
|
16
16
|
let osversion = await DeviceInfo.getSystemVersion()
|
|
17
17
|
|
|
18
|
-
let i = 0;
|
|
19
18
|
let internetType = "";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
i++
|
|
25
|
-
})
|
|
19
|
+
try {
|
|
20
|
+
const stat = await NetInfo.fetch();
|
|
21
|
+
internetType = stat.type;
|
|
22
|
+
} catch(e) {}
|
|
26
23
|
|
|
27
24
|
const arr = {
|
|
28
25
|
session_id: global.session_id,
|
|
@@ -72,8 +69,12 @@ const setGlobalErrorHandler = () => {
|
|
|
72
69
|
// Function to handle unhandled promise rejections
|
|
73
70
|
const captureUnhandledRejections = () => {
|
|
74
71
|
// Listen for unhandled promise rejections
|
|
72
|
+
const originalHandler = window.onunhandledrejection;
|
|
75
73
|
window.onunhandledrejection = (reason, promise) => {
|
|
76
74
|
logError(reason, false);
|
|
75
|
+
if (typeof originalHandler === 'function') {
|
|
76
|
+
originalHandler(reason, promise);
|
|
77
|
+
}
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
80
|
|
|
@@ -16,6 +16,8 @@ import { useGlobalState } from 'shakebug-react-native/src/Componanats/GlobalStat
|
|
|
16
16
|
|
|
17
17
|
LogBox.ignoreAllLogs()
|
|
18
18
|
|
|
19
|
+
let stopWatchIntervalId = null;
|
|
20
|
+
|
|
19
21
|
const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitle, allowToReportBugByShaking, allowToReportBugByScreenCapture, allowCrashReport }) => {
|
|
20
22
|
|
|
21
23
|
const { ShakebugSDKScreenShotDetector, ShakebugSDKSharedPreferencesModule, ShakebugSDKCustomScreenCapture} = NativeModules;
|
|
@@ -33,7 +35,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
33
35
|
|
|
34
36
|
useEffect(() => {
|
|
35
37
|
const subscription = DeviceEventEmitter.addListener('ScreenshotTaken', async () => {
|
|
36
|
-
if (allowToReportBugByScreenCapture == true) {
|
|
38
|
+
if (allowToReportBugByScreenCapture == true && global.isFeatureEnabled?.('2')) {
|
|
37
39
|
if (!global.isScreenShotDetected && global.application_id != "" && global.application_id != undefined) {
|
|
38
40
|
OpenShakebug()
|
|
39
41
|
}
|
|
@@ -49,7 +51,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
49
51
|
const subscription = screenShotEmitter.addListener(
|
|
50
52
|
'ScreenshotTaken',
|
|
51
53
|
(event) => {
|
|
52
|
-
if (allowToReportBugByScreenCapture == true) {
|
|
54
|
+
if (allowToReportBugByScreenCapture == true && global.isFeatureEnabled?.('2')) {
|
|
53
55
|
// setIsScreenShot(true)
|
|
54
56
|
if (!global.isScreenShotDetected && global.application_id != "" && global.application_id != undefined) {
|
|
55
57
|
OpenShakebug()
|
|
@@ -132,7 +134,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
132
134
|
iscrashSaveed = await ShakebugSDKSharedPreferencesModule.getString('iscrashSaveed')
|
|
133
135
|
const Custom_User_Id = await ShakebugSDKSharedPreferencesModule.getString('custom_user_id')
|
|
134
136
|
|
|
135
|
-
if (iscrashSaveed.length > 10 && allowCrashReport) {
|
|
137
|
+
if (iscrashSaveed.length > 10 && allowCrashReport && global.isFeatureEnabled?.('4')) {
|
|
136
138
|
|
|
137
139
|
let data = JSON.parse(iscrashSaveed)
|
|
138
140
|
|
|
@@ -195,7 +197,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
195
197
|
global.isDraw = false;
|
|
196
198
|
global.isShow = false;
|
|
197
199
|
startTimeRef.current = null
|
|
198
|
-
clearInterval(
|
|
200
|
+
if (stopWatchIntervalId) clearInterval(stopWatchIntervalId);
|
|
199
201
|
setIsLoading(false)
|
|
200
202
|
global.isRecording = false;
|
|
201
203
|
navigate("AddDetailsScreen", { media: res.result.outputURL, mediaType: 'Recordvideo', themeColor: themeColor, SDKScreenTitle: `${SDKScreenTitle}` })
|
|
@@ -232,13 +234,13 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
232
234
|
return () => {
|
|
233
235
|
// AppState.removeEventListener('change', handleAppStateChange);
|
|
234
236
|
AppStateListener.remove()
|
|
235
|
-
clearInterval(
|
|
237
|
+
if (stopWatchIntervalId) clearInterval(stopWatchIntervalId);
|
|
236
238
|
};
|
|
237
239
|
}, []);
|
|
238
240
|
|
|
239
241
|
const startTimer = () => {
|
|
240
242
|
startTimeRef.current = Date.now();
|
|
241
|
-
|
|
243
|
+
stopWatchIntervalId = setInterval(() => {
|
|
242
244
|
if (global.isRecording) {
|
|
243
245
|
const elapsed = Math.floor((Date.now() - startTimeRef.current) / 1000);
|
|
244
246
|
updateTimer(elapsed);
|
|
@@ -251,7 +253,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
251
253
|
const sec = parseInt(elapsed % 60);
|
|
252
254
|
|
|
253
255
|
if (elapsed == global.videoDuration) {
|
|
254
|
-
clearInterval(
|
|
256
|
+
if (stopWatchIntervalId) clearInterval(stopWatchIntervalId);
|
|
255
257
|
setTimeout(() => {
|
|
256
258
|
Stop()
|
|
257
259
|
}, 1000)
|
|
@@ -269,7 +271,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
269
271
|
global.isDraw = false;
|
|
270
272
|
global.isShow = false;
|
|
271
273
|
startTimeRef.current = null
|
|
272
|
-
clearInterval(
|
|
274
|
+
if (stopWatchIntervalId) clearInterval(stopWatchIntervalId);
|
|
273
275
|
})
|
|
274
276
|
}
|
|
275
277
|
|
|
@@ -282,10 +284,14 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
282
284
|
let xdata = 0;
|
|
283
285
|
let ydata = 0;
|
|
284
286
|
let zdata = 0;
|
|
287
|
+
let isMounted = true;
|
|
288
|
+
let localSubscription = null;
|
|
289
|
+
let localPollingInterval = null;
|
|
285
290
|
|
|
286
291
|
DeviceInfo.isEmulator().then(res => {
|
|
287
|
-
if (!
|
|
288
|
-
|
|
292
|
+
if (!isMounted) return;
|
|
293
|
+
if (!res && global.isRecording == false && allowToReportBugByShaking !== false && global.isFeatureEnabled?.('2')) {
|
|
294
|
+
localSubscription = accelerometer.subscribe(async ({ x, y, z, timestamp }) => {
|
|
289
295
|
|
|
290
296
|
let calculate = Math.sqrt(x * x + y * y + z * z);
|
|
291
297
|
|
|
@@ -304,7 +310,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
304
310
|
const ImgUrl = await ref.current.capture()
|
|
305
311
|
if (!isShow) {
|
|
306
312
|
if (ImgUrl != undefined || ImgUrl != null) {
|
|
307
|
-
|
|
313
|
+
if (localSubscription) localSubscription.unsubscribe();
|
|
308
314
|
global.IsBackground = false
|
|
309
315
|
global.isShakebugSDKOpen = true
|
|
310
316
|
navigate("FirstScreen", { img: `${ImgUrl}`, themeColor: `${themeColor}`, SDKScreenTitle: `${SDKScreenTitle}` })
|
|
@@ -333,7 +339,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
333
339
|
|
|
334
340
|
}
|
|
335
341
|
if (ImgUrl != undefined || ImgUrl != null) {
|
|
336
|
-
|
|
342
|
+
if (localSubscription) localSubscription.unsubscribe();
|
|
337
343
|
global.isShakebugSDKOpen = true
|
|
338
344
|
navigate("FirstScreen", { img: `${ImgUrl}`, themeColor: `${themeColor}`, SDKScreenTitle: `${SDKScreenTitle}` })
|
|
339
345
|
}
|
|
@@ -350,7 +356,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
350
356
|
})
|
|
351
357
|
|
|
352
358
|
if (isFocused == false) {
|
|
353
|
-
|
|
359
|
+
if (localSubscription) localSubscription.unsubscribe()
|
|
354
360
|
xdata = 0;
|
|
355
361
|
ydata = 0;
|
|
356
362
|
zdata = 0;
|
|
@@ -359,7 +365,7 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
359
365
|
}
|
|
360
366
|
}
|
|
361
367
|
else {
|
|
362
|
-
setInterval(() => {
|
|
368
|
+
localPollingInterval = setInterval(() => {
|
|
363
369
|
if (global.isTrigger == true && global.isShakebugOpen == false) {
|
|
364
370
|
global.isShakebugOpen = true;
|
|
365
371
|
global.isTrigger = true;
|
|
@@ -369,6 +375,16 @@ const ShakeFunction = ({ children, themeColor, showTutorialScreen, SDKScreenTitl
|
|
|
369
375
|
}
|
|
370
376
|
})
|
|
371
377
|
|
|
378
|
+
return () => {
|
|
379
|
+
isMounted = false;
|
|
380
|
+
if (localSubscription) {
|
|
381
|
+
localSubscription.unsubscribe();
|
|
382
|
+
}
|
|
383
|
+
if (localPollingInterval) {
|
|
384
|
+
clearInterval(localPollingInterval);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
372
388
|
}, [isFocused])
|
|
373
389
|
|
|
374
390
|
const OpenShakebug = async () => {
|
package/src/Screens/Shakebug.js
CHANGED
|
@@ -24,6 +24,7 @@ import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
24
24
|
|
|
25
25
|
console.ignoredYellowBox = ["Warning: Each", "Warning: Failed"];
|
|
26
26
|
|
|
27
|
+
export const ShakebugPropsContext = React.createContext({});
|
|
27
28
|
|
|
28
29
|
global.session_id = "";
|
|
29
30
|
global.application_id = "";
|
|
@@ -52,11 +53,19 @@ global.isScreeenShotTaken = false;
|
|
|
52
53
|
global.restrictedViews = [];
|
|
53
54
|
global.currentScreen = ""
|
|
54
55
|
global.isShakebugSDKOpen = false;
|
|
55
|
-
global.sdk_version = "2.
|
|
56
|
+
global.sdk_version = "2.3.0";
|
|
56
57
|
global.app_lunch_count = 0;
|
|
57
58
|
global.POPUP_LAUNCH_THRESHOLD = 3;
|
|
58
59
|
global.POPUP_COOLDOWN_DAYS = 2;
|
|
59
60
|
global.KEY_REVIEW_SUBMITTED = false;
|
|
61
|
+
global.shakebug_type = "";
|
|
62
|
+
|
|
63
|
+
global.isFeatureEnabled = (id) => {
|
|
64
|
+
if (!global.shakebug_type) return false;
|
|
65
|
+
const types = global.shakebug_type.split(',').map(s => s.trim());
|
|
66
|
+
if (types.includes('1')) return true;
|
|
67
|
+
return types.includes(id.toString());
|
|
68
|
+
};
|
|
60
69
|
|
|
61
70
|
function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirstTime, ShakebugThemeColor, changeSDKScreenTitle, allowToReportBugByShakingMobile, allowToReportBugByScreenCapture, allowCrashReport, ShakebugLanguage, makeLogEnabled, setShakebugSDKEndPointURL }) {
|
|
62
71
|
|
|
@@ -156,12 +165,12 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
156
165
|
|
|
157
166
|
const afterDaysTimestamp = now + sevenDaysInMs;
|
|
158
167
|
|
|
159
|
-
if (LAST_POPUP_TIME > afterDaysTimestamp) {
|
|
168
|
+
if (LAST_POPUP_TIME > afterDaysTimestamp && global.isFeatureEnabled?.('6')) {
|
|
160
169
|
setShowModal(true)
|
|
161
170
|
}
|
|
162
171
|
|
|
163
172
|
}
|
|
164
|
-
else if (IS_REVIEW_SUBMITTED != "true") {
|
|
173
|
+
else if (IS_REVIEW_SUBMITTED != "true" && global.isFeatureEnabled?.('6')) {
|
|
165
174
|
setShowModal(true)
|
|
166
175
|
}
|
|
167
176
|
}
|
|
@@ -237,7 +246,7 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
237
246
|
}
|
|
238
247
|
|
|
239
248
|
let i = 0;
|
|
240
|
-
NetInfo.addEventListener(state => {
|
|
249
|
+
const unsubscribe = NetInfo.addEventListener(state => {
|
|
241
250
|
if (i == 0) {
|
|
242
251
|
if (state.isConnected == true) {
|
|
243
252
|
fetchData()
|
|
@@ -249,6 +258,12 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
249
258
|
}
|
|
250
259
|
i++;
|
|
251
260
|
})
|
|
261
|
+
|
|
262
|
+
return () => {
|
|
263
|
+
if (unsubscribe) {
|
|
264
|
+
unsubscribe();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
252
267
|
}, [Android_appkey, iOS_appkey])
|
|
253
268
|
|
|
254
269
|
|
|
@@ -264,7 +279,7 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
264
279
|
StartSession()
|
|
265
280
|
}
|
|
266
281
|
else if (nextAppState == "background" || nextAppState == 'inactive') {
|
|
267
|
-
if (global.session_id != "" && global.IsBackground == 'true') {
|
|
282
|
+
if (global.session_id != "" && global.IsBackground == 'true' && global.isFeatureEnabled?.('3')) {
|
|
268
283
|
async function FetchEndSessionData() {
|
|
269
284
|
try {
|
|
270
285
|
const { success, message } = await SessionEndApi(global.session_id);
|
|
@@ -304,9 +319,10 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
304
319
|
try {
|
|
305
320
|
let BundleId = DeviceInfo.getBundleId();
|
|
306
321
|
|
|
307
|
-
const { success, application_id: newApplication_id, message, total_mau, used_mau, total_video, used_video, video_duration } = await MatchKeyApi(appkey, BundleId);
|
|
322
|
+
const { success, application_id: newApplication_id, message, total_mau, used_mau, total_video, used_video, video_duration, shakebug_type } = await MatchKeyApi(appkey, BundleId);
|
|
308
323
|
|
|
309
324
|
global.videoDuration = video_duration;
|
|
325
|
+
global.shakebug_type = shakebug_type || "";
|
|
310
326
|
|
|
311
327
|
if (success) {
|
|
312
328
|
if (total_video == "Unlimited") {
|
|
@@ -362,7 +378,7 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
362
378
|
|
|
363
379
|
// For call Startsesstion and get session id
|
|
364
380
|
const StartSession = async () => {
|
|
365
|
-
if (global.session_id == "") {
|
|
381
|
+
if (global.session_id == "" && global.isFeatureEnabled?.('3')) {
|
|
366
382
|
try {
|
|
367
383
|
const { success, session_id: newSessionId, message } = await SessionStartApi(global.latitude, global.longitude, global.application_id);
|
|
368
384
|
if (success) {
|
|
@@ -389,67 +405,9 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
389
405
|
})
|
|
390
406
|
}
|
|
391
407
|
|
|
392
|
-
// For shakeFunctionscreen with childern as props
|
|
393
|
-
const ShakeScreen = () => {
|
|
394
|
-
|
|
395
|
-
DeviceInfo.isEmulator()
|
|
396
|
-
.then(res => {
|
|
397
|
-
global.isRealDevice = !res
|
|
398
|
-
})
|
|
399
|
-
|
|
400
|
-
return (
|
|
401
|
-
<ShakeFunction isRealDevice={global.isRealDevice} themeColor={ThemeColor} showTutorialScreen={showTutorialScreenFirstTime} SDKScreenTitle={[FirstScreenTitle, SecondScreenTitle]} allowToReportBugByShaking={allowToReportBugByShakingMobile} allowToReportBugByScreenCapture={allowToReportBugByScreenCapture} allowCrashReport={allowCrashReport} ShakebugLanguage={ShakebugLanguage}>
|
|
402
|
-
{children}
|
|
403
|
-
</ShakeFunction>
|
|
404
|
-
)
|
|
405
|
-
}
|
|
406
|
-
|
|
407
408
|
// For handel error globaly
|
|
408
409
|
setGlobalErrorHandler()
|
|
409
410
|
|
|
410
|
-
const { width } = Dimensions.get('window');
|
|
411
|
-
|
|
412
|
-
// For register all screen
|
|
413
|
-
const screens = {
|
|
414
|
-
ShakebugHome: ShakeScreen,
|
|
415
|
-
TutorialScreen: TutorialScreen,
|
|
416
|
-
FirstScreen: FirstScreen,
|
|
417
|
-
TrimVideoScreen: TrimVideoScreen,
|
|
418
|
-
AddDetailsScreen: AddDetailsScreen
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
// For navigation in register screen
|
|
422
|
-
const NavigationContainer = () => {
|
|
423
|
-
const { navigationState } = useNavigation();
|
|
424
|
-
const animation = React.useRef(new Animated.Value(0)).current;
|
|
425
|
-
|
|
426
|
-
React.useEffect(() => {
|
|
427
|
-
Animated.timing(animation, {
|
|
428
|
-
toValue: navigationState.length - 1,
|
|
429
|
-
duration: 300,
|
|
430
|
-
useNativeDriver: true,
|
|
431
|
-
}).start();
|
|
432
|
-
}, [navigationState]);
|
|
433
|
-
|
|
434
|
-
return (
|
|
435
|
-
<View style={styles.container}>
|
|
436
|
-
{navigationState.map((screen, index) => {
|
|
437
|
-
const ScreenComponent = screens[screen.name];
|
|
438
|
-
const translateX = animation.interpolate({
|
|
439
|
-
inputRange: [index - 1, index, index + 1],
|
|
440
|
-
outputRange: [width, 0, -width],
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
return (
|
|
444
|
-
<Animated.View key={index} style={[styles.screen, { transform: [{ translateX }] }]}>
|
|
445
|
-
<ScreenComponent {...screen.params} />
|
|
446
|
-
</Animated.View>
|
|
447
|
-
);
|
|
448
|
-
})}
|
|
449
|
-
</View>
|
|
450
|
-
);
|
|
451
|
-
};
|
|
452
|
-
|
|
453
411
|
return (
|
|
454
412
|
<View
|
|
455
413
|
style={{
|
|
@@ -457,11 +415,13 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
457
415
|
height: '100%'
|
|
458
416
|
}}
|
|
459
417
|
>
|
|
460
|
-
<
|
|
461
|
-
<
|
|
462
|
-
<
|
|
463
|
-
|
|
464
|
-
|
|
418
|
+
<ShakebugPropsContext.Provider value={{ ThemeColor, showTutorialScreenFirstTime, FirstScreenTitle, SecondScreenTitle, allowToReportBugByShakingMobile, allowToReportBugByScreenCapture, allowCrashReport, ShakebugLanguage, children }}>
|
|
419
|
+
<GlobalStateProvider>
|
|
420
|
+
<NavigationProvider>
|
|
421
|
+
<NavigationContainerComponent />
|
|
422
|
+
</NavigationProvider>
|
|
423
|
+
</GlobalStateProvider>
|
|
424
|
+
</ShakebugPropsContext.Provider>
|
|
465
425
|
|
|
466
426
|
<CustomeAlert
|
|
467
427
|
isVisible={isAlert}
|
|
@@ -478,12 +438,80 @@ function Shakebug({ children, Android_appkey, iOS_appkey, showTutorialScreenFirs
|
|
|
478
438
|
)
|
|
479
439
|
}
|
|
480
440
|
|
|
441
|
+
const ShakeScreenInner = () => {
|
|
442
|
+
const props = React.useContext(ShakebugPropsContext);
|
|
443
|
+
|
|
444
|
+
useEffect(() => {
|
|
445
|
+
DeviceInfo.isEmulator()
|
|
446
|
+
.then(res => {
|
|
447
|
+
global.isRealDevice = !res
|
|
448
|
+
})
|
|
449
|
+
}, []);
|
|
450
|
+
|
|
451
|
+
return (
|
|
452
|
+
<ShakeFunction
|
|
453
|
+
isRealDevice={global.isRealDevice}
|
|
454
|
+
themeColor={props.ThemeColor}
|
|
455
|
+
showTutorialScreen={props.showTutorialScreenFirstTime}
|
|
456
|
+
SDKScreenTitle={[props.FirstScreenTitle, props.SecondScreenTitle]}
|
|
457
|
+
allowToReportBugByShaking={props.allowToReportBugByShakingMobile}
|
|
458
|
+
allowToReportBugByScreenCapture={props.allowToReportBugByScreenCapture}
|
|
459
|
+
allowCrashReport={props.allowCrashReport}
|
|
460
|
+
ShakebugLanguage={props.ShakebugLanguage}
|
|
461
|
+
>
|
|
462
|
+
{props.children}
|
|
463
|
+
</ShakeFunction>
|
|
464
|
+
)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const screens = {
|
|
468
|
+
ShakebugHome: ShakeScreenInner,
|
|
469
|
+
TutorialScreen: TutorialScreen,
|
|
470
|
+
FirstScreen: FirstScreen,
|
|
471
|
+
TrimVideoScreen: TrimVideoScreen,
|
|
472
|
+
AddDetailsScreen: AddDetailsScreen
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
const NavigationContainerComponent = () => {
|
|
476
|
+
const { width } = Dimensions.get('window');
|
|
477
|
+
const { navigationState } = useNavigation();
|
|
478
|
+
const animation = React.useRef(new Animated.Value(0)).current;
|
|
479
|
+
|
|
480
|
+
React.useEffect(() => {
|
|
481
|
+
Animated.timing(animation, {
|
|
482
|
+
toValue: navigationState.length - 1,
|
|
483
|
+
duration: 300,
|
|
484
|
+
useNativeDriver: true,
|
|
485
|
+
}).start();
|
|
486
|
+
}, [navigationState]);
|
|
487
|
+
|
|
488
|
+
return (
|
|
489
|
+
<View style={styles.container}>
|
|
490
|
+
{navigationState.map((screen, index) => {
|
|
491
|
+
const ScreenComponent = screens[screen.name];
|
|
492
|
+
const translateX = animation.interpolate({
|
|
493
|
+
inputRange: [index - 1, index, index + 1],
|
|
494
|
+
outputRange: [width, 0, -width],
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
return (
|
|
498
|
+
<Animated.View key={index} style={[styles.screen, { transform: [{ translateX }] }]}>
|
|
499
|
+
<ScreenComponent {...screen.params} />
|
|
500
|
+
</Animated.View>
|
|
501
|
+
);
|
|
502
|
+
})}
|
|
503
|
+
</View>
|
|
504
|
+
);
|
|
505
|
+
};
|
|
506
|
+
|
|
481
507
|
|
|
482
508
|
export default Shakebug;
|
|
483
509
|
|
|
484
510
|
// For add event api
|
|
485
511
|
export const AddEvent = async (name, value) => {
|
|
486
512
|
|
|
513
|
+
if (!global.isFeatureEnabled?.('5')) return;
|
|
514
|
+
|
|
487
515
|
const defaultConfig = {
|
|
488
516
|
levels: {
|
|
489
517
|
debug: 0,
|