Skip to content

Commit b1adb4d

Browse files
Update demo app for release 4.3.0 (#931)
1 parent 18bb8b0 commit b1adb4d

File tree

7 files changed

+66
-38
lines changed

7 files changed

+66
-38
lines changed

DemoApp/app/App.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Alert, YellowBox } from 'react-native';
55
import { createBottomTabNavigator, createAppContainer } from 'react-navigation';
66
import Toast from 'react-native-simple-toast';
77

8-
import Crashes, { UserConfirmation, ErrorAttachmentLog } from 'appcenter-crashes';
8+
import Crashes, { UserConfirmation } from 'appcenter-crashes';
99

1010
import AppCenterScreen from './screens/AppCenterScreen';
1111
import TransmissionScreen from './screens/TransmissionScreen';
@@ -54,22 +54,7 @@ Crashes.setListener({
5454

5555
getErrorAttachments(report) {
5656
console.log(`Get error attachments for report with id: ${report.id}'`);
57-
return (async () => {
58-
const attachments = [];
59-
const [textAttachment, binaryAttachment, binaryName, binaryType] = await Promise.all([
60-
AttachmentsProvider.getTextAttachment(),
61-
AttachmentsProvider.getBinaryAttachment(),
62-
AttachmentsProvider.getBinaryName(),
63-
AttachmentsProvider.getBinaryType(),
64-
]);
65-
if (textAttachment !== null) {
66-
attachments.push(ErrorAttachmentLog.attachmentWithText(textAttachment, 'hello.txt'));
67-
}
68-
if (binaryAttachment !== null && binaryName !== null && binaryType !== null) {
69-
attachments.push(ErrorAttachmentLog.attachmentWithBinary(binaryAttachment, binaryName, binaryType));
70-
}
71-
return attachments;
72-
})();
57+
return AttachmentsProvider.getErrorAttachments();
7358
},
7459

7560
onBeforeSending() {

DemoApp/app/AttachmentsProvider.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import AsyncStorage from '@react-native-community/async-storage';
55
import RNFS from 'react-native-fs';
6+
import { ErrorAttachmentLog } from 'appcenter-crashes';
67

78
const TEXT_ATTACHMENT_KEY = 'TEXT_ATTACHMENT_KEY';
89
const BINARY_FILENAME_KEY = 'BINARY_FILENAME_KEY';
@@ -28,6 +29,25 @@ export default class AttachmentsProvider {
2829
}
2930
}
3031

32+
static async getErrorAttachments() {
33+
return (async () => {
34+
const attachments = [];
35+
const [textAttachment, binaryAttachment, binaryName, binaryType] = await Promise.all([
36+
AttachmentsProvider.getTextAttachment(),
37+
AttachmentsProvider.getBinaryAttachment(),
38+
AttachmentsProvider.getBinaryName(),
39+
AttachmentsProvider.getBinaryType(),
40+
]);
41+
if (textAttachment !== null) {
42+
attachments.push(ErrorAttachmentLog.attachmentWithText(textAttachment, 'hello.txt'));
43+
}
44+
if (binaryAttachment !== null && binaryName !== null && binaryType !== null) {
45+
attachments.push(ErrorAttachmentLog.attachmentWithBinary(binaryAttachment, binaryName, binaryType));
46+
}
47+
return attachments;
48+
})();
49+
}
50+
3151
static async saveTextAttachment(value) {
3252
await this.updateItem(TEXT_ATTACHMENT_KEY, value);
3353
}

DemoApp/app/screens/CrashesScreen.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { Component } from 'react';
55
import { Image, View, Text, TextInput, Switch, SectionList, TouchableOpacity, NativeModules } from 'react-native';
66
import ImagePicker from 'react-native-image-picker';
77

8-
import Crashes from 'appcenter-crashes';
8+
import Crashes, { ExceptionModel } from 'appcenter-crashes';
99

1010
import AttachmentsProvider from '../AttachmentsProvider';
1111
import SharedStyles from '../SharedStyles';
@@ -72,6 +72,16 @@ export default class CrashesScreen extends Component {
7272
foo.method1();
7373
}
7474

75+
async trackError(includeProperties) {
76+
try {
77+
throw new Error('Custom error');
78+
} catch (error) {
79+
const properties = includeProperties ? { property1: '100', property2: '200' } : null;
80+
const attachments = await AttachmentsProvider.getErrorAttachments();
81+
Crashes.trackError(ExceptionModel.createFromError(error), properties, attachments);
82+
}
83+
}
84+
7585
async nativeCrash() {
7686
// In Android debug or non app store environment for iOS.
7787
await Crashes.generateTestCrash();
@@ -168,6 +178,20 @@ export default class CrashesScreen extends Component {
168178
],
169179
renderItem: actionRenderItem
170180
},
181+
{
182+
title: 'Track error',
183+
data: [
184+
{
185+
title: 'Track error',
186+
action: () => this.trackError(false)
187+
},
188+
{
189+
title: 'Track error with properties',
190+
action: () => this.trackError(true)
191+
},
192+
],
193+
renderItem: actionRenderItem
194+
},
171195
{
172196
title: 'Miscellaneous',
173197
data: [
@@ -184,7 +208,7 @@ export default class CrashesScreen extends Component {
184208
}
185209
],
186210
renderItem: valueRenderItem
187-
}
211+
},
188212
]}
189213
/>
190214
</View>

