DataDog / expo-datadog

Datadog SDK for Expo
Apache License 2.0
8 stars 5 forks source link

JS Sourcemaps not getting uploaded #16

Open udeyrishi opened 10 months ago

udeyrishi commented 10 months ago

Describe what happened

I'm trying to configure DataDog for error monitoring for my Expo app per this guide. I have the iosDsyms and iosSourcemaps properties set to true for the expo-datadog plugin, and yet the errors on DD seem to be complaining that the JS sourcemaps are missing. The stack traces are not human-readable either.

Unminification failed: Upload your sourcemaps to see unminified stack traces

The build logs on EAS also just just mention the dSYM upload step; I don't see anything related to JS sourcemaps:

› Executing » Upload dSYMs to Datadog

Not sure if this is a bug in the expo plugin, or if something else is wrong with my build config, but starting here. Looking at my eas.json, there's nothing added there (e.g., buildArtifactPath, or other variables) that might change the stock behaviour of eas build.

Steps to reproduce the issue:

  1. Add the following to the plugins array in app.config.ts:
[
      "expo-datadog",
      {
        errorTracking: {
          iosDsyms: true,
          iosSourcemaps: true,
        },
      },
]
  1. Run eas build:
npx eas-cli build --profile <my_profile> --platform ios --auto-submit --non-interactive --no-wait

Describe what you expected:

That warning about the unminification having being failed to be gone, and the JS error stack traces to be more human readable.

Additional context

We currently ship just to iOS, so this issue is just focussed on that for now.

louiszawadzki commented 10 months ago

Hi @udeyrishi, thanks for reaching out!

Unfortunately we cannot reproduce the issue on our end. To help us troubleshoot, could you open the XCode Logs from your EAS build, then look for "Starting upload." (with the dot at the end). If you have a match, could you copy/paste the next few lines, including a block looking like:

Command summary:
✅ Uploaded 1 sourcemap in 0.594 seconds.

(You might not have a ✅ emoji in your case).

If you don't have a match, can you run the following steps:

Thanks a lot!

udeyrishi commented 10 months ago

Ah, I did have a match! Here you go:

+ HBC_SOURCEMAP_FILE=/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/KindredDEV.app/main.jsbundle.map
+ /Users/expo/.nvm/versions/node/v18.17.1/bin/node /Users/expo/workingdir/build/node_modules/react-native/scripts/compose-source-maps.js /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/main.jsbundle.map /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/KindredDEV.app/main.jsbundle.map -o /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/DerivedSources/main.jsbundle.map
[bundle script]: + rm /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/KindredDEV.app/main.jsbundle.map
[bundle script]: + rm /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/main.jsbundle.map
[bundle script]: + BUNDLE_FILE=/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/KindredDEV.app/main.jsbundle
[bundle script]: + [[ false != true ]]
+ [[ ! -f /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/KindredDEV.app/main.jsbundle ]]
Starting upload. 
Upload of /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/DerivedSources/main.jsbundle.map for bundle main.jsbundle on platform ios with project path /Users/expo/workingdir/build/ios
version: 2023.42.0 build: 51 service: com.livekindred-dev.app
Please ensure you use the same values during SDK initialization to guarantee the success of the unminify process.
After upload is successful sourcemap files will be processed and ready to use within the next 5 minutes. 
⚠️ An error occured while invoking git: Error: fatal: not a git repository (or any of the parent directories): .git

Make sure the command is running within your git repository to fully leverage Datadog's git integration.
To ignore this warning use the --disable-git flag.
Uploading sourcemap /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/DerivedSources/main.jsbundle.map for JS file main.jsbundle

Command summary:
✅ Uploaded 1 sourcemap in 1.331 seconds.

WriteAuxiliaryFile /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/Script-800E24972A6A228C8D4807E9.sh (in target 'KindredDEV' from project 'KindredDEV')
    cd /Users/expo/workingdir/build/ios
    write-file /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/Script-800E24972A6A228C8D4807E9.sh

PhaseScriptExecution [CP]\ Copy\ Pods\ Resources /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/Script-800E24972A6A228C8D4807E9.sh (in target 'KindredDEV' from project 'KindredDEV')
    cd /Users/expo/workingdir/build/ios
    /bin/sh -c /Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/IntermediateBuildFilesPath/KindredDEV.build/Release-iphoneos/KindredDEV.build/Script-800E24972A6A228C8D4807E9.sh
/Users/expo/workingdir/build/ios/Pods/CleverTap-iOS-SDK/CleverTapSDK/AmazonRootCA1.cer
/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/CleverTap-iOS-SDK/CleverTapSDK.bundle
/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/EXConstants/EXConstants.bundle
/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/EXUpdates/EXUpdates.bundle
/Users/expo/Library/Developer/Xcode/DerivedData/KindredDEV-exexzfecsdmdolfutjjmjsxrscin/Build/Intermediates.noindex/ArchiveIntermediates/KindredDEV/BuildProductsPath/Release-iphoneos/React-Core/AccessibilityResources.bundle
building file list ... done

This warning is interesting:

Please ensure you use the same values during SDK initialization to guarantee the success of the unminify process.

I don't see anything in the SDK initialization guide that requires me to explicitly set any versions, although I do see the DdSdkReactNativeConfiguration::version property for overriding it. Could it be that my sourcemaps are getting uploaded, they're just not getting linked correctly? Is there anywhere in the DataDog console where I can inspect the previously uploaded sourcemaps, and how they're being linked to specific versions?

louiszawadzki commented 10 months ago

Hi @udeyrishi,

Thanks for coming back to us so quickly. It seems that there's no issue in the upload itself. You don't have to set the version on DdSdkReactNativeConfiguration here as the upload script detects the version from your app and already ensures they are the same.

I recommend you to reach out to our support team as they will be able to check a lot more possible causes for the issue and you can more easily share private information about your project with them.

wcastand commented 5 months ago

we have the same issue (android or ios) the sourcemaps are listed on datadog but not linked properly to the errors.

export const config = new DatadogProviderConfiguration(
    Env.DATADOG_API_KEY,
    Env.DATADOG_ENV,
    Env.DATADOG_APP_ID,
    true, // track User interactions (e.g.: Tap on buttons. You can use 'accessibilityLabel' element property to give tap action the name, otherwise element type will be reported)
    true, // track XHR Resources
    true,
)

config.site = "EU1"
config.nativeCrashReportEnabled = true

export const onSDKInitialized = () => {
    DdSdkReactNative.setAttributes({
        appVersion: Constants.expoConfig?.version ?? "unknown",
    })
}
// app.config.js
[
            "expo-datadog",
            {
                errorTracking: {
                    iosDsyms: true,
                    iosSourcemaps: true,
                    androidSourcemaps: true,
                    androidProguardMappingFiles: true,
                },
            },
        ],

we don't have any error on the eas build and like i said the sourcemaps artefacts are listed on the datadog UI in Uploaded Debug Symbols for front-end applications

with the proper version / platform / etc but somehow not linked properly when in the error tracking (same as udeyrishi, i get the warning msg in the errors)

DavidLichy commented 4 months ago

We had the same issue and was able to fix by moving expo-datadog to the end of the plugins array to make sure the other build phases are present when the dd plugin generates the source map script.