Skip to content

Commit

Permalink
Merge pull request #676 from Instabug/release/10.13.0
Browse files Browse the repository at this point in the history
[MOB-8381] Release/10.13.0
  • Loading branch information
ymabdallah authored Mar 17, 2022
2 parents 6b4ea10 + 7d05bf8 commit a30a507
Show file tree
Hide file tree
Showing 113 changed files with 6,348 additions and 5,443 deletions.
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.github/
.circleci/

*.iml
.idea/
.DS_Store
Expand All @@ -7,10 +10,20 @@ android/android.iml
android/gradlew
android/gradlew.bat
android/local.properties
android/.project
android/.settings
*Test.java

ios/.DS_Store

build/
InstabugSample/
node_modules/
coverage/
__tests__/

Dangerfile
babel.config.js
codecov.yml
typescript_validator.js
.prettierrc.js
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 10.13.0 (2022-03-17)

* Adds Instabug Experiments APIs
* Adds defensive type checking in Instabug logging APIs
* Bumps Instabug iOS SDK to v10.11.9
* Bumps Instabug Android SDK to v10.13.0
* Adapts the strict requirement of newer Expo versions to use the React header with the iOS import statements
* Fixes an issue with GraphQL requests not being grouped correctly
* Excludes unnecessary files from the published npm package

## 10.11.0 (2021-12-23)

