4
4
5
5
import android .graphics .Bitmap ;
6
6
import android .net .Uri ;
7
- import android .util .Log ;
8
7
import android .view .View ;
9
8
10
9
import com .facebook .react .bridge .Arguments ;
20
19
import com .facebook .react .uimanager .NativeViewHierarchyManager ;
21
20
import com .facebook .react .uimanager .UIBlock ;
22
21
import com .facebook .react .uimanager .UIManagerModule ;
23
- import com .instabug .apm .APM ;
24
22
import com .instabug .bug .instabugdisclaimer .Internal ;
25
23
import com .instabug .library .Feature ;
26
24
import com .instabug .library .Instabug ;
27
25
import com .instabug .library .InstabugColorTheme ;
28
26
import com .instabug .library .InstabugCustomTextPlaceHolder ;
29
27
import com .instabug .library .LogLevel ;
30
- import com .instabug .library .Platform ;
31
28
import com .instabug .library .internal .module .InstabugLocale ;
32
29
import com .instabug .library .invocation .InstabugInvocationEvent ;
33
30
import com .instabug .library .logging .InstabugLog ;
37
34
import com .instabug .library .visualusersteps .State ;
38
35
import com .instabug .reactlibrary .utils .ArrayUtil ;
39
36
import com .instabug .reactlibrary .utils .EventEmitterModule ;
40
- import com .instabug .reactlibrary .utils .InstabugUtil ;
41
37
import com .instabug .reactlibrary .utils .MainThreadHandler ;
42
38
43
39
import org .json .JSONException ;
44
40
import org .json .JSONObject ;
45
41
import org .json .JSONTokener ;
46
42
47
43
import java .io .File ;
48
- import java .lang .reflect .InvocationTargetException ;
49
44
import java .lang .reflect .Method ;
50
45
import java .util .ArrayList ;
51
46
import java .util .Arrays ;
@@ -92,7 +87,7 @@ public void removeListeners(Integer count) {
92
87
super .removeListeners (count );
93
88
}
94
89
95
- /**
90
+ /**
96
91
* Enables or disables Instabug functionality.
97
92
* @param isEnabled A boolean to enable/disable Instabug.
98
93
*/
@@ -111,7 +106,7 @@ public void run() {
111
106
}
112
107
}
113
108
});
114
- }
109
+ }
115
110
116
111
/**
117
112
* Initializes the SDK.
@@ -120,59 +115,15 @@ public void run() {
120
115
*/
121
116
@ ReactMethod
122
117
public void init (final String token , final ReadableArray invocationEventValues , final String logLevel ) {
123
- MainThreadHandler .runOnMainThread (new Runnable () {
124
- @ Override
125
- public void run () {
126
- try {
127
- final ArrayList <String > keys = ArrayUtil .parseReadableArrayOfStrings (invocationEventValues );
128
- final ArrayList <InstabugInvocationEvent > parsedInvocationEvents = ArgsRegistry .invocationEvents .getAll (keys );
129
- final int parsedLogLevel = ArgsRegistry .sdkLogLevels .getOrDefault (logLevel , LogLevel .ERROR );
130
-
131
- setCurrentPlatform ();
132
- setBaseUrlForDeprecationLogs ();
133
-
134
- new Instabug .Builder (getCurrentActivity ().getApplication (), token )
135
- .setInvocationEvents (parsedInvocationEvents .toArray (new InstabugInvocationEvent [0 ]))
136
- .setSdkDebugLogsLevel (parsedLogLevel )
137
- .build ();
138
-
139
- // Temporarily disabling APM hot launches
140
- APM .setHotAppLaunchEnabled (false );
141
- } catch (Exception e ) {
142
- e .printStackTrace ();
143
- }
144
- }
118
+ MainThreadHandler .runOnMainThread (() -> {
119
+ final ArrayList <String > keys = ArrayUtil .parseReadableArrayOfStrings (invocationEventValues );
120
+ final ArrayList <InstabugInvocationEvent > parsedInvocationEvents = ArgsRegistry .invocationEvents .getAll (keys );
121
+ final InstabugInvocationEvent [] invocationEvents = parsedInvocationEvents .toArray (new InstabugInvocationEvent [0 ]);
122
+ final int parsedLogLevel = ArgsRegistry .sdkLogLevels .getOrDefault (logLevel , LogLevel .ERROR );
123
+ RNInstabug .getInstance ().init (getCurrentActivity ().getApplication (), token , parsedLogLevel , invocationEvents );
145
124
});
146
125
}
147
126
148
- private void setCurrentPlatform () {
149
- try {
150
- Method method = InstabugUtil .getMethod (Class .forName ("com.instabug.library.Instabug" ), "setCurrentPlatform" , int .class );
151
- if (method != null ) {
152
- Log .i ("IB-CP-Bridge" , "invoking setCurrentPlatform with platform: " + Platform .RN );
153
- method .invoke (null , Platform .RN );
154
- } else {
155
- Log .e ("IB-CP-Bridge" , "setCurrentPlatform was not found by reflection" );
156
- }
157
- } catch (Exception e ) {
158
- e .printStackTrace ();
159
- }
160
- }
161
-
162
- private void setBaseUrlForDeprecationLogs () {
163
- try {
164
- Method method = InstabugUtil .getMethod (Class .forName ("com.instabug.library.util.InstabugDeprecationLogger" ), "setBaseUrl" , String .class );
165
- if (method != null ) {
166
- method .invoke (null , "https://docs.instabug.com/docs/react-native-sdk-migration-guide" );
167
- }
168
- } catch (ClassNotFoundException e ) {
169
- e .printStackTrace ();
170
- } catch (IllegalAccessException e ) {
171
- e .printStackTrace ();
172
- } catch (InvocationTargetException e ) {
173
- e .printStackTrace ();
174
- }
175
- }
176
127
177
128
/**
178
129
* Adds tag(s) to issues before sending them
@@ -282,7 +233,7 @@ public void run() {
282
233
}
283
234
});
284
235
}
285
-
236
+
286
237
/**
287
238
* Gets tags.
288
239
*
@@ -576,7 +527,7 @@ public void run() {
576
527
}
577
528
});
578
529
}
579
-
530
+
580
531
/**
581
532
* Overrides any of the strings shown in the SDK with custom ones.
582
533
* Allows you to customize any of the strings shown to users in the SDK.
@@ -1076,4 +1027,4 @@ public Map<String, Object> getConstants() {
1076
1027
1077
1028
return constants ;
1078
1029
}
1079
- }
1030
+ }
0 commit comments