aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

aws pinpoint does not record events after react native upgrade #12207

Closed konampruthvirajkumar closed 10 months ago

konampruthvirajkumar commented 11 months ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Analytics

Amplify Categories

analytics

Environment information

System: OS: macOS 13.6 CPU: (10) arm64 Apple M1 Pro Memory: 128.89 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.14.2 - /usr/local/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 9.5.0 - /usr/local/bin/npm Watchman: 2023.07.10.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 117.0.5938.149 Edge: 117.0.2045.47 Safari: 16.6 npmPackages: @babel/core: ^7.20.0 => 7.22.11 @babel/preset-env: ^7.20.0 => 7.22.10 @babel/runtime: ^7.20.0 => 7.22.11 @dynatrace/react-native-plugin: ^2.273.1 => 2.273.1 @fullstory/react-native: ^1.2.1 => 1.2.1 @okta/okta-react-native: 2.6.0 => 2.6.0 @react-native-async-storage/async-storage: ^1.18.2 => 1.19.3 @react-native-community/datetimepicker: ^7.1.0 => 7.6.0 @react-native-community/hooks: ^2.8.0 => 2.8.1 @react-native-community/netinfo: ^9.0.0 => 9.4.1 @react-native-community/push-notification-ios: ^1.11.0 => 1.11.0 @react-native-firebase/analytics: ^18.3.1 => 18.3.1 @react-native-firebase/app: ^18.3.1 => 18.3.1 @react-native-firebase/installations: ^18.3.1 => 18.3.1 @react-native/eslint-config: ^0.72.2 => 0.72.2 @react-native/metro-config: ^0.72.0 => 0.72.11 @react-navigation/bottom-tabs: ^6.5.8 => 6.5.8 @react-navigation/elements: ^1.3.18 => 1.3.18 (1.3.19) @react-navigation/native: ^6.0.8 => 6.1.8 @react-navigation/native-stack: ^6.9.13 => 6.9.13 @react-navigation/stack: ^6.2.0 => 6.3.18 @rnx-kit/align-deps: ^2.2.4 => 2.2.4 @tsconfig/react-native: ^3.0.0 => 3.0.2 @types/lodash: ^4.14.197 => 4.14.197 @types/react: ^18.0.24 => 18.2.21 @types/react-native-vector-icons: ^6.4.14 => 6.4.14 @types/react-test-renderer: ^18.0.0 => 18.0.0 HelloWorld: 0.0.1 accordion-collapse-react-native: ^1.1.1 => 1.1.1 amazon-cognito-identity-js: ^6.3.6 => 6.3.6 amazon-cognito-identity-js/internals: undefined () aws-amplify: 5.3.11 => 5.3.11 axios-retry: ^3.7.0 => 3.7.0 babel-jest: ^29.2.1 => 29.6.4 babel-plugin-module-resolver: ^5.0.0 => 5.0.0 babel-plugin-root-import: ^6.6.0 => 6.6.0 date-fns: ^2.30.0 => 2.30.0 eslint: ^8.19.0 => 8.48.0 example: 1.0.1 (0.0.1) examples: 0.0.1 i18next: ^23.4.6 => 23.4.6 immer: ^10.0.3 => 10.0.3 (9.0.6) jest: ^29.2.1 => 29.6.4 lodash: ^4.17.21 => 4.17.21 metro-react-native-babel-preset: ^0.76.5 => 0.76.8 moment: ^2.29.4 => 2.29.4 moment-timezone: ^0.5.43 => 0.5.43 native-base: ^3.4.28 => 3.4.28 (3.4.25) pod-install: ^0.1.39 => 0.1.39 prettier: ^2.4.1 => 2.8.8 qs: ^6.11.2 => 6.11.2 react: 18.2.0 => 18.2.0 react-i18next: ^13.2.1 => 13.2.1 react-native: ^0.72.0 => 0.72.5 react-native-app-intro-slider: ^4.0.4 => 4.0.4 react-native-autoheight-webview: ^1.6.5 => 1.6.5 react-native-base64: ^0.2.1 => 0.2.1 react-native-bootsplash: ^5.0.2 => 5.0.2 react-native-calendars: ^1.1300.0 => 1.1300.0 react-native-device-info: ^10.9.0 => 10.9.0 react-native-devsettings: ^1.0.5 => 1.0.5 react-native-document-picker: ^9.0.1 => 9.0.1 react-native-error-boundary: ^1.2.3 => 1.2.3 react-native-file-viewer: ^2.1.5 => 2.1.5 react-native-fs: ^2.18.0 => 2.20.0 react-native-gesture-handler: ^2.12.0 => 2.13.1 react-native-html-to-pdf: ^0.12.0 => 0.12.0 react-native-image-picker: ^5.6.1 => 5.6.1 react-native-keyboard-aware-scroll-view: ^0.9.5 => 0.9.5 react-native-keychain: ^8.1.2 => 8.1.2 react-native-kochava-tracker: ^2.4.0 => 2.4.0 react-native-linear-gradient: ^2.8.2 => 2.8.2 react-native-marketingcloudsdk: ^8.0.0 => 8.0.0 react-native-modal-datetime-picker: ^17.1.0 => 17.1.0 react-native-normalize: ^1.0.1 => 1.0.1 react-native-pager-view: ^6.2.1 => 6.2.1 react-native-password-strength-meter: ^0.0.5 => 0.0.5 react-native-permissions: ^3.8.4 => 3.8.4 react-native-progress-dialog: ^0.0.5 => 0.0.5 react-native-push-notification: ^8.1.1 => 8.1.1 react-native-qualtrics: ^2.5.0 => 2.5.0 react-native-raw-bottom-sheet: ^2.2.0 => 2.2.0 react-native-render-html: ^6.1.0 => 6.3.4 react-native-safe-area-context: ^4.5.3 => 4.7.2 react-native-screens: ^3.21.0 => 3.25.0 react-native-snackbar: ^2.6.2 => 2.6.2 react-native-svg: ^13.9.0 => 13.14.0 react-native-svg-transformer: ^1.1.0 => 1.1.0 react-native-tab-view: ^3.5.2 => 3.5.2 react-native-user-inactivity: ^1.2.0 => 1.2.0 react-native-uuid: ^2.0.1 => 2.0.1 react-native-vector-icons: ^10.0.0 => 10.0.0 react-native-webview: ^13.2.2 => 13.6.0 react-query: ^3.39.3 => 3.39.3 react-redux: ^8.1.2 => 8.1.2 react-test-renderer: 18.2.0 => 18.2.0 redux: ^4.2.1 => 4.2.1 redux-persist: ^6.0.0 => 6.0.0 redux-persist/integration/react: undefined () redux-saga: ^1.2.3 => 1.2.3 redux-saga/effects: undefined () reselect: ^4.1.8 => 4.1.8 shared-ui-components: ^1.49.0 => 1.49.0 typesafe-actions: ^5.1.0 => 5.1.0 typescript: 4.8.4 => 4.8.4 yup: ^1.2.0 => 1.2.0 npmGlobalPackages: @aws-amplify/cli: 12.3.0 @prettier/plugin-ruby: 4.0.2 eslint: 8.48.0

