Skip to content

fix: replace allSettled shim, fix imports from plugins #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/src/plugins/ConsentManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SegmentEvent,
} from '@segment/analytics-react-native';

import type { SegmentClient } from '@segment/analytics-react-native/src/analytics';
import type { SegmentClient } from '@segment/analytics-react-native';

import { Alert } from 'react-native';

Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ import {
import { getPluginsWithFlush, getPluginsWithReset } from './util';
import { getUUID } from './uuid';

// Important! We need to polyfill Promise.allSettled because it's not supported in RN (https://github.com/facebook/react-native/issues/30236)
allSettled.shim();

type OnContextLoadCallback = (type: UpdateType) => void | Promise<void>;

export class SegmentClient {
Expand Down Expand Up @@ -469,7 +466,7 @@ export class SegmentClient {
promises.push(plugin.flush());
});

await Promise.allSettled(promises);
await allSettled(promises);

return Promise.resolve();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const libraryInfo = {
name: '@segment/analytics-react-native',
version: '2.4.0',
version: '2.5.0',
};
2 changes: 1 addition & 1 deletion packages/core/src/plugins/QueueFlushingPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//@ts-ignore
import { Plugin, PluginType } from '@segment/analytics-react-native';
import type { SegmentClient } from '@segment/analytics-react-native/src/analytics';
import {
Plugin,
PluginType,
SegmentClient,
} from '@segment/analytics-react-native';
import { NativeModules } from 'react-native';

export class AdvertisingIdPlugin extends Plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@segment/analytics-react-native';
import track from './methods/track';
import screen from './methods/screen';
import type { SegmentClient } from '@segment/analytics-react-native/src/analytics';
import type { SegmentClient } from '@segment/analytics-react-native';

import { Settings } from 'react-native-fbsdk-next';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IdentifyEventType } from '@segment/analytics-react-native/src';
import type { IdentifyEventType } from '@segment/analytics-react-native';
import identify from '../identify';

const mockSetUserId = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ScreenEventType } from '@segment/analytics-react-native/src';
import type { ScreenEventType } from '@segment/analytics-react-native';
import screen from '../screen';

const mockScreen = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/plugin-firebase/src/methods/screen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import firebaseAnalytics from '@react-native-firebase/analytics';
import type { ScreenEventType } from '@segment/analytics-react-native/src';
import type { ScreenEventType } from '@segment/analytics-react-native';

export default async (event: ScreenEventType) => {
await firebaseAnalytics().logScreenView({
Expand Down
7 changes: 5 additions & 2 deletions packages/plugins/plugin-idfa/src/IdfaPlugin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Plugin, PluginType } from '@segment/analytics-react-native';
import type { SegmentClient } from '../../../core/src/analytics';
import {
Plugin,
PluginType,
SegmentClient,
} from '@segment/analytics-react-native';
import { IdfaEvents } from './IdfaEvents';
import type { IdfaData } from './types';
import { AnalyticsReactNativePluginIdfa } from './AnalyticsReactNativePluginIdfa';
Expand Down
6 changes: 4 additions & 2 deletions packages/plugins/plugin-mixpanel/src/methods/alias.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Mixpanel } from 'mixpanel-react-native';
import type { AliasEventType } from '@segment/analytics-react-native';
import type { SegmentClient } from '@segment/analytics-react-native/src/analytics';
import type {
AliasEventType,
SegmentClient,
} from '@segment/analytics-react-native';

export default async (
event: AliasEventType,
Expand Down