Skip to content

Commit

Permalink
Feat/oct 12 release (#161)
Browse files Browse the repository at this point in the history
* update: experiment list

* fix: copilot consent and home page loads

* feat: consent flow

* feat: copilot flow

* disable server logs

* feat: update racommendations to include all promtpts in category

* feat: move apple health connection to settings

* minor: remove apple health from settings page

* feat: update prompt summaries

* feat: enable swipe, reword text

* nit: small changes

* fix: client dump

* fix: make update url seperate

* flush: mobile
  • Loading branch information
oreHGA authored Oct 14, 2023
1 parent d86d0ec commit b0b5e4d
Show file tree
Hide file tree
Showing 28 changed files with 845 additions and 427 deletions.
3 changes: 2 additions & 1 deletion fusionMobile/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Notifications from "expo-notifications";
import React from "react";
import { Alert, Linking, Platform, StatusBar } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { withIAPContext } from "react-native-iap";
import Toast from "react-native-toast-message";

import { FontLoader } from "./FontLoader";
Expand Down Expand Up @@ -307,7 +308,7 @@ function App() {
);
}

let AppEntryPoint = App;
let AppEntryPoint = withIAPContext(App);

if (Constants.expoConfig?.extra?.storybookEnabled === "true") {
AppEntryPoint = require("./.storybook").default;
Expand Down
5 changes: 4 additions & 1 deletion fusionMobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ react {
// Override `hermesEnabled` by `expo.jsEngine`
ext {
hermesEnabled = (findProperty('expo.jsEngine') ?: "hermes") == "hermes"
supportLibVersion = "28.0.0"
}

/**
Expand Down Expand Up @@ -115,11 +116,13 @@ android {

namespace 'com.neurofusion.fusion'
defaultConfig {
missingDimensionStrategy "store", "play"
applicationId 'com.neurofusion.fusion'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionCode 40
versionName "1.3.0"
missingDimensionStrategy 'store', 'play'
}

splits {
Expand Down
1 change: 1 addition & 0 deletions fusionMobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

buildscript {
ext {
supportLibVersion = "28.0.0"
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '33.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
Expand Down
9 changes: 6 additions & 3 deletions fusionMobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
ios: {
supportsTablet: true,
bundleIdentifier: "com.neurofusion.fusion",
buildNumber: "1",
buildNumber: "5",
backgroundColor: "#0B0816",
config: {
usesNonExemptEncryption: false,
Expand All @@ -32,7 +32,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
backgroundColor: "#0B0816",
},
package: "com.neurofusion.fusion",
versionCode: 1,
versionCode: 40,
softwareKeyboardLayoutMode: "pan",
},
web: {
Expand All @@ -53,6 +53,9 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
fusionNostrPublicKey:
"5f3a52d8027cdde03a41857e98224dafd69495204d93071199aa86921aa02674",
},
plugins: [["expo-notifications", { icon: "./assets/notification-icon.png" }]],
plugins: [
["expo-notifications", { icon: "./assets/notification-icon.png" }],
"react-native-iap",
],
owner: "oreogundipe",
});
4 changes: 4 additions & 0 deletions fusionMobile/ios/Fusion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
96905EF65AED1B983A6B3ABC /* libPods-Fusion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58EEBF8E8E6FB1BC6CAF49B5 /* libPods-Fusion.a */; };
B18059E884C0ABDD17F3DC3D /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */; };
BB2F792D24A3F905000567C9 /* Expo.plist in Resources */ = {isa = PBXBuildFile; fileRef = BB2F792C24A3F905000567C9 /* Expo.plist */; };
D101827F2AD7791800144FB1 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D101827E2AD7791800144FB1 /* StoreKit.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -31,6 +32,7 @@
7A4D352CD337FB3A3BF06240 /* Pods-Fusion.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Fusion.release.xcconfig"; path = "Target Support Files/Pods-Fusion/Pods-Fusion.release.xcconfig"; sourceTree = "<group>"; };
AA286B85B6C04FC6940260E9 /* SplashScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = SplashScreen.storyboard; path = Fusion/SplashScreen.storyboard; sourceTree = "<group>"; };
BB2F792C24A3F905000567C9 /* Expo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Expo.plist; sourceTree = "<group>"; };
D101827E2AD7791800144FB1 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
FAC715A2D49A985799AEE119 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-Fusion/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -41,6 +43,7 @@
buildActionMask = 2147483647;
files = (
96905EF65AED1B983A6B3ABC /* libPods-Fusion.a in Frameworks */,
D101827F2AD7791800144FB1 /* StoreKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -66,6 +69,7 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
D101827E2AD7791800144FB1 /* StoreKit.framework */,
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
58EEBF8E8E6FB1BC6CAF49B5 /* libPods-Fusion.a */,
);
Expand Down
2 changes: 1 addition & 1 deletion fusionMobile/ios/Fusion/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<string>5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>
Expand Down
6 changes: 6 additions & 0 deletions fusionMobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ PODS:
- React-Core
- RNGestureHandler (2.9.0):
- React-Core
- RNIap (12.10.8):
- React-Core
- RNPermissions (3.8.1):
- React-Core
- RNReanimated (2.14.4):
Expand Down Expand Up @@ -629,6 +631,7 @@ DEPENDENCIES:
- "RNFitnessTracker (from `../node_modules/@kilohealth/rn-fitness-tracker`)"
- RNFS (from `../node_modules/react-native-fs`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNIap (from `../node_modules/react-native-iap`)
- RNPermissions (from `../node_modules/react-native-permissions`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
Expand Down Expand Up @@ -792,6 +795,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-fs"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNIap:
:path: "../node_modules/react-native-iap"
RNPermissions:
:path: "../node_modules/react-native-permissions"
RNReanimated:
Expand Down Expand Up @@ -886,6 +891,7 @@ SPEC CHECKSUMS:
RNFitnessTracker: 3d80a66cbb25525ec0f92e8bdb1bf506837577d4
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNGestureHandler: 071d7a9ad81e8b83fe7663b303d132406a7d8f39
RNIap: 99a559a3642155b47aa0622f9693632010a0b4f7
RNPermissions: 8614afba1abbd56ae5c02e2af8ab6e8e11f8e236
RNReanimated: cc5e3aa479cb9170bcccf8204291a6950a3be128
RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f
Expand Down
1 change: 1 addition & 0 deletions fusionMobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"react-native-gesture-handler": "~2.9.0",
"react-native-get-random-values": "1.8.0",
"react-native-health": "^1.14.0",
"react-native-iap": "^12.10.8",
"react-native-modal-datetime-picker": "^15.0.0",
"react-native-paper": "^5.7.2",
"react-native-permissions": "^3.8.0",
Expand Down
26 changes: 25 additions & 1 deletion fusionMobile/src/contexts/account.context.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import * as SecureStore from "expo-secure-store";
import { ReactNode, createContext, useEffect, useState } from "react";

import { UserPreferences } from "~/@types";
import { nostrService } from "~/services/nostr.service";

export const AccountContext = createContext<null | {
userNpub: string;
userApiToken: string;
userLoading: boolean;
userPreferences: UserPreferences;
setUserPreferences: React.Dispatch<React.SetStateAction<UserPreferences>>;
}>(null);

export const AccountContextProvider = ({
Expand All @@ -16,6 +20,10 @@ export const AccountContextProvider = ({
const [userNpub, setUserNpub] = useState<string>("");
const [userApiToken, setUserApiToken] = useState<string>("");
const [userLoading, setUserLoading] = useState<boolean>(true);
const [userPreferences, setUserPreferences] = useState<UserPreferences>({
enableCopilot: false,
enableResearchMode: false,
});

useEffect(() => {
(async () => {
Expand All @@ -26,12 +34,28 @@ export const AccountContextProvider = ({
const apiToken = await nostrService.getApiToken(userDetails!);
setUserApiToken(apiToken!);

// now make request to get user preferences
const copilotConsent =
(await SecureStore.getItemAsync("copilot_consent")) === "true";
setUserPreferences({
enableCopilot: copilotConsent,
enableResearchMode: false,
});

setUserLoading(false);
})();
}, []);

return (
<AccountContext.Provider value={{ userNpub, userApiToken, userLoading }}>
<AccountContext.Provider
value={{
userNpub,
userApiToken,
userLoading,
userPreferences,
setUserPreferences,
}}
>
{children}
</AccountContext.Provider>
);
Expand Down
87 changes: 3 additions & 84 deletions fusionMobile/src/pages/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
Keyboard,
Linking,
ScrollView,
Platform,
} from "react-native";
import RNFS from "react-native-fs";
import AppleHealthKit, { HealthValue } from "react-native-health";

import {
NotificationConfigDays,
Expand All @@ -26,12 +24,7 @@ import {
import { Button, Input, Screen } from "~/components";
import { AccountContext } from "~/contexts/account.context";
import { promptService } from "~/services";
import {
appInsights,
maskPromptId,
permissions,
saveFileToDevice,
} from "~/utils";
import { appInsights, maskPromptId, saveFileToDevice } from "~/utils";

export function AccountScreen() {
const [feedbackText, setFeedbackText] = React.useState("");
Expand All @@ -47,71 +40,6 @@ export function AccountScreen() {
});
}, []);

const showStepsToday = async () => {
if (Platform.OS === "ios") {
AppleHealthKit.initHealthKit(permissions, (error) => {
/* Called after we receive a response from the system */
if (error) {
console.log("[ERROR] Cannot grant permissions!");
}

/* Can now read or write to HealthKit */
const options = {
startDate: dayjs().startOf("day").toISOString(),
};

// AppleHealthKit.getSleepSamples(
// options,
// async (err: any, results: HealthValue[]) => {
// if (err) {
// return;
// }

// await saveFileToDevice(
// `fusionSleep.json`,
// JSON.stringify(results),
// true,
// "application/json",
// "public.json"
// );
// // console.log(results);
// }
// );

// AppleHealthKit.getDailyStepCountSamples(
// options,
// async (err: any, results: HealthValue[]) => {
// if (err) {
// return;
// }

// await saveFileToDevice(
// `fusionSteps.json`,
// JSON.stringify(results),
// true,
// "application/json",
// "public.json"
// );
// // console.log(results);
// }
// );

AppleHealthKit.getStepCount(
options,
(err: any, results: HealthValue) => {
if (err) {
return;
}
Alert.alert(
"Total steps today",
`${Math.floor(results.value)} steps`
);
}
);
});
}
};

const exportData = async (dataType: string) => {
// get all the available prompts
// get all the responses
Expand Down Expand Up @@ -160,7 +88,7 @@ export function AccountScreen() {
const importData = async () => {
// read the prompt.csv file & sequentially call save prompts
const promptFilePath =
RNFS.DocumentDirectoryPath + "/fusionPrompts_1696402800.csv";
RNFS.DocumentDirectoryPath + "/fusionPrompts_1696834800.csv";

RNFS.readFile(promptFilePath, "utf8")
.then((content) => {
Expand Down Expand Up @@ -196,7 +124,7 @@ export function AccountScreen() {

// read the responses.csv file & sequentially call save responses
const responseFilePath =
RNFS.DocumentDirectoryPath + "/fusionResponses_1696402800.csv";
RNFS.DocumentDirectoryPath + "/fusionResponses_1696834800.csv";

RNFS.readFile(responseFilePath, "utf8")
.then((content) => {
Expand Down Expand Up @@ -325,15 +253,6 @@ export function AccountScreen() {
fullWidth
onPress={async () => await importData()}
/> */}

{Platform.OS === "ios" && (
<Button
title="Show Steps from Apple Health"
variant="ghost"
fullWidth
onPress={async () => await showStepsToday()}
/>
)}
</View>
</ScrollView>
</TouchableWithoutFeedback>
Expand Down
Loading

1 comment on commit b0b5e4d

@vercel
Copy link

@vercel vercel bot commented on b0b5e4d Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fusion – ./neurofusion/next-client

fusion-git-master-neurofusion-research-inc.vercel.app
fusion-neurofusion-research-inc.vercel.app
usefusion.app
www.usefusion.app

Please sign in to comment.