segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
366 stars 188 forks source link

error: SyntaxError: ...node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts: Unexpected token, expected "," (5:26) #607

Closed ofri-7chairs closed 1 year ago

ofri-7chairs commented 2 years ago

Whenever I try to run the app the app is crashing and I get this error: error: SyntaxError: ...node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts: Unexpected token, expected "," (5:26) referring to: import { PluginType, type SegmentEvent } from '../types';

Steps to reproduce yarn add @segment/analytics-react-native ... react-native run-ios

Expected behavior

Actual behavior

oscb commented 2 years ago

@ofri-7chairs which version of Typescript are you using? I'm unable to repro this on 4.5.2 as in the example but not sure if it might be be caused due to differing version of TS.

ofri-7chairs commented 2 years ago

@oscb my "typescript": "4.0.5". if its required some typescript version please add it to the docs.

using: "@segment/analytics-react-native": "^2.3.2" works for me.

for this version I also didn't have to install @segment/sovran-react-native and @react-native-async-storage/async-storage as its in package.json dependencies.

reyn-nova commented 2 years ago

Thanks @ofri-7chairs installing version 2.3.2 remove this error, but I still need to install @segment/sovran-react-native though, pod install doesn't work without it

tavour-frank commented 2 years ago

Also getting this error on both platforms

analytics-react-native version: 2.4.0 Integrations versions (if used): React Native version: 0.65.1 iOS or Android or both? both

Steps to reproduce yarn add @segment/analytics-react-native ... react-native run-ios Or react-native run-android

likeaj6 commented 2 years ago
diff --git a/node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts b/node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts
index c55b56d..0212405 100644
--- a/node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts
+++ b/node_modules/@segment/analytics-react-native/src/plugins/QueueFlushingPlugin.ts
@@ -2,7 +2,7 @@ import { createStore, Store, Unsubscribe } from '@segment/sovran-react-native';
 import type { SegmentClient } from '../analytics';
 import { defaultConfig } from '../constants';
 import { UtilityPlugin } from '../plugin';
