Skip to content

Commit 116ff59

Browse files
Merge 1c0d3ef into 5fefdf7
2 parents 5fefdf7 + 1c0d3ef commit 116ff59

23 files changed

+1016
-104
lines changed

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313
!/android/**/*
1414
!src/js/NativeRNSentry.ts
1515
!scripts/collect-modules.sh
16+
!scripts/copy-debugid.js
17+
!scripts/hasSourceMapDebugId.js
18+
!scripts/hasSourceMapDebugId.js
19+
!scripts/sentry-xcode.sh
20+
!scripts/sentry-xcode-debug-files.sh

jest.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
collectCoverage: true,
3+
preset: 'react-native',
4+
setupFilesAfterEnv: ['<rootDir>/test/mockConsole.ts'],
5+
globals: {
6+
__DEV__: true,
7+
'ts-jest': {
8+
tsConfig: './tsconfig.json',
9+
diagnostics: false,
10+
},
11+
},
12+
moduleFileExtensions: ['ts', 'tsx', 'js'],
13+
testPathIgnorePatterns: ['<rootDir>/test/e2e/', '<rootDir>/test/tools/', '<rootDir>/test/react-native/versions'],
14+
testEnvironment: 'node',
15+
testMatch: ['**/*.test.(ts|tsx)'],
16+
};

jest.config.tools.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
collectCoverage: true,
3+
preset: 'ts-jest',
4+
setupFilesAfterEnv: ['<rootDir>/test/mockConsole.ts'],
5+
globals: {
6+
__DEV__: true,
7+
},
8+
testMatch: ['**/test/tools/**/*.ts'],
9+
transform: {
10+
'^.+\\.(ts|tsx)$': [
11+
'ts-jest',
12+
{
13+
tsconfig: './tsconfig.build.tools.json',
14+
diagnostics: false,
15+
},
16+
],
17+
},
18+
};

package.json

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"build:tools": "tsc -p tsconfig.build.tools.json",
2525
"downlevel": "downlevel-dts dist ts3.8/dist --to=3.8",
2626
"clean": "rimraf dist coverage",
27-
"test": "jest",
27+
"test": "yarn test:sdk && yarn test:tools",
28+
"test:sdk": "jest",
29+
"test:tools": "jest --config jest.config.tools.js",
2830
"fix": "yarn fix:eslint && yarn fix:prettier",
2931
"fix:eslint": "eslint --config .eslintrc.js --fix .",
3032
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
@@ -72,20 +74,23 @@
7274
"@sentry/wizard": "3.13.0",
7375
"@types/jest": "^29.5.3",
7476
"@types/react": "^18.2.14",
77+
"@types/uuid": "^9.0.4",
7578
"babel-jest": "^29.6.2",
7679
"downlevel-dts": "^0.11.0",
7780
"eslint": "^7.6.0",
7881
"eslint-plugin-react": "^7.20.6",
7982
"eslint-plugin-react-native": "^3.8.1",
8083
"jest": "^29.6.2",
8184
"jest-environment-jsdom": "^29.6.2",
85+
"metro": "0.76",
8286
"prettier": "^2.0.5",
8387
"react": "18.2.0",
8488
"react-native": "0.72.4",
8589
"replace-in-file": "^7.0.1",
8690
"rimraf": "^4.1.1",
8791
"ts-jest": "^29.1.1",
88-
"typescript": "4.9.5"
92+
"typescript": "4.9.5",
93+
"uuid": "^9.0.1"
8994
},
9095
"rnpm": {
9196
"commands": {},
@@ -95,33 +100,6 @@
95100
},
96101
"ios": {}
97102
},
98-
"jest": {
99-
"collectCoverage": true,
100-
"preset": "react-native",
101-
"setupFilesAfterEnv": [
102-
"<rootDir>/test/mockConsole.ts"
103-
],
104-
"globals": {
105-
"__DEV__": true,
106-
"ts-jest": {
107-
"tsConfig": "./tsconfig.json",
108-
"diagnostics": false
109-
}
110-
},
111-
"moduleFileExtensions": [
112-
"ts",
113-
"tsx",
114-
"js"
115-
],
116-
"testPathIgnorePatterns": [
117-
"<rootDir>/test/e2e/",
118-
"<rootDir>/test/react-native/versions"
119-
],
120-
"testEnvironment": "node",
121-
"testMatch": [
122-
"**/*.test.(ts|tsx)"
123-
]
124-
},
125103
"codegenConfig": {
126104
"name": "RNSentrySpec",
127105
"type": "modules",

sample-new-architecture/android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ project.ext.sentryCli = [
7474
"../..",
7575
],
7676
skipCollectModules: false,
77+
copyDebugIdScript: "../../../scripts/copy-debugid.js",
78+
hasSourceMapDebugIdScript: "../../../scripts/hasSourceMapDebugId.js",
7779
]
7880

7981
apply from: "../../../sentry.gradle"

sample-new-architecture/android/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# The setting is particularly useful for tweaking memory settings.
1212
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
1313
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14+
org.gradle.logging.level=lifecycle
1415

1516
# When configured, Gradle will run in incubating parallel mode.
1617
# This option should only be used with decoupled projects. More details, visit

