Skip to content

Commit dd6075a

Browse files
authored
Merge pull request #652 from Instabug/release/10.11.0
[MOB-6511] Release/10.11.0
2 parents 36f7923 + 625c662 commit dd6075a

File tree

119 files changed

+16983
-6126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+16983
-6126
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ workflows:
223223
context: cross-platform
224224
- test_module
225225
- test_sample
226-
# - test_android
226+
- test_android
227227
- test_ios
228228
- e2e_ios
229229
# - e2e_android
File renamed without changes.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 10.11.0 (2021-12-23)
2+
3+
* Adds GraphQL support for APM network traces with proper grouping
4+
* Adds APM.endAppLaunch API
5+
* Bumps Instabug native SDKs to v10.11
6+
* Fixes an issue with iOS sourcemap upload that causes the build to fail
7+
18
## 10.9.1 (2021-10-13)
29

310
* Bumps Instabug Android SDK to v10.9.1

Dangerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ if github.pr_body.length < 3 && git.lines_of_code > 10
88
end
99

1010
if !git.modified_files.include?("CHANGELOG.md") && !declared_trivial
11-
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)
11+
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)
1212
end

InstabugSample/ios/InstabugSampleTests/InstabugAPMTests.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ - (void) testSetAppLaunchEnabled {
7777
OCMVerify([mock setAppLaunchEnabled:isEnabled]);
7878
}
7979

80+
- (void) testEndAppLaunch {
81+
id mock = OCMClassMock([IBGAPM class]);
82+
83+
OCMStub([mock endAppLaunch]);
84+
[self.instabugBridge endAppLaunch];
85+
OCMVerify([mock endAppLaunch]);
86+
}
87+
8088
- (void) testSetAutoUITraceEnabled {
8189
id mock = OCMClassMock([IBGAPM class]);
8290
BOOL isEnabled = YES;

InstabugSample/metro.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ module.exports = {
1414
},
1515
}),
1616
},
17+
maxWorkers: 2,
1718
};

__tests__/apm.spec.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import "react-native";
7-
import { NativeModules } from "react-native";
7+
import { NativeModules, Platform } from "react-native";
88
import "../jest/mockAPM";
99
import APM from "../modules/APM";
1010
import sinon from "sinon";
@@ -21,6 +21,9 @@ describe("APM Module", () => {
2121
const endExecutionTrace = sinon.spy(NativeModules.IBGAPM, "endExecutionTrace");
2222
const startUITrace = sinon.spy(NativeModules.IBGAPM, "startUITrace");
2323
const endUITrace = sinon.spy(NativeModules.IBGAPM, "endUITrace");
24+
const endAppLaunch = sinon.spy(NativeModules.IBGAPM, "endAppLaunch");
25+
const setNetworkLoggingEnabled = sinon.spy(NativeModules.Instabug, "setNetworkLoggingEnabled");
26+
const _ibgSleep = sinon.spy(NativeModules.IBGAPM, "ibgSleep");
2427

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

44+
it("should call the native method setNetworkEnabledIOS", () => {
45+
Platform.OS = 'ios';
46+
APM.setNetworkEnabledIOS(true);
47+
48+
expect(setNetworkLoggingEnabled.calledOnceWithExactly(true)).toBe(true);
49+
});
50+
51+
it("should call the native method endAppLaunch", () => {
52+
APM.endAppLaunch();
53+
54+
expect(endAppLaunch.calledOnceWithExactly()).toBe(true);
55+
});
56+
4157
it("should call the native method setAutoUITraceEnabled", () => {
4258
APM.setAutoUITraceEnabled(true);
4359

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

5066
expect(setLogLevel.calledOnceWithExactly(APM.logLevel.verbose)).toBe(true);
5167
});
52-
68+
5369
it("should call the native method startExecutionTrace", () => {
5470
APM.startExecutionTrace("trace");
55-
71+
5672
expect(startExecutionTrace.calledOnceWith("trace")).toBe(true);
5773
});
58-
74+
5975
it("should call the native method setExecutionTraceAttribute", () => {
6076
const trace = APM.startExecutionTrace("trace").then(() => {
6177
trace.setAttribute("key", "value");
6278
expect(setExecutionTraceAttribute.calledOnceWithExactly(expect.any(String), "key", "value")).toBe(true);
6379
});
6480
});
65-
81+
6682
it("should call the native method endExecutionTrace", () => {
6783
const trace = APM.startExecutionTrace("trace").then(() => {
6884
trace.end();
6985
expect(endExecutionTrace.calledOnceWithExactly(expect.any(String))).toBe(true);
7086
});
7187
});
72-
88+
7389
it("should call the native method startUITrace", () => {
7490
APM.startUITrace("uiTrace");
7591

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

8298
expect(endUITrace.calledOnceWithExactly()).toBe(true);
8399
});
100+
101+
it("should call the native method _ibgSleep", () => {
102+
APM._ibgSleep();
103+
104+
expect(_ibgSleep.calledOnceWithExactly()).toBe(true);
105+
});
84106
});

