diff --git a/packages/atlas/src/hooks/useGetAssetUrl.ts b/packages/atlas/src/hooks/useGetAssetUrl.ts index 838f172908..7ef8a1cbbe 100644 --- a/packages/atlas/src/hooks/useGetAssetUrl.ts +++ b/packages/atlas/src/hooks/useGetAssetUrl.ts @@ -34,6 +34,8 @@ export const getSingleAssetUrl = async ( dataObjectId: id, dataObjectType: type || undefined, resolvedUrl: distributionAssetUrl, + // https://mrbovo.distributor.cc/distributor/api/v1/assets/48451 -> regexp match for https://mrbovo.distributor.cc + distributorUrl: distributionAssetUrl.match(/https?:\/\/[^/]+/)?.[0] ?? undefined, } const [assetTestPromise, cleanup] = testAssetDownload(distributionAssetUrl, type, opts) const assetTestPromiseWithTimeout = withTimeout( diff --git a/packages/atlas/src/providers/uploads/uploads.hooks.ts b/packages/atlas/src/providers/uploads/uploads.hooks.ts index af24eb4ff9..ac9f43e1fb 100644 --- a/packages/atlas/src/providers/uploads/uploads.hooks.ts +++ b/packages/atlas/src/providers/uploads/uploads.hooks.ts @@ -180,7 +180,7 @@ export const useStartFileUpload = () => { // only retry on Axios error, otherwise code is to blame if (networkFailure) { - UserEventsLogger.logDistributorError({ dataObjectId: asset.id, storageOperatorId: uploadOperator.id }, e) + UserEventsLogger.logUploadError({ dataObjectId: asset.id, storageOperatorId: uploadOperator.id }, e) markStorageOperatorFailed(uploadOperator.id) const retry = opts?.retry ?? 0 diff --git a/packages/atlas/src/utils/logs/asset.ts b/packages/atlas/src/utils/logs/asset.ts index f25bb7758f..56867a4c15 100644 --- a/packages/atlas/src/utils/logs/asset.ts +++ b/packages/atlas/src/utils/logs/asset.ts @@ -49,11 +49,15 @@ type UserLogEvent = { [x: string]: unknown } -export type DistributorEventEntry = { +export type DataObjectEventEntry = { dataObjectId?: string | null dataObjectType?: DataObjectType['__typename'] | AssetType resolvedUrl?: string -} & StorageOperatorEventDetails +} + +export type StorageOperatorEventEntry = DataObjectEventEntry & StorageOperatorEventDetails + +export type DistributorEventEntry = DataObjectEventEntry & DistributorEventDetails type CodecInfo = { assetType: string | null @@ -149,6 +153,15 @@ class _UserEventsLogger { this.addErrorEvent(event) } + logUploadError(entry: StorageOperatorEventEntry, error: Error) { + const event: UserLogEvent = { + type: 'distributor-response-error', + ...entry, + error: error.message, + } + this.addErrorEvent(event) + } + logDistributorResponseTimeout(entry: DistributorEventEntry) { const event: UserPerformanceEvent = { type: 'distributor-response-timeout', @@ -182,7 +195,7 @@ class _UserEventsLogger { this.addErrorEvent(event) } - logAssetUploadFailedEvent(entry: DistributorEventEntry, error: Error) { + logAssetUploadFailedEvent(entry: StorageOperatorEventEntry, error: Error) { const event: UserLogEvent = { type: 'asset-upload-failed', ...entry,