@@ -988,6 +988,13 @@ private String readStringFromFile(File path) throws IOException {
988
988
}
989
989
}
990
990
991
+ public void fetchNativeLogAttributes (Promise promise ) {
992
+ final @ NotNull SentryOptions options = ScopesAdapter .getInstance ().getOptions ();
993
+ final @ Nullable Context context = this .getReactApplicationContext ().getApplicationContext ();
994
+ final @ Nullable IScope currentScope = InternalSentrySdk .getCurrentScope ();
995
+ fetchNativeLogContexts (promise , options , context , currentScope );
996
+ }
997
+
991
998
public void fetchNativeDeviceContexts (Promise promise ) {
992
999
final @ NotNull SentryOptions options = ScopesAdapter .getInstance ().getOptions ();
993
1000
final @ Nullable Context context = this .getReactApplicationContext ().getApplicationContext ();
@@ -1025,6 +1032,47 @@ protected void fetchNativeDeviceContexts(
1025
1032
promise .resolve (deviceContext );
1026
1033
}
1027
1034
1035
+ // Basically fetchNativeDeviceContexts but filtered to only get contexts info.
1036
+ protected void fetchNativeLogContexts (
1037
+ Promise promise ,
1038
+ final @ NotNull SentryOptions options ,
1039
+ final @ Nullable Context osContext ,
1040
+ final @ Nullable IScope currentScope ) {
1041
+ if (!(options instanceof SentryAndroidOptions ) || osContext == null ) {
1042
+ promise .resolve (null );
1043
+ return ;
1044
+ }
1045
+
1046
+ Object contextsObj =
1047
+ InternalSentrySdk .serializeScope (osContext , (SentryAndroidOptions ) options , currentScope )
1048
+ .get ("contexts" );
1049
+
1050
+ if (!(contextsObj instanceof Map )) {
1051
+ promise .resolve (null );
1052
+ return ;
1053
+ }
1054
+
1055
+ @ SuppressWarnings ("unchecked" )
1056
+ Map <String , Object > contextsMap = (Map <String , Object >) contextsObj ;
1057
+
1058
+ Map <String , Object > contextItems = new HashMap <>();
1059
+ if (contextsMap .containsKey ("os" )) {
1060
+ contextItems .put ("os" , contextsMap .get ("os" ));
1061
+ }
1062
+
1063
+ if (contextsMap .containsKey ("device" )) {
1064
+ contextItems .put ("device" , contextsMap .get ("device" ));
1065
+ }
1066
+
1067
+ contextItems .put ("release" , options .getRelease ());
1068
+
1069
+ Map <String , Object > logContext = new HashMap <>();
1070
+ logContext .put ("contexts" , contextItems );
1071
+ Object filteredContext = RNSentryMapConverter .convertToWritable (logContext );
1072
+
1073
+ promise .resolve (filteredContext );
1074
+ }
1075
+
1028
1076
public void fetchNativeSdkInfo (Promise promise ) {
1029
1077
final @ Nullable SdkVersion sdkVersion =
1030
1078
ScopesAdapter .getInstance ().getOptions ().getSdkVersion ();
0 commit comments