__tests__/networkLogger.spec.js

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jest.mock('NativeModules', () => {
1919
networkLog: jest.fn(),
2020
addListener: jest.fn()
2121
},
22+
IBGAPM: {
23+
networkLog: jest.fn(),
24+
},
2225
};
2326
});
2427

@@ -33,6 +36,8 @@ describe('NetworkLogger Module', () => {
3336
const enableInterception = sinon.spy(Interceptor, 'enableInterception');
3437
const disableInterception = sinon.spy(Interceptor, 'disableInterception');
3538
const networkLog = sinon.spy(NativeModules.Instabug, 'networkLog');
39+
const apmNetworkLog = sinon.spy(NativeModules.IBGAPM, 'networkLog');
40+
const apolloLinkRequestHandler = sinon.spy(NetworkLogger, 'apolloLinkRequestHandler')
3641

3742
const network = {
3843
url: 'https://api.instabug.com',
@@ -53,6 +58,8 @@ describe('NetworkLogger Module', () => {
5358
networkLog.resetHistory();
5459
IBGEventEmitter.removeAllListeners();
5560
NetworkLogger.setNetworkDataObfuscationHandler(null);
61+
apmNetworkLog.resetHistory();
62+
apolloLinkRequestHandler.resetHistory();
5663
});
5764

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

100107
expect(networkLog.calledOnceWithExactly(JSON.stringify(network))).toBe(true);
101-
108+
expect(apmNetworkLog.calledOnceWithExactly(JSON.stringify(network))).toBe(true);
102109
});
103110

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

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

150158
expect(networkLog.notCalled).toBe(true);
151-
159+
expect(apmNetworkLog.notCalled).toBe(true);
152160
});
153161

162+
it('should test that operationSetContext at apollo handler called', async () => {
163+
const operation = {
164+
setContext : (callback) => callback({ headers : {} }),
165+
operationName : "operationName"
166+
};
167+
const forward = jest.fn();
168+
const operationSetContextMock = sinon.spy(operation, 'setContext')
169+
170+
NetworkLogger.apolloLinkRequestHandler(operation, forward);
171+
expect(operationSetContextMock.calledOnce).toBe(true);
172+
});
173+
174+
it('should test that apollo handler called with catch error', async () => {
175+
const operation = {};
176+
const forward = jest.fn();
177+
178+
NetworkLogger.apolloLinkRequestHandler(operation, forward);
179+
expect(apolloLinkRequestHandler.calledOnce).toBe(true);
180+
});
154181

155182
});

__tests__/xhrNetworkInterceptor.spec.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'react-native';
22
import sinon from 'sinon';
33
import FakeRequest from '../jest/fakeNetworkRequest';
4+
import InstabugConstants from '../utils/InstabugConstants';
45

56
global.XMLHttpRequest = sinon.useFakeXMLHttpRequest();
67

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

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

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

