Skip to content

Commit 017433c

Browse files
Merge pull request #548 from Instabug/release/v10.0.0
Release/v10.0.0
2 parents 8c60a20 + e5d4f18 commit 017433c

File tree

101 files changed

+1664
-2040
lines changed

Some content is hidden

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

101 files changed

+1664
-2040
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v10.0.0 (2021-02-10)
2+
3+
* Introduces Instabug’s new App Performance Monitoring (APM)
4+
* Adds support for Push Notifications
5+
* Bumps the minimum supported iOS version to iOS 10
6+
* Various bug fixes and improvements
7+
18
## v9.1.10 (2020-12-02)
29

310
* Fixes a crash caused by the network logger when the object passed is too large

InstabugSample/ios/InstabugSample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
BAD36E3122F19973007F5E74 /* InstabugRepliesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BAD36E3022F19973007F5E74 /* InstabugRepliesTests.m */; };
2222
BAD36E3322F19B1B007F5E74 /* InstabugSurveysTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BAD36E3222F19B1B007F5E74 /* InstabugSurveysTests.m */; };
2323
C006102922E9EBCA00EDC852 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C006102822E9EBCA00EDC852 /* libOCMock.a */; };
24+
C0AB369625854A6100F1E21E /* InstabugAPMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C0AB369525854A6100F1E21E /* InstabugAPMTests.m */; };
2425
/* End PBXBuildFile section */
2526

2627
/* Begin PBXContainerItemProxy section */
@@ -63,9 +64,9 @@
6364
BAD36E3022F19973007F5E74 /* InstabugRepliesTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InstabugRepliesTests.m; sourceTree = "<group>"; };
6465
BAD36E3222F19B1B007F5E74 /* InstabugSurveysTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InstabugSurveysTests.m; sourceTree = "<group>"; };
6566
C006102822E9EBCA00EDC852 /* libOCMock.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libOCMock.a; path = usr/lib/libOCMock.a; sourceTree = "<group>"; };
67+
C0AB369525854A6100F1E21E /* InstabugAPMTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InstabugAPMTests.m; sourceTree = "<group>"; };
6668
C74E4010ABE7AFC7DB5E79DC /* Pods-InstabugSampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugSampleTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InstabugSampleTests/Pods-InstabugSampleTests.debug.xcconfig"; sourceTree = "<group>"; };
6769
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
68-
FA49CB8462F384E9EDD7DDFD /* Instabug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Instabug.framework; path = "../node_modules/instabug-reactnative/ios/Instabug.framework"; sourceTree = "<group>"; };
6970
/* End PBXFileReference section */
7071

