-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(sample): Update new arch sample (#2853)
- add sample module (legacy) - make it compatible with legacy arch - clean up `before_send` console log - refactor sentry init options
- Loading branch information
1 parent
e73f4ed
commit 3d699fc
Showing
18 changed files
with
164 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.7.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions
42
...le-new-architecture/android/app/src/main/java/com/samplenewarchitecture/AssetsModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.samplenewarchitecture; | ||
import android.content.Context; | ||
|
||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.WritableArray; | ||
import com.facebook.react.bridge.WritableNativeArray; | ||
|
||
import java.io.InputStream; | ||
|
||
public class AssetsModule extends ReactContextBaseJavaModule { | ||
|
||
AssetsModule(ReactApplicationContext context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "AssetsModule"; | ||
} | ||
|
||
@ReactMethod | ||
public void getExampleAssetData(Promise promise) { | ||
try { | ||
InputStream stream = this.getReactApplicationContext().getResources().getAssets() | ||
.open("logo_mini.png"); | ||
int size = stream.available(); | ||
byte[] buffer = new byte[size]; | ||
stream.read(buffer); | ||
stream.close(); | ||
WritableArray array = new WritableNativeArray(); | ||
for (int i = 0; i < size; i++) { | ||
array.pushInt(buffer[i]); | ||
} | ||
promise.resolve(array); | ||
} catch (Exception e) { | ||
promise.reject(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...e-new-architecture/android/app/src/main/java/com/samplenewarchitecture/SamplePackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.samplenewarchitecture; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SamplePackage implements ReactPackage { | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules( | ||
ReactApplicationContext reactContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
|
||
modules.add(new AssetsModule(reactContext)); | ||
|
||
return modules; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export NODE_BINARY=$(command -v node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
sample-new-architecture/ios/sampleNewArchitecture/Images.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...tecture/ios/sampleNewArchitecture/Images.xcassets/ExampleBinaryData.dataset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"data" : [ | ||
{ | ||
"filename" : "logo_mini.png", | ||
"idiom" : "universal", | ||
"universal-type-identifier" : "image\/png" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+1.91 KB
...s/sampleNewArchitecture/Images.xcassets/ExampleBinaryData.dataset/logo_mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
sample-new-architecture/ios/sampleNewArchitecture/RCTAssetsModule.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#import <React/RCTBridgeModule.h> | ||
@interface RCTAssetsModule : NSObject <RCTBridgeModule> | ||
@end |
28 changes: 28 additions & 0 deletions
28
sample-new-architecture/ios/sampleNewArchitecture/RCTAssetsModule.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#import "RCTAssetsModule.h" | ||
|
||
@implementation RCTAssetsModule | ||
|
||
RCT_EXPORT_METHOD(getExampleAssetData: (RCTPromiseResolveBlock)resolve | ||
rejecter:(RCTPromiseRejectBlock)reject) | ||
{ | ||
NSDataAsset *data = [[NSDataAsset alloc] initWithName:@"ExampleBinaryData"]; | ||
if (data == nil) { | ||
reject(@"SampleSentryReactNative",@"Failed to load exmaple binary data asset.", nil); | ||
} | ||
|
||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:data.data.length]; | ||
|
||
const char *bytes = [data.data bytes]; | ||
|
||
for (int i = 0; i < [data.data length]; i++) | ||
{ | ||
[array addObject:[[NSNumber alloc] initWithChar:bytes[i]]]; | ||
} | ||
|
||
resolve(array); | ||
} | ||
|
||
RCT_EXPORT_MODULE(AssetsModule); | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ Sentry.init({ | |
// Replace the example DSN below with your own DSN: | ||
dsn: SENTRY_INTERNAL_DSN, | ||
debug: true, | ||
beforeSend: (event, hint) => { | ||
console.log('Event beforeSend:', event, 'hint:', hint); | ||
beforeSend: (event: Sentry.Event) => { | ||
console.log('Event beforeSend:', event); | ||
return event; | ||
}, | ||
// This will be called with a boolean `didCallNativeInit` when the native SDK has been contacted. | ||
|
@@ -59,11 +59,14 @@ Sentry.init({ | |
// This will capture ALL TRACES and likely use up all your quota | ||
tracesSampleRate: 1.0, | ||
attachStacktrace: true, | ||
// Attach screenshots to events. | ||
attachScreenshot: true, | ||
// Attach view hierarchy to events. | ||
attachViewHierarchy: true, | ||
// Sets the `release` and `dist` on Sentry events. Make sure this matches EXACTLY with the values on your sourcemaps | ||
// otherwise they will not work. | ||
// release: '[email protected]+1', | ||
// dist: `1`, | ||
attachViewHierarchy: true, | ||
}); | ||
|
||
const Stack = createStackNavigator(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters