DataDog / dd-sdk-reactnative

Datadog SDK for ReactNative
Apache License 2.0
115 stars 41 forks source link

Batch (RUM Request) failed because your token is invalid - after app upgrade #722

Closed ncpa0cpl closed 2 weeks ago

ncpa0cpl commented 2 weeks ago

Describe the bug

After performing apk upgrade to a new version, DD logs don't make it out to the DataDog servers and can't be seen in the log explorer. The error messages in the logcat report a invalid token, but that cannot be the case as the token in this app is hardcoded right into the config and didn't change in the newer version.

Newer apk version is using @datadog/mobile-react-native at version 2.4.3, while the old apk has that package at version 2.3.6, though I am not sure if this is relevant as I also tried to downgrade this package to the previous version and am still experiencing this issue.

Curiously I tested upgrading on two devices, one with Android 10 and one with Android 12. This problem only occurs on the Android 12, on 10 it works without any problems.

Also, I am not sure it this is relevant at all but I am always performing the upgrade while the app is running in the foreground (since this is how it will always be performed in the production).

I'd appreciate any help as this is a blocker that prevents us from releasing the new version of our app.

Reproduction steps

Upgrade apk to a newer version

SDK logs

09-05 14:41:21.074  4234  4271 D v5.d    : SdkCore was not set in DatadogSDKWrapperStorage, using default instance.
09-05 14:41:21.080  4234  4271 W Datadog : The Datadog library has already been initialized.
09-05 14:41:21.158  4234  4279 W Datadog : [_dd.sdk_core.default]: tag "version:***" was modified to "version:***" to match our constraints.
09-05 14:41:32.546  4234  4285 E Datadog : [_dd.sdk_core.default]: Batch *** [18462 bytes] (RUM Request) failed because your token is invalid; the batch was dropped. Make sure that the provided token still exists and you're targeting the relevant Datadog site.
09-05 14:41:32.682  4234  4285 E Datadog : [_dd.sdk_core.default]: Batch *** [26932 bytes] (Logs Request) failed because your token is invalid; the batch was dropped. Make sure that the provided token still exists and you're targeting the relevant Datadog site.

Expected behavior

No response

Affected SDK versions

2.3.6

Latest working SDK version

don't know

Did you confirm if the latest SDK version fixes the bug?

Yes

Integration Methods

Yarn

React Native Version

0.74.5

Package.json Contents