7172
/* Begin PBXFrameworksBuildPhase section */
@@ -101,6 +102,7 @@
101102
BAD36E2E22F19788007F5E74 /* InstabugFeatureRequestsTests.m */,
102103
BAD36E3022F19973007F5E74 /* InstabugRepliesTests.m */,
103104
BAD36E3222F19B1B007F5E74 /* InstabugSurveysTests.m */,
105+
C0AB369525854A6100F1E21E /* InstabugAPMTests.m */,
104106
);
105107
path = InstabugSampleTests;
106108
sourceTree = "<group>";
@@ -410,6 +412,7 @@
410412
BAD36E1E22F0906A007F5E74 /* IBGConstants.m in Sources */,
411413
BAD36E3322F19B1B007F5E74 /* InstabugSurveysTests.m in Sources */,
412414
BAD36E2F22F19788007F5E74 /* InstabugFeatureRequestsTests.m in Sources */,
415+
C0AB369625854A6100F1E21E /* InstabugAPMTests.m in Sources */,
413416
BAD36E1C22F08B27007F5E74 /* InstabugBugReportingTests.m in Sources */,
414417
BAD36E2D22F1955C007F5E74 /* InstabugChatsTests.m in Sources */,
415418
00E356F31AD99517003FC87E /* InstabugSampleTests.m in Sources */,
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
//
2+
// InstabugAPMTests.m
3+
// InstabugSampleTests
4+
//
5+
// Created by Ali Abdelfattah on 12/12/20.
6+
// Copyright © 2020 Facebook. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "OCMock/OCMock.h"
11+
#import "InstabugAPMBridge.h"
12+
#import <Instabug/IBGTypes.h>
13+
#import <Instabug/IBGAPM.h>
14+
#import "Instabug/Instabug.h"
15+
#import "IBGConstants.h"
16+
17+
@interface InstabugAPMTests : XCTestCase
18+
@property (nonatomic, retain) InstabugAPMBridge *instabugBridge;
19+
@end
20+
21+
@protocol APMCPTestProtocol <NSObject>
22+
/**
23+
* This protocol helps in correctly mapping APM mocked methods
24+
* when their method name matches another method in a different
25+
* module that differs in method signature.
26+
*/
27+
- (void)setEnabled:(BOOL)isEnabled;
28+
29+
@end
30+
31+
@protocol ExecutionTraceCPTestProtocol <NSObject>
32+
/**
33+
* This protocol helps in correctly mapping IBGExecutionTrace mocked methods
34+
* when their method name matches another method in a different
35+
* module that differs in method signature.
36+
*/
37+
- (void)end;
38+
@end
39+
40+
@implementation InstabugAPMTests
41+
42+
- (void)setUp {
43+
// Put setup code here. This method is called before the invocation of each test method in the class.
44+
self.instabugBridge = [[InstabugAPMBridge alloc] init];
45+
}
46+
47+
/*
48+
+------------------------------------------------------------------------+
49+
| APM Module |
50+
+------------------------------------------------------------------------+
51+
*/
52+
53+
- (void) testSetAPMEnabled {
54+
id mock = OCMClassMock([IBGAPM class]);
55+
BOOL isEnabled = YES;
56+
57+
OCMStub([mock setEnabled:isEnabled]);
58+
[self.instabugBridge setEnabled:isEnabled];
59+
OCMVerify([mock setEnabled:isEnabled]);
60+
}
61+
62+
- (void) testSetLogLevel {
63+
id mock = OCMClassMock([IBGAPM class]);
64+
BOOL logLevel = IBGLogLevelVerbose;
65+
66+
OCMStub([mock setLogLevel:logLevel]);
67+
[self.instabugBridge setLogLevel:logLevel];
68+
OCMVerify([mock setLogLevel:logLevel]);
69+
}
70+
71+
- (void) testSetAppLaunchEnabled {
72+
id mock = OCMClassMock([IBGAPM class]);
73+
BOOL isEnabled = YES;
74+
75+
OCMStub([mock setAppLaunchEnabled:isEnabled]);
76+
[self.instabugBridge setAppLaunchEnabled:isEnabled];
77+
OCMVerify([mock setAppLaunchEnabled:isEnabled]);
78+
}
79+
80+
- (void) testSetAutoUITraceEnabled {
81+
id mock = OCMClassMock([IBGAPM class]);
82+
BOOL isEnabled = YES;
83+
84+
OCMStub([mock setAutoUITraceEnabled:isEnabled]);
85+
[self.instabugBridge setAutoUITraceEnabled:isEnabled];
86+
OCMVerify([mock setAutoUITraceEnabled:isEnabled]);
87+
}
88+
89+
- (void) testStartExecutionTrace {
90+
id mock = OCMClassMock([IBGAPM class]);
91+
NSString* traceName = @"Trace_1";
92+
NSString* traceKey = @"1";
93+
RCTResponseSenderBlock callback = ^(NSArray *response) {};
94+
95+
OCMStub([mock startExecutionTraceWithName:traceName]);
96+
[self.instabugBridge startExecutionTrace:traceName :traceKey :callback];
97+
OCMVerify([mock startExecutionTraceWithName:traceName]);
98+
}
99+
100+
- (void) testSetExecutionTraceAttribute {
101+
NSString* traceName = @"Trace_1";
102+
NSString* traceId = @"Id_1";
103+
NSString* traceKey = @"Key_1";
104+
NSString* traceValue = @"1";
105+
RCTResponseSenderBlock callback = ^(NSArray *response) {};
106+
IBGExecutionTrace * trace = [IBGExecutionTrace alloc];
107+
id mock = OCMClassMock([IBGAPM class]);
108+
id traceMock = OCMPartialMock(trace);
109+
110+
OCMStub([mock startExecutionTraceWithName:traceName]).andReturn(trace);
111+
[self.instabugBridge startExecutionTrace:traceName :traceId :callback];
112+
113+
OCMStub([traceMock setAttributeWithKey:traceKey value:traceValue]);
114+
[self.instabugBridge setExecutionTraceAttribute:traceId :traceKey :traceValue];
115+
OCMVerify([traceMock setAttributeWithKey:traceKey value:traceValue]);
116+
}
117+
118+
- (void) testEndExecutionTrace {
119+
NSString* traceName = @"Trace_1";
120+
NSString* traceId = @"Id_1";
121+
RCTResponseSenderBlock callback = ^(NSArray *response) {};
122+
IBGExecutionTrace * trace = [IBGExecutionTrace alloc];
123+
id apmMock = OCMClassMock([IBGAPM class]);
124+
id<ExecutionTraceCPTestProtocol> traceMock = OCMPartialMock(trace);
125+
126+
OCMStub([apmMock startExecutionTraceWithName:traceName]).andReturn(trace);
127+
[self.instabugBridge startExecutionTrace:traceName :traceId :callback];
128+
129+
OCMStub([traceMock end]);
130+
[self.instabugBridge endExecutionTrace:traceId];
131+
OCMVerify([traceMock end]);
132+
}
133+
134+
- (void) testStartUITrace {
135+
id mock = OCMClassMock([IBGAPM class]);
136+
NSString* traceName = @"UITrace_1";
137+
138+
OCMStub([mock startUITraceWithName:traceName]);
139+
[self.instabugBridge startUITrace:traceName];
140+
OCMVerify([mock startUITraceWithName:traceName]);
141+
}
142+
143+
- (void) testEndUITrace {
144+
id mock = OCMClassMock([IBGAPM class]);
145+
146+
OCMStub([mock endUITrace]);
147+
[self.instabugBridge endUITrace];
148+
OCMVerify([mock endUITrace]);
149+
}
150+
151+
@end

