@@ -10,15 +10,18 @@ import { type NormalizedOptions } from "../utils/normalizeOptions.ts";
10
10
import { detectProvider } from "../utils/provider.ts" ;
11
11
import { uploadStats } from "../utils/uploadStats.ts" ;
12
12
import { sendSentryBundleStats } from "../utils/sentryUtils.ts" ;
13
+ import { type SentryClient } from "../sentry.ts" ;
13
14
14
15
interface BundleAnalysisUploadPluginArgs {
15
16
options : NormalizedOptions ;
16
17
bundleAnalysisUploadPlugin : BundleAnalysisUploadPlugin ;
18
+ sentryClient : SentryClient ;
17
19
}
18
20
19
21
export const bundleAnalysisPluginFactory = ( {
20
22
options,
21
23
bundleAnalysisUploadPlugin,
24
+ sentryClient,
22
25
} : BundleAnalysisUploadPluginArgs ) : UnpluginOptions => {
23
26
const output : Output = {
24
27
version : "1" ,
@@ -66,26 +69,65 @@ export const bundleAnalysisPluginFactory = ({
66
69
const inputs : ProviderUtilInputs = { envs, args } ;
67
70
const provider = await detectProvider ( inputs ) ;
68
71
72
+ const getPreSignedURLStart = Date . now ( ) ;
69
73
let url = "" ;
70
74
try {
71
75
url = await getPreSignedURL ( {
72
- apiURL : options ?. apiUrl ?? "https://api.codecov.io" ,
76
+ apiURL : options ?. apiUrl ,
73
77
uploadToken : options ?. uploadToken ,
74
78
serviceParams : provider ,
75
79
retryCount : options ?. retryCount ,
76
80
} ) ;
81
+ sentryClient ?. metricsAggregator ?. add (
82
+ "c" ,
83
+ "request_presigned_url.success" ,
84
+ 1 ,
85
+ ) ;
77
86
} catch ( error ) {
87
+ sentryClient ?. metricsAggregator ?. add (
88
+ "c" ,
89
+ "request_presigned_url.error" ,
90
+ 1 ,
91
+ ) ;
78
92
return ;
93
+ } finally {
94
+ sentryClient ?. metricsAggregator ?. add (
95
+ "d" ,
96
+ "request_presigned_url" ,
97
+ Date . now ( ) - getPreSignedURLStart ,
98
+ "millisecond" ,
99
+ ) ;
79
100
}
80
101
102
+ const uploadStart = Date . now ( ) ;
81
103
try {
82
104
await uploadStats ( {
83
105
preSignedUrl : url ,
84
106
bundleName : output . bundleName ,
85
107
message : JSON . stringify ( output ) ,
86
108
retryCount : options ?. retryCount ,
109
+ sentryClient,
87
110
} ) ;
88
- } catch { }
111
+ sentryClient ?. metricsAggregator ?. add (
112
+ "c" ,
113
+ "upload_bundle_stats.success" ,
114
+ 1 ,
115
+ ) ;
116
+ } catch {
117
+ sentryClient ?. metricsAggregator ?. add (
118
+ "c" ,
119
+ "upload_bundle_stats.error" ,
120
+ 1 ,
121
+ ) ;
122
+ return ;
123
+ } finally {
124
+ sentryClient ?. metricsAggregator ?. add (
125
+ "d" ,
126
+ "upload_bundle_stats" ,
127
+ Date . now ( ) - uploadStart ,
128
+ "millisecond" ,
129
+ ) ;
130
+ }
89
131
} ,
90
132
} ;
91
133
} ;
0 commit comments