Skip to content

Commit

Permalink
Merge pull request #125 from socialappslab/fix/565/disable-rollbar-temp
Browse files Browse the repository at this point in the history
feat: add ios to pipeline (remove rollbar)
  • Loading branch information
zant authored Jan 29, 2025
2 parents cb4125d + 39c854d commit 58b6258
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .sh/update-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ rm .env.production && mv .env.development .env
printf "\nEXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN=$EXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN" >> .env

yarn install
eas build --platform android --profile development --non-interactive
eas build --platform --profile development --non-interactive
14 changes: 7 additions & 7 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export default {
"expo-font",
"expo-asset",
"expo-localization",
[
"./plugins/rollbar-config-plugin",
{
environment: "development",
rollbarPostToken: process.env.EXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN,
},
],
// [
// "./plugins/rollbar-config-plugin",
// {
// environment: "development",
// rollbarPostToken: process.env.EXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN,
// },
// ],
[
"expo-location",
{
Expand Down
14 changes: 7 additions & 7 deletions app/(auth)/(tabs)/visits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,23 @@ import {
} from "@/components/themed";
import { ClosableBottomSheet } from "@/components/themed/ClosableBottomSheet";
import VisitSummary from "@/components/VisitSummary";
import { authApi } from "@/config/axios";
import Colors from "@/constants/Colors";
import { useAuth } from "@/context/AuthProvider";
import { useBrigades } from "@/hooks/useBrigades";
import useCreateMutation from "@/hooks/useCreateMutation";
import { useVisit } from "@/hooks/useVisit";
import { QuestionnaireState, useVisitStore } from "@/hooks/useVisitStore";
import { BaseObject, ErrorResponse, Team } from "@/schema";
import { VisitData } from "@/types";
import { countSetFilters, extractAxiosErrorData, formatDate } from "@/util";
import { normalizeVisitData } from "@/util/normalizeVisitData";
import { BottomSheetModal } from "@gorhom/bottom-sheet";
import useAxios from "axios-hooks";
import { deserialize, ExistingDocumentObject } from "jsonapi-fractal";
import { useEffect, useMemo, useRef, useState } from "react";
import { Platform, RefreshControl, StyleSheet } from "react-native";
import Toast from "react-native-toast-message";
import { Routes } from "../(visit)/_layout";
import { useBrigades } from "@/hooks/useBrigades";
import { authApi } from "@/config/axios";
import { sanitizeInspections } from "../(visit)/sanitizeInspections";

interface HouseReport {
Expand Down Expand Up @@ -149,8 +148,9 @@ export default function Visits() {
const { storedVisits, cleanUpStoredVisit } = useVisitStore();
const { language, isConnected } = useVisit();
const [selectedVisit, setSelectedVisit] = useState<QuestionnaireState>();
const { user, meData, rollbar } = useAuth();
const [team, setTeam] = useState<Team | null>(null);
// const { user, meData, rollbar } = useAuth();
const { meData } = useAuth();
const [setTeam] = useState<Team | null>(null);
const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false);
const { filters, setFilter } = useBrigades();
Expand Down Expand Up @@ -266,7 +266,7 @@ export default function Visits() {

try {
setLoading(true);
rollbar.log(JSON.stringify(visitToSubmit));
// rollbar?.log(JSON.stringify(visitToSubmit));
await createVisit({ json_params: JSON.stringify(visitToSubmit) });
cleanUpStoredVisit(visitToSubmit);
setSuccess(true);
Expand All @@ -278,7 +278,7 @@ export default function Visits() {
setLoading(false);
} catch (error) {
const errorData = extractAxiosErrorData(error);
rollbar.error(visitToSubmit, errorData);
// rollbar?.error(visitToSubmit, errorData);
Toast.show({
type: "error",
text1: t(["errorCodes.generic"]),
Expand Down
4 changes: 2 additions & 2 deletions app/(auth)/(visit)/summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default function Summary() {
// We only make the request if it's connected
if (isConnected)
await createVisit({ json_params: JSON.stringify(sanitizedVisitData) });
if (isConnected && rollbar)
rollbar.log(JSON.stringify(sanitizedVisitData));
// if (isConnected && rollbar)
// rollbar.log(JSON.stringify(sanitizedVisitData));

Toast.show({
type: "success",
Expand Down
51 changes: 28 additions & 23 deletions context/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
import { resetAuthApi, setAccessTokenToHeaders } from "@/config/axios";
import useUser from "@/hooks/useUser";
import { ErrorResponse } from "@/schema";
import { Client } from "rollbar-react-native";
// import { Client } from "rollbar-react-native";
import { Platform } from "react-native";

type AuthProviderType = {
user: IUser | null;
Expand All @@ -26,7 +27,7 @@ type AuthProviderType = {
login: (token: string, refreshToken: string, user: IUser) => boolean;
logout: () => void;
reFetchMe: () => void;
rollbar: Client;
// rollbar: Client | null;
};

function useProtectedRoute(user: IUser | null) {
Expand Down Expand Up @@ -69,22 +70,24 @@ export default function AuthProvider({ children }: { children: ReactNode }) {
const [[, userFromLocalStorage], setUserLocalStorage] = useUser();
const [user, setLoadedUser] = useState<IUser | null>(null);
const [meData, setMeData] = useState<IUser | null>(null);
const [rollbar, setRollbar] = useState<Client | null>(null);

const setRollbarClient = (person: {
id: string;
email?: string;
username?: string;
}) => {
const client = new Client({
accessToken: process.env.EXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN,
captureUncaught: true,
captureDeviceInfo: true,
payload: person,
});
client.setPerson(person.id, undefined, person.email);
setRollbar(client);
};
// const [rollbar, setRollbar] = useState<Client | null>(null);

// const setRollbarClient = (person: {
// id: string;
// email?: string;
// username?: string;
// }) => {
// if (Platform.OS !== "ios") {
// const client = new Client({
// accessToken: process.env.EXPO_PUBLIC_CLIENT_ITEM_ACCESS_TOKEN,
// captureUncaught: true,
// captureDeviceInfo: true,
// payload: person,
// });
// client.setPerson(person.id, undefined, person.email);
// setRollbar(client);
// }
// };

const [[loadingToken, token], setToken] = useStorageState(
ACCESS_TOKEN_LOCAL_STORAGE_KEY,
Expand Down Expand Up @@ -131,11 +134,13 @@ export default function AuthProvider({ children }: { children: ReactNode }) {
setToken(token);
setAccessTokenToHeaders(token);
setRefreshToken(refreshToken);
setRollbarClient({
id: user.id,
email: user.email || user.phone,
username: user.username,
});
// if (Platform.OS !== "ios") {
// setRollbarClient({
// id: user.id,
// email: user.email || user.phone,
// username: user.username,
// });
// }
return true;
};

Expand Down
5 changes: 5 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"buildType": "app-bundle"
}
},
"test_flight": {
"developmentClient": false,
"distribution": "store",
"autoIncrement": "true"
},
"preview": {
"distribution": "internal"
},
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
"react-native-toast-message": "^2.2.0",
"react-native-web": "~0.19.10",
"redux-devtools-expo-dev-plugin": "^0.2.1",
"rollbar": "^2.26.4",
"rollbar-react-native": "^1.0.0-beta.5",
"zod": "^3.23.8",
"zustand": "^5.0.0-rc.2"
},
Expand Down
4 changes: 3 additions & 1 deletion plugins/rollbar-config-plugin/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const withRollbarAndroid = require("./withRollbarAndroid");

const withRollbar = (config, options) => {
config = withRollbarAndroid(config, options);
if (!config.ios) {
config = withRollbarAndroid(config, options);
}

return config;
};
Expand Down

0 comments on commit 58b6258

Please sign in to comment.