__tests__/apm.spec.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/**
2+
* @format
3+
* @lint-ignore-every XPLATJSCOPYRIGHT1
4+
*/
5+
6+
import "react-native";
7+
import { NativeModules } from "react-native";
8+
import "../jest/mockAPM";
9+
import APM from "../modules/APM";
10+
import sinon from "sinon";
11+
12+
import IBGEventEmitter from "../utils/IBGEventEmitter";
13+
14+
describe("APM Module", () => {
15+
const setEnabled = sinon.spy(NativeModules.IBGAPM, "setEnabled");
16+
const setAppLaunchEnabled = sinon.spy(NativeModules.IBGAPM, "setAppLaunchEnabled");
17+
const setLogLevel = sinon.spy(NativeModules.IBGAPM, "setLogLevel");
18+
const setAutoUITraceEnabled = sinon.spy(NativeModules.IBGAPM, "setAutoUITraceEnabled");
19+
const startExecutionTrace = sinon.spy(NativeModules.IBGAPM, "startExecutionTrace");
20+
const setExecutionTraceAttribute = sinon.spy(NativeModules.IBGAPM, "setExecutionTraceAttribute");
21+
const endExecutionTrace = sinon.spy(NativeModules.IBGAPM, "endExecutionTrace");
22+
const startUITrace = sinon.spy(NativeModules.IBGAPM, "startUITrace");
23+
const endUITrace = sinon.spy(NativeModules.IBGAPM, "endUITrace");
24+
25+
beforeEach(() => {
26+
IBGEventEmitter.removeAllListeners();
27+
});
28+
29+
it("should call the native method setEnabled", () => {
30+
APM.setEnabled(true);
31+
32+
expect(setEnabled.calledOnceWithExactly(true)).toBe(true);
33+
});
34+
35+
it("should call the native method setAppLaunchEnabled", () => {
36+
APM.setAppLaunchEnabled(true);
37+
38+
expect(setAppLaunchEnabled.calledOnceWithExactly(true)).toBe(true);
39+
});
40+
41+
it("should call the native method setAutoUITraceEnabled", () => {
42+
APM.setAutoUITraceEnabled(true);
43+
44+
expect(setAutoUITraceEnabled.calledOnceWithExactly(true)).toBe(true);
45+
});
46+
47+
it("should call the native method setLogLevel", () => {
48+
APM.setLogLevel(APM.logLevel.verbose);
49+
50+
expect(setLogLevel.calledOnceWithExactly(APM.logLevel.verbose)).toBe(true);
51+
});
52+
53+
it("should call the native method startExecutionTrace", () => {
54+
APM.startExecutionTrace("trace");
55+
56+
expect(startExecutionTrace.calledOnceWith("trace")).toBe(true);
57+
});
58+
59+
it("should call the native method setExecutionTraceAttribute", () => {
60+
const trace = APM.startExecutionTrace("trace").then(() => {
61+
trace.setAttribute("key", "value");
62+
expect(setExecutionTraceAttribute.calledOnceWithExactly(expect.any(String), "key", "value")).toBe(true);
63+
});
64+
});
65+
66+
it("should call the native method endExecutionTrace", () => {
67+
const trace = APM.startExecutionTrace("trace").then(() => {
68+
trace.end();
69+
expect(endExecutionTrace.calledOnceWithExactly(expect.any(String))).toBe(true);
70+
});
71+
});
72+
73+
it("should call the native method startUITrace", () => {
74+
APM.startUITrace("uiTrace");
75+
76+
expect(startUITrace.calledOnceWithExactly("uiTrace")).toBe(true);
77+
});
78+
79+
it("should call the native method endUITrace", () => {
80+
APM.endUITrace();
81+
82+
expect(endUITrace.calledOnceWithExactly()).toBe(true);
83+
});
84+
});

