Skip to content

Commit a49ebe9

Browse files
committed
✨ Add Sample App feature
1 parent 20fde87 commit a49ebe9

File tree

21 files changed

+385
-571
lines changed

21 files changed

+385
-571
lines changed

InstabugSample/.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["react-native"]
3-
}
2+
"presets": ["react-native"]
3+
}

InstabugSample/.flowconfig

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,45 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2328

2429
[options]
25-
module.system=haste
30+
emoji=true
2631

27-
experimental.strict_type_args=true
32+
module.system=haste
2833

2934
munge_underscores=true
3035

3136
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3237

38+
module.file_ext=.js
39+
module.file_ext=.jsx
40+
module.file_ext=.json
41+
module.file_ext=.native.js
42+
3343
suppress_type=$FlowIssue
3444
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
3647

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3950
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4052

4153
unsafe.enable_getters_and_setters=true
4254

4355
[version]
44-
^0.37.0
56+
^0.61.0

InstabugSample/.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ yarn-error.log
3939
# BUCK
4040
buck-out/
4141
\.buckd/
42-
android/app/libs
4342
*.keystore
4443

4544
# fastlane
4645
#
4746
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4847
# screenshots whenever they are needed.
4948
# For more information about the recommended setup visit:
50-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5150

52-
fastlane/report.xml
53-
fastlane/Preview.html
54-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots

InstabugSample/App.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
* @flow
5+
*/
6+
7+
import React, { Component } from 'react';
8+
import {
9+
Platform,
10+
StyleSheet,
11+
Text,
12+
View,
13+
TouchableOpacity
14+
} from 'react-native';
15+
16+
import Instabug from'instabug-reactnative';
17+
18+
19+
const instructions = Platform.select({
20+
ios: 'Press Cmd+R to reload,\n' +
21+
'Cmd+D or shake for dev menu',
22+
android: 'Double tap R on your keyboard to reload,\n' +
23+
'Shake or press menu button for dev menu',
24+
});
25+
26+
export default class App extends Component<{}> {
27+
28+
constructor(props) {
29+
super(props);
30+
Instabug.setReportCategories("Performance","UI","Flow","Other");
31+
Instabug.setPromptOptionsEnabled(true, true, true);
32+
}
33+
34+
render() {
35+
return (
36+
<View style={styles.container}>
37+
<Text style={styles.details}>
38+
Hello Instabug awesome user! The purpose of this application is to show you the different
39+
options for customizing the SDK and how easy it is to integrate it to your existing app
40+
</Text>
41+
<TouchableOpacity style={styles.button} onPress={()=>this.showIntroMessage()}>
42+
<Text style={styles.text}> SHOW INTRO MESSAGE </Text>
43+
</TouchableOpacity>
44+
<TouchableOpacity style={styles.button} onPress={()=>this.invoke()}>
45+
<Text style={styles.text}> INVOKE </Text>
46+
</TouchableOpacity>
47+
<TouchableOpacity style={styles.button} onPress={()=>this.sendBugReport()}>
48+
<Text style={styles.text}> SEND BUG REPORT </Text>
49+
</TouchableOpacity>
50+
<TouchableOpacity style={styles.button} onPress={()=>this.sendFeedback()}>
51+
<Text style={styles.text}> SEND FEEDBACK </Text>
52+
</TouchableOpacity>
53+
<TouchableOpacity style={styles.button} onPress={()=>this.startNewConversation()}>
54+
<Text style={styles.text}> START A NEW CONVERSATION </Text>
55+
</TouchableOpacity>
56+
<TouchableOpacity style={styles.button} onPress={()=>this.showUnreadMessagesCount()}>
57+
<Text style={styles.text}> GET UNREAD MESSAGES COUNT </Text>
58+
</TouchableOpacity>
59+
</View>
60+
);
61+
}
62+
63+
showIntroMessage() {
64+
Instabug.showIntroMessage();
65+
}
66+
67+
invoke() {
68+
Instabug.invoke();
69+
}
70+
71+
sendBugReport() {
72+
Instabug.invokeWithInvocationMode(Instabug.invocationMode.newBug);
73+
}
74+
75+
sendFeedback() {
76+
Instabug.invokeWithInvocationMode(Instabug.invocationMode.newFeedback);
77+
}
78+
79+
startNewConversation() {
80+
Instabug.invokeWithInvocationMode(Instabug.invocationMode.newChat);
81+
}
82+
83+
showUnreadMessagesCount() {
84+
Instabug.getUnreadMessagesCount((count) => {
85+
alert("Messages: " + count);
86+
});
87+
}
88+
}
89+
90+
const styles = StyleSheet.create({
91+
container: {
92+
flex: 1,
93+
alignItems: 'center',
94+
backgroundColor: '#F5FCFF',
95+
},
96+
details: {
97+
textAlign: 'center',
98+
color: '#333333',
99+
margin: 20
100+
},
101+
text: {
102+
color: '#FFFFFF'
103+
},
104+
button: {
105+
marginTop: 10,
106+
backgroundColor: "#1D82DC",
107+
padding: 10,
108+
alignItems: 'center',
109+
borderRadius: 5
110+
}
111+
});

InstabugSample/android/app/BUCK

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import re
2-
31
# To learn about Buck see [Docs](https://buckbuild.com/).
42
# To run your application with Buck:
53
# - install Buck
@@ -11,56 +9,57 @@ import re
119
#
1210

