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

bandit dogfood on ios #107

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion package-testing/react-native-sdk-relay/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
"ios": {
"supportsTablet": true
"supportsTablet": true,
"bundleIdentifier": "com.leoateppo.react-native-sdk-relay"
},
"android": {
"adaptiveIcon": {
Expand Down
7 changes: 0 additions & 7 deletions package-testing/react-native-sdk-relay/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ export default function TabLayout() {
>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
}}
/>
<Tabs.Screen
name="bandits"
options={{
title: 'Bandits',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
Expand Down
100 changes: 0 additions & 100 deletions package-testing/react-native-sdk-relay/app/(tabs)/bandits.tsx

This file was deleted.

118 changes: 76 additions & 42 deletions package-testing/react-native-sdk-relay/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,100 @@
import { Image, StyleSheet, Platform } from 'react-native';
import { StyleSheet } from 'react-native';

import { HelloWave } from '@/components/HelloWave';
import { Collapsible } from '@/components/Collapsible';
import ParallaxScrollView from '@/components/ParallaxScrollView';
import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { IconSymbol } from '@/components/ui/IconSymbol';
import { useEffect, useState } from 'react';
import { getInstance } from '@eppo/react-native-sdk';
import { useSubjectAttributes } from '@/hooks/useSubjectAttributes';
import { useEppoPrecomputedClient } from '@/hooks/useEppoPrecomputedClient';

export default function BanditTabScreen() {
const [updateHighlightsBanditVariation, setUpdateHighlightsBanditVariation] = useState<string>('LOADING...');
const [updateHighlightsBanditAction, setUpdateHighlightsBanditAction] = useState<string>('');

const [updateHighlightsFlagValue, setUpdateHighlightsFlagValue] = useState<string>('LOADING...');
const [precomputedFlagValue, setPrecomputedFlagValue] = useState<string>('LOADING...');

const subjectAttributes = useSubjectAttributes();
const client = useEppoPrecomputedClient();

// const client = useEppoPrecomputedClient();

useEffect(() => {
try {
const result = client.getBanditAction('update-highlights-bandit', 'NONE');

setUpdateHighlightsBanditVariation(result?.variation ?? 'ERROR');
setUpdateHighlightsBanditAction(result?.action ?? 'ERROR');

const flagResult = getInstance().getStringAssignment(
'update-highlights-bandit',
'user123',
subjectAttributes,
'NONE',
);
setUpdateHighlightsFlagValue(flagResult);

const precomputedFlagResult = client.getStringAssignment('update-highlights-bandit', 'NONE');
setPrecomputedFlagValue(precomputedFlagResult);
} catch (error) {
console.error('Error in bandit effect:', error);
setUpdateHighlightsBanditVariation('ERROR');
setUpdateHighlightsBanditAction('ERROR');
}
}, [client, subjectAttributes]);

export default function HomeScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#A1CEDC', dark: '#1D3D47' }}
headerImage={<Image source={require('@/assets/images/partial-react-logo.png')} style={styles.reactLogo} />}
headerBackgroundColor={{ light: '#D0D0D0', dark: '#353636' }}
headerImage={
<IconSymbol
size={310}
color="#808080"
name="chevron.left.forwardslash.chevron.right"
style={styles.headerImage}
/>
}
>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Welcome!</ThemedText>
<HelloWave />
<ThemedText type="title">Bandits</ThemedText>
</ThemedView>
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Step 1: Try it</ThemedText>
<ThemedText>Here we are seeing the first bandits on a mobile app!</ThemedText>
<Collapsible title="update-highlights-bandit">
<ThemedText>
Edit <ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> to see changes. Press{' '}
<ThemedText type="defaultSemiBold">
{Platform.select({
ios: 'cmd + d',
android: 'cmd + m',
web: 'F12',
})}
</ThemedText>{' '}
to open developer tools.
<ThemedText type="defaultSemiBold">VariationValue</ThemedText>{' '}
<ThemedText>{updateHighlightsBanditVariation}</ThemedText>
</ThemedText>
</ThemedView>
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Step 2: Explore</ThemedText>
<ThemedText>Tap the Explore tab to learn more about what's included in this starter app.</ThemedText>
</ThemedView>
<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Step 3: Get a fresh start</ThemedText>
<ThemedText>
When you're ready, run <ThemedText type="defaultSemiBold">npm run reset-project</ThemedText> to get a fresh{' '}
<ThemedText type="defaultSemiBold">app</ThemedText> directory. This will move the current{' '}
<ThemedText type="defaultSemiBold">app</ThemedText> to{' '}
<ThemedText type="defaultSemiBold">app-example</ThemedText>.
<ThemedText type="defaultSemiBold">Bandit Value</ThemedText>{' '}
<ThemedText>{updateHighlightsBanditAction}</ThemedText>
</ThemedText>
</ThemedView>
</Collapsible>
<Collapsible title="update-highlights-bandit Flag Value">
<ThemedText>
<ThemedText type="defaultSemiBold">Traditional Client</ThemedText>{' '}
<ThemedText>{updateHighlightsFlagValue}</ThemedText>
</ThemedText>
<ThemedText>
<ThemedText type="defaultSemiBold">Precomputed Client</ThemedText>{' '}
<ThemedText>{precomputedFlagValue}</ThemedText>
</ThemedText>
</Collapsible>
</ParallaxScrollView>
);
}

const styles = StyleSheet.create({
headerImage: {
color: '#808080',
bottom: -90,
left: -35,
position: 'absolute',
},
titleContainer: {
flexDirection: 'row',
alignItems: 'center',
gap: 8,
},
stepContainer: {
gap: 8,
marginBottom: 8,
},
reactLogo: {
height: 178,
width: 290,
bottom: 0,
left: 0,
position: 'absolute',
},
});
30 changes: 30 additions & 0 deletions package-testing/react-native-sdk-relay/ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Bundle artifacts
*.jsbundle

# CocoaPods
/Pods/
11 changes: 11 additions & 0 deletions package-testing/react-native-sdk-relay/ios/.xcode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
66 changes: 66 additions & 0 deletions package-testing/react-native-sdk-relay/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']

platform :ios, podfile_properties['ios.deploymentTarget'] || '15.1'
install! 'cocoapods',
:deterministic_uuids => false

prepare_react_native_project!

target 'reactnativesdkrelay' do
use_expo_modules!

if ENV['EXPO_USE_COMMUNITY_AUTOLINKING'] == '1'
config_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
else
config_command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'ios'
]
end

config = use_native_modules!(config_command)

use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
:privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
)

post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
:ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
)

# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end
Loading
Loading