Skip to content
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

[MOB-12033] Restructure native Directory #933

Merged
merged 3 commits into from
Mar 2, 2023
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 src/models/Report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';

import { NativeInstabug } from '../native';
import { NativeInstabug } from '../native/NativeInstabug';

interface LogInfo {
log: string;
Expand Down
2 changes: 1 addition & 1 deletion src/models/Trace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeAPM } from '../native';
import { NativeAPM } from '../native/NativeAPM';

export default class Trace {
constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/modules/APM.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Platform } from 'react-native';

import Trace from '../models/Trace';
import { NativeAPM, NativeInstabug } from '../native';
import { NativeAPM } from '../native/NativeAPM';
import { NativeInstabug } from '../native/NativeInstabug';
import { logLevel } from '../utils/ArgsRegistry';

export { logLevel };
Expand Down
2 changes: 1 addition & 1 deletion src/modules/BugReporting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';

import { NativeBugReporting } from '../native';
import { NativeBugReporting } from '../native/NativeBugReporting';
import {
dismissType,
extendedBugReportMode,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/CrashReporting.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Platform } from 'react-native';
import type { ExtendedError } from 'react-native/Libraries/Core/Devtools/parseErrorStack';

import { NativeCrashReporting } from '../native';
import type { CrashData } from '../native/CrashReportingNativeModule';
import type { CrashData } from '../native/NativeCrashReporting';
import { NativeCrashReporting } from '../native/NativeCrashReporting';
import InstabugUtils from '../utils/InstabugUtils';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/modules/FeatureRequests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeFeatureRequests } from '../native';
import { NativeFeatureRequests } from '../native/NativeFeatureRequests';
import { actionTypes } from '../utils/ArgsRegistry';
import type { ActionType } from '../utils/Enums';

Expand Down
2 changes: 1 addition & 1 deletion src/modules/Instabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { NavigationAction, NavigationState as NavigationStateV4 } from 'rea

import type { InstabugConfig } from '../models/InstabugConfig';
import Report from '../models/Report';
import { NativeInstabug } from '../native';
import { NativeInstabug } from '../native/NativeInstabug';
import {
IBGPosition,
actionTypes,
Expand Down
3 changes: 2 additions & 1 deletion src/modules/NetworkLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Platform } from 'react-native';

import type { RequestHandler } from '@apollo/client';

import { NativeAPM, NativeInstabug } from '../native';
import { NativeAPM } from '../native/NativeAPM';
import { NativeInstabug } from '../native/NativeInstabug';
import IBGEventEmitter from '../utils/IBGEventEmitter';
import InstabugConstants from '../utils/InstabugConstants';
import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkInterceptor';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Replies.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';

import { NativeReplies } from '../native';
import { NativeReplies } from '../native/NativeReplies';
import IBGEventEmitter from '../utils/IBGEventEmitter';
import InstabugConstants from '../utils/InstabugConstants';

Expand Down
4 changes: 2 additions & 2 deletions src/modules/Surveys.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Platform } from 'react-native';

import { NativeSurveys } from '../native';
import type { Survey } from '../native/SurveysNativeModule';
import { NativeSurveys } from '../native/NativeSurveys';
import type { Survey } from '../native/NativeSurveys';
import IBGEventEmitter from '../utils/IBGEventEmitter';
import InstabugConstants from '../utils/InstabugConstants';

Expand Down
3 changes: 3 additions & 0 deletions src/native/ApmNativeModule.ts → src/native/NativeAPM.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NativeModule } from 'react-native';

import type { logLevel } from '../utils/ArgsRegistry';
import { NativeModules } from './NativePackage';

export interface ApmNativeModule extends NativeModule {
// Essential APIs //
Expand Down Expand Up @@ -28,3 +29,5 @@ export interface ApmNativeModule extends NativeModule {
/** @deprecated */
setLogLevel(level: logLevel): void;
}

export const NativeAPM = NativeModules.IBGAPM;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
RecordingButtonPosition,
ReportType,
} from '../utils/Enums';
import { NativeModules } from './NativePackage';

export interface BugReportingNativeModule extends NativeModule {
// Essential APIs //
Expand Down Expand Up @@ -57,3 +58,5 @@ export interface BugReportingNativeModule extends NativeModule {
handler: (dismissType: dismissType | DismissType, reportType: reportType | ReportType) => void,
): void;
}

export const NativeBugReporting = NativeModules.IBGBugReporting;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { NativeModule, Platform } from 'react-native';
import type { StackFrame } from 'react-native/Libraries/Core/Devtools/parseErrorStack';

import { NativeModules } from './NativePackage';

