Skip to content

Commit e4b8c7a

Browse files
DavidMina96ymabdallah
authored andcommitted
[MOB-11439] Add init API (#867)
We need our SDK initialization API to take an extensible configuration rather than a fixed set of parameters. For that, we add a new initialization API Instabug.init and deprecate Instabug.start.
1 parent b509f53 commit e4b8c7a

File tree

17 files changed

+77
-39
lines changed

17 files changed

+77
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
- Deprecates Instabug.start in favour of Instabug.init that takes a configuration object for SDK initialization.
4+
15
## 11.6.0 (2022-12-29)
26

37
- Bumps Instabug Android SDK to v11.7.0

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ To start using Instabug, import it as follows, then initialize it in the `constr
3939
```javascript
4040
import Instabug from 'instabug-reactnative';
4141

42-
Instabug.start('APP_TOKEN', [Instabug.invocationEvent.shake]);
42+
Instabug.init({
43+
token: 'APP_TOKEN',
44+
invocationEvents: [Instabug.invocationEvent.shake],
45+
});
4346
```
4447

4548
_You can find your app token by selecting the SDK tab from your [**Instabug dashboard**](https://dashboard.instabug.com)._
@@ -64,7 +67,7 @@ If your app doesn’t already access the microphone or photo library, we recomme
6467

6568
## Uploading Source Map Files for Crash Reports
6669

67-
For your app crashes to show up with a fully symbolicated stack trace, we will automatically generate the source map files and upload them to your dashboard on release build. To do so, we rely on your app token being explicitly added to `Instabug.start('YOUR_APP_TOKEN')` in JavaScript.
70+
For your app crashes to show up with a fully symbolicated stack trace, we will automatically generate the source map files and upload them to your dashboard on release build. To do so, we rely on your app token being explicitly added to `Instabug.init({token: 'YOUR_APP_TOKEN'})` in JavaScript.
6871

6972
If your app token is defined as a constant, you can set an environment variable `INSTABUG_APP_TOKEN` to be used instead.
7073
We also automatically read your `versionName` and `versionCode` to upload your sourcemap file. alternatively, can also set the environment variables `INSTABUG_APP_VERSION_NAME` and `INSTABUG_APP_VERSION_CODE` to be used instead.

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,13 @@ public void run() {
127127
});
128128
}
129129

130-
/**
131-
* Starts the SDK.
132-
* @param token string The token that identifies the app, you can find
133-
* it on your dashboard.
134-
* @param invocationEventValues ReadableArray The events that invokes
135-
* the SDK's UI.
136-
*/
137-
@ReactMethod
138-
public void start(final String token, final ReadableArray invocationEventValues) {
130+
/**
131+
* Initializes the SDK.
132+
* @param token The token that identifies the app. You can find it on your dashboard.
133+
* @param invocationEventValues The events that invoke the SDK's UI.
134+
*/
135+
@ReactMethod
136+
public void init(final String token, final ReadableArray invocationEventValues) {
139137
MainThreadHandler.runOnMainThread(new Runnable() {
140138
@Override
141139
public void run() {

android/upload_sourcemap.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ export NODE_BINARY=node
1111

1212
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
1313
echo "Instabug: Looking for Token..."
14+
INSTABUG_APP_TOKEN=$(grep -r -A 6 --exclude-dir={node_modules,ios,android} --exclude='*.json' "Instabug.init({" ./ -m1 | grep "token:[[:space:]]*[\"\'][0-9a-zA-Z]*[\"\']" | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2 | cut -d "'" -f 2)
15+
if [ -z "${INSTABUG_APP_TOKEN}" ]; then
1416
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} --exclude='*.json' "Instabug.start[WithToken]*([\"\'][0-9a-zA-Z]*[\"\']" ./ -m 1 | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2 | cut -d "'" -f 2)
17+
fi
1518
fi
1619

1720
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
18-
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.start Or added the environment variable INSTABUG_APP_TOKEN"
21+
echo "Instabug: err: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.init Or added the environment variable INSTABUG_APP_TOKEN"
1922
exit 0
2023
else
2124
if [ ! "${INSTABUG_APP_VERSION_CODE}" ] || [ -z "${INSTABUG_APP_VERSION_CODE}" ]; then

example/ios/InstabugSample.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@
401401
name = "[CP-User] [instabug-reactnative] Upload Sourcemap";
402402
runOnlyForDeploymentPostprocessing = 0;
403403
shellPath = /bin/sh;
404-
shellScript = "#!/bin/sh\ncd ${PROJECT_DIR}\ncd ..\nif [ -s \"$HOME/.nvm/nvm.sh\" ]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [ -x \"$(command -v brew)\" ] && [ -s \"$(brew --prefix nvm)/nvm.sh\" ]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\nexport NODE_BINARY=node\n\nINSTABUG_SOURCEMAPS_UPLOAD_DISABLE=$(echo $INSTABUG_SOURCEMAPS_UPLOAD_DISABLE | tr 'A-Z' 'a-z')\nif [ \"${INSTABUG_SOURCEMAPS_UPLOAD_DISABLE}\" = \"true\" ]; then\n echo \"Instabug: Environment variable INSTABUG_SOURCEMAPS_UPLOAD_DISABLE was set to true, skipping sourcemap upload\"\n exit 0\nfi\n\nif [ ! \"$INFOPLIST_FILE\" ] || [ -z \"$INFOPLIST_FILE\" ]; then\n echo \"Instabug: INFOPLIST_FILE not found in Xcode build settings, skipping sourcemap upload\"\n exit 0\nfi\n\nif [ ! \"${PROJECT_DIR}\" ] || [ -z \"${PROJECT_DIR}\" ]; then\n echo \"Instabug: PROJECT_DIR not found in Xcode build settings, skipping sourcemap upload\"\n exit 0\nfi\n\nPLIST_ABS_PATH=\"$PROJECT_DIR/$INFOPLIST_FILE\"\necho \"Instabug: PLIST_ABS_PATH: $PLIST_ABS_PATH\"\n\nif [ ! \"${INSTABUG_APP_TOKEN}\" ] || [ -z \"${INSTABUG_APP_TOKEN}\" ]; then\n echo \"Instabug: Looking for Token...\"\n INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} \"Instabug.start[WithToken]*([\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" ./ -m 1 | grep -o \"[\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" | cut -d \"\\\"\" -f 2 | cut -d \"'\" -f 2)\nfi\n\nif [ ! \"${INSTABUG_APP_TOKEN}\" ] || [ -z \"${INSTABUG_APP_TOKEN}\" ]; then\n echo \"Instabug: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.start Or added the environment variable INSTABUG_APP_TOKEN\"\n exit 0\nelse\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n INSTABUG_APP_VERSION_CODE=$(/usr/libexec/PlistBuddy -c 'print CFBundleVersion' ${PLIST_ABS_PATH} )\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n echo \"CFBundleVersion could not be found, please upload the sourcemap files manually\"\n exit 0\n fi\n INSTABUG_APP_VERSION_CODE_ENV=$(grep -o '$(.*)' <<< $INSTABUG_APP_VERSION_CODE | cut -d \"(\" -f2 | cut -d \")\" -f1)\n if !([ ! \"${INSTABUG_APP_VERSION_CODE_ENV}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE_ENV}\" ]); then\n INSTABUG_APP_VERSION_CODE=${!INSTABUG_APP_VERSION_CODE_ENV}\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n echo \"Environment variable $INSTABUG_APP_VERSION_CODE_ENV was specified inside Info.plist but was not found, please upload the sourcemap files manually\" \n exit 0\n fi\n fi\n fi\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n INSTABUG_APP_VERSION_NAME=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' ${PLIST_ABS_PATH} )\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n echo \"CFBundleShortVersionString could not be found, please upload the sourcemap files manually\"\n exit 0\n fi\n INSTABUG_APP_VERSION_NAME_ENV=$(grep -o '$(.*)' <<< $INSTABUG_APP_VERSION_NAME | cut -d \"(\" -f2 | cut -d \")\" -f1)\n if !([ ! \"${INSTABUG_APP_VERSION_NAME_ENV}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME_ENV}\" ]); then\n INSTABUG_APP_VERSION_NAME=${!INSTABUG_APP_VERSION_NAME_ENV}\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n echo \"Environment variable $INSTABUG_APP_VERSION_NAME_ENV was specified inside Info.plist but was not found, please upload the sourcemap files manually\" \n exit 0\n fi\n fi\n fi\n if [ -z \"${INSTABUG_ENTRY_FILE}\" ]; then \n ENTRY_FILE='index.js'\n else \n ENTRY_FILE=${INSTABUG_ENTRY_FILE}\n fi\n if [ ! -f $ENTRY_FILE ]; then\n echo \"Instabug: err: entry file not found. Make sure\" \"\\\"${ENTRY_FILE}\\\"\" \"exists in your projects root directory. Or add the environment variable INSTABUG_ENTRY_FILE with the name of your entry file\"\n exit 0\n fi\n VERSION='{\"code\":\"'\"$INSTABUG_APP_VERSION_CODE\"'\",\"name\":\"'\"$INSTABUG_APP_VERSION_NAME\"'\"}'\n echo \"Instabug: Token:\" \"\\\"\"${INSTABUG_APP_TOKEN}\"\\\"\"\n echo \"Instabug: VERSION: $VERSION\"\n echo \"Instabug: Entry file found\" \"\\\"\"${ENTRY_FILE}\"\\\"\"\n echo \"Instabug: Generating sourcemap files...\"\n HERMES_ENABLED=$(grep hermes-engine ./ios/Podfile.lock -m 1)\n INSTALLED_RN_VERSION_MAJOR=$(node -p \"require('./node_modules/react-native/package.json').version\" | cut -d \".\" -f2)\n if [[ ! -z \"$HERMES_ENABLED\" && \"$INSTALLED_RN_VERSION_MAJOR\" -ge 65 && \"$INSTALLED_RN_VERSION_MAJOR\" -lt 70 ]]; then\n EXTRA_ARGS=\"--minify false\"\n fi\n #Generate ios sourcemap\n npx react-native bundle --platform ios \\\n --reset-cache \\\n --entry-file $ENTRY_FILE \\\n --dev false \\\n --bundle-output ./ios/main.jsbundle \\\n --sourcemap-output ./ios-sourcemap.json \\\n $EXTRA_ARGS\n \n echo \"Instabug: Uploading files...\"\n #Upload ios sourcemap\n curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F \"app_version=${VERSION}\" -F \"symbols_file=@./ios-sourcemap.json\" -F \"application_token=${INSTABUG_APP_TOKEN}\" -F \"platform=react_native\" -F \"os=ios\" \n rm -rf ios-sourcemap.json\n echo \nfi\n";
404+
shellScript = "#!/bin/sh\ncd ${PROJECT_DIR}\ncd ..\nif [ -s \"$HOME/.nvm/nvm.sh\" ]; then\n. \"$HOME/.nvm/nvm.sh\"\nelif [ -x \"$(command -v brew)\" ] && [ -s \"$(brew --prefix nvm)/nvm.sh\" ]; then\n. \"$(brew --prefix nvm)/nvm.sh\"\nfi\nexport NODE_BINARY=node\n\nINSTABUG_SOURCEMAPS_UPLOAD_DISABLE=$(echo $INSTABUG_SOURCEMAPS_UPLOAD_DISABLE | tr 'A-Z' 'a-z')\nif [ \"${INSTABUG_SOURCEMAPS_UPLOAD_DISABLE}\" = \"true\" ]; then\n echo \"Instabug: Environment variable INSTABUG_SOURCEMAPS_UPLOAD_DISABLE was set to true, skipping sourcemap upload\"\n exit 0\nfi\n\nif [ ! \"$INFOPLIST_FILE\" ] || [ -z \"$INFOPLIST_FILE\" ]; then\n echo \"Instabug: INFOPLIST_FILE not found in Xcode build settings, skipping sourcemap upload\"\n exit 0\nfi\n\nif [ ! \"${PROJECT_DIR}\" ] || [ -z \"${PROJECT_DIR}\" ]; then\n echo \"Instabug: PROJECT_DIR not found in Xcode build settings, skipping sourcemap upload\"\n exit 0\nfi\n\nPLIST_ABS_PATH=\"$PROJECT_DIR/$INFOPLIST_FILE\"\necho \"Instabug: PLIST_ABS_PATH: $PLIST_ABS_PATH\"\n\nif [ ! \"${INSTABUG_APP_TOKEN}\" ] || [ -z \"${INSTABUG_APP_TOKEN}\" ]; then\n echo \"Instabug: Looking for Token...\"\n INSTABUG_APP_TOKEN=$(grep -r -A 6 --exclude-dir={node_modules,ios,android} --exclude='*.json' \"Instabug.init({\" ./ -m1 | grep \"token:[[:space:]]*[\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" | grep -o \"[\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" | cut -d \"\\\"\" -f 2 | cut -d \"'\" -f 2)\n if [ -z \"${INSTABUG_APP_TOKEN}\" ]; then\n INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} --exclude='*.json' \"Instabug.start[WithToken]*([\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" ./ -m 1 | grep -o \"[\\\"\\'][0-9a-zA-Z]*[\\\"\\']\" | cut -d \"\\\"\" -f 2 | cut -d \"'\" -f 2)\n fi\nfi\n\nif [ ! \"${INSTABUG_APP_TOKEN}\" ] || [ -z \"${INSTABUG_APP_TOKEN}\" ]; then\n echo \"Instabug: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.init Or added the environment variable INSTABUG_APP_TOKEN\"\n exit 0\nelse\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n INSTABUG_APP_VERSION_CODE=$(/usr/libexec/PlistBuddy -c 'print CFBundleVersion' ${PLIST_ABS_PATH} )\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n echo \"CFBundleVersion could not be found, please upload the sourcemap files manually\"\n exit 0\n fi\n INSTABUG_APP_VERSION_CODE_ENV=$(grep -o '$(.*)' <<< $INSTABUG_APP_VERSION_CODE | cut -d \"(\" -f2 | cut -d \")\" -f1)\n if !([ ! \"${INSTABUG_APP_VERSION_CODE_ENV}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE_ENV}\" ]); then\n INSTABUG_APP_VERSION_CODE=${!INSTABUG_APP_VERSION_CODE_ENV}\n if [ ! \"${INSTABUG_APP_VERSION_CODE}\" ] || [ -z \"${INSTABUG_APP_VERSION_CODE}\" ]; then\n echo \"Environment variable $INSTABUG_APP_VERSION_CODE_ENV was specified inside Info.plist but was not found, please upload the sourcemap files manually\" \n exit 0\n fi\n fi\n fi\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n INSTABUG_APP_VERSION_NAME=$(/usr/libexec/PlistBuddy -c 'print CFBundleShortVersionString' ${PLIST_ABS_PATH} )\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n echo \"CFBundleShortVersionString could not be found, please upload the sourcemap files manually\"\n exit 0\n fi\n INSTABUG_APP_VERSION_NAME_ENV=$(grep -o '$(.*)' <<< $INSTABUG_APP_VERSION_NAME | cut -d \"(\" -f2 | cut -d \")\" -f1)\n if !([ ! \"${INSTABUG_APP_VERSION_NAME_ENV}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME_ENV}\" ]); then\n INSTABUG_APP_VERSION_NAME=${!INSTABUG_APP_VERSION_NAME_ENV}\n if [ ! \"${INSTABUG_APP_VERSION_NAME}\" ] || [ -z \"${INSTABUG_APP_VERSION_NAME}\" ]; then\n echo \"Environment variable $INSTABUG_APP_VERSION_NAME_ENV was specified inside Info.plist but was not found, please upload the sourcemap files manually\" \n exit 0\n fi\n fi\n fi\n if [ -z \"${INSTABUG_ENTRY_FILE}\" ]; then \n ENTRY_FILE='index.js'\n else \n ENTRY_FILE=${INSTABUG_ENTRY_FILE}\n fi\n if [ ! -f $ENTRY_FILE ]; then\n echo \"Instabug: err: entry file not found. Make sure\" \"\\\"${ENTRY_FILE}\\\"\" \"exists in your projects root directory. Or add the environment variable INSTABUG_ENTRY_FILE with the name of your entry file\"\n exit 0\n fi\n VERSION='{\"code\":\"'\"$INSTABUG_APP_VERSION_CODE\"'\",\"name\":\"'\"$INSTABUG_APP_VERSION_NAME\"'\"}'\n echo \"Instabug: Token:\" \"\\\"\"${INSTABUG_APP_TOKEN}\"\\\"\"\n echo \"Instabug: VERSION: $VERSION\"\n echo \"Instabug: Entry file found\" \"\\\"\"${ENTRY_FILE}\"\\\"\"\n echo \"Instabug: Generating sourcemap files...\"\n HERMES_ENABLED=$(grep hermes-engine ./ios/Podfile.lock -m 1)\n INSTALLED_RN_VERSION_MAJOR=$(node -p \"require('./node_modules/react-native/package.json').version\" | cut -d \".\" -f2)\n if [[ ! -z \"$HERMES_ENABLED\" && \"$INSTALLED_RN_VERSION_MAJOR\" -ge 65 && \"$INSTALLED_RN_VERSION_MAJOR\" -lt 70 ]]; then\n EXTRA_ARGS=\"--minify false\"\n fi\n #Generate ios sourcemap\n npx react-native bundle --platform ios \\\n --reset-cache \\\n --entry-file $ENTRY_FILE \\\n --dev false \\\n --bundle-output ./ios/main.jsbundle \\\n --sourcemap-output ./ios-sourcemap.json \\\n $EXTRA_ARGS\n \n echo \"Instabug: Uploading files...\"\n #Upload ios sourcemap\n curl -X POST 'https://api.instabug.com/api/sdk/v3/symbols_files' -F \"app_version=${VERSION}\" -F \"symbols_file=@./ios-sourcemap.json\" -F \"application_token=${INSTABUG_APP_TOKEN}\" -F \"platform=react_native\" -F \"os=ios\" \n rm -rf ios-sourcemap.json\n echo \nfi\n";
405405
};
406406
DD1AA4DBFEAB75A854826F0C /* [CP] Embed Pods Frameworks */ = {
407407
isa = PBXShellScriptBuildPhase;

example/ios/InstabugSampleTests/InstabugSampleTests.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ - (void)testSetEnabled {
6161
OCMVerify([mock setEnabled:isEnabled]);
6262
}
6363

64-
- (void)testStart {
64+
- (void)testInit {
6565
id<InstabugCPTestProtocol> mock = OCMClassMock([Instabug class]);
6666
IBGInvocationEvent floatingButtonInvocationEvent = IBGInvocationEventFloatingButton;
6767
NSString *appToken = @"app_token";
6868
NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil];
69-
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing [Instabug start]"];
69+
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing [Instabug init]"];
7070

7171
OCMStub([mock startWithToken:appToken invocationEvents:floatingButtonInvocationEvent]);
72-
[self.instabugBridge start:appToken invocationEvents:invocationEvents];
72+
[self.instabugBridge init:appToken invocationEvents:invocationEvents];
7373

7474
[[NSRunLoop mainRunLoop] performBlock:^{
7575
OCMVerify([mock startWithToken:appToken invocationEvents:floatingButtonInvocationEvent]);

example/src/App.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const Tab = createBottomTabNavigator();
1212

1313
export function App() {
1414
useEffect(() => {
15-
Instabug.start('2c63627b9923e10eee2c8abf92e6925f', [Instabug.invocationEvent.floatingButton]);
15+
Instabug.init({
16+
token: '2c63627b9923e10eee2c8abf92e6925f',
17+
invocationEvents: [Instabug.invocationEvent.floatingButton],
18+
});
1619
}, []);
1720

1821
return (

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
- (void)setEnabled:(BOOL)isEnabled;
2929

30-
- (void)start:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray;
30+
- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray;
3131

3232
- (void)setUserData:(NSString *)userData;
3333

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ - (dispatch_queue_t)methodQueue {
4141
Instabug.enabled = isEnabled;
4242
}
4343

44-
RCT_EXPORT_METHOD(start:(NSString *)token invocationEvents:(NSArray*)invocationEventsArray) {
45-
SEL setPrivateApiSEL = NSSelectorFromString(@"setCurrentPlatform:");
44+
RCT_EXPORT_METHOD(init:(NSString *)token invocationEvents:(NSArray*)invocationEventsArray) {
45+
SEL setPrivateApiSEL = NSSelectorFromString(@"setCurrentPlatform:");
4646
if ([[Instabug class] respondsToSelector:setPrivateApiSEL]) {
4747
NSInteger *platform = IBGPlatformReactNative;
4848
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[Instabug class] methodSignatureForSelector:setPrivateApiSEL]];

ios/upload_sourcemap.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ echo "Instabug: PLIST_ABS_PATH: $PLIST_ABS_PATH"
2929

3030
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
3131
echo "Instabug: Looking for Token..."
32-
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} "Instabug.start[WithToken]*([\"\'][0-9a-zA-Z]*[\"\']" ./ -m 1 | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2 | cut -d "'" -f 2)
32+
INSTABUG_APP_TOKEN=$(grep -r -A 6 --exclude-dir={node_modules,ios,android} --exclude='*.json' "Instabug.init({" ./ -m1 | grep "token:[[:space:]]*[\"\'][0-9a-zA-Z]*[\"\']" | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2 | cut -d "'" -f 2)
33+
if [ -z "${INSTABUG_APP_TOKEN}" ]; then
34+
INSTABUG_APP_TOKEN=$(grep -r --exclude-dir={node_modules,ios,android} --exclude='*.json' "Instabug.start[WithToken]*([\"\'][0-9a-zA-Z]*[\"\']" ./ -m 1 | grep -o "[\"\'][0-9a-zA-Z]*[\"\']" | cut -d "\"" -f 2 | cut -d "'" -f 2)
35+
fi
3336
fi
3437

3538
if [ ! "${INSTABUG_APP_TOKEN}" ] || [ -z "${INSTABUG_APP_TOKEN}" ]; then
36-
echo "Instabug: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.start Or added the environment variable INSTABUG_APP_TOKEN"
39+
echo "Instabug: INSTABUG_APP_TOKEN not found. Make sure you've added the SDK initialization line Instabug.init Or added the environment variable INSTABUG_APP_TOKEN"
3740
exit 0
3841
else
3942
if [ ! "${INSTABUG_APP_VERSION_CODE}" ] || [ -z "${INSTABUG_APP_VERSION_CODE}" ]; then

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Models
2+
import type { InstabugConfig } from './models/InstabugConfig';
23
import Report from './models/Report';
34
import Trace from './models/Trace';
45
// Modules
@@ -24,6 +25,7 @@ export {
2425
Surveys,
2526
};
2627

28+
export type { InstabugConfig };
2729
export type { Survey };
2830

2931
export default Instabug;

src/models/InstabugConfig.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { invocationEvent } from '../utils/ArgsRegistry';
2+
3+
export interface InstabugConfig {
4+
token: string;
5+
invocationEvents: invocationEvent[];
6+
}

0 commit comments

Comments
 (0)