Skip to content

Commit

Permalink
Merge pull request #652 from Instabug/release/10.11.0
Browse files Browse the repository at this point in the history
[MOB-6511] Release/10.11.0
  • Loading branch information
ymabdallah authored Dec 23, 2021
2 parents 36f7923 + 625c662 commit dd6075a
Show file tree
Hide file tree
Showing 119 changed files with 16,983 additions and 6,126 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ workflows:
context: cross-platform
- test_module
- test_sample
# - test_android
- test_android
- test_ios
- e2e_ios
# - e2e_android
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 10.11.0 (2021-12-23)

* Adds GraphQL support for APM network traces with proper grouping
* Adds APM.endAppLaunch API
* Bumps Instabug native SDKs to v10.11
* Fixes an issue with iOS sourcemap upload that causes the build to fail

## 10.9.1 (2021-10-13)

* Bumps Instabug Android SDK to v10.9.1
Expand Down
2 changes: 1 addition & 1 deletion Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ if github.pr_body.length < 3 && git.lines_of_code > 10
end

if !git.modified_files.include?("CHANGELOG.md") && !declared_trivial
fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-Flutter/blob/master/CHANGELOG.md).", sticky: false)
warn("You have not included a CHANGELOG entry! \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-Flutter/blob/master/CHANGELOG.md).", sticky: false)
end
8 changes: 8 additions & 0 deletions InstabugSample/ios/InstabugSampleTests/InstabugAPMTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ - (void) testSetAppLaunchEnabled {
OCMVerify([mock setAppLaunchEnabled:isEnabled]);
}

- (void) testEndAppLaunch {
id mock = OCMClassMock([IBGAPM class]);

OCMStub([mock endAppLaunch]);
[self.instabugBridge endAppLaunch];
OCMVerify([mock endAppLaunch]);
}

