diff --git a/.github/workflows/build_deps.yml b/.github/workflows/build_deps.yml index 6cd71744b1..b3d065236a 100644 --- a/.github/workflows/build_deps.yml +++ b/.github/workflows/build_deps.yml @@ -115,7 +115,7 @@ jobs: tar -czvf OrcaSlicer_dep_ubuntu_$(date +"%Y%m%d").tar.gz destdir - # Upload Artifacts + # Upload Artifacts (commented out to reduce artifact storage usage) # - name: Upload Mac ${{ inputs.arch }} artifacts # if: inputs.os == 'macos-14' # uses: actions/upload-artifact@v4 @@ -123,21 +123,21 @@ jobs: # name: OrcaSlicer_dep_mac_${{ env.date }} # path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.tar.gz - - name: Upload Windows artifacts - if: inputs.os == 'windows-latest' - uses: actions/upload-artifact@v4 - with: - name: OrcaSlicer_dep_win64_${{ env.date }} - path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.zip + # - name: Upload Windows artifacts + # if: inputs.os == 'windows-latest' + # uses: actions/upload-artifact@v4 + # with: + # name: OrcaSlicer_dep_win64_${{ env.date }} + # path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep*.zip - - name: Upload Ubuntu artifacts - if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} - env: - ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} - uses: actions/upload-artifact@v4 - with: - name: OrcaSlicer_dep_ubuntu_${{ env.ubuntu-ver }}_${{ env.date }} - path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep_ubuntu_*.tar.gz + # - name: Upload Ubuntu artifacts + # if: ${{ ! env.ACT && inputs.os == 'ubuntu-20.04' || inputs.os == 'ubuntu-24.04' }} + # env: + # ubuntu-ver: ${{ (inputs.os == 'ubuntu-20.04' && '2004') || (inputs.os == 'ubuntu-24.04' && '2404') || '' }} + # uses: actions/upload-artifact@v4 + # with: + # name: OrcaSlicer_dep_ubuntu_${{ env.ubuntu-ver }}_${{ env.date }} + # path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep_ubuntu_*.tar.gz build_orca: name: Build Snapmaker_Orca @@ -159,5 +159,6 @@ jobs: with: os: ${{ inputs.os }} pdb-artifact-name: PDB - release: ${{ github.sha }} + dsym-artifact-name: ${{ inputs.os == 'macos-14' && format('dSYM_Mac_{0}', needs.build_orca.outputs.release) || '' }} + release: ${{ needs.build_orca.outputs.release || github.sha }} secrets: inherit \ No newline at end of file diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index b9411fd28d..8b0489360a 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -13,6 +13,10 @@ on: arch: required: false type: string + outputs: + release: + description: "Release version/tag for the build" + value: ${{ jobs.build_orca.outputs.release }} jobs: build_orca: @@ -118,7 +122,7 @@ jobs: # Thanks to RaySajuuk, it's working now - name: Sign app and notary - if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || github.ref == 'refs/heads/2.2.0') && inputs.os == 'macos-14' + if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || github.ref == 'refs/heads/2.2.1') && inputs.os == 'macos-14' working-directory: ${{ github.workspace }} env: BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} @@ -171,7 +175,7 @@ jobs: fi - name: Create DMG without notary - if: github.ref != 'refs/heads/main' && inputs.os == 'macos-14' && github.ref != 'refs/heads/2.2.0' + if: github.ref != 'refs/heads/main' && inputs.os == 'macos-14' && github.ref != 'refs/heads/2.2.1' working-directory: ${{ github.workspace }} run: | mkdir -p ${{ github.workspace }}/build/universal/Snapmaker_Orca_dmg @@ -204,8 +208,16 @@ jobs: path: ${{ github.workspace }}/Snapmaker_Orca_profile_validator_Mac_universal_${{ env.ver }}.dmg if-no-files-found: ignore + - name: Upload dSYM artifacts mac + if: inputs.os == 'macos-14' + uses: actions/upload-artifact@v4 + with: + name: dSYM_Mac_${{ env.ver }} + path: ${{ github.workspace }}/build/universal/Snapmaker_Orca/dSYM + if-no-files-found: warn + - name: Deploy Mac release - if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.0') && inputs.os == 'macos-14' + if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.1') && inputs.os == 'macos-14' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} @@ -216,7 +228,7 @@ jobs: max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted - name: Check if profile validator DMG exists - if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.0') && inputs.os == 'macos-14' + if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.1') && inputs.os == 'macos-14' id: check_dmg working-directory: ${{ github.workspace }} run: | @@ -230,7 +242,7 @@ jobs: shell: bash - name: Deploy Mac Snapmaker_Orca_profile_validator DMG release - if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.0') && inputs.os == 'macos-14' && steps.check_dmg.outputs.exists == 'true' + if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.1') && inputs.os == 'macos-14' && steps.check_dmg.outputs.exists == 'true' uses: WebFreak001/deploy-nightly@v3.2.0 with: upload_url: https://uploads.github.com/repos/Snapmaker/OrcaSlicer/releases/169912305/assets{?name,label} @@ -374,7 +386,7 @@ jobs: chmod +x ./build/Snapmaker_Orca_Linux_AppImage${{ env.ubuntu-ver-str }}_${{ env.ver }}.AppImage - name: Build orca_custom_preset_tests - if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.0') && inputs.os == 'ubuntu-24.04' + if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.1') && inputs.os == 'ubuntu-24.04' working-directory: ${{ github.workspace }}/build/src/Release shell: bash run: | @@ -414,7 +426,7 @@ jobs: asset_content_type: application/octet-stream max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted - name: Deploy Ubuntu release - if: ${{ ! env.ACT && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.0') && inputs.os == 'ubuntu-24.04' }} + if: ${{ ! env.ACT && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/2.2.1') && inputs.os == 'ubuntu-24.04' }} uses: rickstaa/action-create-tag@v1 with: tag: "nightly-builds" diff --git a/.github/workflows/sentry_cli.yml b/.github/workflows/sentry_cli.yml index 0693fab2a0..3470cb0fca 100644 --- a/.github/workflows/sentry_cli.yml +++ b/.github/workflows/sentry_cli.yml @@ -11,6 +11,10 @@ on: required: false type: string description: "Artifact name for Windows PDB archive (e.g., 'PDB')" + dsym-artifact-name: + required: false + type: string + description: "Artifact name for macOS dSYM archive (e.g., 'dSYM_Mac_V1.0.0')" release: required: true type: string @@ -86,7 +90,78 @@ jobs: } # ==================== macOS ==================== + - name: "[macOS] Install sentry-cli" + if: inputs.os == 'macos-14' + run: | + # Try multiple installation methods for reliability + # Method 1: Official install script (most reliable) + if ! command -v sentry-cli &> /dev/null; then + echo "Installing sentry-cli via official script..." + curl -sL https://sentry.io/get-cli/ | bash || true + fi + + # Method 2: npm fallback + if ! command -v sentry-cli &> /dev/null; then + echo "Official script failed, trying npm..." + npm install -g @sentry/cli || true + fi + + # Method 3: Direct binary download fallback + if ! command -v sentry-cli &> /dev/null; then + echo "npm failed, downloading binary directly..." + SENTRY_CLI_VERSION=$(curl -s https://api.github.com/repos/getsentry/sentry-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + curl -sL "https://github.com/getsentry/sentry-cli/releases/download/${SENTRY_CLI_VERSION}/sentry-cli-Darwin-universal" -o /usr/local/bin/sentry-cli + chmod +x /usr/local/bin/sentry-cli + fi + + # Verify installation + if command -v sentry-cli &> /dev/null; then + echo "sentry-cli installed successfully:" + sentry-cli --version + else + echo "::error::Failed to install sentry-cli via all methods" + exit 1 + fi + - name: "[macOS] Download dSYM artifact" + if: inputs.os == 'macos-14' + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.dsym-artifact-name }} + path: ./symbols + + - name: "[macOS] Upload dSYM to Sentry (sentry-cli)" + if: inputs.os == 'macos-14' + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_LOG_LEVEL: debug + run: | + echo "Checking for dSYM files in ./symbols..." + find ./symbols -name "*.dSYM" -type d | while read dsym; do + echo "Found dSYM: $dsym" + done + + dsymCount=$(find ./symbols -name "*.dSYM" -type d | wc -l | tr -d ' ') + if [ "$dsymCount" -gt 0 ]; then + echo "Found $dsymCount dSYM file(s) to upload from ./symbols:" + find ./symbols -name "*.dSYM" -type d | while read dsym; do + echo " - $dsym" + done + echo "" + echo "Starting Sentry upload with debug logging..." + # upload-dif does not support --release flag, it auto-associates with releases + sentry-cli --log-level=debug --auth-token "$SENTRY_AUTH_TOKEN" upload-dif --org "${{ secrets.SENTRY_ORG }}" --project "${{ secrets.SENTRY_PROJECT }}" ./symbols + UPLOAD_EXIT_CODE=$? + if [ $UPLOAD_EXIT_CODE -ne 0 ]; then + echo "::error::Sentry upload failed with exit code $UPLOAD_EXIT_CODE" + exit 1 + fi + else + echo "::error::No dSYM files found in ./symbols" + echo "Contents of ./symbols:" + find ./symbols -type f -o -type d | head -20 + exit 1 + fi # ==================== Linux ==================== diff --git a/CMakeLists.txt b/CMakeLists.txt index cc83da3582..590cbb2645 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -404,6 +404,13 @@ endif () if (APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=partial-availability -Werror=unguarded-availability -Werror=unguarded-availability-new") + + # Generate debug symbols for Release builds on macOS (required for dSYM generation and Sentry crash reporting) + # This adds -g flag to produce DWARF debug info that dsymutil can extract + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -g") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -g") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g") endif () if(MSVC) diff --git a/build_release_macos.sh b/build_release_macos.sh index 59152caccd..16d86e36a5 100755 --- a/build_release_macos.sh +++ b/build_release_macos.sh @@ -265,39 +265,38 @@ function build_slicer() { find ./Snapmaker_Orca_profile_validator.app/ -name '.DS_Store' -delete fi - # Generate dSYM debug symbols for Sentry crash reporting - if [ "$SLIC3R_SENTRY" = "1" ]; then - echo "Generating dSYM debug symbols..." - DSYM_DIR="./dSYM" - mkdir -p "${DSYM_DIR}" - - # Generate dSYM for main app - if [ -f "${APP_MACOS_DIR}/Snapmaker_Orca" ]; then - echo "Generating dSYM for Snapmaker_Orca..." - dsymutil "${APP_MACOS_DIR}/Snapmaker_Orca" -o "${DSYM_DIR}/Snapmaker_Orca.dSYM" - fi - - # Generate dSYM for crashpad_handler if it exists - if [ -f "${APP_MACOS_DIR}/crashpad_handler" ]; then - echo "Generating dSYM for crashpad_handler..." - dsymutil "${APP_MACOS_DIR}/crashpad_handler" -o "${DSYM_DIR}/crashpad_handler.dSYM" - fi - - # Generate dSYM for libsentry.dylib if it exists - if [ -f "${APP_FRAMEWORKS_DIR}/libsentry.dylib" ]; then - echo "Generating dSYM for libsentry.dylib..." - dsymutil "${APP_FRAMEWORKS_DIR}/libsentry.dylib" -o "${DSYM_DIR}/libsentry.dSYM" - fi - - # Generate dSYM for profile_validator if it exists - if [ -f "./Snapmaker_Orca_profile_validator.app/Contents/MacOS/Snapmaker_Orca_profile_validator" ]; then - echo "Generating dSYM for Snapmaker_Orca_profile_validator..." - dsymutil "./Snapmaker_Orca_profile_validator.app/Contents/MacOS/Snapmaker_Orca_profile_validator" -o "${DSYM_DIR}/Snapmaker_Orca_profile_validator.dSYM" - fi - - echo "dSYM files generated in ${DSYM_DIR}" - ls -la "${DSYM_DIR}" + # Generate dSYM debug symbols for debugging and Sentry crash reporting + # Always generate dSYM files - they are useful for crash analysis even without Sentry + echo "Generating dSYM debug symbols..." + DSYM_DIR="./dSYM" + mkdir -p "${DSYM_DIR}" + + # Generate dSYM for main app + if [ -f "${APP_MACOS_DIR}/Snapmaker_Orca" ]; then + echo "Generating dSYM for Snapmaker_Orca..." + dsymutil "${APP_MACOS_DIR}/Snapmaker_Orca" -o "${DSYM_DIR}/Snapmaker_Orca.dSYM" 2>/dev/null || echo "Warning: Failed to generate dSYM for Snapmaker_Orca (no debug symbols?)" fi + + # Generate dSYM for crashpad_handler if it exists + if [ -f "${APP_MACOS_DIR}/crashpad_handler" ]; then + echo "Generating dSYM for crashpad_handler..." + dsymutil "${APP_MACOS_DIR}/crashpad_handler" -o "${DSYM_DIR}/crashpad_handler.dSYM" 2>/dev/null || true + fi + + # Generate dSYM for libsentry.dylib if it exists + if [ -f "${APP_FRAMEWORKS_DIR}/libsentry.dylib" ]; then + echo "Generating dSYM for libsentry.dylib..." + dsymutil "${APP_FRAMEWORKS_DIR}/libsentry.dylib" -o "${DSYM_DIR}/libsentry.dSYM" 2>/dev/null || true + fi + + # Generate dSYM for profile_validator if it exists + if [ -f "./Snapmaker_Orca_profile_validator.app/Contents/MacOS/Snapmaker_Orca_profile_validator" ]; then + echo "Generating dSYM for Snapmaker_Orca_profile_validator..." + dsymutil "./Snapmaker_Orca_profile_validator.app/Contents/MacOS/Snapmaker_Orca_profile_validator" -o "${DSYM_DIR}/Snapmaker_Orca_profile_validator.dSYM" 2>/dev/null || true + fi + + echo "dSYM files generated in ${DSYM_DIR}" + ls -la "${DSYM_DIR}" 2>/dev/null || echo "No dSYM files generated" ) # extract version @@ -394,39 +393,37 @@ function build_universal() { echo "Universal binary for Snapmaker_Orca_profile_validator created at $UNIVERSAL_VALIDATOR_APP" fi - # Generate dSYM for universal binary if Sentry is enabled - if [ "$SLIC3R_SENTRY" = "1" ]; then - echo "Generating dSYM for universal binary..." - DSYM_DIR="$PROJECT_BUILD_DIR/Snapmaker_Orca/dSYM" - mkdir -p "${DSYM_DIR}" - - # Generate dSYM for universal main app - if [ -f "$UNIVERSAL_APP/$BINARY_PATH" ]; then - echo "Generating dSYM for universal Snapmaker_Orca..." - dsymutil "$UNIVERSAL_APP/$BINARY_PATH" -o "${DSYM_DIR}/Snapmaker_Orca.dSYM" - fi - - # Generate dSYM for universal crashpad_handler if it exists - if [ -f "$UNIVERSAL_APP/Contents/MacOS/crashpad_handler" ]; then - echo "Generating dSYM for universal crashpad_handler..." - dsymutil "$UNIVERSAL_APP/Contents/MacOS/crashpad_handler" -o "${DSYM_DIR}/crashpad_handler.dSYM" - fi - - # Generate dSYM for universal libsentry.dylib if it exists - if [ -f "$UNIVERSAL_APP/Contents/Frameworks/libsentry.dylib" ]; then - echo "Generating dSYM for universal libsentry.dylib..." - dsymutil "$UNIVERSAL_APP/Contents/Frameworks/libsentry.dylib" -o "${DSYM_DIR}/libsentry.dSYM" - fi - - # Generate dSYM for universal profile_validator if it exists - if [ -f "$UNIVERSAL_VALIDATOR_APP/$VALIDATOR_BINARY_PATH" ]; then - echo "Generating dSYM for universal Snapmaker_Orca_profile_validator..." - dsymutil "$UNIVERSAL_VALIDATOR_APP/$VALIDATOR_BINARY_PATH" -o "${DSYM_DIR}/Snapmaker_Orca_profile_validator.dSYM" - fi - - echo "Universal dSYM files generated in ${DSYM_DIR}" - ls -la "${DSYM_DIR}" + # Generate dSYM for universal binary - always generate for debugging and Sentry crash reporting + echo "Generating dSYM for universal binary..." + DSYM_DIR="$PROJECT_BUILD_DIR/Snapmaker_Orca/dSYM" + mkdir -p "${DSYM_DIR}" + + # Generate dSYM for universal main app + if [ -f "$UNIVERSAL_APP/$BINARY_PATH" ]; then + echo "Generating dSYM for universal Snapmaker_Orca..." + dsymutil "$UNIVERSAL_APP/$BINARY_PATH" -o "${DSYM_DIR}/Snapmaker_Orca.dSYM" 2>/dev/null || echo "Warning: Failed to generate dSYM for universal Snapmaker_Orca" fi + + # Generate dSYM for universal crashpad_handler if it exists + if [ -f "$UNIVERSAL_APP/Contents/MacOS/crashpad_handler" ]; then + echo "Generating dSYM for universal crashpad_handler..." + dsymutil "$UNIVERSAL_APP/Contents/MacOS/crashpad_handler" -o "${DSYM_DIR}/crashpad_handler.dSYM" 2>/dev/null || true + fi + + # Generate dSYM for universal libsentry.dylib if it exists + if [ -f "$UNIVERSAL_APP/Contents/Frameworks/libsentry.dylib" ]; then + echo "Generating dSYM for universal libsentry.dylib..." + dsymutil "$UNIVERSAL_APP/Contents/Frameworks/libsentry.dylib" -o "${DSYM_DIR}/libsentry.dSYM" 2>/dev/null || true + fi + + # Generate dSYM for universal profile_validator if it exists + if [ -f "$UNIVERSAL_VALIDATOR_APP/$VALIDATOR_BINARY_PATH" ]; then + echo "Generating dSYM for universal Snapmaker_Orca_profile_validator..." + dsymutil "$UNIVERSAL_VALIDATOR_APP/$VALIDATOR_BINARY_PATH" -o "${DSYM_DIR}/Snapmaker_Orca_profile_validator.dSYM" 2>/dev/null || true + fi + + echo "Universal dSYM files generated in ${DSYM_DIR}" + ls -la "${DSYM_DIR}" 2>/dev/null || echo "No dSYM files generated" } case "${BUILD_TARGET}" in diff --git a/deps/Sentry/Sentry.cmake b/deps/Sentry/Sentry.cmake index f636281dbe..138580b24f 100644 --- a/deps/Sentry/Sentry.cmake +++ b/deps/Sentry/Sentry.cmake @@ -82,6 +82,7 @@ endif() Snapmaker_Orca_add_cmake_project(Sentry GIT_REPOSITORY https://github.com/getsentry/sentry-native.git GIT_TAG 0.12.1 + GIT_SHALLOW ON PATCH_COMMAND ${SENTRY_PATCH_COMMAND} CMAKE_ARGS ${_sentry_cmake_generator} diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index 03399d72d1..0b2224adb5 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -26,11 +26,25 @@ #include #include +#include namespace Slic3r { #ifdef SLIC3R_SENTRY +#define SENTRY_EVENT_TRACE "trace" +#define SENTRY_EVENT_DEBUG "info" +#define SENTRY_EVENT_INFO "debug" +#define SENTRY_EVENT_WARNING "warning" +#define SENTRY_EVENT_ERROR "error" +#define SENTRY_EVENT_FATAL "fatal" + +#define MACHINE_MODULE "Moonraker_Mqtt" + +#define SENTRY_KEY_LEVEL "level" + + + static sentry_value_t on_crash_callback(const sentry_ucontext_t* uctx, sentry_value_t event, void* closure) { (void) uctx; @@ -40,17 +54,69 @@ static sentry_value_t on_crash_callback(const sentry_ucontext_t* uctx, sentry_va return event; } +static sentry_value_t before_send(sentry_value_t event, void* hint, void* data) +{ + sentry_value_t level_val = sentry_value_get_by_key(event, SENTRY_KEY_LEVEL); + + std::string eventLevel = sentry_value_as_string(sentry_value_get_by_key(event, SENTRY_KEY_LEVEL)); + + //module name + sentry_value_t logger_val = sentry_value_get_by_key(event, "logger"); + std::string logger = sentry_value_as_string(logger_val); + + if (MACHINE_MODULE == logger) + { + srand((unsigned int) time(0)); + int random_num = rand() % 100; + int randNumber = rand() % 100 + 1; + if (randNumber < 85) + { + sentry_value_decref(event); + return sentry_value_new_null(); + } + else + { + return event; + } + } + + if (SENTRY_EVENT_FATAL == eventLevel || + SENTRY_EVENT_ERROR == eventLevel || + SENTRY_EVENT_TRACE == eventLevel) + { + return event; + } + else if (SENTRY_EVENT_WARNING == eventLevel) + { + srand((unsigned int) time(0)); + int random_num = rand() % 100; + int randNumber = rand() % 100 + 1; + if (randNumber > 5) + { + sentry_value_decref(event); + return sentry_value_new_null(); + } + else + { + return event; + } + } + + //info trace debug not report + sentry_value_decref(event); + return sentry_value_new_null(); + +} + void initSentryEx() { sentry_options_t* options = sentry_options_new(); - std::string dsn = ""; + std::string dsn = std::string("https://c74b617c2aedc291444d3a238d23e780@o4508125599563776.ingest.us.sentry.io/4510425163956224"); { -#ifdef __APPLE__ - - std::string dsn = std::string("https://ac473187efb8877f36bd31694ffd5dec@o4508125599563776.ingest.us.sentry.io/4510425212059648"); +#ifdef __APPLE__ #elif _WIN32 - std::string dsn = std::string("https://c74b617c2aedc291444d3a238d23e780@o4508125599563776.ingest.us.sentry.io/4510425163956224"); + #endif sentry_options_set_dsn(options, dsn.c_str()); std::string handlerDir = ""; @@ -130,7 +196,7 @@ void initSentryEx() sentry_options_set_auto_session_tracking(options, 0); sentry_options_set_symbolize_stacktraces(options, 1); sentry_options_set_on_crash(options, on_crash_callback, NULL); - sentry_options_set_before_send(options, NULL, NULL); + sentry_options_set_before_send(options, before_send, NULL); sentry_options_set_sample_rate(options, 1.0); sentry_options_set_traces_sample_rate(options, 1.0); @@ -138,6 +204,7 @@ void initSentryEx() sentry_init(options); sentry_start_session(); + //sentryReportLog(SENTRY_LOG_ERROR, "init sentry error", "initSentry module"); } } @@ -181,9 +248,13 @@ void sentryReportLogEx(SENTRY_LOG_LEVEL logLevel, funcModule.c_str(), logContent.c_str() ); + + if (!logTraceId.empty()) + { + sentry_value_t tags = sentry_value_get_by_key(event, "snapmaker_tags"); + sentry_value_set_by_key(tags, "snapmaker_trace_id", sentry_value_new_string(logTraceId.c_str())); + } - if (!logTraceId.empty()) - sentry_set_trace(logTraceId.c_str(), ""); if (!logTagKey.empty()) sentry_set_tag(logTagKey.c_str(), logTagValue.c_str());