@@ -8,23 +8,23 @@ import {
88import { type UnpluginContextMeta , type UnpluginOptions } from "unplugin" ;
99import { getPreSignedURL } from "../utils/getPreSignedURL.ts" ;
1010import { uploadStats } from "../utils/uploadStats.ts" ;
11- import { type SentryClient } from "../sentry.ts" ;
11+ import { type SentryMetrics } from "../sentry.ts" ;
1212import { type NormalizedOptions } from "../utils/normalizeOptions.ts" ;
1313import { createGauge } from "../utils/fetchWithRetry.ts" ;
1414
1515interface BundleAnalysisUploadPluginArgs {
1616 userOptions : NormalizedOptions ;
1717 unpluginMetaContext : UnpluginContextMeta ;
1818 bundleAnalysisUploadPlugin : BundleAnalysisUploadPlugin ;
19- sentryClient : SentryClient ;
19+ sentryMetrics : SentryMetrics ;
2020 handleRecoverableError : ( error : unknown ) => void ;
2121}
2222
2323export const bundleAnalysisPluginFactory = ( {
2424 userOptions,
2525 unpluginMetaContext,
2626 bundleAnalysisUploadPlugin,
27- sentryClient ,
27+ sentryMetrics ,
2828 handleRecoverableError,
2929} : BundleAnalysisUploadPluginArgs ) : UnpluginOptions => {
3030 const output : Output = {
@@ -66,7 +66,7 @@ export const bundleAnalysisPluginFactory = ({
6666 let url = "" ;
6767 const gauge = createGauge ( {
6868 bundler : unpluginMetaContext . framework ,
69- sentryClient ,
69+ sentryMetrics ,
7070 } ) ;
7171 const getPreSignedURLStart = Date . now ( ) ;
7272 try {
@@ -77,27 +77,18 @@ export const bundleAnalysisPluginFactory = ({
7777 retryCount : userOptions ?. retryCount ,
7878 gauge,
7979 } ) ;
80- sentryClient ?. metricsAggregator ?. add (
81- "c" ,
82- "request_presigned_url.success" ,
83- 1 ,
84- "none" ,
85- { bundler : unpluginMetaContext . framework } ,
86- ) ;
80+ sentryMetrics ?. increment ( "request_presigned_url.success" , 1 , "none" , {
81+ bundler : unpluginMetaContext . framework ,
82+ } ) ;
8783 } catch ( error ) {
88- sentryClient ?. metricsAggregator ?. add (
89- "c" ,
90- "request_presigned_url.error" ,
91- 1 ,
92- "none" ,
93- { bundler : unpluginMetaContext . framework } ,
94- ) ;
84+ sentryMetrics ?. increment ( "request_presigned_url.error" , 1 , "none" , {
85+ bundler : unpluginMetaContext . framework ,
86+ } ) ;
9587
9688 handleRecoverableError ( error ) ;
9789 return ;
9890 } finally {
99- sentryClient ?. metricsAggregator ?. add (
100- "d" ,
91+ sentryMetrics ?. distribution (
10192 "request_presigned_url" ,
10293 Date . now ( ) - getPreSignedURLStart ,
10394 "millisecond" ,
@@ -113,24 +104,15 @@ export const bundleAnalysisPluginFactory = ({
113104 retryCount : userOptions ?. retryCount ,
114105 gauge,
115106 } ) ;
116- sentryClient ?. metricsAggregator ?. add (
117- "c" ,
118- "upload_bundle_stats.success" ,
119- 1 ,
120- "none" ,
121- { bundler : unpluginMetaContext . framework } ,
122- ) ;
107+ sentryMetrics ?. increment ( "upload_bundle_stats.success" , 1 , "none" , {
108+ bundler : unpluginMetaContext . framework ,
109+ } ) ;
123110 } catch ( error ) {
124- sentryClient ?. metricsAggregator ?. add (
125- "c" ,
126- "upload_bundle_stats.error" ,
127- 1 ,
128- ) ;
111+ sentryMetrics ?. increment ( "upload_bundle_stats.error" , 1 ) ;
129112 handleRecoverableError ( error ) ;
130113 return ;
131114 } finally {
132- sentryClient ?. metricsAggregator ?. add (
133- "d" ,
115+ sentryMetrics ?. distribution (
134116 "upload_bundle_stats" ,
135117 Date . now ( ) - uploadStart ,
136118 "millisecond" ,
0 commit comments