Skip to content

Commit

Permalink
feat: upgrade RN 0.76+
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunita Prajapati committed Jan 7, 2025
1 parent 6f823eb commit cc56c6f
Show file tree
Hide file tree
Showing 11 changed files with 11,481 additions and 7,948 deletions.
20 changes: 6 additions & 14 deletions examples/AnalyticsReactNativeExample/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/

import 'react-native-gesture-handler';
import * as React from 'react';
// import RNBootSplash from 'react-native-bootsplash';
Expand All @@ -27,14 +20,14 @@ import Home from './Home';
import SecondPage from './SecondPage';
import Modal from './Modal';
import {useState} from 'react';
//import {Logger} from './plugins/Logger';
import {Logger} from './plugins/Logger';

// import {AmplitudeSessionPlugin} from '@segment/analytics-react-native-plugin-amplitude-session';
// import { ConsentManager } from './plugins/ConsentManager';
// import { FirebasePlugin } from '@segment/analytics-react-native-plugin-firebase';
// import { FacebookAppEventsPlugin } from '@segment/analytics-react-native-plugin-facebook-app-events';
// import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa';
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';
// import { IdfaPlugin } from '@segment/analytics-react-native-plugin-idfa';
// import { AdvertisingIdPlugin } from '@segment/analytics-react-native-plugin-advertising-id';
// import { ClevertapPlugin } from '@segment/analytics-react-native-plugin-clevertap';
// import { BrazePlugin } from '@segment/analytics-react-native-plugin-braze';

Expand All @@ -52,9 +45,9 @@ const segmentClient = createClient({
],
});

// const LoggerPlugin = new Logger();
const LoggerPlugin = new Logger();

// segmentClient.add({plugin: LoggerPlugin});
segmentClient.add({plugin: LoggerPlugin});

