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
354 stars 181 forks source link

Upgrading from 2.16.1 to 2.17.0 breaks our app #903

Closed adamivancza closed 3 months ago

adamivancza commented 6 months ago

Steps to reproduce

I've tried to update our from 2.16.1 to 2.17.0 the app won't start up and I can see this message on the packager console:

TypeError: Super expression must either be null or a function, js engine: hermes

We have a couple of custom plugins as well, tried to disable all of them but nothing seemed to help.

Expected behavior

App should be able to start up with the most recent version

Actual behavior

Unhandled error in the packager output, app stuck on splash screen

oscb commented 6 months ago

Hey @adamivancza, we deprecated 2.17 for now until we get down to this error. Seems to have started happening in later versions of RN.

Quick question: could you share a minimal repro project? I don't think the problem is likely your app code, but I feel it's likely something about babel, typescript or RN configuration itself. Possible some interaction between versions of those tools and our code.

We've been trying to repro this with simple apps with no luck, but we're not really messing up too much with the configuration. Very eager to get to the bottom of this one.

adamivancza commented 6 months ago

hey @oscb! we're using TS v5.0.4. Also we're using rnx-kit bundler and this happens to us in debug mode too, not just in release mode.

oscb commented 6 months ago

@adamivancza oh, interesting. Going to test out that particular version of TS. So far we have tested a few RN + TS version combinations but haven't had luck reproducing. My guess is that this could be caused by a particular (but commonly used) configuration that we haven't tried.

Any chance you could share your configuration files? In particular interested on TS, Babel, RN config (if any) ?

adamivancza commented 6 months ago

hey @oscb! could you email me at adam.ivancza [@] theinfatuation.com? I don't want to share anything publicly here.

Jackman3005 commented 5 months ago

Hello đź‘‹ , Just checking in to see if there has been any progress on this? I seem to be getting the same issue!

oscb commented 5 months ago

@Jackman3005 we have a release in beta right now that we think should fix this 2.18.0-beta.1.

Can you give it a try and let us know if this solves the issue? Team has been trying hard to figure this one out but we don't have a repro (but did have a hunch of what might be). Any validation would be helpful!

hubastard commented 5 months ago

@oscb

So, I was also getting this error and I found the issue. It's caused by a cycle dependency in ConsentPlugin.ts.

The current import looks like this:

import {
  Plugin,
  type SegmentClient,
  type DestinationPlugin,
  IntegrationSettings,
  PluginType,
  SegmentAPIIntegration,
  SegmentEvent,
  TrackEventType,
} from '..';

But it's importing on the index.ts file located in the parent folder ... But this index file also exports ConsentPlugin.ts which causes a cycle dependency and result in this error.

A quick fix is to import selectively the files that you want instead of importing them from the index to avoid the cycle dependency:

import { Plugin } from '../plugin';
import { PluginType } from '../types';
import type { IntegrationSettings, SegmentAPIIntegration, SegmentEvent, TrackEventType } from '../types';
import type { DestinationPlugin } from '../plugin';
import type { SegmentClient } from '../analytics';
oscb commented 4 months ago

Just released v2.18.0 with the circular dependency fix and another issue with the typings we think could be the problem. Let us know if that fixes it for you

papaschmidt commented 4 months ago

We have been having this issue as well. It results in unit test failing:

  â—Ź Test suite failed to run

    TypeError: Super expression must either be null or a function

      15 |  * Plugin that injects additional user traits to every event
      16 |  */
    > 17 | export class InjectTraits extends PlatformPlugin {
         |                          ^
      18 |   type = PluginType.before;
      19 |
      20 |   async execute(event: SegmentEvent): Promise<SegmentEvent> {

      at _inherits (node_modules/@babel/runtime/helpers/inherits.js:4:11)
      at src/utils/helpers/segmentEventPlugin.ts:17:26
      at Object.<anonymous> (src/utils/helpers/segmentEventPlugin.ts:63:4)
      at Object.require (src/hooks/useSegmentClient/useSegmentClient.ts:6:1)

The error goes away if I disable the plugin, which is obviously not a solution. We are getting this on v2.7.1 (yeah, we're behind), but even upgrading to the latest version here doesn't help.

oscb commented 4 months ago

@papaschmidt might be a different issue as I had confirmed offline Adam's original bug here was fixed with 2.18 release.

I'm curious what's the last version of the lib you're using that works with this code?

adamivancza commented 4 months ago

yeah, I can confirm that my original issue was resolved with the latest 2.18.0 release so we can close this issue?

papaschmidt commented 4 months ago

@papaschmidt might be a different issue as I had confirmed offline Adam's original bug here was fixed with 2.18 release.

I'm curious what's the last version of the lib you're using that works with this code?

This turned out to be a red herring for me. It pointed to this being an issue but it turned out something else was causing it. I don’t have this issue anymore.

Thanks

oscb commented 3 months ago

@papaschmidt glad to hear that! Closing this issue now