__tests__/index.spec.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,6 @@ describe('Instabug Module', () => {
196196

197197
});
198198

199-
it('should not call the native method setPushNotificationsEnabled when platform is android', () => {
200-
201-
Platform.OS = 'android';
202-
Instabug.setPushNotificationsEnabled(true);
203-
204-
expect(setPushNotificationsEnabled.notCalled).toBe(true);
205-
206-
});
207-
208199
it('should call the native method setLocale', () => {
209200

210201
const locale = Instabug.locale.english;

__tests__/replies.spec.js

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ describe('Replies Module', () => {
2121
const setChatNotificationEnabled = sinon.spy(NativeModules.IBGReplies, 'setInAppNotificationEnabled');
2222
const setEnableInAppNotificationSound = sinon.spy(NativeModules.IBGReplies, 'setInAppNotificationSound');
2323
const setPushNotificationsEnabled = sinon.spy(NativeModules.IBGReplies, 'setPushNotificationsEnabled');
24+
const setPushNotificationRegistrationToken = sinon.spy(NativeModules.IBGReplies, 'setPushNotificationRegistrationToken');
25+
const setNotificationIcon = sinon.spy(NativeModules.IBGReplies, 'setNotificationIcon');
26+
const setPushNotificationChannelId = sinon.spy(NativeModules.IBGReplies, 'setPushNotificationChannelId');
27+
const setSystemReplyNotificationSoundEnabled = sinon.spy(NativeModules.IBGReplies, 'setSystemReplyNotificationSoundEnabled');
2428

2529
beforeEach(() => {
2630
setOnNewReplyReceivedCallback.resetHistory();
2731
setEnableInAppNotificationSound.resetHistory();
2832
IBGEventEmitter.removeAllListeners();
2933
setPushNotificationsEnabled.resetHistory();
34+
setPushNotificationRegistrationToken.resetHistory();
35+
setNotificationIcon.resetHistory();
36+
setPushNotificationChannelId.resetHistory();
37+
setSystemReplyNotificationSoundEnabled.resetHistory();
3038
});
3139

3240
it('should call the native method setRepliesEnabled', () => {
@@ -115,24 +123,73 @@ describe('Replies Module', () => {
115123

116124
});
117125

126+
118127
it('should call the native method setPushNotificationsEnabled', () => {
119128

120-
Platform.OS = 'ios';
121129
Replies.setPushNotificationsEnabled(true);
122130

123131
expect(setPushNotificationsEnabled.calledOnceWithExactly(true)).toBe(true);
124132

125133
});
126134

127135

128-
it('should not call the native method setPushNotificationsEnabled when platform is android', () => {
136+
it('should call the native method setPushNotificationRegistrationToken on Android', () => {
137+
Platform.OS = 'android';
138+
Replies.setPushNotificationRegistrationTokenAndroid('123');
139+
140+
expect(setPushNotificationRegistrationToken.calledOnceWithExactly('123')).toBe(true);
141+
});
142+
143+
it('should not call the native method setPushNotificationRegistrationToken on iOS', () => {
144+
Platform.OS = 'ios';
145+
Replies.setPushNotificationRegistrationTokenAndroid(true);
146+
147+
expect(setPushNotificationRegistrationToken.notCalled).toBe(true);
148+
});
149+
129150

151+
it('should call the native method setNotificationIcon on Android', () => {
130152
Platform.OS = 'android';
131-
Replies.setPushNotificationsEnabled(true);
153+
Replies.setNotificationIconAndroid(123);
154+
155+
expect(setNotificationIcon.calledOnceWithExactly(123)).toBe(true);
156+
});
132157

133-
expect(setPushNotificationsEnabled.notCalled).toBe(true);
158+
it('should not call the native method setNotificationIcon on iOS', () => {
159+
Platform.OS = 'ios';
160+
Replies.setNotificationIconAndroid(123);
134161

162+
expect(setNotificationIcon.notCalled).toBe(true);
135163
});
136164

137165

166+
it('should call the native method setPushNotificationChannelId on Android', () => {
167+
Platform.OS = 'android';
168+
Replies.setPushNotificationChannelIdAndroid('123');
169+
170+
expect(setPushNotificationChannelId.calledOnceWithExactly('123')).toBe(true);
171+
});
172+
173+
it('should not call the native method setPushNotificationChannelId on iOS', () => {
174+
Platform.OS = 'ios';
175+
Replies.setPushNotificationChannelIdAndroid('123');
176+
177+
expect(setPushNotificationChannelId.notCalled).toBe(true);
178+
});
179+
180+
181+
it('should call the native method setSystemReplyNotificationSoundEnabled on Android', () => {
182+
Platform.OS = 'android';
183+
Replies.setSystemReplyNotificationSoundEnabledAndroid(true);
184+
185+
expect(setSystemReplyNotificationSoundEnabled.calledOnceWithExactly(true)).toBe(true);
186+
});
187+
188+
it('should not call the native method setSystemReplyNotificationSoundEnabled on iOS', () => {
189+
Platform.OS = 'ios';
190+
Replies.setSystemReplyNotificationSoundEnabledAndroid(true);
191+
192+
expect(setSystemReplyNotificationSoundEnabled.notCalled).toBe(true);
193+
});
194+
138195
});

0 commit comments

Comments
 (0)