export interface CrashData {
message: string;
e_message: string;
Expand All @@ -15,3 +17,5 @@ export interface CrashReportingNativeModule extends NativeModule {
sendJSCrash(data: CrashData | string): void;
sendHandledJSCrash(data: CrashData | string): void;
}

export const NativeCrashReporting = NativeModules.IBGCrashReporting;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { NativeModule } from 'react-native';

import type { actionTypes } from '../utils/ArgsRegistry';
import type { ActionType } from '../utils/Enums';
import { NativeModules } from './NativePackage';

export interface FeatureRequestsNativeModule extends NativeModule {
setEnabled(isEnabled: boolean): void;
Expand All @@ -11,3 +12,5 @@ export interface FeatureRequestsNativeModule extends NativeModule {
types: actionTypes[] | ActionType[],
): void;
}

export const NativeFeatureRequests = NativeModules.IBGFeatureRequests;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
} from '../utils/Enums';
import type { NetworkData } from '../utils/XhrNetworkInterceptor';
import type { NativeConstants } from './NativeConstants';
import { NativeModules } from './NativePackage';

export interface InstabugNativeModule extends NativeModule {
getConstants(): NativeConstants;
Expand Down Expand Up @@ -120,3 +121,5 @@ export interface InstabugNativeModule extends NativeModule {
/** @deprecated */
callPrivateApi(apiName: string, param: any[]): void;
}

export const NativeInstabug = NativeModules.Instabug;
21 changes: 21 additions & 0 deletions src/native/NativePackage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NativeModules as ReactNativeModules } from 'react-native';

import type { ApmNativeModule } from './NativeAPM';
import type { BugReportingNativeModule } from './NativeBugReporting';
import type { CrashReportingNativeModule } from './NativeCrashReporting';
import type { FeatureRequestsNativeModule } from './NativeFeatureRequests';
import type { InstabugNativeModule } from './NativeInstabug';
import type { RepliesNativeModule } from './NativeReplies';
import type { SurveysNativeModule } from './NativeSurveys';

export interface InstabugNativePackage {
IBGAPM: ApmNativeModule;
IBGBugReporting: BugReportingNativeModule;
IBGCrashReporting: CrashReportingNativeModule;
IBGFeatureRequests: FeatureRequestsNativeModule;
Instabug: InstabugNativeModule;
IBGReplies: RepliesNativeModule;
IBGSurveys: SurveysNativeModule;
}

export const NativeModules = ReactNativeModules as InstabugNativePackage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { NativeModule } from 'react-native';

import { NativeModules } from './NativePackage';

export interface RepliesNativeModule extends NativeModule {
// Essential APIs //
setEnabled(isEnabled: boolean): void;
Expand All @@ -22,3 +24,5 @@ export interface RepliesNativeModule extends NativeModule {
setPushNotificationChannelId(id: string): void;
setSystemReplyNotificationSoundEnabled(isEnabled: boolean): void;
}

export const NativeReplies = NativeModules.IBGReplies;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { NativeModule } from 'react-native';

import { NativeModules } from './NativePackage';

export interface Survey {
title: string;
}
Expand All @@ -24,3 +26,5 @@ export interface SurveysNativeModule extends NativeModule {
setOnShowHandler(onShowHandler: () => void): void;
setOnDismissHandler(onDismissHandler: () => void): void;
}

export const NativeSurveys = NativeModules.IBGSurveys;
29 changes: 0 additions & 29 deletions src/native/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/ArgsRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeInstabug } from '../native';
import { NativeInstabug } from '../native/NativeInstabug';

const constants = NativeInstabug.getConstants();

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Enums.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeInstabug } from '../native';
import { NativeInstabug } from '../native/NativeInstabug';

const constants = NativeInstabug.getConstants();

Expand Down
4 changes: 2 additions & 2 deletions src/utils/InstabugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import parseErrorStackLib, {
import type { NavigationState as NavigationStateV5, PartialState } from '@react-navigation/native';
import type { NavigationState as NavigationStateV4 } from 'react-navigation';

import { NativeCrashReporting } from '../native';
import type { CrashData } from '../native/CrashReportingNativeModule';
import type { CrashData } from '../native/NativeCrashReporting';
import { NativeCrashReporting } from '../native/NativeCrashReporting';

export const parseErrorStack = (error: ExtendedError): StackFrame[] => {
return parseErrorStackLib(error);
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockAPM.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ApmNativeModule } from '../../src/native/ApmNativeModule';
import type { ApmNativeModule } from '../../src/native/NativeAPM';

const mockAPM: ApmNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockBugReporting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BugReportingNativeModule } from '../../src/native/BugReportingNativeModule';
import type { BugReportingNativeModule } from '../../src/native/NativeBugReporting';

const mockBugReporting: BugReportingNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockCrashReporting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CrashReportingNativeModule } from '../../src/native/CrashReportingNativeModule';
import type { CrashReportingNativeModule } from '../../src/native/NativeCrashReporting';

const mockCrashReporting: CrashReportingNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockFeatureRequests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FeatureRequestsNativeModule } from '../../src/native/FeatureRequestsNativeModule';
import type { FeatureRequestsNativeModule } from '../../src/native/NativeFeatureRequests';

