Skip to content

Commit 866dc12

Browse files
Create instabug-reactnative
1 parent 948b9a8 commit 866dc12

20 files changed

+398
-580
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.idea/
3+
4+
.DS_Store
5+
android/.DS_Store
6+
ios/.DS_Store
7+
8+
build/

.npmignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.idea/
3+
.DS_Store
4+
5+
android/.DS_Store
6+
android/android.iml
7+
android/gradlew
8+
android/gradlew.bat
9+
android/local.properties
10+
11+
ios/.DS_Store
12+
13+
build/
14+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Instabug
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,50 @@
11

2-
# react-native-instabug-reactnative
2+
# instabug-reactnative
33

44
## Getting started
55

6-
`$ npm install react-native-instabug-reactnative --save`
6+
`$ npm install https://github.com/Instabug/instabug-reactnative --save`
77

88
### Mostly automatic installation
99

10-
`$ react-native link react-native-instabug-reactnative`
10+
`$ react-native link instabug-reactnative`
1111

1212
### Manual installation
1313

1414

1515
#### iOS
1616

1717
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
18-
2. Go to `node_modules``react-native-instabug-reactnative` and add `RNInstabugReactnative.xcodeproj`
18+
2. Go to `node_modules``instabug-reactnative` and add `RNInstabugReactnative.xcodeproj`
1919
3. In XCode, in the project navigator, select your project. Add `libRNInstabugReactnative.a` to your project's `Build Phases``Link Binary With Libraries`
2020
4. Run your project (`Cmd+R`)<
2121

2222
#### Android
2323

2424
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
25-
- Add `import com.reactlibrary.RNInstabugReactnativePackage;` to the imports at the top of the file
25+
- Add `import com.instabug.reactlibrary.RNInstabugReactnativePackage;` to the imports at the top of the file
2626
- Add `new RNInstabugReactnativePackage()` to the list returned by the `getPackages()` method
2727
2. Append the following lines to `android/settings.gradle`:
2828
```
29-
include ':react-native-instabug-reactnative'
30-
project(':react-native-instabug-reactnative').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-instabug-reactnative/android')
29+
include ':instabug-reactnative'
30+
project(':instabug-reactnative').projectDir = new File(rootProject.projectDir, '../node_modules/instabug-reactnative/android')
3131
```
3232
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
3333
```
34-
compile project(':react-native-instabug-reactnative')
34+
compile project(':instabug-reactnative')
3535
```
3636

