Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into fix--sentry-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Marin2705 committed May 2, 2023
2 parents ecb0141 + 5abaf3f commit 51bf274
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 13 deletions.
5 changes: 2 additions & 3 deletions app/src/components/bubble/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState } from "react";
import { useFocusEffect, useNavigation } from "@react-navigation/native";
import ReminderBubble from "./reminder-bubble";
const ReminderStorageKey = "@Reminder";
import AsyncStorage from "@react-native-async-storage/async-storage";
import localStorage from "../../utils/localStorage";

export default () => {
const navigation = useNavigation();
Expand All @@ -11,7 +10,7 @@ export default () => {
useFocusEffect(
React.useCallback(() => {
(async () => {
const reminder = await AsyncStorage.getItem(ReminderStorageKey);
const reminder = await localStorage.getReminder();
setReminderBubbleVisible(!reminder);
})();
}, [])
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/bubble/reminder-bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import Text from "../MyText";
const ReminderItem = ({ onPress }) => {
return (
<TouchableOpacity onPress={onPress}>
<View className="bg-white border shadow-sm border-gray-300 rounded-xl p-3 mb-5">
<Text className="font-bold text-primary text-base">
<View className="bg-primary border shadow-sm border-gray-300 rounded-xl p-3 mb-5">
<Text className="font-[Karla-Bold] text-white text-base">
Mettre un rappel
</Text>
<Text className="text-black text-sm mt-2">
<Text className="text-white text-sm mt-2">
Saisir tous les jours votre suivi me permet de mieux suivre mon
évolution
</Text>
Expand Down
2 changes: 1 addition & 1 deletion app/src/scenes/contribute/contributeCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ContributeItem = ({ onPress }) => {
return (
<TouchableOpacity onPress={onPress}>
<View className="bg-white border shadow-sm border-gray-300 rounded-xl p-3 mb-5">
<Text className="font-bold text-primary text-base">
<Text className="font-[Karla-Bold] text-primary text-base">
Contribuer à BPCO'Mieux
</Text>
<Text className="text-black text-sm mt-2">
Expand Down
15 changes: 11 additions & 4 deletions app/src/scenes/reminder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { colors } from "../../utils/colors";
import dayjs from "dayjs";
import * as Device from "expo-device";
import * as Notifications from "expo-notifications";
import logEvents from "../../services/logEvents";

const Reminder = ({ navigation, route }) => {
const DEFAULT_REMINDER = dayjs().hour(8).minute(0);
Expand All @@ -45,6 +46,10 @@ const Reminder = ({ navigation, route }) => {
if (!existingReminder) {
setReminderRequest(DEFAULT_REMINDER);
}

inOnboarding
? logEvents.logOnboardingReminderValidate(reminder)
: logEvents.logReminderValidate(reminder);
navigation.navigate(
inOnboarding ? ONBOARDING_STEPS.STEP_EXPLANATION : "tabs"
);
Expand All @@ -54,17 +59,16 @@ const Reminder = ({ navigation, route }) => {
if (!dayjs(newReminder).isValid()) return;
setReminder(dayjs(newReminder));
setReminderSetupVisible(false);
// TODO: save reminder, schedule notification...
await localStorage.setReminder(newReminder);
await registerForPushNotificationsAsync();
await scheduleDailyReminer(
dayjs(newReminder).get("hour"),
dayjs(newReminder).get("minute")
);

// await scheduleNotification(newReminder);
// const scheduled =
// await NotificationService.getScheduledLocalNotifications();
inOnboarding
? logEvents.logOnboardingReminderSet(reminder)
: logEvents.logReminderSet(reminder);
};

return (
Expand Down Expand Up @@ -150,6 +154,7 @@ const registerForPushNotificationsAsync = async () => {
if (finalStatus !== "granted") {
// alert("Failed to get push token for push notification!");
Alert.alert("Erreur", "impossible d'activer les notifications");
logEvents.logPushNotificationsRegisterErrorFinalStatus(finalStatus);
return;
}
// token = (await Notifications.getExpoPushTokenAsync()).data;
Expand All @@ -160,6 +165,8 @@ const registerForPushNotificationsAsync = async () => {
"Erreur",
"impossible d'activer les notifications sur cet appareil"
);
logEvents.logPushNotificationsRegisterErrorDevice();
return;
}

// return token;
Expand Down
2 changes: 1 addition & 1 deletion app/src/scenes/status/DiaryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DiaryList = ({ ...props }) => {
</Text>
</TouchableWithoutFeedback>
</View>
<View className="pl-[15px] ml-1 -my-1 pb-1 border-l-[0.4px] border-primary">
<View className="pl-[15px] ml-1 -my-1 pb-3 border-l-[0.4px] border-primary">
<StatusItem alert={surveyAlert} />
{showConsulted ? (
<ConsultedItem
Expand Down
2 changes: 1 addition & 1 deletion app/src/scenes/status/status-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export default ({ alert }) => {
</View>
);
} else {
return <View className="my-4" />;
return <View className="my-2" />;
}
};
60 changes: 60 additions & 0 deletions app/src/services/logEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const CATEGORIES = {
PROFILE: "PROFILE",
SURVEY: "SURVEY",
CONSULTED: "CONSULTED",
REMINDER: "REMINDER",
};
const ACTIONS = {
APP_OPEN: "APP_OPEN",
Expand Down Expand Up @@ -131,6 +132,59 @@ const ACTIONS = {
CONSULTED_DETAILS: "CONSULTED_DETAILS",
CONSULTED_DATE_ANSWERED: "CONSULTED_DATE_ANSWERED",
CONSULTED_PREVIOUS_SCREEN: "CONSULTED_PREVIOUS_SCREEN",
REMINDER_SET: "REMINDER_SET",
REMINDER_VALIDATE: "REMINDER_VALIDATE",
PUSH_NOTIFICATIONS_REGISTER_ERROR_FINAL_STATUS:
"PUSH_NOTIFICATIONS_REGISTER_ERROR_FINAL_STATUS",
PUSH_NOTIFICATIONS_REGISTER_ERROR_DEVICE:
"PUSH_NOTIFICATIONS_REGISTER_ERROR_DEVICE",
};

const logPushNotificationsRegisterErrorFinalStatus = async (finalStatus) => {
await logEvent({
category: CATEGORIES.REMINDER,
action: ACTIONS.PUSH_NOTIFICATIONS_REGISTER_ERROR_FINAL_STATUS,
name: finalStatus,
});
};

const logPushNotificationsRegisterErrorDevice = async () => {
await logEvent({
category: CATEGORIES.REMINDER,
action: ACTIONS.PUSH_NOTIFICATIONS_REGISTER_ERROR_DEVICE,
});
};

const logOnboardingReminderSet = async (reminder) => {
await logEvent({
category: CATEGORIES.ONBOARDING,
action: ACTIONS.REMINDER_SET,
name: reminder,
});
};

const logOnboardingReminderValidate = async (reminder) => {
await logEvent({
category: CATEGORIES.ONBOARDING,
action: ACTIONS.REMINDER_VALIDATE,
name: reminder,
});
};

const logReminderSet = async (reminder) => {
await logEvent({
category: CATEGORIES.REMINDER,
action: ACTIONS.REMINDER_SET,
name: reminder,
});
};

const logReminderValidate = async (reminder) => {
await logEvent({
category: CATEGORIES.REMINDER,
action: ACTIONS.REMINDER_VALIDATE,
name: reminder,
});
};

const logAppVisit = async () => {
Expand Down Expand Up @@ -488,4 +542,10 @@ export default {
logConsultedDetails,
logConsultedDateAnswered,
logConsultedPreviousScreen,
logReminderValidate,
logReminderSet,
logOnboardingReminderValidate,
logOnboardingReminderSet,
logPushNotificationsRegisterErrorDevice,
logPushNotificationsRegisterErrorFinalStatus,
};

0 comments on commit 51bf274

Please sign in to comment.