const mockFeatureRequests: FeatureRequestsNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockInstabug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InstabugNativeModule } from '../../src/native/InstabugNativeModule';
import type { InstabugNativeModule } from '../../src/native/NativeInstabug';

const mockInstabug: InstabugNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockNativeModules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InstabugNativePackage } from '../../src/native';
import type { InstabugNativePackage } from '../../src/native/NativePackage';
import mockAPM from './mockAPM';
import mockBugReporting from './mockBugReporting';
import mockCrashReporting from './mockCrashReporting';
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockReplies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { RepliesNativeModule } from '../../src/native/RepliesNativeModule';
import type { RepliesNativeModule } from '../../src/native/NativeReplies';

const mockReplies: RepliesNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/mockSurveys.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SurveysNativeModule } from '../../src/native/SurveysNativeModule';
import type { SurveysNativeModule } from '../../src/native/NativeSurveys';

const mockSurveys: SurveysNativeModule = {
addListener: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/models/Report.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Platform } from 'react-native';

import Report from '../../src/models/Report';
import { NativeInstabug } from '../../src/native';
import { NativeInstabug } from '../../src/native/NativeInstabug';

describe('Report Model', () => {
let report: Report;
Expand Down
2 changes: 1 addition & 1 deletion test/models/Trace.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Trace from '../../src/models/Trace';
import { NativeAPM } from '../../src/native';
import { NativeAPM } from '../../src/native/NativeAPM';

describe('Trace Model', () => {
it('should set the id, name and attributes if passed', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/modules/APM.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { mocked } from 'ts-jest/utils';

import Trace from '../../src/models/Trace';
import * as APM from '../../src/modules/APM';
import { NativeAPM, NativeInstabug } from '../../src/native';
import { NativeAPM } from '../../src/native/NativeAPM';
import { NativeInstabug } from '../../src/native/NativeInstabug';

describe('APM Module', () => {
it('should call the native method setEnabled', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/BugReporting.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Platform } from 'react-native';

import * as BugReporting from '../../src/modules/BugReporting';
import { NativeBugReporting } from '../../src/native';
import { NativeBugReporting } from '../../src/native/NativeBugReporting';
import {
ExtendedBugReportMode,
FloatingButtonPosition,
Expand Down
2 changes: 1 addition & 1 deletion test/modules/CrashReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../mocks/mockInstabugUtils';
import { Platform } from 'react-native';

import * as CrashReporting from '../../src/modules/CrashReporting';
import { NativeCrashReporting } from '../../src/native';
import { NativeCrashReporting } from '../../src/native/NativeCrashReporting';

describe('CrashReporting Module', () => {
it('should call the native method setEnabled', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/FeatureRequests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as FeatureRequests from '../../src/modules/FeatureRequests';
import { NativeFeatureRequests } from '../../src/native';
import { NativeFeatureRequests } from '../../src/native/NativeFeatureRequests';
import { ActionType } from '../../src/utils/Enums';

describe('Feature Requests Module', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/Instabug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import waitForExpect from 'wait-for-expect';

import Report from '../../src/models/Report';
import * as Instabug from '../../src/modules/Instabug';
import { NativeInstabug } from '../../src/native';
import { NativeInstabug } from '../../src/native/NativeInstabug';
import {
ColorTheme,
InvocationEvent,
Expand Down
3 changes: 2 additions & 1 deletion test/modules/NetworkLogger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Platform } from 'react-native';
import waitForExpect from 'wait-for-expect';

import * as NetworkLogger from '../../src/modules/NetworkLogger';
import { NativeAPM, NativeInstabug } from '../../src/native';
import { NativeAPM } from '../../src/native/NativeAPM';
import { NativeInstabug } from '../../src/native/NativeInstabug';
import IBGEventEmitter from '../../src/utils/IBGEventEmitter';
import IBGConstants from '../../src/utils/InstabugConstants';
import Interceptor from '../../src/utils/XhrNetworkInterceptor';
Expand Down
2 changes: 1 addition & 1 deletion test/modules/Replies.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Platform } from 'react-native';

import * as Replies from '../../src/modules/Replies';
import { NativeReplies } from '../../src/native';
import { NativeReplies } from '../../src/native/NativeReplies';
import IBGEventEmitter from '../../src/utils/IBGEventEmitter';
import IBGConstants from '../../src/utils/InstabugConstants';

Expand Down
2 changes: 1 addition & 1 deletion test/modules/Surveys.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Platform } from 'react-native';

import * as Surveys from '../../src/modules/Surveys';
import { NativeSurveys } from '../../src/native';
import { NativeSurveys } from '../../src/native/NativeSurveys';
import IBGEventEmitter from '../../src/utils/IBGEventEmitter';
import IBGConstants from '../../src/utils/InstabugConstants';

Expand Down
Loading