-import { PluginType, type SegmentEvent } from '../types';
+import { PluginType, SegmentEvent } from '../types';

 /**
  * This plugin manages a queue where all events get added to after timeline processing.

Works if you just remove it

ofri-7chairs commented 2 years ago

yes, but it needs to be in the library... @oscb can you add the fix?

ryan-k-swyftx commented 2 years ago

Also experiencing this

ivanguimam commented 2 years ago

Same problem

Captura de Tela 2022-08-08 às 11 16 56
{
  "androidVersionCode": 196,
  "iosVersionCode": "148",
  "name": "app",
  "version": "4.0.1",
  "private": true,
  "scripts": {
    "android": "adb reverse tcp:9090 tcp:9090 && yarn react-native run-android",
    "android:clean": "yarn clear:android && yarn && yarn android",
    "androidBundle": "cd android && ./gradlew bundleRelease",
    "androidBundle:clean": "yarn clear:android && yarn && yarn androidBundle",
    "androidRelease": "cd android && ./gradlew assembleRelease",
    "androidRelease:clean": "yarn clear:android && yarn && yarn androidRelease",
    "androidRelease:install": "adb install android/app/build/outputs/apk/release/app-release.apk",
    "clear:android": "rm -rf node_modules/ android/build android/app/build/ android/.gradle/",
    "clear:ios": "rm -rf node_modules/ ios/Pods/ ios/Podfile.lock",
    "ios": "./node_modules/.bin/react-native run-ios",
    "ios:clean": "yarn clear:ios && yarn && cd ios && pod install && cd ..",
    "lint:check": "eslint -c .eslintrc.js './**/*.{ts,tsx,js,jsx}'",
    "lint:write": "eslint --fix -c .eslintrc.js './**/*.{ts,tsx,js,jsx}'",
    "mock:compile": "./node_modules/.bin/tsc -p mock-server/tsconfig.json",
    "mock:cp": "cp mock-server/app/atomicPlusReport/atomic_plus_report.html out-tsc/mock-server/app/atomicPlusReport/atomic_plus_report.html",
    "mock:start": "rm -rf out-tsc/mock-server && yarn mock:compile && yarn mock:cp && node mock-server/dyson.js",
    "postinstall": "npx jetify && patch-package",
    "prettier:write": "prettier --write {app,src}/**/*.tsx {app,src}/**/*.ts {app,src}/**/*.jsx {app,src}/**/*.js {app,__mocks__}/**/*.ts {app,mock-server}/**/*.ts index.js test.js",
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "prestorybook": "rnstl",
    "storybook": "start-storybook -p 7007",
    "test": "jest --runInBand --detectOpenHandles --config ./jest.config.js",
    "type:check": "./node_modules/.bin/tsc -p . --noEmit --skipLibCheck"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "1.17.7",
    "@react-native-community/async-storage": "^1.6.2",
    "@react-native-community/cli": "4.8.0",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/netinfo": "^4.4.0",
    "@react-native-firebase/app": "8.4.6",
    "@segment/analytics-react-native": "2.5.1",
    "@segment/sovran-react-native": "0.4.3",
    "axios": "^0.18.0",
    "bugsnag-react-native": "2.23.7",
    "bugsnag-sourcemaps": "1.3.0",
    "cpf-cnpj-validator": "1.0.3",
    "eventemitter3": "^3.1.2",
    "formik": "^1.3.2",
    "immutable": "^4.0.0-rc.12",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "numeral": "^2.0.6",
    "patch-package": "6.2.0",
    "react": "16.13.1",
    "react-native": "0.63.3",
    "react-native-action-button": "^2.8.5",
    "react-native-auto-height-image": "^1.0.5",
    "react-native-autolink": "^3.0.0",
    "react-native-bottom-action-sheet": "^1.0.2",
    "react-native-branch": "5.4.0",
    "react-native-camera": "3.6.0",
    "react-native-chart-kit": "https://github.com/indiespirit/react-native-chart-kit.git",
    "react-native-circular-progress": "1.3.6",
    "react-native-color-matrix-image-filters": "5.2.0",
    "react-native-config": "1.3.3",
    "react-native-counter": "https://github.com/JEGardner/react-native-counter.git#a444b60bad6af928372056b456a6d4e15969b64d",
    "react-native-device-info": "^0.24.3",
    "react-native-dropdownalert": "^3.7.1",
    "react-native-easy-content-loader": "0.3.2",
    "react-native-fbsdk-next": "7.3.3",
    "react-native-image-crop-picker": "0.35.1",
    "react-native-image-header-scroll-view": "^0.10.1",
    "react-native-image-progress": "^1.1.1",
    "react-native-iphone-x-helper": "^1.2.1",
    "react-native-keyboard-aware-scroll-view": "0.9.2",
    "react-native-masked-text": "^1.9.2",
    "react-native-modal-dropdown": "https://github.com/siemiatj/react-native-modal-dropdown.git",
    "react-native-navigation": "7.11.3",
    "react-native-navigation-hooks": "6.3.0",
    "react-native-onesignal": "3.4.1",
    "react-native-scrollable-tab-view": "https://github.com/jayshooo/react-native-scrollable-tab-view.git#6ac253a078c71b0cf143f3f8bd75aee7b4ddde58",
    "react-native-simple-markdown": "https://github.com/10levels/react-native-simple-markdown.git#178c8ad9d609edc8d30dd47c4a7055712f696831",
    "react-native-snap-carousel": "3.9.1",
    "react-native-status-bar-height": "^2.3.1",
    "react-native-svg": "^8.0.8",
    "react-native-tracking-transparency": "0.1.1",
    "react-native-video": "5.0.2",
    "react-native-webview": "^7.4.3",
    "react-redux": "^5.1.1",
    "redux": "4.0.1",
    "redux-axios-middleware": "^4.0.0",
    "redux-thunk": "^2.3.0",
    "reduxsauce": "^1.1.0",
    "slugify": "^1.3.4",
    "typesafe-actions": "^4.4.2",
    "yup": "^0.26.6"
  },
  "devDependencies": {
    "@babel/core": "7.8.4",
    "@babel/runtime": "7.8.4",
    "@react-native-community/eslint-config": "2.0.0",
    "@storybook/addon-actions": "5.3.13",
    "@storybook/addon-links": "5.3.13",
    "@storybook/addons": "5.3.13",
    "@storybook/react-native": "5.3.13",
    "@storybook/react-native-server": "5.3.13",
    "@types/dotenv": "^6.1.0",
    "@types/enzyme": "^3.1.15",
    "@types/enzyme-adapter-react-16": "^1.0.3",
    "@types/faker": "^4.1.5",
    "@types/jest": "24.0.24",
    "@types/lodash": "^4.14.119",
    "@types/node": "^11.9.4",
    "@types/numeral": "^0.0.25",
    "@types/react": "16.9.49",
    "@types/react-native": "0.63.17",
    "@types/react-native-modal-dropdown": "0.6.1",
    "@types/react-native-scrollable-tab-view": "^0.8.5",
    "@types/react-native-snap-carousel": "3.8.2",
    "@types/react-native-video": "^3.1.5",
    "@types/react-redux": "^6.0.9",
    "@types/react-test-renderer": "16.9.3",
    "@types/redux-mock-store": "^1.0.0",
    "@types/sinon": "^5.0.7",
    "@types/storybook__react": "5.2.1",
    "@types/yup": "^0.26.2",
    "@typescript-eslint/eslint-plugin": "4.10.0",
    "@typescript-eslint/parser": "4.10.0",
    "axios-mock-adapter": "^1.15.0",
    "babel-jest": "24.9.0",
    "babel-loader": "8.0.6",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "dotenv": "^6.2.0",
    "dyson": "https://github.com/ivanguimam/dyson.git",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.4",
    "eslint": "7.15.0",
    "eslint-config-airbnb-typescript": "12.0.0",
    "eslint-config-prettier": "7.0.0",
    "eslint-import-resolver-typescript": "2.3.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsx-a11y": "6.4.1",
    "eslint-plugin-prettier": "3.3.0",
    "eslint-plugin-react": "7.21.5",
    "eslint-plugin-react-native": "3.10.0",
    "faker": "^4.1.0",
    "jest": "24.9.0",
    "jest-enzyme": "7.1.2",
    "jest-fetch-mock": "^1.7.4",
    "jetifier": "^1.6.4",
    "jsdom": "16.4.0",
    "metro-react-native-babel-preset": "0.59.0",
    "plist": "^3.0.1",
    "prettier": "2.2.1",
    "react-devtools": "^3.4.3",
    "react-dom": "^16.6.3",
    "react-native-cli": "^2.0.1",
    "react-native-mock": "^0.3.1",
    "react-native-storybook-loader": "1.8.1",
    "react-test-renderer": "16.13.1",
    "reactotron-react-native": "4.0.2",
    "redux-mock-store": "^1.5.3",
    "sinon": "^7.1.1",
    "ts-jest": "^23.10.4",
    "typescript": "4.5.2"
  },
  "config": {
    "react-native-storybook-loader": {
      "searchDir": [
        "./src"
      ],
      "pattern": "**/*.stories.tsx",
      "outputFile": "./storybook/storyLoader.ts"
    }
  }
}
oscb commented 1 year ago

Closing due to inactivity. These imports have been removed already in latter versions of the app and aren't able to reproduce this in TS 4.5+.