From 5cf6a1cb9200315028b4ba4073a13a516bcabe1f Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Fri, 16 Aug 2024 14:00:47 +0300 Subject: [PATCH 1/8] fix(ios): network log empty response body --- src/utils/XhrNetworkInterceptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts index 701533f15c..9423064689 100644 --- a/src/utils/XhrNetworkInterceptor.ts +++ b/src/utils/XhrNetworkInterceptor.ts @@ -152,7 +152,7 @@ export default { const _response = this._response; cloneNetwork.requestBody = typeof _response === 'string' ? _response : JSON.stringify(_response); - cloneNetwork.responseBody = null; + cloneNetwork.responseBody = ''; } if (this.response) { From 99bf41266c1fcd8b32158f6ccf3773783cb049ab Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Fri, 16 Aug 2024 14:08:09 +0300 Subject: [PATCH 2/8] fix(ios): network log empty response body --- test/utils/XhrNetworkInterceptor.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/utils/XhrNetworkInterceptor.spec.ts b/test/utils/XhrNetworkInterceptor.spec.ts index b014bc9d9c..7ec818278f 100644 --- a/test/utils/XhrNetworkInterceptor.spec.ts +++ b/test/utils/XhrNetworkInterceptor.spec.ts @@ -236,7 +236,7 @@ describe('Network Interceptor', () => { expect.objectContaining({ errorDomain: 'ClientError', errorCode: 0, - responseBody: null, + responseBody: '', }), ); }); From 6e29a7c8a71591fb50d4110d87c95652dcbc8b1e Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 13 Aug 2024 17:37:27 +0300 Subject: [PATCH 3/8] chore: enhance expo router tracking support (#1272) --- CHANGELOG.md | 6 ++++++ examples/default/src/App.tsx | 4 +++- src/modules/Instabug.ts | 2 +- test/modules/Instabug.spec.ts | 23 +++++++++++++++++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9400332650..acb003486f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...dev) + +### Added + +- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). + ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) ### Added diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index ae548f97c5..33a3c34f94 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -35,7 +35,9 @@ export const App: React.FC = () => { }, []); useEffect(() => { - Instabug.setNavigationListener(navigationRef); + const unregisterListener = Instabug.setNavigationListener(navigationRef); + + return unregisterListener; }, [navigationRef]); return ( diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index b0a05032c4..29ff1d27c9 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -544,7 +544,7 @@ export const onStateChange = (state?: NavigationStateV5) => { export const setNavigationListener = ( navigationRef: NavigationContainerRefWithCurrent, ) => { - navigationRef.addListener('state', () => { + return navigationRef.addListener('state', () => { onStateChange(navigationRef.getRootState()); }); }; diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index 518e53ce93..fdc1b91b24 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -238,20 +238,39 @@ describe('Instabug Module', () => { }); it('setNavigationListener should call the onStateChange on a screen change', async () => { + const mockedState = { routes: [{ name: 'ScreenName' }], index: 0 }; + const mockNavigationContainerRef = { current: null, navigate: jest.fn(), reset: jest.fn(), goBack: jest.fn(), dispatch: jest.fn(), - getRootState: jest.fn(), + getRootState: () => mockedState, canGoBack: jest.fn(), - addListener: jest.fn(), + + addListener: jest.fn((event, callback) => { + expect(event).toBe('state'); + callback(mockedState); + return jest.fn(); + }), removeListener: jest.fn(), } as unknown as NavigationContainerRefWithCurrent; + const onStateChangeMock = jest.fn(); + + jest.spyOn(Instabug, 'onStateChange').mockImplementation(onStateChangeMock); + Instabug.setNavigationListener(mockNavigationContainerRef); + expect(mockNavigationContainerRef.addListener).toBeCalledTimes(1); + expect(mockNavigationContainerRef.addListener).toHaveBeenCalledWith( + 'state', + expect.any(Function), + ); + + expect(onStateChangeMock).toBeCalledTimes(1); + expect(onStateChangeMock).toHaveBeenCalledWith(mockNavigationContainerRef.getRootState()); }); it('should call the native method init', () => { From 011125aefa46e9c4456f367a917de3e3de084efa Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:38:04 +0300 Subject: [PATCH 4/8] ci: generalize enterprise releases (#1275) --- .circleci/config.yml | 159 +++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 74 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c218cf7e93..64a6b4013a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,10 +59,67 @@ commands: type: string replace: type: string + working_directory: + type: string + default: ~/project steps: - run: name: Find and Replace in << parameters.files >> command: node ~/project/scripts/replace.js << parameters.search >> << parameters.replace >> << parameters.files >> + working_directory: << parameters.working_directory >> + + prepare_custom_package: + parameters: + npm_package: + type: string + android_package: + type: string + api_endpoint: + type: string + working_directory: + type: string + default: ~/project + steps: + - run: + name: Remove README.md file + command: rm README.md + working_directory: << parameters.working_directory >> + - find_and_replace: + files: package.json android/sourcemaps.gradle ios/sourcemaps.sh + search: instabug-reactnative + replace: << parameters.npm_package >> + working_directory: << parameters.working_directory >> + - find_and_replace: + files: cli/upload/uploadSourcemaps.ts cli/upload/uploadSoFiles.ts + search: api.instabug.com + replace: << parameters.api_endpoint >> + working_directory: << parameters.working_directory >> + - find_and_replace: + files: android/native.gradle + search: 'com.instabug.library:instabug:' + replace: 'com.instabug.library-<< parameters.android_package >>:instabug:' + working_directory: << parameters.working_directory >> + + prepare_dream11: + parameters: + working_directory: + type: string + default: ~/project + steps: + - install_node_modules + - prepare_custom_package: + npm_package: '@instabug/instabug-reactnative-dream11' + android_package: dream11 + api_endpoint: st001012dream11.instabug.com + working_directory: << parameters.working_directory >> + - run: + name: Give execute permission to Dream11 script + command: chmod +x ./scripts/dream-11-delete-unused-features.sh + working_directory: << parameters.working_directory >> + - run: + name: Remove unused features + command: ./scripts/dream-11-delete-unused-features.sh + working_directory: << parameters.working_directory >> notify_github: parameters: @@ -264,33 +321,16 @@ jobs: release_custom_package: parameters: - npm_package: - type: string - android_package: - type: string - api_endpoint: - type: string + prepare_steps: + type: steps + default: [] working_directory: ~/project executor: name: node/default steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - - run: - name: Remove README.md file - command: rm README.md - - find_and_replace: - files: package.json android/sourcemaps.gradle ios/sourcemaps.sh - search: instabug-reactnative - replace: << parameters.npm_package >> - - find_and_replace: - files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts - search: api.instabug.com - replace: << parameters.api_endpoint >> - - find_and_replace: - files: android/native.gradle - search: 'com.instabug.library:instabug:' - replace: 'com.instabug.library-<< parameters.android_package >>:instabug:' - run: name: Build the SDK command: yarn build @@ -301,45 +341,6 @@ jobs: name: Publish new enterprise version command: npm publish - # Automate the enterprise D11 sdk changes - release_d11: - working_directory: ~/project - executor: - name: node/default - steps: - - advanced-checkout/shallow-checkout - - install_node_modules - - run: - name: Remove README.md file - command: rm README.md - - find_and_replace: - files: package.json ios/sourcemaps.sh android/sourcemaps.gradle - search: instabug-reactnative - replace: '@instabug/instabug-reactnative-dream11' - - find_and_replace: - files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts - search: api.instabug.com - replace: st001012dream11.instabug.com - - find_and_replace: - files: android/native.gradle - search: com.instabug.library:instabug - replace: 'com.instabug.library-dream11:instabug' - - run: - name: give exec permssion to d11 script - command: chmod +x ./scripts/dream-11-delete-unused-features.sh - - run: - name: remove un-required features - command: ./scripts/dream-11-delete-unused-features.sh - - run: - name: Build the SDK - command: yarn build - - run: - name: Authorize with npm - command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - - run: - name: Publish new enterprise version - command: npm publish - publish: macos: xcode: 13.4.1 @@ -463,12 +464,6 @@ workflows: filters: branches: only: master - - hold_release_d11: - requires: *release_dependencies - type: approval - filters: - branches: - only: dream11 - publish: requires: - hold_publish @@ -481,6 +476,7 @@ workflows: filters: branches: only: master + - hold_release_nn: requires: *release_dependencies type: approval @@ -494,9 +490,12 @@ workflows: filters: branches: only: master - npm_package: '@instabug/react-native-nn' - android_package: nn - api_endpoint: st001009nn.instabug.com + prepare_steps: + - prepare_custom_package: + npm_package: '@instabug/react-native-nn' + android_package: nn + api_endpoint: st001009nn.instabug.com + - hold_release_injazat: requires: *release_dependencies type: approval @@ -510,12 +509,24 @@ workflows: filters: branches: only: master - npm_package: '@instabug/react-native-injazat' - android_package: injazat - api_endpoint: st001013mec1.instabug.com - - release_d11: + prepare_steps: + - prepare_custom_package: + npm_package: '@instabug/react-native-injazat' + android_package: injazat + api_endpoint: st001013mec1.instabug.com + + - hold_release_dream11: + requires: *release_dependencies + type: approval + filters: + branches: + only: dream11 + - release_custom_package: + name: release_dream11 requires: - - hold_release_d11 + - hold_release_dream11 filters: branches: only: dream11 + prepare_steps: + - prepare_dream11 From e77c2c53424aaed32055b7cd61114d1ff891f6d9 Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:02:11 +0300 Subject: [PATCH 5/8] ci: run tests before enterprise releases (#1271) --- .circleci/config.yml | 151 +++++++++++++++--- .../RNInstabugExampleReactnativePackage.java | 8 - .../app/src/main/res/raw/instabug_config.json | 4 + examples/default/android/build.gradle | 8 + .../InstabugExample.xcodeproj/project.pbxproj | 4 + .../ios/InstabugExample/Instabug.plist | Bin 0 -> 157 bytes .../ios/InstabugTests/InstabugSampleTests.m | 1 - .../ios/InstabugTests/RNInstabugTests.m | 1 - ios/RNInstabug/InstabugReactBridge.h | 1 - ios/RNInstabug/InstabugReactBridge.m | 1 - scripts/customize-ios-endpoints.sh | 28 ++++ scripts/dream-11-delete-unused-features.sh | 70 ++++---- scripts/replace.js | 24 ++- 13 files changed, 231 insertions(+), 70 deletions(-) create mode 100644 examples/default/android/app/src/main/res/raw/instabug_config.json create mode 100644 examples/default/ios/InstabugExample/Instabug.plist create mode 100755 scripts/customize-ios-endpoints.sh mode change 100644 => 100755 scripts/dream-11-delete-unused-features.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 64a6b4013a..d8334f0b32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,6 +17,12 @@ references: - e2e_ios - e2e_android + dream11_prepare_config: &dream11_prepare_config + prepare_steps: + - prepare_dream11 + requires: + - hold_test_dream11 + commands: install_node_modules: parameters: @@ -36,15 +42,28 @@ commands: parameters: working_directory: type: string + deployment: + type: boolean + default: false steps: - restore_cache: name: Restore Pods Cache keys: - v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }} - - run: - name: Install Pods - working_directory: << parameters.working_directory >> - command: pod install --deployment + - when: + condition: << parameters.deployment >> + steps: + - run: + name: Install Pods + working_directory: << parameters.working_directory >> + command: pod install --deployment + - unless: + condition: << parameters.deployment >> + steps: + - run: + name: Install Pods + working_directory: << parameters.working_directory >> + command: pod install - save_cache: name: Save Pods Cache key: v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }} @@ -120,6 +139,11 @@ commands: name: Remove unused features command: ./scripts/dream-11-delete-unused-features.sh working_directory: << parameters.working_directory >> + # Remove the NDK package to avoid dependency conflicts on Android. + - run: + name: Remove the NDK package + command: yarn remove instabug-reactnative-ndk + working_directory: << parameters.working_directory >>/examples/default notify_github: parameters: @@ -158,20 +182,38 @@ jobs: command: yarn lint:ci test_module: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false executor: name: node/default steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - run: name: Run Tests command: yarn test - - persist_to_workspace: - root: coverage - paths: - - lcov.info + - when: + condition: << parameters.collect_coverage >> + steps: + - persist_to_workspace: + root: coverage + paths: + - lcov.info test_android: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false executor: name: android/android-machine tag: '2024.01.1' @@ -180,15 +222,18 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout - # - node/install-yarn + - steps: << parameters.prepare_steps >> - install_node_modules - android/run-tests: working-directory: android test-command: ./gradlew test - - persist_to_workspace: - root: ~/project/android/build/reports/jacoco/jacocoTestReport - paths: - - jacocoTestReport.xml + - when: + condition: << parameters.collect_coverage >> + steps: + - persist_to_workspace: + root: ~/project/android/build/reports/jacoco/jacocoTestReport + paths: + - jacocoTestReport.xml validate_shell_files: machine: @@ -217,10 +262,18 @@ jobs: app-dir: examples/default - install_pods: working_directory: examples/default/ios + deployment: true - run: git --no-pager diff - run: git diff-index HEAD --exit-code -p -I EXCLUDED_ARCHS # Ignore Arch Changes test_ios: + parameters: + prepare_steps: + type: steps + default: [] + collect_coverage: + type: boolean + default: false macos: xcode: 13.4.1 resource_class: macos.m1.medium.gen1 @@ -229,6 +282,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - install_pods: working_directory: ios @@ -243,16 +297,23 @@ jobs: -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \ test | xcpretty - - run: - name: Convert xcresult into JSON report - working_directory: ios/coverage - command: xcrun xccov view --report --json result.xcresult > xcode.json - - persist_to_workspace: - root: ios/coverage - paths: - - xcode.json + - when: + condition: << parameters.collect_coverage >> + steps: + - run: + name: Convert xcresult into JSON report + working_directory: ios/coverage + command: xcrun xccov view --report --json result.xcresult > xcode.json + - persist_to_workspace: + root: ios/coverage + paths: + - xcode.json e2e_ios: + parameters: + prepare_steps: + type: steps + default: [] macos: xcode: 13.4.1 resource_class: macos.m1.medium.gen1 @@ -260,6 +321,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout + - steps: << parameters.prepare_steps >> - install_node_modules - node/install-packages: pkg-manager: yarn @@ -276,6 +338,11 @@ jobs: name: Rebuild Detox.framework Cache working_directory: examples/default command: detox clean-framework-cache && detox build-framework-cache + # This is a workaround until the iOS SDK is updated to prioritize the custom + # Instabug.plist over the internal Config.plist. + - run: + name: Customize API Endpoints + command: ./scripts/customize-ios-endpoints.sh - run: name: Detox - Build Release App working_directory: examples/default @@ -286,6 +353,10 @@ jobs: command: detox test --configuration ios.sim.release --cleanup e2e_android: + parameters: + prepare_steps: + type: steps + default: [] executor: name: android/android-machine tag: '2024.01.1' @@ -294,7 +365,7 @@ jobs: INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true steps: - advanced-checkout/shallow-checkout - # - node/install-yarn + - steps: << parameters.prepare_steps >> - install_node_modules - node/install-packages: pkg-manager: yarn @@ -439,11 +510,14 @@ workflows: - test_android - test_ios - lint - - test_module - - test_android + - test_module: + collect_coverage: true + - test_android: + collect_coverage: true + - test_ios: + collect_coverage: true - validate_shell_files - sync_generated_files - - test_ios - e2e_ios - e2e_android - hold_generate_snapshot: @@ -515,8 +589,33 @@ workflows: android_package: injazat api_endpoint: st001013mec1.instabug.com + # Dream11 tests + - hold_test_dream11: + type: approval + - test_module: + name: test_module_dream11 + <<: *dream11_prepare_config + - test_android: + name: test_android_dream11 + <<: *dream11_prepare_config + - test_ios: + name: test_ios_dream11 + <<: *dream11_prepare_config + - e2e_android: + name: e2e_android_dream11 + <<: *dream11_prepare_config + - e2e_ios: + name: e2e_ios_dream11 + <<: *dream11_prepare_config + + # Dream11 release - hold_release_dream11: - requires: *release_dependencies + requires: + - test_module_dream11 + - test_android_dream11 + - test_ios_dream11 + - e2e_android_dream11 + - e2e_ios_dream11 type: approval filters: branches: diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java index 304ab68704..977afa782e 100644 --- a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java +++ b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java @@ -6,14 +6,6 @@ import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; -import com.instabug.reactlibrary.RNInstabugAPMModule; -import com.instabug.reactlibrary.RNInstabugBugReportingModule; -import com.instabug.reactlibrary.RNInstabugCrashReportingModule; -import com.instabug.reactlibrary.RNInstabugFeatureRequestsModule; -import com.instabug.reactlibrary.RNInstabugReactnativeModule; -import com.instabug.reactlibrary.RNInstabugRepliesModule; -import com.instabug.reactlibrary.RNInstabugSessionReplayModule; -import com.instabug.reactlibrary.RNInstabugSurveysModule; import java.util.ArrayList; import java.util.Collections; diff --git a/examples/default/android/app/src/main/res/raw/instabug_config.json b/examples/default/android/app/src/main/res/raw/instabug_config.json new file mode 100644 index 0000000000..86b3a7a225 --- /dev/null +++ b/examples/default/android/app/src/main/res/raw/instabug_config.json @@ -0,0 +1,4 @@ +{ + "instabug-domain": "api.instabug.com", + "apm-domain": "api-apm.instabug.com" +} diff --git a/examples/default/android/build.gradle b/examples/default/android/build.gradle index 0336ff851f..7fa616eb1b 100644 --- a/examples/default/android/build.gradle +++ b/examples/default/android/build.gradle @@ -27,5 +27,13 @@ allprojects { maven { url("$rootDir/../node_modules/detox/Detox-android") } + + maven { + credentials { + username System.getenv("DREAM11_MAVEN_USERNAME") + password System.getenv("DREAM11_MAVEN_PASSWORD") + } + url "https://mvn.instabug.com/nexus/repository/dream-11" + } } } diff --git a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj index afe4ffe605..3b05a8f1e0 100644 --- a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj +++ b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ CC3DF8932A1DFC9A003E9914 /* InstabugSurveysTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */; }; CC3DF8942A1DFC9A003E9914 /* InstabugAPMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */; }; CC3DF8952A1DFC9A003E9914 /* IBGConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */; }; + CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */ = {isa = PBXBuildFile; fileRef = CC487A9B2C71FCFC0021F680 /* Instabug.plist */; }; CCF1E4092B022CF20024802D /* RNInstabugTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF1E4082B022CF20024802D /* RNInstabugTests.m */; }; CD36F4707EA1F435D2CC7A15 /* libPods-InstabugExample-InstabugTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF7A6E02D40E0CEEA833CC4 /* libPods-InstabugExample-InstabugTests.a */; }; F7BF47401EF3A435254C97BB /* libPods-InstabugExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BAED0D0441A708AE2390E153 /* libPods-InstabugExample.a */; }; @@ -64,6 +65,7 @@ CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugSurveysTests.m; sourceTree = ""; }; CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugAPMTests.m; sourceTree = ""; }; CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IBGConstants.m; sourceTree = ""; }; + CC487A9B2C71FCFC0021F680 /* Instabug.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; name = Instabug.plist; path = InstabugExample/Instabug.plist; sourceTree = ""; }; CCF1E4082B022CF20024802D /* RNInstabugTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNInstabugTests.m; sourceTree = ""; }; DBCB1B1D023646D84146C91E /* Pods-InstabugExample-InstabugTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugExample-InstabugTests.release.xcconfig"; path = "Target Support Files/Pods-InstabugExample-InstabugTests/Pods-InstabugExample-InstabugTests.release.xcconfig"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; @@ -120,6 +122,7 @@ 13B07FAE1A68108700A75B9A /* InstabugExample */ = { isa = PBXGroup; children = ( + CC487A9B2C71FCFC0021F680 /* Instabug.plist */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, @@ -296,6 +299,7 @@ buildActionMask = 2147483647; files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, + CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/examples/default/ios/InstabugExample/Instabug.plist b/examples/default/ios/InstabugExample/Instabug.plist new file mode 100644 index 0000000000000000000000000000000000000000..24d035f427616a1490762b3e7c6b8861c863c4a4 GIT binary patch literal 157 zcmYc)$jK}&F)+Bq$i&PN=b2Yrl9*JQ?ik=38srlV;{w_70_qthB?ZM+`ud3lnYxJu vxq6vU#d^v4xgbIP;*@OtGUIpwWh9ljRB`aiXaq5U0V5-XW?+TVFscFo;^Zpb literal 0 HcmV?d00001 diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 565a21b1a7..70ef410258 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -8,7 +8,6 @@ #import #import "OCMock/OCMock.h" #import "Instabug/Instabug.h" -#import "Instabug/IBGSurvey.h" #import "InstabugReactBridge.h" #import #import "IBGConstants.h" diff --git a/examples/default/ios/InstabugTests/RNInstabugTests.m b/examples/default/ios/InstabugTests/RNInstabugTests.m index 0df2fd8430..cde248ad30 100644 --- a/examples/default/ios/InstabugTests/RNInstabugTests.m +++ b/examples/default/ios/InstabugTests/RNInstabugTests.m @@ -1,7 +1,6 @@ #import #import "OCMock/OCMock.h" #import "Instabug/Instabug.h" -#import "Instabug/IBGSurvey.h" #import #import "RNInstabug.h" #import "RNInstabug/Instabug+CP.h" diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index c2accc9955..a3cfc21c13 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -12,7 +12,6 @@ #import #import #import -#import #import #import #import "ArgsRegistry.h" diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index a6f56109c2..dd18513163 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -8,7 +8,6 @@ #import #import #import -#import #import #import #import diff --git a/scripts/customize-ios-endpoints.sh b/scripts/customize-ios-endpoints.sh new file mode 100755 index 0000000000..2fecd9d729 --- /dev/null +++ b/scripts/customize-ios-endpoints.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Replaces the internal Config.plist file inside the Instabug iOS SDK with the +# Instabug.plist file in the example app. +# +# This is a workaround until the iOS SDK is updated to prioritize the custom +# Instabug.plist over the internal Config.plist. + +instabug_plist=examples/default/ios/InstabugExample/Instabug.plist + +if [ ! -f $instabug_plist ]; then + echo "Instabug.plist not found" + exit 1 +fi + +for dir in examples/default/ios/Pods/Instabug/Instabug.xcframework/ios-*/ +do + echo "Replacing Config.plist in $dir" + + config_path=$dir/Instabug.framework/InstabugResources.bundle/Config.plist + + if [ ! -f $config_path ]; then + echo "Config.plist not found in $dir" + exit 1 + fi + + cp -f $instabug_plist $config_path +done diff --git a/scripts/dream-11-delete-unused-features.sh b/scripts/dream-11-delete-unused-features.sh old mode 100644 new mode 100755 index 58ab392885..fa10a9181e --- a/scripts/dream-11-delete-unused-features.sh +++ b/scripts/dream-11-delete-unused-features.sh @@ -2,47 +2,61 @@ # remove survey and featureRequest features in JavaScript files deletedFeaturesFilesInJavaScript=("Surveys" "FeatureRequests" "Survey") -for feature in "${deletedFeaturesFilesInJavaScript[@]}"; - do - echo "$feature" -rm -f src/modules/"$feature".ts -rm -f test/mocks/mock"$feature".ts -sed -i "s/import..*$feature';//g" src/index.ts -sed -i "s/$feature,//g" src/index.ts - +for feature in "${deletedFeaturesFilesInJavaScript[@]}"; do + echo "$feature" + + rm -f src/modules/"$feature".ts + rm -f src/native/Native"$feature".ts + rm -f test/mocks/mock"$feature".ts + rm -f test/modules/"$feature".spec.ts + + node scripts/replace.js --pattern "import.+$feature';" "" src/index.ts + node scripts/replace.js --pattern "$feature," "" src/index.ts + node scripts/replace.js --pattern ".*$feature.*" "" src/native/NativePackage.ts + node scripts/replace.js --pattern ".*$feature.*" "" test/mocks/mockNativeModules.ts done -npx eslint src/index.ts --fix + +npx eslint src/index.ts --fix # remove survey and featureRequest features in Android files deletedFeaturesFilesInAndroidApp=("RNInstabugSurveysModule" "RNInstabugFeatureRequestsModule") -for feature in "${deletedFeaturesFilesInAndroidApp[@]}"; - do - echo "$feature" - -rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java -rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java -sed -i "s/modules.add(new $feature(reactContext));//g" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +for feature in "${deletedFeaturesFilesInAndroidApp[@]}"; do + echo "$feature" + rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java + rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java + node scripts/replace.js "modules.add(new $feature(reactContext));" "" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java done # remove survey and featureRequest features in IOS files deletedFeaturesFilesInIosApp=("InstabugSurveysBridge" "InstabugFeatureRequestsBridge") -for feature in "${deletedFeaturesFilesInIosApp[@]}"; - do - echo "$feature" -rm -f ios/RNInstabug/"$feature".h -rm -f ios/RNInstabug/"$feature".m +for feature in "${deletedFeaturesFilesInIosApp[@]}"; do + echo "$feature" + rm -f ios/RNInstabug/"$feature".h + rm -f ios/RNInstabug/"$feature".m done -sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.m -sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.h +# Remove unused features iOS test files +iosTestFiles=("InstabugSurveysTests.m" "InstabugFeatureRequestsTests.m") +for file in "${iosTestFiles[@]}"; do + echo "Deleting $file" + + rm -f examples/default/ios/InstabugTests/"$file" + node scripts/replace.js --pattern ".*$file.*" "" examples/default/ios/InstabugExample.xcodeproj/project.pbxproj +done -# remove all locales except English locale -sed -i -E '/english/!s/.*constants.locale.*//g' src/utils/Enums.ts -npx eslint src/index.ts --fix src/utils/Enums.ts +node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.m +node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.h -sed -i "s/return (major == 7 && minor >= 3) || major >= 8/return false/g" android/build.gradle +# Remove all locales except for English +# This ugly regular expression matches all lines not containing "english" and containing "constants.locale" +node scripts/replace.js --pattern "^(?!.*english).+constants\.locale.*" "" src/utils/Enums.ts +npx eslint src/index.ts --fix src/utils/Enums.ts -sed -i "s/static boolean supportsNamespace() {/static boolean supportsNamespace() { \n return false/g" android/build.gradle +node scripts/replace.js "return (major == 7 && minor >= 3) || major >= 8" "return false" android/build.gradle +# Note: printf is used here as the string contains a newline character which would be escaped otherwise. +node scripts/replace.js "static boolean supportsNamespace() {" "$(printf "static boolean supportsNamespace() {\n return false")" android/build.gradle +# Add Dream11 custom iOS build podspec to Podfile +node scripts/replace.js "target 'InstabugExample' do" "$(printf "target 'InstabugExample' do\n pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/dream11/Instabug.podspec'")" examples/default/ios/Podfile diff --git a/scripts/replace.js b/scripts/replace.js index 5682b47265..aeb483ae8f 100644 --- a/scripts/replace.js +++ b/scripts/replace.js @@ -10,10 +10,25 @@ const fs = require('fs'); const path = require('path'); +const { parseArgs } = require('util'); -const [search, replace, ...files] = process.argv.slice(2); +const { values, positionals } = parseArgs({ + allowPositionals: true, + options: { + pattern: { + type: 'boolean', + default: false, + short: 'p', + }, + }, +}); -if (!search || !replace || !files.length) { +const [search, replace, ...files] = positionals; + +/** Whether to replace the search string as a regular expression or as a literal string. */ +const isPattern = values.pattern; + +if (search == null || replace == null || !files.length) { // The path of the script relative to the directory where the user ran the // script to be used in the error message demonstrating the usage. const scriptPath = path.relative(process.cwd(), __filename); @@ -21,7 +36,7 @@ if (!search || !replace || !files.length) { console.error('Missing arguments.'); console.table({ search, replace, files }); - console.error(`Usage: node ${scriptPath} `); + console.error(`Usage: node ${scriptPath} [-p | --pattern] `); process.exit(1); } @@ -31,7 +46,8 @@ for (const file of files) { const fileContent = fs.readFileSync(filePath, 'utf8'); - const newContent = fileContent.replaceAll(search, replace); + const searchPattern = isPattern ? new RegExp(search, 'gm') : search; + const newContent = fileContent.replaceAll(searchPattern, replace); fs.writeFileSync(filePath, newContent); } catch (error) { From 8aade4804d42bbae8ded2d7d32593909d6cc068c Mon Sep 17 00:00:00 2001 From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:35:40 +0300 Subject: [PATCH 6/8] ci: publish snapshots to npm (#1274) --- .circleci/config.yml | 35 +++++++++++------------------------ scripts/snapshot-branch.sh | 30 ------------------------------ scripts/snapshot-comment.md | 4 ++-- scripts/snapshot-version.sh | 11 +++++++++++ 4 files changed, 24 insertions(+), 56 deletions(-) delete mode 100755 scripts/snapshot-branch.sh create mode 100755 scripts/snapshot-version.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index d8334f0b32..efca5acab3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -469,35 +469,22 @@ jobs: - run: yarn build - run: yarn remove @instabug/danger-plugin-coverage - run: - name: Remove build files from .gitignore - command: sed -i '/dist/d' .gitignore && sed -i '/bin/d' .gitignore - - run: - name: Get snapshot branch name - command: | - source scripts/snapshot-branch.sh - echo "export SNAPSHOT_BRANCH=$SNAPSHOT_BRANCH" >> "$BASH_ENV" - - run: - name: Setup Git - command: | - git config --global user.name "Instabug-CP-CI" - git config --global user.email github-ci+cp@instabug.com - - run: - name: Create snapshot branch - command: git checkout -b $SNAPSHOT_BRANCH - - run: - name: Commit changes + name: Get snapshot version command: | - git add . - git commit -m "chore: add generate files" + source scripts/snapshot-version.sh + echo "export SNAPSHOT_VERSION=$SNAPSHOT_VERSION" >> "$BASH_ENV" - run: - name: Push snapshot - command: git push --force origin $SNAPSHOT_BRANCH + name: Authorize with NPM + command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + - run: npm version $SNAPSHOT_VERSION --no-git-tag-version + - run: npm publish --tag snapshot - run: name: Install jq command: sudo apt-get update && sudo apt-get install -y jq - - run: - name: Replace snapshot branch in comment template - command: sed -i "s|{BRANCH}|$SNAPSHOT_BRANCH|g" scripts/snapshot-comment.md + - find_and_replace: + files: scripts/snapshot-comment.md + search: '{VERSION}' + replace: $SNAPSHOT_VERSION - notify_github: data: "$(jq -Rcs '{ body: . }' scripts/snapshot-comment.md)" diff --git a/scripts/snapshot-branch.sh b/scripts/snapshot-branch.sh deleted file mode 100755 index 652dd1bb98..0000000000 --- a/scripts/snapshot-branch.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -pr_url="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open" -pr_response=$(curl --location --request GET "$pr_url" --header "Authorization: Bearer $RELEASE_GITHUB_TOKEN") - -if [ $(echo "$pr_response" | jq length) -eq 0 ]; then - echo "No PR found, proceeding with branch name instead" - - SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH" -else - pr_description=$(echo "$pr_response" | jq -r '.[].body') - - # The `sed "s/\r//g"` is used to remove the carriage return character \r from the end of the string - SNAPSHOT_BRANCH=$(echo -E "$pr_description" | grep 'Snapshot name:' | cut -d ':' -f 2 | xargs echo -n | sed "s/\r//g" || echo -n) - - if [ -z "$SNAPSHOT_BRANCH" ]; then - echo "No custom snapshot name found, proceeding with default snapshot naming convention" - - version=$(jq -r '.version' package.json) - jira_id=$(echo -E "$pr_description" | grep 'Jira ID:' | grep -Eo '[A-Z]+-[0-9]+' || echo -n) - - if [ -z "$jira_id" ]; then - echo "No Jira ID found, proceeding with branch name instead" - - SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH" - else - SNAPSHOT_BRANCH="snapshot/$version-$jira_id" - fi - fi -fi diff --git a/scripts/snapshot-comment.md b/scripts/snapshot-comment.md index 25ee16227b..6acb6d7267 100644 --- a/scripts/snapshot-comment.md +++ b/scripts/snapshot-comment.md @@ -5,11 +5,11 @@ Your snapshot has been generated! :rocket: You can install the snapshot through NPM: ```sh -npm install https://github.com/Instabug/Instabug-React-Native\#{BRANCH} +npm install instabug-reactnative@{VERSION} ``` or Yarn: ```sh -yarn add https://github.com/Instabug/Instabug-React-Native\#{BRANCH} +yarn add instabug-reactnative@{VERSION} ``` diff --git a/scripts/snapshot-version.sh b/scripts/snapshot-version.sh new file mode 100755 index 0000000000..7ba0a0fd58 --- /dev/null +++ b/scripts/snapshot-version.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Generates a snapshot version following the format {version}-{pr}{random-3-digit}-SNAPSHOT +# Example: 13.3.0-502861-SNAPSHOT + +pr=$(basename $CIRCLE_PULL_REQUEST) +random=$(($RANDOM % 900 + 100)) +version=$(jq -r '.version' package.json) +suffix="SNAPSHOT" + +SNAPSHOT_VERSION="$version-$pr$random-$suffix" From 3e494b1cc42ba00769ce31e1700f14a624f8f7b4 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Wed, 11 Sep 2024 15:16:36 +0300 Subject: [PATCH 7/8] fix: added changelog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acb003486f..4176f5fe9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,11 @@ ### Added -- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). +- Add support for Expo Router navigation tracking ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). + +### Fixed + +- Fix APM network logging on iOS when the response body is missing or empty. ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024) From 64afcb62dae8397424ccd7dc0b3aaccd3f653cf5 Mon Sep 17 00:00:00 2001 From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:12:28 +0300 Subject: [PATCH 8/8] Update CHANGELOG.md Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com> --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4176f5fe9f..5d81354bd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,11 @@ ### Added -- Add support for Expo Router navigation tracking ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). +- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)). ### Fixed -- Fix APM network logging on iOS when the response body is missing or empty. ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)). +- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)). ## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)