1311
lib_deps = []
12+
1413
for jarfile in glob(['libs/*.jar']):
15-
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
14+
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
1615
lib_deps.append(':' + name)
1716
prebuilt_jar(
1817
name = name,
1918
binary_jar = jarfile,
2019
)
2120

2221
for aarfile in glob(['libs/*.aar']):
23-
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
22+
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
2423
lib_deps.append(':' + name)
2524
android_prebuilt_aar(
2625
name = name,
2726
aar = aarfile,
2827
)
2928

3029
android_library(
31-
name = 'all-libs',
32-
exported_deps = lib_deps
30+
name = "all-libs",
31+
exported_deps = lib_deps,
3332
)
3433

3534
android_library(
36-
name = 'app-code',
37-
srcs = glob([
38-
'src/main/java/**/*.java',
39-
]),
40-
deps = [
41-
':all-libs',
42-
':build_config',
43-
':res',
44-
],
35+
name = "app-code",
36+
srcs = glob([
37+
"src/main/java/**/*.java",
38+
]),
39+
deps = [
40+
":all-libs",
41+
":build_config",
42+
":res",
43+
],
4544
)
4645

4746
android_build_config(
48-
name = 'build_config',
49-
package = 'com.instabugsample',
47+
name = "build_config",
48+
package = "com.instabugsample",
5049
)
5150

5251
android_resource(
53-
name = 'res',
54-
res = 'src/main/res',
55-
package = 'com.instabugsample',
52+
name = "res",
53+
package = "com.instabugsample",
54+
res = "src/main/res",
5655
)
5756

5857
android_binary(
59-
name = 'app',
60-
package_type = 'debug',
61-
manifest = 'src/main/AndroidManifest.xml',
62-
keystore = '//android/keystores:debug',
63-
deps = [
64-
':app-code',
65-
],
58+
name = "app",
59+
keystore = "//android/keystores:debug",
60+
manifest = "src/main/AndroidManifest.xml",
61+
package_type = "debug",
62+
deps = [
63+
":app-code",
64+
],
6665
)

InstabugSample/android/app/build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ import com.android.build.OutputFile
3333
* // bundleInPaidRelease: true,
3434
* // bundleInBeta: true,
3535
*
36+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
37+
* // for example: to disable dev mode in the staging build type (if configured)
38+
* devDisabledInStaging: true,
39+
* // The configuration property can be in the following formats
40+
* // 'devDisabledIn${productFlavor}${buildType}'
41+
* // 'devDisabledIn${buildType}'
42+
*
3643
* // the root of your project, i.e. where "package.json" lives
3744
* root: "../../",
3845
*
@@ -58,13 +65,17 @@ import com.android.build.OutputFile
5865
* inputExcludes: ["android/**", "ios/**"],
5966
*
6067
* // override which node gets called and with what additional arguments
61-
* nodeExecutableAndArgs: ["node"]
68+
* nodeExecutableAndArgs: ["node"],
6269
*
6370
* // supply additional arguments to the packager
6471
* extraPackagerArgs: []
6572
* ]
6673
*/
6774

75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
6879
apply from: "../../node_modules/react-native/react.gradle"
6980

7081
/**
@@ -123,9 +134,6 @@ android {
123134
}
124135
}
125136
}
126-
repositories {
127-
maven { url "https://jitpack.io" }
128-
}
129137
}
130138

131139
dependencies {

InstabugSample/android/app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050

5151
-dontwarn com.facebook.react.**
5252

53+
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
54+
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
55+
-dontwarn android.text.StaticLayout
56+
5357
# okhttp
5458

5559
-keepattributes Signature

InstabugSample/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<activity
2020
android:name=".MainActivity"
2121
android:label="@string/app_name"
22-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
22+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
23+
android:windowSoftInputMode="adjustResize">
2324
<intent-filter>
2425
<action android:name="android.intent.action.MAIN" />
2526
<category android:name="android.intent.category.LAUNCHER" />

InstabugSample/android/app/src/main/java/com/instabugsample/MainApplication.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.instabugsample;
22

33
import android.app.Application;
4-
import android.util.Log;
54

65
import com.facebook.react.ReactApplication;
76
import com.instabug.reactlibrary.RNInstabugReactnativePackage;
8-
import com.facebook.react.ReactInstanceManager;
97
import com.facebook.react.ReactNativeHost;
108
import com.facebook.react.ReactPackage;
119
import com.facebook.react.shell.MainReactPackage;
@@ -26,9 +24,19 @@ public boolean getUseDeveloperSupport() {
2624
protected List<ReactPackage> getPackages() {
2725
return Arrays.<ReactPackage>asList(
2826
new MainReactPackage(),
29-
new RNInstabugReactnativePackage("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this,"shake","#1D82DC")
27+
new RNInstabugReactnativePackage.Builder("YOUR_ANDROID_APPLICATION_TOKEN",MainApplication.this)
28+
.setInvocationEvent("shake")
29+
.setPrimaryColor("#1D82DC")
30+
.setFloatingEdge("left")
31+
.setFloatingButtonOffsetFromTop(250)
32+
.build()
3033
);
3134
}
35+
36+
@Override
37+
protected String getJSMainModuleName() {
38+
return "index";
39+
}
3240
};
3341

3442
@Override

0 commit comments

Comments
 (0)