Update sentry lines and comment new image picker.

This commit is contained in:
Patrick Fic
2025-05-30 13:55:18 -07:00
parent 895091468a
commit 00002ed0f5
11 changed files with 146 additions and 62 deletions

View File

@@ -17,29 +17,30 @@ cleanAxios.interceptors.request.eject(axiosAuthInterceptorId);
export const handleUpload = async (ev, context) => {
const { mediaId, onError, onSuccess, onProgress } = ev;
const { bodyshop, jobId } = context;
try {
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
const newFile = await (
await fetch(imageData.localUri || imageData.uri)
).blob();
let extension = imageData.localUri.split(".").pop();
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
const newFile = await (
await fetch(imageData.localUri || imageData.uri)
).blob();
let extension = imageData.localUri.split(".").pop();
//Default to Cloudinary in case of split treatment errors.
let destination =
splitClient?.getTreatment("Imgproxy") === "on" ? "imgproxy" : "cloudinary";
//Default to Cloudinary in case of split treatment errors.
let destination =
splitClient?.getTreatment("Imgproxy") === "on" ? "imgproxy" : "cloudinary";
let key =
destination === "imgproxy"
? `${bodyshop.id}/${jobId}/${replaceAccents(
let key =
destination === "imgproxy"
? `${bodyshop.id}/${jobId}/${replaceAccents(
imageData.filename || imageData.uri.split("/").pop()
).replace(/[^A-Z0-9]+/gi, "_")}-${new Date().getTime()}.${extension}`
: `${bodyshop.id}/${jobId}/${(
: `${bodyshop.id}/${jobId}/${(
imageData.filename || imageData.uri.split("/").pop()
).replace(/\.[^/.]+$/, "")}-${new Date().getTime()}`;
const res =
destination === "imgproxy"
? await uploadToImgproxy(
const res =
destination === "imgproxy"
? await uploadToImgproxy(
key,
mediaId,
imageData,
@@ -51,7 +52,7 @@ export const handleUpload = async (ev, context) => {
onProgress,
context
)
: await uploadToCloudinary(
: await uploadToCloudinary(
key,
mediaId,
imageData,
@@ -63,7 +64,18 @@ export const handleUpload = async (ev, context) => {
onProgress,
context
);
return res;
return res;
} catch (error) {
console.log("Error creating upload promise", error.message, error.stack);
if (onError) onError(error.message);
Sentry.captureException(error);
return {
success: false,
error: error.message,
stack: error.stack,
mediaId,
};
}
};
export const handleUploadImgproxy = async (ev, context) => {
@@ -196,7 +208,7 @@ export const uploadToImgproxy = async (
stack: error.stack,
mediaId,
};
Sentry.Native.captureException(error);
Sentry.captureException(error);
}
const documentInsert = await client.mutate({
@@ -270,7 +282,7 @@ export const uploadToCloudinary = async (
});
} catch (error) {
console.log("ERROR GETTING SIGNED URL", error);
Sentry.Native.captureException(error);
Sentry.captureException(error);
return { success: false, error: error };
}
@@ -319,7 +331,7 @@ export const uploadToCloudinary = async (
);
} catch (error) {
console.log("CLOUDINARY error", error.response, cloudinaryUploadResponse);
Sentry.Native.captureException(error);
Sentry.captureException(error);
if (onError) onError(error.message);
return { success: false, error: error };