{
  "dependencies": {
    "@datadog/mobile-react-native": "2.4.3",
    "@pusher/pusher-websocket-react-native": "1.3.1",
    "@react-native-async-storage/async-storage": "1.24.0",
    "@react-native-community/netinfo": "11.3.2",
    "@react-native-cookies/cookies": "6.2.1",
    "@react-native/metro-config": "0.74.87",
    "@react-navigation/drawer": "6.7.2",
    "@react-navigation/native": "6.1.18",
    "@react-navigation/stack": "6.4.1",
    "@reduxjs/toolkit": "2.2.5",
    "@touchbistro/bill-processor": "0.0.68",
    "@touchbistro/vcs-client": "0.463.0",
    "async-await-queue": "2.1.4",
    "axios": "1.7.3",
    "class-validator": "0.14.1",
    "decimal.js": "10.4.3",
    "eventemitter3": "5.0.1",
    "i18next": "23.12.2",
    "identifierfy": "2.0.0",
    "ipaddr.js": "2.2.0",
    "launchdarkly-react-native-client-sdk": "9.3.0",
    "lodash": "4.17.21",
    "luxon": "3.5.0",
    "react": "18.3.1",
    "react-i18next": "15.0.1",
    "react-native": "0.74.5",
    "react-native-background-timer": "2.4.1",
    "react-native-bcrypt": "2.4.0",
    "react-native-date-picker": "5.0.4",
    "react-native-device-info": "11.1.0",
    "react-native-dropdown-picker": "5.4.6",
    "react-native-flipper": "0.212.0",
    "react-native-gesture-handler": "2.16.2",
    "react-native-get-random-values": "1.11.0",
    "react-native-immersive-mode": "2.0.2",
    "react-native-json-tree": "1.3.0",
    "react-native-keyboard-aware-scroll-view": "0.9.5",
    "react-native-keychain": "8.2.0",
    "react-native-reanimated": "3.14.0",
    "react-native-reanimated-table": "0.0.2",
    "react-native-safe-area-context": "4.10.8",
    "react-native-screens": "3.34.0",
    "react-native-sound": "0.11.2",
    "react-native-sqlite-storage": "6.0.1",
    "react-native-star-io10": "1.4.0",
    "react-native-svg": "15.5.0",
    "react-native-svg-transformer": "1.5.0",
    "react-native-swipe-list-view": "3.2.9",
    "react-native-url-polyfill": "2.0.0",
    "react-native-webview": "13.10.5",
    "react-redux": "9.1.2",
    "redux": "5.0.1",
    "redux-thunk": "3.1.0",
    "tsconfig-paths": "4.2.0",
    "typeorm": "0.3.20",
    "uuid": "10.0.0"
  },
  "devDependencies": {
    "@babel/core": "7.25.2",
    "@babel/eslint-parser": "7.25.1",
    "@babel/plugin-proposal-decorators": "7.24.7",
    "@babel/plugin-proposal-logical-assignment-operators": "7.20.7",
    "@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
    "@babel/plugin-proposal-optional-chaining": "7.21.0",
    "@babel/preset-env": "7.25.3",
    "@babel/preset-typescript": "7.24.7",
    "@babel/runtime": "7.25.0",
    "@datadog/datadog-ci": "2.41.0",
    "@react-native/babel-preset": "0.74.87",
    "@react-native/codegen": "0.74.87",
    "@react-native/gradle-plugin": "0.74.87",
    "@react-native/typescript-config": "0.74.87",
    "@side/jest-runtime": "1.1.0",
    "@swc/core": "1.7.6",
    "@swc/jest": "0.2.36",
    "@testing-library/jest-native": "5.4.3",
    "@testing-library/react-hooks": "8.0.1",
    "@testing-library/react-native": "12.5.1",
    "@touchbistro/danger-plugin": "0.7.1",
    "@touchbistro/node-locale": "2.0.4",
    "@types/better-sqlite3": "7.6.11",
    "@types/jest": "29.5.12",
    "@types/lodash": "4.17.7",
    "@types/luxon": "3.4.2",
    "@types/module-alias": "2.0.4",
    "@types/react": "18.3.3",
    "@types/react-native": "0.73.0",
    "@types/react-native-background-timer": "2.0.2",
    "@types/react-native-bcrypt": "2.4.6",
    "@types/react-native-dotenv": "0.2.2",
    "@types/react-native-sqlite-storage": "6.0.5",
    "@types/react-native-table-component": "1.2.8",
    "@types/react-redux": "7.1.33",
    "@types/react-test-renderer": "18.3.0",
    "@types/redux-mock-store": "1.0.6",
    "@types/uuid": "10.0.0",
    "@typescript-eslint/eslint-plugin": "7.13.0",
    "@typescript-eslint/parser": "7.13.0",
    "babel-jest": "29.7.0",
    "babel-plugin-import-glob": "2.0.0",
    "babel-plugin-module-resolver": "5.0.2",
    "babel-plugin-transform-remove-console": "6.9.4",
    "babel-plugin-transform-typescript-metadata": "0.3.2",
    "better-sqlite3": "11.1.2",
    "chalk": "5.3.0",
    "commander": "12.1.0",
    "danger": "12.3.3",
    "eslint": "8.57.0",
    "eslint-config-prettier": "9.1.0",
    "eslint-plugin-jest": "28.6.0",
    "eslint-plugin-jsdoc": "48.2.12",
    "eslint-plugin-prettier": "5.1.3",
    "eslint-plugin-promise": "6.2.0",
    "eslint-plugin-react": "7.34.2",
    "eslint-plugin-react-hooks": "4.6.2",
    "eslint-plugin-react-native": "4.1.0",
    "eslint-plugin-simple-import-sort": "12.1.1",
    "jest": "29.7.0",
    "jest-config": "29.7.0",
    "jest-junit": "16.0.0",
    "jest-websocket-mock": "2.5.0",
    "mock-async-storage": "2.9.0",
    "module-alias": "2.2.3",
    "patch-package": "8.0.0",
    "postinstall-postinstall": "2.1.0",
    "prettier": "3.3.3",
    "prettier-plugin-jsdoc": "1.3.0",
    "react-native-dotenv": "3.4.11",
    "react-test-renderer": "18.3.1",
    "redux-flipper": "2.0.3",
    "redux-mock-store": "1.5.4",
    "string.prototype.replaceall": "1.0.10",
    "swc_mut_cjs_exports": "0.99.0",
    "ts-node": "10.9.2",
    "typescript": "5.5.4"
  },
  "resolutions": {
    "jest": "29.7.0",
    "jest-config": "29.7.0",
    "react": "18.3.1",
    "react-native": "0.74.5",
    "react-native-reanimated": "3.14.0",
    "@types/react": "18.3.3",
    "@types/react-native": "0.73.0"
  },
  "packageManager": "yarn@1.22.19"
}

iOS Setup

No response

Android Setup

No response

Device Information

No response

Other relevant information

No response

ncpa0cpl commented 2 weeks ago

It seems that we had a Native Module in Java, which I wasn't aware of, that was setting up the DD client separately from the rest of the app, and it had been provided with a incorrect token. (hence the The Datadog library has already been initialized error)