Skip to content

Release: 13.0.0 #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
extends: '@react-native-community',
plugins: ['prettier', 'jest'],
plugins: ['prettier', 'jest', 'jsdoc'],
overrides: [
{
// Jest Overrides
Expand Down Expand Up @@ -34,6 +34,7 @@ module.exports = {
},
],
rules: {
'jsdoc/no-undefined-types': 'warn',
'prettier/prettier': 'error',
'prefer-const': 'error',
},
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# Changelog

## [13.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.9.0...dev) (April 19, 2024)

### Added

- Add `Instabug.willRedirectToStore` API for use in custom app rating prompts ([#1186](https://github.com/Instabug/Instabug-React-Native/pull/1186)).
- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).

### Changed

- Bump Instabug iOS SDK to v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0).
- Bump Instabug Android SDK to v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0).

## [12.9.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.8.0...dev)(April 2, 2024)

### Added

- Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137))
- Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)).

### Deprecated

- Deprecate Execution Traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setAttribute` in favor of the new App Flows APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).

### Changed

- Bump Instabug Android SDK to v12.9.0 ([#1168](https://github.com/Instabug/Instabug-React-Native/pull/1168)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.9.0).
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ android {
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
versionCode 1
versionName "12.9.0"
versionName "13.0.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
Expand Down
2 changes: 1 addition & 1 deletion android/native.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.ext.instabug = [
version: '12.9.0'
version: '13.0.0'
]

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.os.SystemClock;
import android.util.Log;

import androidx.annotation.NonNull;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand All @@ -29,6 +30,8 @@ public class RNInstabugAPMModule extends ReactContextBaseJavaModule {
public RNInstabugAPMModule(ReactApplicationContext reactApplicationContext) {
super(reactApplicationContext);
}

@Deprecated
HashMap<String, ExecutionTrace> traces = new HashMap<String, ExecutionTrace>();

@Nonnull
Expand Down Expand Up @@ -121,10 +124,92 @@ public void run() {
});
}

/**
* Starts an AppFlow with the specified name.
* <br/>
* On starting two flows with the same name the older flow will end with force abandon end reason.
* AppFlow name cannot exceed 150 characters otherwise it's truncated,
* leading and trailing whitespaces are also ignored.
*
* @param name AppFlow name. It can not be empty string or null.
* Starts a new AppFlow, if APM is enabled, feature is enabled
* and Instabug SDK is initialised.
*/
@ReactMethod
public void startFlow(@NonNull final String name) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
APM.startFlow(name);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Sets custom attributes for AppFlow with a given name.
* <br/>
* Setting an attribute value to null will remove its corresponding key if it already exists.
* <br/>
* Attribute key name cannot exceed 30 characters.
* Leading and trailing whitespaces are also ignored.
* Does not accept empty strings or null.
* <br/>
* Attribute value name cannot exceed 60 characters,
* leading and trailing whitespaces are also ignored.
* Does not accept empty strings.
* <br/>
* If a trace is ended, attributes will not be added and existing ones will not be updated.
* <br/>
*
* @param name AppFlow name. It can not be empty string or null
* @param key AppFlow attribute key. It can not be empty string or null
* @param value AppFlow attribute value. It can not be empty string. Null to remove attribute
*/
@ReactMethod
public void setFlowAttribute(@NonNull final String name, @NonNull final String key, final String value) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
APM.setFlowAttribute(name, key, value);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Ends AppFlow with a given name.
*
* @param name AppFlow name to be ended. It can not be empty string or null
*/
@ReactMethod
public void endFlow(@NonNull final String name) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
APM.endFlow(name);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Starts an execution trace
*
* @param name string name of the trace.
*
* @deprecated see {@link #startFlow(String)}
*/
@Deprecated
@ReactMethod
public void startExecutionTrace(final String name, final String id, final Promise promise) {
MainThreadHandler.runOnMainThread(new Runnable() {
Expand All @@ -148,10 +233,14 @@ public void run() {

/**
* Adds a new attribute to trace
* @param id String id of the trace.
*
* @param id String id of the trace.
* @param key attribute key
* @param value attribute value. Null to remove attribute
*
* @deprecated see {@link #setFlowAttribute}
*/
@Deprecated
@ReactMethod
public void setExecutionTraceAttribute(final String id, final String key, final String value) {
MainThreadHandler.runOnMainThread(new Runnable() {
Expand All @@ -168,8 +257,12 @@ public void run() {

/**
* Ends a trace
*
* @param id string id of the trace.
*
* @deprecated see {@link #endFlow}
*/
@Deprecated
@ReactMethod
public void endExecutionTrace(final String id) {
MainThreadHandler.runOnMainThread(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,20 @@ public void run() {
});
}

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

/**
* Map between the exported JS constant and the arg key in {@link ArgsRegistry}.
* The constant name and the arg key should match to be able to resolve the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,37 @@ public void givenTruesetEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
verify(promise).resolve(any());
}

@Test
public void testStartFlow() {
String appFlowName = "appFlowName";

apmModule.startFlow(appFlowName);

mockAPM.verify(() -> APM.startFlow(appFlowName));
mockAPM.verifyNoMoreInteractions();
}

@Test
public void testEndFlow() {
String appFlowName = "appFlowName";

apmModule.endFlow(appFlowName);

mockAPM.verify(() -> APM.endFlow(appFlowName));
mockAPM.verifyNoMoreInteractions();
}

@Test
public void testSetFlowAttribute() {
String appFlowName = "appFlowName";
String flowAttributeKey = "attributeKey";
String flowAttributeValue = "attributeValue";
apmModule.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue);

mockAPM.verify(() -> APM.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue));
mockAPM.verifyNoMoreInteractions();
}

// @Test
// public void givenString$setExecutionTraceAttribute_whenQuery_thenShouldCallNativeApiWithIntArgs() {
// // given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,13 @@ public void testIdentifyUserWithId() {
verify(Instabug.class,times(1));
Instabug.clearAllExperiments();
}

@Test
public void testWillRedirectToStore() {
// when
rnModule.willRedirectToStore();

// then
mockInstabug.verify(() -> Instabug.willRedirectToStore());
}
}
44 changes: 35 additions & 9 deletions examples/default/ios/InstabugTests/InstabugAPMTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ - (void) testSetAPMEnabled {
- (void) testSetAppLaunchEnabled {
id mock = OCMClassMock([IBGAPM class]);
BOOL isEnabled = YES;

OCMStub([mock setColdAppLaunchEnabled:isEnabled]);
[self.instabugBridge setAppLaunchEnabled:isEnabled];
OCMVerify([mock setColdAppLaunchEnabled:isEnabled]);
}

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

OCMStub([mock endAppLaunch]);
[self.instabugBridge endAppLaunch];
OCMVerify([mock endAppLaunch]);
Expand All @@ -79,7 +79,7 @@ - (void) testEndAppLaunch {
- (void) testSetAutoUITraceEnabled {
id mock = OCMClassMock([IBGAPM class]);
BOOL isEnabled = YES;

OCMStub([mock setAutoUITraceEnabled:isEnabled]);
[self.instabugBridge setAutoUITraceEnabled:isEnabled];
OCMVerify([mock setAutoUITraceEnabled:isEnabled]);
Expand All @@ -91,7 +91,7 @@ - (void) testStartExecutionTrace {
NSString* traceKey = @"1";
RCTPromiseResolveBlock resolve = ^(id result) {};
RCTPromiseRejectBlock reject = ^(NSString *code, NSString *message, NSError *error) {};

OCMStub([mock startExecutionTraceWithName:traceName]);
[self.instabugBridge startExecutionTrace:traceName :traceKey :resolve :reject];
OCMVerify([mock startExecutionTraceWithName:traceName]);
Expand All @@ -107,10 +107,10 @@ - (void) testSetExecutionTraceAttribute {
IBGExecutionTrace * trace = [IBGExecutionTrace alloc];
id mock = OCMClassMock([IBGAPM class]);
id traceMock = OCMPartialMock(trace);

OCMStub([mock startExecutionTraceWithName:traceName]).andReturn(trace);
[self.instabugBridge startExecutionTrace:traceName :traceId :resolve :reject];

OCMStub([traceMock setAttributeWithKey:traceKey value:traceValue]);
[self.instabugBridge setExecutionTraceAttribute:traceId :traceKey :traceValue];
OCMVerify([traceMock setAttributeWithKey:traceKey value:traceValue]);
Expand All @@ -127,24 +127,50 @@ - (void) testEndExecutionTrace {

OCMStub([apmMock startExecutionTraceWithName:traceName]).andReturn(trace);
[self.instabugBridge startExecutionTrace:traceName :traceId :resolve :reject];

OCMStub([traceMock end]);
[self.instabugBridge endExecutionTrace:traceId];
OCMVerify([traceMock end]);
}

- (void) testStartFlow {
id mock = OCMClassMock([IBGAPM class]);
NSString* appFlowName = @"APP_Flow_1";

[self.instabugBridge startFlow:appFlowName];
OCMVerify([mock startFlowWithName:appFlowName]);
}

- (void) testEndFlow {
id mock = OCMClassMock([IBGAPM class]);
NSString* appFlowName = @"APP_Flow_1";

[self.instabugBridge endFlow:appFlowName];
OCMVerify([mock endFlowWithName:appFlowName]);
}

- (void) testSetFlowAttribute {
id mock = OCMClassMock([IBGAPM class]);
NSString* appFlowName = @"APP_Flow_1";
NSString* attributeKey = @"Attribute_Key_1";
NSString* attributeValue = @"Attribute_Value_1";

[self.instabugBridge setFlowAttribute:appFlowName :attributeKey :attributeValue];
OCMVerify([mock setAttributeForFlowWithName:appFlowName key:attributeKey value:attributeValue]);
}

- (void) testStartUITrace {
id mock = OCMClassMock([IBGAPM class]);
NSString* traceName = @"UITrace_1";

OCMStub([mock startUITraceWithName:traceName]);
[self.instabugBridge startUITrace:traceName];
OCMVerify([mock startUITraceWithName:traceName]);
}

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

OCMStub([mock endUITrace]);
[self.instabugBridge endUITrace];
OCMVerify([mock endUITrace]);
Expand Down
13 changes: 13 additions & 0 deletions examples/default/ios/InstabugTests/InstabugSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ - (void)testShow {
}


- (void)testWillRedirectToStore {

id mock = OCMClassMock([Instabug class]);

[self.instabugBridge willRedirectToStore];

OCMVerify([mock willRedirectToAppStore]);

[mock stopMocking];
}



/*
+------------------------------------------------------------------------+
| Log Module |
Expand Down
Loading