From 8f53340fc42e9abe3b607eb6327fd9e70301e64c Mon Sep 17 00:00:00 2001 From: Mateo Miccino Date: Thu, 19 Jan 2023 09:08:58 -0300 Subject: [PATCH] feat: add sentry integration (#460) --- .circleci/config.yml | 8 +- ci-playmode-test.sh | 3 + scripts/.gitignore | 130 +++++++ ...download-and-generate-renderer-protocol.sh | 46 +++ scripts/package-lock.json | 342 ++++++++++++++++++ scripts/package.json | 19 + scripts/src/inject-sentry-params.ts | 76 ++++ scripts/src/tsconfig.json | 26 ++ scripts/tsconfig.json | 30 ++ unity-renderer-desktop/Assets/Plugins.meta | 8 + .../Assets/Plugins/Sentry.meta | 8 + .../Plugins/Sentry/SentryCliOptions.asset | 21 ++ .../Sentry/SentryCliOptions.asset.meta | 8 + .../Assets/Resources/Sentry.meta | 8 + .../Resources/Sentry/SentryOptions.asset | 54 +++ .../Resources/Sentry/SentryOptions.asset.meta | 8 + unity-renderer-desktop/Packages/manifest.json | 1 + .../Packages/packages-lock.json | 7 + 18 files changed, 802 insertions(+), 1 deletion(-) create mode 100644 scripts/.gitignore create mode 100644 scripts/download-and-generate-renderer-protocol.sh create mode 100644 scripts/package-lock.json create mode 100644 scripts/package.json create mode 100644 scripts/src/inject-sentry-params.ts create mode 100644 scripts/src/tsconfig.json create mode 100644 scripts/tsconfig.json create mode 100644 unity-renderer-desktop/Assets/Plugins.meta create mode 100644 unity-renderer-desktop/Assets/Plugins/Sentry.meta create mode 100644 unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset create mode 100644 unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset.meta create mode 100644 unity-renderer-desktop/Assets/Resources/Sentry.meta create mode 100644 unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset create mode 100644 unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset.meta diff --git a/.circleci/config.yml b/.circleci/config.yml index fb7d3301..3b3f9bc8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -123,7 +123,7 @@ jobs: checkout: <<: *working_directory_root docker: - - image: cimg/base:2021.04 + - image: cimg/node:14.19.3-browsers steps: - run: name: Prepare image @@ -131,6 +131,12 @@ jobs: sudo apt-get update sudo apt-get install -y jq - checkout + - run: + name: Update sentry params + command: | + cd scripts + npm install + npm run inject-sentry-params # persist to workspace to use in downstream jobs - persist_to_workspace: diff --git a/ci-playmode-test.sh b/ci-playmode-test.sh index 5857d6f5..2e814bd9 100644 --- a/ci-playmode-test.sh +++ b/ci-playmode-test.sh @@ -4,6 +4,9 @@ source ci-setup.sh echo "Running playmode tests for $PROJECT_PATH" +# Disable Sentry +sed -i 's/k__BackingField: 1/k__BackingField: 0/' unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset + xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' $UNITY_PATH/Editor/Unity \ -batchmode \ -projectPath "$PROJECT_PATH" \ diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 00000000..c6bba591 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1,130 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/scripts/download-and-generate-renderer-protocol.sh b/scripts/download-and-generate-renderer-protocol.sh new file mode 100644 index 00000000..1302c21c --- /dev/null +++ b/scripts/download-and-generate-renderer-protocol.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -e + +install_proto() +{ + PROTOC_PATH=node_modules/.bin/protobuf/bin/protoc + if [[ ! -f "$PROTOC_PATH" ]]; then # Check if is instaled + PROTOBUF_VERSION=3.20.1 + + if [[ "$OSTYPE" == "darwin"* ]]; then + PROTOBUF_ZIP=protoc-${PROTOBUF_VERSION}-osx-x86_64.zip + else + PROTOBUF_ZIP=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip + fi + curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOBUF_ZIP} + mkdir -p node_modules/.bin/protobuf + unzip -o ${PROTOBUF_ZIP} -d node_modules/.bin/protobuf + rm ${PROTOBUF_ZIP} + + chmod +x "${PROTOC_PATH}" + fi + echo "${PROTOC_PATH}" # Return protoc path +} + +mkdir -p temp && cd temp +PROTOC=$(install_proto) +npm install @dcl/protocol@next +npm install protoc-gen-dclunity@next + +RENDERER_PROTOCOL_PATH=node_modules/@dcl/protocol/renderer-protocol/ +CODEGEN_PLUGIN_PATH=node_modules/protoc-gen-dclunity/dist/index.js +OUTPUT_PATH=unity-renderer/Assets/Scripts/MainScripts/DCL/WorldRuntime/KernelCommunication/RPC/GeneratedCode/ +mkdir -p ${OUTPUT_PATH} + + +PROTOS=$(find "${RENDERER_PROTOCOL_PATH}" -name '*.proto' -print) + +echo "Generating: " +echo ${PROTOS} + +PROTOC \ + --plugin=protoc-gen-dclunity="${CODEGEN_PLUGIN_PATH}" \ + --dclunity_out="${OUTPUT_PATH}" \ + --csharp_out="${OUTPUT_PATH}" \ + --csharp_opt=file_extension=.gen.cs \ + "${PROTOS}" \ No newline at end of file diff --git a/scripts/package-lock.json b/scripts/package-lock.json new file mode 100644 index 00000000..3fe287d4 --- /dev/null +++ b/scripts/package-lock.json @@ -0,0 +1,342 @@ +{ + "name": "do-not-publish", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "do-not-publish", + "version": "1.0.0", + "license": "Apache-2.0", + "devDependencies": { + "@types/node": "^14.14.35", + "ts-node": "^10.9.1", + "typescript": "^4.2.3" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", + "dev": true + }, + "node_modules/@types/node": { + "version": "14.18.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz", + "integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", + "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz", + "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==", + "dev": true + }, + "@types/node": { + "version": "14.18.36", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz", + "integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ==", + "dev": true + }, + "acorn": { + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "dev": true + }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + } + }, + "typescript": { + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", + "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", + "dev": true + }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + } + } +} diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 00000000..de1674c9 --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,19 @@ +{ + "name": "do-not-publish", + "version": "1.0.0", + "description": "", + "scripts": { + "inject-sentry-params": "ts-node --project src/tsconfig.json src/inject-sentry-params.ts" + }, + "private": true, + "keywords": [], + "author": "", + "license": "Apache-2.0", + "devDependencies": { + "@types/node": "^14.14.35", + "ts-node": "^10.9.1", + "typescript": "^4.2.3" + }, + "dependencies": { + } +} diff --git a/scripts/src/inject-sentry-params.ts b/scripts/src/inject-sentry-params.ts new file mode 100644 index 00000000..2f1bce83 --- /dev/null +++ b/scripts/src/inject-sentry-params.ts @@ -0,0 +1,76 @@ +import * as fs from 'node:fs' + +async function main() { + if (!process.env.CIRCLE_BRANCH) throw new Error('env var CIRCLE_BRANCH not set!') + if (!process.env.CIRCLE_SHA1) throw new Error('env var CIRCLE_SHA1 not set!') + if (!process.env.SENTRY_DSN) throw new Error('env var SENTRY_DSN not set!') + if (!process.env.SENTRY_AUTH_TOKEN) throw new Error('env var SENTRY_AUTH not set!') + + // Inject sentry environment parameters + + const fileToEdit = + '../unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset' + const fileContents = fs.readFileSync(fileToEdit).toString() + + let rendererEnvironment = 'editor' + + if (process.env.CIRCLE_BRANCH == 'main') { + rendererEnvironment = 'production' + } else if (process.env.CIRCLE_BRANCH == 'dev') { + rendererEnvironment = 'development' + } else { + rendererEnvironment = `branch` + } + + const searchParams = { + dsn: 'https://dsn.dsn/', + env: '', + release: '', + } + + for (const key in searchParams) { + const value = (searchParams as any)[key] + if (!fileContents.includes(value)) + throw new Error( + `the file ${fileToEdit} does not contain any ${value} string to replace`, + ) + } + + fs.writeFileSync( + fileToEdit, + fileContents + .replace(searchParams.dsn, process.env.SENTRY_DSN) + .replace(searchParams.env, rendererEnvironment) + .replace(searchParams.release, process.env.CIRCLE_SHA1) + ) + + // Inject CLI parameters for sources/symbols + const cliSearchParams = { + auth: '', + } + + const cliFileToEdit = + '../unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset' + const cliFileContents = fs.readFileSync(cliFileToEdit).toString() + + for (const key in cliSearchParams) { + const value = (cliSearchParams as any)[key] + if (!cliFileContents.includes(value)) + throw new Error( + `the file ${cliFileToEdit} does not contain any ${value} string to replace`, + ) + } + + fs.writeFileSync( + cliFileToEdit, + cliFileContents.replace( + cliSearchParams.auth, + process.env.SENTRY_AUTH_TOKEN, + ), + ) +} + +main().catch((err) => { + console.error(err) + process.exit(1) +}) diff --git a/scripts/src/tsconfig.json b/scripts/src/tsconfig.json new file mode 100644 index 00000000..27f6b388 --- /dev/null +++ b/scripts/src/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2016", + "noEmit": true, + "diagnostics": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "inlineSourceMap": false, + "inlineSources": false, + "sourceMap": true, + "declaration": true, + "declarationMap": true, + "moduleResolution": "node", + "stripInternal": true, + "resolveJsonModule": true, + "strict": true, + "pretty": true, + "forceConsistentCasingInFileNames": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "allowJs": true + } + } \ No newline at end of file diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 00000000..4523f562 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "ESNext", + "target": "es2020", + "noEmit": true, + "diagnostics": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "inlineSourceMap": false, + "inlineSources": false, + "sourceMap": true, + "declarationDir": "./dist", + "declaration": true, + "declarationMap": true, + "moduleResolution": "node", + "stripInternal": true, + "strict": true, + "pretty": true, + "forceConsistentCasingInFileNames": true, + "noUnusedParameters": true, + "noUnusedLocals": true, + "resolveJsonModule": true, + "types": [], + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "baseUrl": "src", + "allowJs": true + }, + "exclude": ["src"] +} \ No newline at end of file diff --git a/unity-renderer-desktop/Assets/Plugins.meta b/unity-renderer-desktop/Assets/Plugins.meta new file mode 100644 index 00000000..e92a2b60 --- /dev/null +++ b/unity-renderer-desktop/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4bc0f1a89b76a764d939bba8a56f783b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer-desktop/Assets/Plugins/Sentry.meta b/unity-renderer-desktop/Assets/Plugins/Sentry.meta new file mode 100644 index 00000000..222a165b --- /dev/null +++ b/unity-renderer-desktop/Assets/Plugins/Sentry.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b7684cb4354ad34e8c7255f8ea03b92 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset b/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset new file mode 100644 index 00000000..4f59e1b3 --- /dev/null +++ b/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset @@ -0,0 +1,21 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 582302131, guid: 7f7ea26e3243148e5ab9a7c58391af93, type: 3} + m_Name: SentryCliOptions + m_EditorClassIdentifier: + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: + k__BackingField: + k__BackingField: decentraland + k__BackingField: unity-renderer \ No newline at end of file diff --git a/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset.meta b/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset.meta new file mode 100644 index 00000000..1d536e4e --- /dev/null +++ b/unity-renderer-desktop/Assets/Plugins/Sentry/SentryCliOptions.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dc3ebb827b56ecb4bae889c629bb880d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer-desktop/Assets/Resources/Sentry.meta b/unity-renderer-desktop/Assets/Resources/Sentry.meta new file mode 100644 index 00000000..e4e1b9f5 --- /dev/null +++ b/unity-renderer-desktop/Assets/Resources/Sentry.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9bd46f14d7c57c94dac6b6d65197752a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset b/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset new file mode 100644 index 00000000..7d6d89c8 --- /dev/null +++ b/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset @@ -0,0 +1,54 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -668357930, guid: 43ec428a58422470fa764bdba9d9bc19, type: 3} + m_Name: SentryOptions + m_EditorClassIdentifier: + k__BackingField: 1 + k__BackingField: https://dsn.dsn/ + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 1 + k__BackingField: 30000 + k__BackingField: + k__BackingField: + k__BackingField: 1 + k__BackingField: 0 + k__BackingField: 1 + k__BackingField: 75 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 100 + k__BackingField: 1 + k__BackingField: 0 + k__BackingField: 0 + k__BackingField: 1 + k__BackingField: 30 + k__BackingField: 0 + k__BackingField: 1 + k__BackingField: 2000 + k__BackingField: 30 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: {fileID: 0} + k__BackingField: {fileID: 0} + k__BackingField: 1 + k__BackingField: 1 + k__BackingField: 2 \ No newline at end of file diff --git a/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset.meta b/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset.meta new file mode 100644 index 00000000..ca9f141d --- /dev/null +++ b/unity-renderer-desktop/Assets/Resources/Sentry/SentryOptions.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca55f40d52591924da6621cccdf67c29 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/unity-renderer-desktop/Packages/manifest.json b/unity-renderer-desktop/Packages/manifest.json index e494997c..e55ce7e7 100644 --- a/unity-renderer-desktop/Packages/manifest.json +++ b/unity-renderer-desktop/Packages/manifest.json @@ -18,6 +18,7 @@ "com.unity.textmeshpro": "3.2.0-pre.3", "com.unity.toolchain.linux-x86_64": "0.1.18-preview", "com.unity.ui": "2.0.0", + "io.sentry.unity": "https://github.com/getsentry/unity.git#0.27.0", "net.tnrd.nsubstitute": "https://github.com/decentraland/Unity3D-NSubstitute.git", "ru.threedisevenzeror.unitygifdecoder": "https://github.com/3DI70R/Unity-GifDecoder.git" }, diff --git a/unity-renderer-desktop/Packages/packages-lock.json b/unity-renderer-desktop/Packages/packages-lock.json index 9a75da8e..4dba04d6 100644 --- a/unity-renderer-desktop/Packages/packages-lock.json +++ b/unity-renderer-desktop/Packages/packages-lock.json @@ -377,6 +377,13 @@ }, "url": "https://packages.unity.com" }, + "io.sentry.unity": { + "version": "https://github.com/getsentry/unity.git#0.27.0", + "depth": 0, + "source": "git", + "dependencies": {}, + "hash": "b562146d739c6f99a76e2b4147a7e034e4344fa8" + }, "net.tnrd.nsubstitute": { "version": "https://github.com/decentraland/Unity3D-NSubstitute.git", "depth": 0,