- (void) testSetAutoUITraceEnabled {
id mock = OCMClassMock([IBGAPM class]);
BOOL isEnabled = YES;
Expand Down
1 change: 1 addition & 0 deletions InstabugSample/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module.exports = {
},
}),
},
maxWorkers: 2,
};
34 changes: 28 additions & 6 deletions __tests__/apm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import "react-native";
import { NativeModules } from "react-native";
import { NativeModules, Platform } from "react-native";
import "../jest/mockAPM";
import APM from "../modules/APM";
import sinon from "sinon";
Expand All @@ -21,6 +21,9 @@ describe("APM Module", () => {
const endExecutionTrace = sinon.spy(NativeModules.IBGAPM, "endExecutionTrace");
const startUITrace = sinon.spy(NativeModules.IBGAPM, "startUITrace");
const endUITrace = sinon.spy(NativeModules.IBGAPM, "endUITrace");
const endAppLaunch = sinon.spy(NativeModules.IBGAPM, "endAppLaunch");
const setNetworkLoggingEnabled = sinon.spy(NativeModules.Instabug, "setNetworkLoggingEnabled");
const _ibgSleep = sinon.spy(NativeModules.IBGAPM, "ibgSleep");

beforeEach(() => {
IBGEventEmitter.removeAllListeners();
Expand All @@ -38,6 +41,19 @@ describe("APM Module", () => {
expect(setAppLaunchEnabled.calledOnceWithExactly(true)).toBe(true);
});

it("should call the native method setNetworkEnabledIOS", () => {
Platform.OS = 'ios';
APM.setNetworkEnabledIOS(true);

expect(setNetworkLoggingEnabled.calledOnceWithExactly(true)).toBe(true);
});

it("should call the native method endAppLaunch", () => {
APM.endAppLaunch();

expect(endAppLaunch.calledOnceWithExactly()).toBe(true);
});

it("should call the native method setAutoUITraceEnabled", () => {
APM.setAutoUITraceEnabled(true);

Expand All @@ -49,27 +65,27 @@ describe("APM Module", () => {

expect(setLogLevel.calledOnceWithExactly(APM.logLevel.verbose)).toBe(true);
});

it("should call the native method startExecutionTrace", () => {
APM.startExecutionTrace("trace");

expect(startExecutionTrace.calledOnceWith("trace")).toBe(true);
});

it("should call the native method setExecutionTraceAttribute", () => {
const trace = APM.startExecutionTrace("trace").then(() => {
trace.setAttribute("key", "value");
expect(setExecutionTraceAttribute.calledOnceWithExactly(expect.any(String), "key", "value")).toBe(true);
});
});

it("should call the native method endExecutionTrace", () => {
const trace = APM.startExecutionTrace("trace").then(() => {
trace.end();
expect(endExecutionTrace.calledOnceWithExactly(expect.any(String))).toBe(true);
});
});

it("should call the native method startUITrace", () => {
APM.startUITrace("uiTrace");

Expand All @@ -81,4 +97,10 @@ describe("APM Module", () => {

expect(endUITrace.calledOnceWithExactly()).toBe(true);
});

it("should call the native method _ibgSleep", () => {
APM._ibgSleep();

expect(_ibgSleep.calledOnceWithExactly()).toBe(true);
});
});
31 changes: 29 additions & 2 deletions __tests__/networkLogger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jest.mock('NativeModules', () => {
networkLog: jest.fn(),
addListener: jest.fn()
},
IBGAPM: {
networkLog: jest.fn(),
},
};
});

Expand All @@ -33,6 +36,8 @@ describe('NetworkLogger Module', () => {
const enableInterception = sinon.spy(Interceptor, 'enableInterception');
const disableInterception = sinon.spy(Interceptor, 'disableInterception');
const networkLog = sinon.spy(NativeModules.Instabug, 'networkLog');
const apmNetworkLog = sinon.spy(NativeModules.IBGAPM, 'networkLog');
const apolloLinkRequestHandler = sinon.spy(NetworkLogger, 'apolloLinkRequestHandler')

const network = {
url: 'https://api.instabug.com',
Expand All @@ -53,6 +58,8 @@ describe('NetworkLogger Module', () => {
networkLog.resetHistory();
IBGEventEmitter.removeAllListeners();
NetworkLogger.setNetworkDataObfuscationHandler(null);
apmNetworkLog.resetHistory();
apolloLinkRequestHandler.resetHistory();
});

it('should set onProgressCallback with callback', () => {
Expand Down Expand Up @@ -98,7 +105,7 @@ describe('NetworkLogger Module', () => {
NetworkLogger.setEnabled(true);

expect(networkLog.calledOnceWithExactly(JSON.stringify(network))).toBe(true);

expect(apmNetworkLog.calledOnceWithExactly(JSON.stringify(network))).toBe(true);
});

it('should send log network when setNetworkDataObfuscationHandler is set and Platform is ios', async () => {
Expand Down Expand Up @@ -137,6 +144,7 @@ describe('NetworkLogger Module', () => {
const newData = clone(network);
newData.requestHeaders['token'] = randomString;
expect(networkLog.calledOnceWithExactly(JSON.stringify(newData))).toBe(true);
expect(apmNetworkLog.calledOnceWithExactly(JSON.stringify(newData))).toBe(true);
});

});
Expand All @@ -148,8 +156,27 @@ describe('NetworkLogger Module', () => {
NetworkLogger.setEnabled(true);

expect(networkLog.notCalled).toBe(true);

expect(apmNetworkLog.notCalled).toBe(true);
});

it('should test that operationSetContext at apollo handler called', async () => {
const operation = {
setContext : (callback) => callback({ headers : {} }),
operationName : "operationName"
};
const forward = jest.fn();
const operationSetContextMock = sinon.spy(operation, 'setContext')

NetworkLogger.apolloLinkRequestHandler(operation, forward);
expect(operationSetContextMock.calledOnce).toBe(true);
});

it('should test that apollo handler called with catch error', async () => {
const operation = {};
const forward = jest.fn();

NetworkLogger.apolloLinkRequestHandler(operation, forward);
expect(apolloLinkRequestHandler.calledOnce).toBe(true);
});

});
55 changes: 52 additions & 3 deletions __tests__/xhrNetworkInterceptor.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'react-native';
import sinon from 'sinon';
import FakeRequest from '../jest/fakeNetworkRequest';
import InstabugConstants from '../utils/InstabugConstants';

global.XMLHttpRequest = sinon.useFakeXMLHttpRequest();

Expand Down Expand Up @@ -44,7 +45,7 @@ describe('Network Interceptor', () => {

it('should set network object on calling setRequestHeader', (done) => {

let requestHeaders = { 'Content-type': 'application/json', 'token': '9u4hiudhi3bf' };
let requestHeaders = { 'content-type': 'application/json', 'token': '9u4hiudhi3bf' };

Interceptor.enableInterception();
Interceptor.setOnDoneCallback((network) => {
Expand Down Expand Up @@ -87,7 +88,7 @@ describe('Network Interceptor', () => {

it('should set responseHeaders in network object on receiving response', (done) => {

const headers = { 'Content-type': 'application/json', 'Accept': 'text/html' }
const headers = { 'Content-type': 'application/json', 'Accept': 'text/html','Content-Length':144 }
Interceptor.enableInterception();
Interceptor.setOnDoneCallback((network) => {
expect(network.responseHeaders['Content-type'].trim()).toEqual(headers['Content-type']);
Expand Down Expand Up @@ -168,6 +169,54 @@ describe('Network Interceptor', () => {
FakeRequest.mockResponse(requests[0]);
expect(callback).not.toHaveBeenCalled();
});
it('should set gqlQueryName in network object on receiving response', (done) => {
const headers = {};
headers[InstabugConstants.GRAPHQL_HEADER] =
InstabugConstants.GRAPHQL_HEADER;
const responseBody = { data: [{ item: 'first' }, { item: 'second' }] };
Interceptor.enableInterception();
Interceptor.setOnDoneCallback((network) => {
expect(network.gqlQueryName).toEqual(
headers[InstabugConstants.GRAPHQL_HEADER]
);
done();
});
FakeRequest.open(method, url);
FakeRequest.setRequestHeaders(headers);
FakeRequest.send();
FakeRequest.mockResponse(requests[0], null, JSON.stringify(responseBody));
});

it('should set gqlQueryName in network object on receiving response with empty string', (done) => {
const headers = {};
headers[InstabugConstants.GRAPHQL_HEADER] = 'null';
Interceptor.enableInterception();
Interceptor.setOnDoneCallback((network) => {
expect(network.gqlQueryName).toEqual('');
done();
});
FakeRequest.open(method, url);
FakeRequest.setRequestHeaders(headers);
FakeRequest.send();
FakeRequest.mockResponse(requests[0]);
});

it('should set serverErrorMessage in network object on receiving response', (done) => {
const headers = {};
headers[InstabugConstants.GRAPHQL_HEADER] =
InstabugConstants.GRAPHQL_HEADER;
const responseBody = { errors: [{ item: 'first' }, { item: 'second' }] };
Interceptor.enableInterception();
Interceptor.setOnDoneCallback((network) => {
expect(network.serverErrorMessage).toEqual('GraphQLError');
done();
});
FakeRequest.open(method, url);
FakeRequest.setRequestHeaders(headers);
FakeRequest.setResponseType('text');
FakeRequest.send();
FakeRequest.mockResponse(requests[0], null, JSON.stringify(responseBody));
});


});
});
12 changes: 5 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ android {
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.facebook.react:react-native:+'
api('com.instabug.library:instabug:10.9.1') {
api('com.instabug.library:instabug:10.11.0') {
exclude group: 'com.android.support:appcompat-v7'
}
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation 'junit:junit:4.12'
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.6.2'
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
testImplementation "org.mockito:mockito-inline:3.4.0"
testImplementation "org.mockito:mockito-android:3.4.0"
testImplementation 'junit:junit:4.13.2'

}


Expand Down
Loading

0 comments on commit dd6075a

Please sign in to comment.