4950
Interceptor.enableInterception();
5051
Interceptor.setOnDoneCallback((network) => {
@@ -87,7 +88,7 @@ describe('Network Interceptor', () => {
8788

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

90-
const headers = { 'Content-type': 'application/json', 'Accept': 'text/html' }
91+
const headers = { 'Content-type': 'application/json', 'Accept': 'text/html','Content-Length':144 }
9192
Interceptor.enableInterception();
9293
Interceptor.setOnDoneCallback((network) => {
9394
expect(network.responseHeaders['Content-type'].trim()).toEqual(headers['Content-type']);
@@ -168,6 +169,54 @@ describe('Network Interceptor', () => {
168169
FakeRequest.mockResponse(requests[0]);
169170
expect(callback).not.toHaveBeenCalled();
170171
});
172+
it('should set gqlQueryName in network object on receiving response', (done) => {
173+
const headers = {};
174+
headers[InstabugConstants.GRAPHQL_HEADER] =
175+
InstabugConstants.GRAPHQL_HEADER;
176+
const responseBody = { data: [{ item: 'first' }, { item: 'second' }] };
177+
Interceptor.enableInterception();
178+
Interceptor.setOnDoneCallback((network) => {
179+
expect(network.gqlQueryName).toEqual(
180+
headers[InstabugConstants.GRAPHQL_HEADER]
181+
);
182+
done();
183+
});
184+
FakeRequest.open(method, url);
185+
FakeRequest.setRequestHeaders(headers);
186+
FakeRequest.send();
187+
FakeRequest.mockResponse(requests[0], null, JSON.stringify(responseBody));
188+
});
189+
190+
it('should set gqlQueryName in network object on receiving response with empty string', (done) => {
191+
const headers = {};
192+
headers[InstabugConstants.GRAPHQL_HEADER] = 'null';
193+
Interceptor.enableInterception();
194+
Interceptor.setOnDoneCallback((network) => {
195+
expect(network.gqlQueryName).toEqual('');
196+
done();
197+
});
198+
FakeRequest.open(method, url);
199+
FakeRequest.setRequestHeaders(headers);
200+
FakeRequest.send();
201+
FakeRequest.mockResponse(requests[0]);
202+
});
203+
204+
it('should set serverErrorMessage in network object on receiving response', (done) => {
205+
const headers = {};
206+
headers[InstabugConstants.GRAPHQL_HEADER] =
207+
InstabugConstants.GRAPHQL_HEADER;
208+
const responseBody = { errors: [{ item: 'first' }, { item: 'second' }] };
209+
Interceptor.enableInterception();
210+
Interceptor.setOnDoneCallback((network) => {
211+
expect(network.serverErrorMessage).toEqual('GraphQLError');
212+
done();
213+
});
214+
FakeRequest.open(method, url);
215+
FakeRequest.setRequestHeaders(headers);
216+
FakeRequest.setResponseType('text');
217+
FakeRequest.send();
218+
FakeRequest.mockResponse(requests[0], null, JSON.stringify(responseBody));
219+
});
171220

172221

173-
});
222+
});

android/build.gradle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ android {
2929
dependencies {
3030
implementation 'com.android.support:multidex:1.0.3'
3131
implementation 'com.facebook.react:react-native:+'
32-
api('com.instabug.library:instabug:10.9.1') {
32+
api('com.instabug.library:instabug:10.11.0') {
3333
exclude group: 'com.android.support:appcompat-v7'
3434
}
35-
testImplementation 'org.mockito:mockito-core:1.10.19'
36-
testImplementation 'junit:junit:4.12'
37-
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
38-
testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.6.2'
39-
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
40-
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
35+
testImplementation "org.mockito:mockito-inline:3.4.0"
36+
testImplementation "org.mockito:mockito-android:3.4.0"
37+
testImplementation 'junit:junit:4.13.2'
38+
4139
}
4240

4341

0 commit comments

Comments
 (0)