37-
#### Windows
38-
[Read it! :D](https://github.com/ReactWindows/react-native)
39-
40-
1. In Visual Studio add the `RNInstabugReactnative.sln` in `node_modules/react-native-instabug-reactnative/windows/RNInstabugReactnative.sln` folder to their solution, reference from their app.
41-
2. Open up your `MainPage.cs` app
42-
- Add `using Cl.Json.RNInstabugReactnative;` to the usings at the top of the file
43-
- Add `new RNInstabugReactnativePackage()` to the `List<IReactPackage>` returned by the `Packages` method
44-
4537

4638
## Usage
4739
```javascript
48-
import RNInstabugReactnative from 'react-native-instabug-reactnative';
40+
import RNInstabugReactnative from 'instabug-reactnative';
4941

5042
// TODO: What do with the module?
5143
RNInstabugReactnative;
5244
```
53-
45+
46+
## License
47+
48+
This software is released under <a href="https://opensource.org/licenses/mit-license.php">MIT License</a>.
49+
50+
© 2016 Instabug. All rights reserved.

android/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ android {
2121

2222
dependencies {
2323
compile 'com.facebook.react:react-native:0.20.+'
24+
compile 'com.instabug.library:instabug:2+'
25+
2426
}
2527

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.reactlibrary">
3+
package="com.instabug.reactlibrary">
44

55
</manifest>
66

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
2+
package com.instabug.reactlibrary;
3+
4+
import com.facebook.react.bridge.ReactApplicationContext;
5+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
6+
import com.facebook.react.bridge.ReactMethod;
7+
import com.facebook.react.bridge.Callback;
8+
9+
import com.instabug.library.IBGInvocationMode;
10+
import com.instabug.library.Instabug;
11+
12+
import java.util.Locale;
13+
import android.net.Uri;
14+
15+
16+
public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
17+
18+
private Instabug mInstabug;
19+
20+
public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Instabug instabug) {
21+
super(reactContext);
22+
this.mInstabug = instabug;
23+
}
24+
25+
@Override
26+
public String getName() {
27+
return "RNInstabugReactnative";
28+
}
29+
30+
/**
31+
* Adds tag(s) to issues before sending them
32+
*
33+
* @param tags
34+
*/
35+
@ReactMethod
36+
public void addTags(String tags) {
37+
try {
38+
String[] result = tags.split(",");
39+
mInstabug.resetTags(); //clear last commit tags
40+
mInstabug.addTags(result);
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
}
45+
46+
/**
47+
* Change Locale of Instabug UI elements(defaults to English)
48+
*
49+
* @param languageTag
50+
*/
51+
@ReactMethod
52+
public void changeLocale(String languageTag) {
53+
try {
54+
switch (languageTag) {
55+
case "CHINA":
56+
case "CHINESE":
57+
case "PRC":
58+
case "SIMPLIFIED_CHINESE":
59+
mInstabug.changeLocale(Locale.CHINESE);
60+
break;
61+
case "TAIWAN":
62+
case "TRADITIONAL_CHINESE":
63+
mInstabug.changeLocale(Locale.TAIWAN);
64+
break;
65+
case "ENGLISH":
66+
mInstabug.changeLocale(Locale.ENGLISH);
67+
break;
68+
case "UK":
69+
mInstabug.changeLocale(Locale.UK);
70+
break;
71+
case "US":
72+
mInstabug.changeLocale(Locale.US);
73+
break;
74+
}
75+
76+
} catch (Exception e) {
77+
e.printStackTrace();
78+
}
79+
}
80+
81+
@ReactMethod
82+
public void report(String value) {
83+
IBGInvocationMode mode = IBGInvocationMode.IBGInvocationModeNA;
84+
if (value.equals("bug")) {
85+
mode = IBGInvocationMode.IBGInvocationModeBugReporter;
86+
} else if (value.equals("feedback")) {
87+
mode = IBGInvocationMode.IBGInvocationModeFeedbackSender;
88+
}
89+
90+
mInstabug.invoke(mode);
91+
}
92+
93+
/**
94+
* The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension
95+
*
96+
* @param fileUri
97+
* @param fileNameWithExtension
98+
*/
99+
@ReactMethod
100+
public void setFileAttachment(String fileUri, String fileNameWithExtension) {
101+
try {
102+
Uri uri = Uri.parse(fileUri);
103+
mInstabug.setFileAttachment(uri, fileNameWithExtension);
104+
} catch (Exception e) {
105+
e.printStackTrace();
106+
}
107+
}
108+
109+
/**
110+
* If your app already acquires the user's email address and you provide it to this method,
111+
* Instabug will pre-fill the user email in reports.
112+
*
113+
* @param userEmail
114+
*/
115+
@ReactMethod
116+
public void setUserEmail(String userEmail) {
117+
try {
118+
mInstabug.setUserEmail(userEmail);
119+
} catch (Exception e) {
120+
e.printStackTrace();
121+
}
122+
}
123+
124+
/**
125+
* Sets the user name that is used in the dashboard's contacts.
126+
*
127+
* @param username
128+
*/
129+
@ReactMethod
130+
public void setUsername(String username) {
131+
try {
132+
mInstabug.setUsername(username);
133+
} catch (Exception e) {
134+
e.printStackTrace();
135+
}
136+
}
137+
138+
/**
139+
* Adds specific user data that you need to be added to the reports
140+
*
141+
* @param userData
142+
*/
143+
@ReactMethod
144+
public void setUserData(String userData) {
145+
try {
146+
mInstabug.setUserData(userData);
147+
} catch (Exception e) {
148+
e.printStackTrace();
149+
}
150+
}
151+
152+
/**
153+
* Call this method to display the discovery dialog explaining the shake gesture or the two
154+
* finger swipe gesture, if you've enabled it.
155+
* i.e: This method is automatically called on first run of the application
156+
*/
157+
@ReactMethod
158+
public void showIntroMessage() {
159+
try {
160+
mInstabug.showIntroMessage();
161+
} catch (Exception e) {
162+
e.printStackTrace();
163+
}
164+
}
165+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
package com.instabug.reactlibrary;
3+
4+
import java.util.Arrays;
5+
import java.util.Collections;
6+
import java.util.List;
7+
import java.util.ArrayList;
8+
import android.app.Application;
9+
10+
import com.facebook.react.ReactPackage;
11+
import com.facebook.react.bridge.NativeModule;
12+
import com.facebook.react.bridge.ReactApplicationContext;
13+
import com.facebook.react.uimanager.ViewManager;
14+
import com.facebook.react.bridge.JavaScriptModule;
15+
16+
import com.instabug.library.IBGColorTheme;
17+
import com.instabug.library.IBGInvocationEvent;
18+
import com.instabug.library.Instabug;
19+
20+
public class RNInstabugReactnativePackage implements ReactPackage {
21+
22+
private String mToken;
23+
private Application mApplication;
24+
25+
private Instabug mInstagbug;
26+
private Instabug.Builder mBuilder;
27+
28+
public RNInstabugReactnativePackage(Instabug instabug) {
29+
this.mInstagbug = instabug;
30+
}
31+
32+
public RNInstabugReactnativePackage(Instabug.Builder builder) {
33+
this.mBuilder = builder;
34+
}
35+
36+
public RNInstabugReactnativePackage(String token, Application application) {
37+
this.mToken = token;
38+
this.mApplication = application;
39+
40+
mInstagbug = new Instabug.Builder(mApplication, mToken)
41+
.setDebugEnabled(true)
42+
.setEmailFieldRequired(false)
43+
.setFloatingButtonOffsetFromTop(400)
44+
.setColorTheme(IBGColorTheme.IBGColorThemeDark)
45+
.setInvocationEvent(IBGInvocationEvent.IBGInvocationEventFloatingButton)
46+
.setShouldShowIntroDialog(false)
47+
//.setInvocationEvent(IBGInvocationEvent.IBGInvocationEventShake)
48+
.build();
49+
50+
}
51+
@Override
52+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
53+
List<NativeModule> modules = new ArrayList<>();
54+
modules.add(new RNInstabugReactnativeModule(reactContext, this.mInstagbug));
55+
return modules;
56+
}
57+
58+
@Override
59+
public List<Class<? extends JavaScriptModule>> createJSModules() {
60+
return Collections.emptyList();
61+
}
62+
63+
@Override
64+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
65+
return Collections.emptyList();
66+
}
67+
}

android/src/main/java/com/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)