* Adds GraphQL support for APM network traces with proper grouping
Expand Down
4 changes: 4 additions & 0 deletions InstabugSample/__tests__/instabugUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe('Test global error handler', () => {
handler({name: 'TypeError', message: 'This is a type error.'}, false);
const expected = {
message: 'TypeError - This is a type error.',
e_message: 'This is a type error.',
e_name: 'TypeError',
os: 'ios',
platform: 'react_native',
exception: [],
Expand All @@ -48,6 +50,8 @@ describe('Test global error handler', () => {
handler({name: 'TypeError', message: 'This is a type error.'}, false);
const expected = {
message: 'TypeError - This is a type error.',
e_message: 'This is a type error.',
e_name: 'TypeError',
os: 'android',
platform: 'react_native',
exception: [],
Expand Down
25 changes: 25 additions & 0 deletions InstabugSample/ios/InstabugSampleTests/InstabugSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,29 @@ - (void)testClearLogs {
OCMVerify([mock clearAllLogs]);
}

- (void)testAddExperiments {
id mock = OCMClassMock([Instabug class]);
NSArray *experiments = @[@"exp1", @"exp2"];

OCMStub([mock addExperiments:experiments]);
[self.instabugBridge addExperiments:experiments];
OCMVerify([mock addExperiments:experiments]);
}

- (void)testRemoveExperiments {
id mock = OCMClassMock([Instabug class]);
NSArray *experiments = @[@"exp1", @"exp2"];

OCMStub([mock removeExperiments:experiments]);
[self.instabugBridge removeExperiments:experiments];
OCMVerify([mock removeExperiments:experiments]);
}

- (void)testClearAllExperiments {
id mock = OCMClassMock([Instabug class]);
OCMStub([mock clearAllExperiments]);
[self.instabugBridge clearAllExperiments];
OCMVerify([mock clearAllExperiments]);
}

@end
8 changes: 4 additions & 4 deletions InstabugSample/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,7 @@ ini@^1.3.4:
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==

instabug-reactnative@../:
version "10.9.1"
version "10.11.0"

internal-slot@^1.0.3:
version "1.0.3"
Expand Down Expand Up @@ -5104,9 +5104,9 @@ nan@^2.14.0:
integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==

nanoid@^3.1.23:
version "3.1.29"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.29.tgz#214fb2d7a33e1a5bef4757b779dfaeb6a4e5aeb4"
integrity sha512-dW2pUSGZ8ZnCFIlBIA31SV8huOGCHb6OwzVCc7A69rb/a+SgPBwfmLvK5TKQ3INPbRkcI8a/Owo0XbiTNH19wg==
version "3.2.0"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c"
integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==

nanomatch@^1.2.9:
version "1.2.13"
Expand Down
75 changes: 6 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ Updating to a new version? Check the [Update Guide](#update-guide) before bumpin
cd ios && pod install && cd ..
```

3. **For React Native >= 0.60**, simply run the command:

```bash
react-native add-instabug
```

**For React Native < 0.60**, link the bridging files in the `instabug-reactnative` package:
3. **For React Native < 0.60**, link the bridging files in the `instabug-reactnative` package:

```bash
react-native link instabug-reactnative
Expand All @@ -55,14 +49,14 @@ Updating to a new version? Check the [Update Guide](#update-guide) before bumpin
```javascript
import Instabug from 'instabug-reactnative';
```
* ### iOS
Initialize it in the `constructor` or `componentWillMount`. This line will let the Instabug SDK work with the default behavior. The SDK will be invoked when the device is shaken. You can customize this behavior through the APIs.
### iOS
- Initialize it in the `constructor` or `componentWillMount`. This line will let the Instabug SDK work with the default behavior. The SDK will be invoked when the device is shaken. You can customize this behavior through the APIs.

```javascript
Instabug.start('IOS_APP_TOKEN', [Instabug.invocationEvent.shake]);
```
* ### Android
1. Open `android/app/src/main/java/[...]/MainApplication.java`
### Android
- Open `android/app/src/main/java/[...]/MainApplication.java`
* Make sure to import the package class:
`import com.instabug.reactlibrary.RNInstabugReactnativePackage;`
* **For React Native >= 0.60**
Expand Down Expand Up @@ -101,18 +95,7 @@ import Instabug from 'instabug-reactnative';
* You can change the invocation event from here, simply by replacing the `"shake"` with any of the following `"button"`, `"none"`, `"screenshot"`, or `"swipe"`. You can change the primary color by replacing the `"#1D82DC"` with any color of your choice.
In the case that you are using the floating button as an invocation event, you can change the floating button edge and the floating button offset using the last two methods, by replacing `"left"` to `"right"`, and by changing the offset number.
You can find your app token by selecting the SDK tab from your [**Instabug dashboard**](https://dashboard.instabug.com/app/sdk/).
2. Make sure the following snippet is added to your project level `build.gradle`. This should be added automatically upon linking. If not, you can add it manually.
```dart
allprojects {
repositories {
maven {
url "https://sdks.instabug.com/nexus/repository/instabug-cp"
}
}
}
```
_You can find your app token by selecting the SDK tab from your [**Instabug dashboard**](https://dashboard.instabug.com)._
## Microphone and Photo Library Usage Description (iOS Only)
Expand Down Expand Up @@ -202,52 +185,6 @@ You can disable Repro Steps using the following API:
Instabug.setReproStepsMode(Instabug.reproStepsMode.disabled);
```
## Update Guide
### Updating to versions 8.0-8.4.x
When updating to version 8.0 through 8.4.x, you'll need to perform the steps below.
1. Unlink Instabug
```bash
react-native unlink instabug-reactnative
```
2. Install the new version of Instabug
```bash
npm install instabug-reactnative
```
3. Link Instabug
```bash
react-native link instabug-reactnative
```
### Updating to version 8.5
_Only for apps using React Native >= 0.60. If you're using a lower version, you don't need to perform any extra steps when updating._
Version 8.5 adds support for React Native 0.60. To use Instabug 8.5 with React Native 0.60, you'll need to perform the following steps.
1. Unlink Instabug
```bash
react-native unlink instabug-reactnative
```
2. Install the new version of Instabug
```bash
npm install instabug-reactnative
```
3. Add Instabug to your project
```bash
react-native add-instabug
```
## Features that are not supported yet
- Push Notification Support for In-App Messaging
- [User Steps](https://help.instabug.com/en/articles/2515300-instabug-report-logs-user-steps).
## Documentation
For more details about the supported APIs and how to use them, check our [**Documentation**](https://docs.instabug.com/docs/react-native-overview).
6 changes: 6 additions & 0 deletions __tests__/crashReporting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ describe('CrashReporting Module', () => {

const expectedObject = {
message: 'TypeError - Invalid type',
e_message: 'Invalid type',
e_name: 'TypeError',
os: 'ios',
platform: 'react_native',
exception: 'javascriptStackTrace'
Expand All @@ -66,6 +68,8 @@ describe('CrashReporting Module', () => {

const expectedObject = {
message: 'TypeError - Invalid type',
e_message: 'Invalid type',
e_name: 'TypeError',
os: 'android',
platform: 'react_native',
exception: 'javascriptStackTrace'
Expand All @@ -84,6 +88,8 @@ describe('CrashReporting Module', () => {
const errorObject = { name: 'TypeError', message: 'Invalid type' };
const expectedObject = {
message: 'TypeError - Invalid type',
e_message: 'Invalid type',
e_name: 'TypeError',
os: 'android',
platform: 'react_native',
exception: 'javascriptStackTrace'
Expand Down
29 changes: 24 additions & 5 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ describe('Instabug Module', () => {
const sendHandledJSCrash = sinon.spy(NativeModules.Instabug, 'sendHandledJSCrash');
const sendJSCrash = sinon.spy(NativeModules.Instabug, 'sendJSCrash');
const reportScreenChange = sinon.spy(NativeModules.Instabug, 'reportScreenChange');
const addExperiments = sinon.spy(NativeModules.Instabug, 'addExperiments');
const removeExperiments = sinon.spy(NativeModules.Instabug, 'removeExperiments');
const clearAllExperiments = sinon.spy(NativeModules.Instabug, 'clearAllExperiments');

beforeEach(() => {
startWithToken.resetHistory();
Expand Down Expand Up @@ -301,7 +304,7 @@ describe('Instabug Module', () => {
const message = 'log';
Instabug.logVerbose(message);

expect(logVerbose.calledOnceWithExactly(message)).toBe(true);
expect(logVerbose.calledOnce).toBe(true);

});

Expand All @@ -310,7 +313,7 @@ describe('Instabug Module', () => {
const message = 'log';
Instabug.logDebug(message);

expect(logDebug.calledOnceWithExactly(message)).toBe(true);
expect(logDebug.calledOnce).toBe(true);

});

Expand All @@ -319,7 +322,7 @@ describe('Instabug Module', () => {
const message = 'log';
Instabug.logInfo(message);

expect(logInfo.calledOnceWithExactly(message)).toBe(true);
expect(logInfo.calledOnce).toBe(true);

});

Expand All @@ -328,7 +331,7 @@ describe('Instabug Module', () => {
const message = 'log';
Instabug.logWarn(message);

expect(logWarn.calledOnceWithExactly(message)).toBe(true);
expect(logWarn.calledOnce).toBe(true);

});

Expand All @@ -337,7 +340,7 @@ describe('Instabug Module', () => {
const message = 'log';
Instabug.logError(message);

expect(logError.calledOnceWithExactly(message)).toBe(true);
expect(logError.calledOnce).toBe(true);

});

Expand Down Expand Up @@ -699,4 +702,20 @@ describe('Instabug Module', () => {

});

it('should call native addExperiments method', () => {
const experiments = ['exp1', 'exp2'];
Instabug.addExperiments(experiments);
expect(addExperiments.calledOnceWithExactly(experiments)).toBeTruthy();
});

it('should call native removeExperiments method', () => {
const experiments = ['exp1', 'exp2'];
Instabug.removeExperiments(experiments);
expect(removeExperiments.calledOnceWithExactly(experiments)).toBeTruthy();
});

it('should call native clearAllExperiments method', () => {
Instabug.clearAllExperiments();
expect(clearAllExperiments.calledOnce).toBeTruthy();
});
});
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.facebook.react:react-native:+'
api('com.instabug.library:instabug:10.11.0') {
api('com.instabug.library:instabug:10.13.0') {
exclude group: 'com.android.support:appcompat-v7'
}
testImplementation "org.mockito:mockito-inline:3.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,52 @@ private void sendEvent(ReactApplicationContext reactContext,
.emit(eventName, params);
}

@ReactMethod
public void addExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Object[] objectArray = ArrayUtil.toArray(experiments);
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
Instabug.addExperiments(Arrays.asList(stringArray));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

@ReactMethod
public void removeExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Object[] objectArray = ArrayUtil.toArray(experiments);
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
Instabug.removeExperiments(Arrays.asList(stringArray));
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

@ReactMethod
public void clearAllExperiments() {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
Instabug.clearAllExperiments();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
Expand Down
Loading

0 comments on commit a30a507

Please sign in to comment.