Describe the bug

This was working well before with react native 0.65.2 aws-amplify 2.x.x. We are in process of upgrading our app seeing these issues

I can see events streaming to the S3 on Android but on iOS I am not able to see the events being streaming to the s3. Additionally, When I debugged with react-native-debugger tool i can see the configure outbound call is made but not the /events endpoint.

Expected behavior

should see the analytics event in s3 buckets.

Reproduction steps

  1. yarn add aws-amplify amazon-cognito-identity-js @react-native-community/netinfo @react-native-async-storage/async-storage

  2. aws-exports.js export default { aws_project_region: '', aws_cognito_identity_pool_id: '', aws_cognito_region: '', aws_mobile_analytics_app_id: '', aws_mobile_analytics_app_region: '', }

  3. index.js

import awsconfig from './aws-exports' Amplify.configure(awsconfig); Analytics.record({ name: 'AlbumVisit', attributes: { type: 'Mobile', action: 'Action', description: 'RN72 UPGRADE', deviceToken: 'string', date: 'date-string', userID: 'jsmith', guid: 'string', application: 'MobileApp', appVersion: '1', request: 'string', response: 'string', responseTime: 'string', APNsPushToken: 'string', uuid: 'string', }, }) .then(() => console.log('called event')) .catch(console.error);

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone 14 Pro

Mobile Operating System

iOS 16.2

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

nadetastic commented 11 months ago

HI @konampruthvirajkumar thanks for opening this issue. Can you confirm with version of aws-amplify you are upgrading to as you see this issues? Curious as to why this works on Android but not on iOS. Also is this specific to a physical device or simulator or both?

konampruthvirajkumar commented 11 months ago

@nadetastic @cwomack i was able to find out the root cause of this issue by setting the logger to DEBUG and found "fetch is not a function"

solved it by adding the whatwg-fetch dependency

written below code in the index.js file import { fetch as fetchPolyfill } from 'whatwg-fetch' global.fetch = fetchPolyfill.

cwomack commented 10 months ago

@konampruthvirajkumar, glad to hear you were able to unblock yourself! Let us know if there's any further issues tied to this.