// To see an example Consent Manager uncomment the following
// const ConsentManagerPlugin = new ConsentManager();
Expand Down Expand Up @@ -136,6 +129,7 @@ const App = () => {
const newRouteName = getActiveRouteName(state);

if (routeName !== newRouteName) {
// eslint-disable-next-line no-void
void segmentClient.screen(newRouteName);

setRouteName(newRouteName);
Expand Down Expand Up @@ -169,5 +163,3 @@ const App = () => {
};

export default App;


4 changes: 2 additions & 2 deletions examples/AnalyticsReactNativeExample/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ GEM
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
bigdecimal (3.1.9)
claide (1.1.0)
cocoapods (1.15.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -71,7 +71,7 @@ GEM
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.17.0)
ffi (1.17.1)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
Expand Down
4 changes: 2 additions & 2 deletions examples/AnalyticsReactNativeExample/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Home = ({navigation}: {navigation: any}) => {
name: 'Alias',
testID: 'BUTTON_ALIAS',
onPress: () => {
void alias('new-id');
void alias('new-id');
},
},
];
Expand All @@ -75,7 +75,7 @@ const Home = ({navigation}: {navigation: any}) => {
name: 'Reset',
testID: 'BUTTON_RESET',
onPress: () => {
void reset();
void reset();
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<uses-permission android:name="android.permission.INTERNET" />


<application
android:name=".MainApplication"
android:label="@string/app_name"
Expand Down
13 changes: 12 additions & 1 deletion examples/AnalyticsReactNativeExample/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
const { srcMap } = require('./workspace')

module.exports = {
presets: ['module:@react-native/babel-preset'],
presets: ['module:metro-react-native-babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: srcMap,
},
],
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2FF01F741210DC5AE9D1F2A5 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
7699B88040F8A987B510C191 /* libPods-AnalyticsReactNativeExample-AnalyticsReactNativeExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-AnalyticsReactNativeExample-AnalyticsReactNativeExampleTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
DAF283317EBCE7025309E6C9 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -246,7 +246,7 @@
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
2FF01F741210DC5AE9D1F2A5 /* PrivacyInfo.xcprivacy in Resources */,
DAF283317EBCE7025309E6C9 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -586,7 +586,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
Expand Down Expand Up @@ -655,7 +658,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = "$(inherited) ";
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<!-- Do not change NSAllowsArbitraryLoads to true, or you will risk app rejection! -->
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSAllowsLocalNetworking</key>
Expand Down
14 changes: 7 additions & 7 deletions examples/AnalyticsReactNativeExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNCMaskedView (0.1.11):
- React
- RNGestureHandler (2.21.2):
- DoubleConversion
- glog
Expand Down Expand Up @@ -1667,8 +1669,6 @@ PODS:
- segment-analytics-react-native (2.20.3):
- React-Core
- sovran-react-native
- segment-analytics-react-native-plugin-idfa (0.7.2):
- React-Core
- SocketRocket (0.7.1)
- sovran-react-native (1.1.3):
- React-Core
Expand Down Expand Up @@ -1742,10 +1742,10 @@ DEPENDENCIES:
- ReactCodegen (from `build/generated/ios`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNScreens (from `../node_modules/react-native-screens`)
- "segment-analytics-react-native (from `../node_modules/@segment/analytics-react-native`)"
- "segment-analytics-react-native-plugin-idfa (from `../node_modules/@segment/analytics-react-native-plugin-idfa`)"
- "sovran-react-native (from `../node_modules/@segment/sovran-react-native`)"
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)

Expand Down Expand Up @@ -1885,14 +1885,14 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNScreens:
:path: "../node_modules/react-native-screens"
segment-analytics-react-native:
:path: "../node_modules/@segment/analytics-react-native"
segment-analytics-react-native-plugin-idfa:
:path: "../node_modules/@segment/analytics-react-native-plugin-idfa"
sovran-react-native:
:path: "../node_modules/@segment/sovran-react-native"
Yoga:
Expand All @@ -1905,7 +1905,7 @@ SPEC CHECKSUMS:
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 06a9c6900587420b90accc394199527c64259db4
RCT-Folly: 84578c8756030547307e4572ab1947de1685c599
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCTDeprecation: fb7d408617e25d7f537940000d766d60149c5fea
RCTRequired: 9aaf0ffcc1f41f0c671af863970ef25c422a9920
RCTTypeSafety: e9a6e7d48184646eb0610295b74c0dd02768cbb2
Expand Down Expand Up @@ -1964,10 +1964,10 @@ SPEC CHECKSUMS:
ReactCodegen: daa13d9e48c9bdb1daac4bd694b9dd54e06681df
ReactCommon: a6b87a7591591f7a52d9c0fec3aa05e0620d5dd3
RNCAsyncStorage: fe98f1b459a87b80f12207da80c50b3a3abb6081
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNGestureHandler: 0e5ae8d72ef4afb855e98dcdbe60f27d938abe13
RNScreens: d022507f2b6d76c73335e9e35aedcf7bb2f791b0
segment-analytics-react-native: d57ed4971cbb995706babf29215ebdbf242ecdab
segment-analytics-react-native-plugin-idfa: aa867f2ae2d7cd96882ccbb638026f839a701dc6
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
sovran-react-native: eec37f82e4429f0e3661f46aaf4fcd85d1b54f60
Yoga: fcc198acd4a55599b3468cfb6ebc526baff5f06e
Expand Down
52 changes: 43 additions & 9 deletions examples/AnalyticsReactNativeExample/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

/**
* Metro configuration
* https://reactnative.dev/docs/metro
*
* @type {import('metro-config').MetroConfig}
*/
const config = {};
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const path = require('path');
const escape = require('escape-string-regexp');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const { peerDeps } = require('./workspace')
const modules = [...peerDeps];
const root = path.resolve(__dirname, '..', '..');

const defaultSourceExts =
require('metro-config/src/defaults/defaults').sourceExts;

const config = {
projectRoot: __dirname,
watchFolders: [root],

resolver: {
unstable_enableSymlinks: true,
// We need to make sure that only one version is loaded for peerDependencies
// So we block them at the root, and alias them to the versions in example's node_modules
blacklistRE: exclusionList(
modules.map(
(m) =>
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
)
),

extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),

sourceExts: defaultSourceExts,
},

transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
5 changes: 3 additions & 2 deletions examples/AnalyticsReactNativeExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"lint": "eslint .",
"start": "react-native start",
"android:deeplink": "adb shell am start -a android.intent.action.VIEW -d \"segmentreactnative://hello\" com.example.segmentanalyticsreactnative",
"ios:deeplink": "xcrun simctl openurl booted segmentreactnative://hello",
"android:emulator": "./android/device_setup.sh",
"clean": "yarn clean:ios && rimraf node_modules",
"clean:ios": "rimraf ios/build ios/Pods",
"test": "jest"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^2.1.0",
"@react-native-community/masked-view": "^0.1.11",
"@react-navigation/native": "^7.0.14",
"@react-navigation/stack": "^7.1.1",
"@segment/analytics-react-native": "^2.20.3",
Expand All @@ -26,7 +26,6 @@
"react-native-gesture-handler": "^2.21.2",
"react-native-get-random-values": "^1.11.0",
"react-native-safe-area-context": "^5.0.0",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "^4.4.0"
},
"devDependencies": {
Expand All @@ -43,10 +42,12 @@
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"babel-plugin-module-resolver": "^5.0.2",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"rimraf": "^6.0.1",
"typescript": "5.0.4"
},
"engines": {
Expand Down
Loading

0 comments on commit cc56c6f

Please sign in to comment.