Skip to content

Commit 1ef4bdd

Browse files
authored
Merge pull request #71 from sentry-demos/add-replay
Add replay
2 parents 57fdc57 + 534dcf2 commit 1ef4bdd

File tree

14 files changed

+246
-110
lines changed

14 files changed

+246
-110
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ yarn-error.log
6464
/coverage
6565

6666
.env
67+
.yalc
68+
yalc.lock
69+
.sentry

ios/sentry_react_native.xcodeproj/project.pbxproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@
604604
"-DFOLLY_CFG_NO_COROUTINES=1",
605605
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
606606
);
607-
OTHER_LDFLAGS = "$(inherited) ";
607+
OTHER_LDFLAGS = (
608+
"$(inherited)",
609+
" ",
610+
);
608611
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
609612
SDKROOT = iphoneos;
610613
USE_HERMES = true;
@@ -677,7 +680,10 @@
677680
"-DFOLLY_CFG_NO_COROUTINES=1",
678681
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
679682
);
680-
OTHER_LDFLAGS = "$(inherited) ";
683+
OTHER_LDFLAGS = (
684+
"$(inherited)",
685+
" ",
686+
);
681687
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
682688
SDKROOT = iphoneos;
683689
USE_HERMES = true;

metro.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ const userConfig = {};
1111

1212
const config = mergeConfig(getDefaultConfig(__dirname), userConfig);
1313

14-
module.exports = withSentryConfig(config);
14+
module.exports = withSentryConfig(config, {
15+
annotateReactComponents: true,
16+
});

package-lock.json

Lines changed: 5 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"react-native-linear-gradient": "^2.8.2",
2626
"react-native-safe-area-context": "^4.8.2",
2727
"react-native-screens": "^3.31.0",
28-
"react-native-toast-message": "^2.1.6",
28+
"react-native-toast-message": "^2.2.0",
2929
"react-native-vector-icons": "^10.1.0",
3030
"react-redux": "^8.1.2",
3131
"redux": "^4.2.1"

src/App.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import TrackerScreen from './screens/TrackerScreen';
1717
import ManualTrackerScreen from './screens/ManualTrackerScreen';
1818
import PerformanceTimingScreen from './screens/PerformanceTimingScreen';
1919
import EndToEndTestsScreen from './screens/EndToEndTestsScreen';
20+
import ProductDetailScreen from './screens/ProductDetailScreen';
2021
import ReduxScreen from './screens/ReduxScreen';
2122
import CartScreen from './screens/CartScreen';
2223
import CheckoutScreen from './screens/CheckoutScreen';
@@ -61,10 +62,16 @@ Sentry.init({
6162
Sentry.reactNativeTracingIntegration({
6263
traceFetch: false, // RN uses XHR to implement fetch, this prevents duplicates
6364
}),
65+
Sentry.mobileReplayIntegration({
66+
maskAllImages: true,
67+
maskAllText: true,
68+
}),
6469
reactNavigationIntegration,
6570
],
6671
tracesSampleRate: 1.0,
6772
profilesSampleRate: 1.0,
73+
replaysOnErrorSampleRate: 1.0,
74+
replaysSessionSampleRate: 1.0,
6875
enableUserInteractionTracing: true,
6976
enableAutoSessionTracking: true,
7077
sessionTrackingIntervalMillis: 5000, // For testing, session close when 5 seconds (instead of the default 30) in the background.
@@ -107,7 +114,7 @@ const App = () => {
107114
);
108115
}}>
109116
<BottomTabNavigator />
110-
<Toast />
117+
{/* <Toast /> */}
111118
</NavigationContainer>
112119
</GestureHandlerRootView>
113120
</SafeAreaProvider>
@@ -190,6 +197,7 @@ const ShopNavigator = () => {
190197
headerShown: false,
191198
}}>
192199
<Stack.Screen name="Home" component={HomeScreen} />
200+
<Stack.Screen name="ProductDetail" component={ProductDetailScreen} />
193201
</Stack.Navigator>
194202
);
195203
};

src/components/StyledProductCard.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View, Text, StyleSheet} from 'react-native';
2+
import {View, Text, StyleSheet, Pressable} from 'react-native';
33
import Toast from 'react-native-toast-message';
44
import {AppDispatch} from '../reduxApp';
55
import {StyledButton} from './StyledButton';
@@ -12,6 +12,8 @@ export const StyledProductCard = (props: {
1212
price: number;
1313
title: string;
1414
imgcropped: string;
15+
description: string;
16+
onPress: () => void;
1517
appDispatch: AppDispatch;
1618
}): React.ReactElement => {
1719
const onAddToCartPressed = () => {
@@ -25,20 +27,22 @@ export const StyledProductCard = (props: {
2527
imgcropped: props.imgcropped,
2628
},
2729
});
30+
const visibilityTimeMs = 1000;
2831
Toast.show({
2932
type: 'success',
3033
position: 'bottom',
3134
text1: 'Added to Cart',
32-
visibilityTime: 0.5,
35+
visibilityTime: visibilityTimeMs,
3336
});
3437
};
3538

3639
return (
37-
<View style={styles.cardContainer}>
40+
<Pressable style={styles.cardContainer} onPress={props.onPress}>
3841
<View style={styles.cardHero}>{selectImage(props.imgcropped)}</View>
3942
<View style={styles.cardDetail}>
4043
<View style={styles.cardDetailContent}>
4144
<Text style={styles.cardTitle}>{props.title}</Text>
45+
<Text style={styles.cardDescription}>{props.description}</Text>
4246
<Text style={styles.itemPrice}>${props.price}</Text>
4347
</View>
4448
<View style={styles.cardDetailAction}>
@@ -52,7 +56,7 @@ export const StyledProductCard = (props: {
5256
/>
5357
</View>
5458
</View>
55-
</View>
59+
</Pressable>
5660
);
5761
};
5862

@@ -111,4 +115,7 @@ const styles = StyleSheet.create({
111115
addToCartButtonDefault: {
112116
margin: 10,
113117
},
118+
cardDescription: {
119+
fontSize: 14,
120+
},
114121
});

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
export const DSN =
22
'https://[email protected]/5716557';
33

4+
// SENTRY_INTERNAL_DSN for testing
5+
// export const DSN =
6+
// 'https://[email protected]/5428561';
7+
48
export const BACKEND_URL =
59
'https://application-monitoring-flask-dot-sales-engineering-sf.appspot.com';
610
// 'http://127.0.0.1:8080'; // for local flask backend

src/navigation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {Product} from './types/Product';
2+
13
export type RootStackParamList = {
24
Home: undefined;
35
Tracker: undefined;
@@ -10,4 +12,5 @@ export type RootStackParamList = {
1012
ListApp: undefined;
1113
Checkout: undefined;
1214
CartScreen: undefined;
15+
ProductDetail: Product;
1316
};

src/screens/CartScreen.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ const CartScreen = ({
6262
}, [navigation]);
6363

6464
const cartItems: Array<CartData> | [] = Object.values(cartData);
65+
66+
if (cartItems.length === 0) {
67+
setTimeout(() => {
68+
console.error('No products in the cart.');
69+
});
70+
}
71+
6572
const subTotalDisplay = (props: subTotal): React.ReactElement => {
6673
const {quantity: q, total: t} = props;
6774
const multiple = q > 1 ? 's' : '';

0 commit comments

Comments
 (0)