DemoApp/ios/Podfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ target 'DemoApp' do
66
# use_frameworks!
77

88
# Pods for DemoApp
9-
pod 'AppCenter/Crashes', '~> 4.2.0'
10-
pod 'AppCenter/Analytics', '~> 4.2.0'
11-
pod 'AppCenterReactNativeShared', '~> 4.2.0'
9+
pod 'AppCenter/Crashes', '~> 4.3.0'
10+
pod 'AppCenter/Analytics', '~> 4.3.0'
11+
pod 'AppCenterReactNativeShared', '~> 4.3.0'
1212

1313
platform :ios, '9.0'
1414

DemoApp/ios/Podfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
PODS:
2-
- AppCenter/Analytics (4.2.0):
2+
- AppCenter/Analytics (4.3.0):
33
- AppCenter/Core
4-
- AppCenter/Core (4.2.0)
5-
- AppCenter/Crashes (4.2.0):
4+
- AppCenter/Core (4.3.0)
5+
- AppCenter/Crashes (4.3.0):
66
- AppCenter/Core
7-
- AppCenterReactNativeShared (4.2.0):
8-
- AppCenter/Core (= 4.2.0)
7+
- AppCenterReactNativeShared (4.3.0):
8+
- AppCenter/Core (= 4.3.0)
99

1010
DEPENDENCIES:
11-
- AppCenter/Analytics (~> 4.2.0)
12-
- AppCenter/Crashes (~> 4.2.0)
13-
- AppCenterReactNativeShared (~> 4.2.0)
11+
- AppCenter/Analytics (~> 4.3.0)
12+
- AppCenter/Crashes (~> 4.3.0)
13+
- AppCenterReactNativeShared (~> 4.3.0)
1414

1515
SPEC REPOS:
1616
https://msmobilecenter.visualstudio.com/SDK/_git/AppCenterSDK-Specs-Private:
1717
- AppCenter
1818
- AppCenterReactNativeShared
1919

2020
SPEC CHECKSUMS:
21-
AppCenter: 5c495ec6b22d072d9bbd0586ddebedb30c1cca64
22-
AppCenterReactNativeShared: de51fd65fc1b892dab6ee646e54146ac4e0dee1e
21+
AppCenter: 1fde01d939ee7c09bc2ff982476d1a891719065c
22+
AppCenterReactNativeShared: b150ce9f33c10395798b2a60aed2e114acd87557
2323

24-
PODFILE CHECKSUM: 1cfd50ac0e60eb368817430a68a13112743fc524
24+
PODFILE CHECKSUM: 68158a0223388bbed08e7c1ba598db31fccc7cea
2525

26-
COCOAPODS: 1.10.1
26+
COCOAPODS: 1.11.0

DemoApp/jest/setup.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Object.defineProperty(ReactNative, 'Switch', {
3232
}
3333
});
3434

35-
3635
jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
3736

3837
// Mock the native image picker library

DemoApp/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
},
1010
"dependencies": {
1111
"@react-native-community/async-storage": "1.6.2",
12-
"appcenter": "^4.2.0",
13-
"appcenter-analytics": "^4.2.0",
14-
"appcenter-crashes": "^4.2.0",
12+
"appcenter": "^4.3.0",
13+
"appcenter-analytics": "^4.3.0",
14+
"appcenter-crashes": "^4.3.0",
1515
"metro": "0.54.1",
1616
"react": "16.8.3",
1717
"react-native": "0.59.9",

0 commit comments

Comments
 (0)