sample-new-architecture/ios/.xcode.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@
99
# For example, to use nvm with brew, add the following line
1010
#. "$(brew --prefix nvm)/nvm.sh" --no-use
1111
export NODE_BINARY=$(command -v node)
12+
13+
export EXTRA_COMPILER_ARGS="-w"
14+
15+
export SENTRY_CLI_EXECUTABLE="../../node_modules/@sentry/cli/bin/sentry-cli"
16+
export SENTRY_CLI_EXTRA_ARGS="--force-foreground"
17+
export SENTRY_CLI_DEBUG_FILES_UPLOAD_EXTRA_ARGS=""
18+
export SENTRY_CLI_RN_XCODE_EXTRA_ARGS=""
19+
export MODULES_PATHS="$PWD/../node_modules,$PWD/../../.."

sample-new-architecture/ios/sampleNewArchitecture.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
);
272272
runOnlyForDeploymentPostprocessing = 0;
273273
shellPath = /bin/sh;
274-
shellScript = "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\n\nexport SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\n\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_CLI=\"../../node_modules/@sentry/cli/bin/sentry-cli\"\nBUNDLE_REACT_NATIVE=\"$SENTRY_CLI react-native xcode --force-foreground $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n\nexport MODULES_PATHS=\"$PWD/../node_modules,$PWD/../../..\"\nCOLLECT_MODULES=\"../../scripts/collect-modules.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$COLLECT_MODULES\\\"\"\n";
274+
shellScript = "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nBUNDLE_REACT_NATIVE=\"/bin/sh ../../scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$BUNDLE_REACT_NATIVE\\\"\"\n";
275275
};
276276
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
277277
isa = PBXShellScriptBuildPhase;
@@ -303,7 +303,7 @@
303303
);
304304
runOnlyForDeploymentPostprocessing = 0;
305305
shellPath = /bin/sh;
306-
shellScript = "set -e\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\n\nexport SENTRY_PROPERTIES=sentry.properties\n\n[[ $SENTRY_INCLUDE_NATIVE_SOURCES == \"true\" ]] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\nSENTRY_CLI=\"../../node_modules/@sentry/cli/bin/sentry-cli\"\nFLAGS=\"--force-foreground $INCLUDE_SOURCES_FLAG\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"$UPLOAD_DEBUG_FILES\\\"\"\n";
306+
shellScript = "#/bin/sh ../../scripts/sentry-xcode-debug-files.sh\n";
307307
};
308308
A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */ = {
309309
isa = PBXShellScriptBuildPhase;

sample-new-architecture/metro.config.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
22
const path = require('path');
33
const blacklist = require('metro-config/src/defaults/exclusionList');
44

5+
const {
6+
createSentryMetroSerializer,
7+
} = require('../dist/js/tools/sentryMetroSerializer');
58
const parentDir = path.resolve(__dirname, '..');
69

710
/**
@@ -41,6 +44,10 @@ const config = {
4144
},
4245
),
4346
},
47+
serializer: {
48+
customSerializer: createSentryMetroSerializer(),
49+
},
4450
};
4551

46-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
52+
const m = mergeConfig(getDefaultConfig(__dirname), config);
53+
module.exports = m;

scripts/copy-debugid.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const process = require('process');
2+
const fs = require('fs');
3+
4+
console.log('Copy `debugId` from packager source map to Hermes source map...');
5+
6+
const packagerSourceMapPath = process.argv[2];
7+
const hermesSourceMapPath = process.argv[3];
8+
9+
if (!packagerSourceMapPath) {
10+
console.log('Please provide packager source map path (A path to copy `debugId` from).');
11+
process.exit(0);
12+
}
13+
if (!hermesSourceMapPath) {
14+
console.log('Please provide Hermes source map path. ((A path to copy `debugId` to))');
15+
process.exit(0);
16+
}
17+
if (!fs.existsSync(packagerSourceMapPath)) {
18+
console.log('Packager source map path (A path to copy `debugId` from).');
19+
process.exit(0);
20+
}
21+
if (!fs.existsSync(hermesSourceMapPath)) {
22+
console.log('Hermes source map not found. ((A path to copy `debugId` to))');
23+
process.exit(0);
24+
}
25+
26+
const from = fs.readFileSync(process.argv[2], 'utf8');
27+
const to = fs.readFileSync(process.argv[3], 'utf8');
28+
29+
const fromParsed = JSON.parse(from);
30+
const toParsed = JSON.parse(to);
31+
32+
if (!fromParsed.debugId && !fromParsed.debug_id) {
33+
console.log('Packager source map does not have `debugId`.');
34+
process.exit(0);
35+
}
36+
37+
if (toParsed.debugId || toParsed.debug_id) {
38+
console.log('Hermes combined source map already has `debugId`.');
39+
process.exit(0);
40+
}
41+
42+
if (fromParsed.debugId) {
43+
toParsed.debugId = fromParsed.debugId;
44+
toParsed.debug_id = fromParsed.debugId;
45+
} else if (fromParsed.debug_id) {
46+
toParsed.debugId = fromParsed.debug_id;
47+
toParsed.debug_id = fromParsed.debug_id;
48+
}
49+
50+
fs.writeFileSync(process.argv[3], JSON.stringify(toParsed));
51+
52+
console.log('Done.');

0 commit comments

Comments
 (0)