@@ -6,26 +6,26 @@ import {
66} from "../types.ts" ;
77import { type UnpluginContextMeta , type UnpluginOptions } from "unplugin" ;
88import { getPreSignedURL } from "../utils/getPreSignedURL.ts" ;
9+ import { uploadStats } from "../utils/uploadStats.ts" ;
10+ import { type SentryMetrics } from "../sentry.ts" ;
911import { type NormalizedOptions } from "../utils/normalizeOptions.ts" ;
1012import { detectProvider } from "../utils/provider.ts" ;
11- import { uploadStats } from "../utils/uploadStats.ts" ;
1213import { sendSentryBundleStats } from "../utils/sentryUtils.ts" ;
13- import { type SentryClient } from "../sentry.ts" ;
1414import { createGauge } from "../utils/fetchWithRetry.ts" ;
1515
1616interface BundleAnalysisUploadPluginArgs {
1717 options : NormalizedOptions ;
1818 unpluginMetaContext : UnpluginContextMeta ;
1919 bundleAnalysisUploadPlugin : BundleAnalysisUploadPlugin ;
20- sentryClient : SentryClient ;
20+ sentryMetrics : SentryMetrics ;
2121 handleRecoverableError : ( error : unknown ) => void ;
2222}
2323
2424export const bundleAnalysisPluginFactory = ( {
2525 options,
2626 unpluginMetaContext,
2727 bundleAnalysisUploadPlugin,
28- sentryClient ,
28+ sentryMetrics ,
2929 handleRecoverableError,
3030} : BundleAnalysisUploadPluginArgs ) : UnpluginOptions => {
3131 const output : Output = {
@@ -77,7 +77,7 @@ export const bundleAnalysisPluginFactory = ({
7777 let url = "" ;
7878 const gauge = createGauge ( {
7979 bundler : unpluginMetaContext . framework ,
80- sentryClient ,
80+ sentryMetrics ,
8181 } ) ;
8282 const getPreSignedURLStart = Date . now ( ) ;
8383 try {
@@ -88,27 +88,18 @@ export const bundleAnalysisPluginFactory = ({
8888 retryCount : options ?. retryCount ,
8989 gauge,
9090 } ) ;
91- sentryClient ?. metricsAggregator ?. add (
92- "c" ,
93- "request_presigned_url.success" ,
94- 1 ,
95- "none" ,
96- { bundler : unpluginMetaContext . framework } ,
97- ) ;
91+ sentryMetrics ?. increment ( "request_presigned_url.success" , 1 , "none" , {
92+ bundler : unpluginMetaContext . framework ,
93+ } ) ;
9894 } catch ( error ) {
99- sentryClient ?. metricsAggregator ?. add (
100- "c" ,
101- "request_presigned_url.error" ,
102- 1 ,
103- "none" ,
104- { bundler : unpluginMetaContext . framework } ,
105- ) ;
95+ sentryMetrics ?. increment ( "request_presigned_url.error" , 1 , "none" , {
96+ bundler : unpluginMetaContext . framework ,
97+ } ) ;
10698
10799 handleRecoverableError ( error ) ;
108100 return ;
109101 } finally {
110- sentryClient ?. metricsAggregator ?. add (
111- "d" ,
102+ sentryMetrics ?. distribution (
112103 "request_presigned_url" ,
113104 Date . now ( ) - getPreSignedURLStart ,
114105 "millisecond" ,
@@ -125,24 +116,15 @@ export const bundleAnalysisPluginFactory = ({
125116 retryCount : options ?. retryCount ,
126117 gauge,
127118 } ) ;
128- sentryClient ?. metricsAggregator ?. add (
129- "c" ,
130- "upload_bundle_stats.success" ,
131- 1 ,
132- "none" ,
133- { bundler : unpluginMetaContext . framework } ,
134- ) ;
119+ sentryMetrics ?. increment ( "upload_bundle_stats.success" , 1 , "none" , {
120+ bundler : unpluginMetaContext . framework ,
121+ } ) ;
135122 } catch ( error ) {
136- sentryClient ?. metricsAggregator ?. add (
137- "c" ,
138- "upload_bundle_stats.error" ,
139- 1 ,
140- ) ;
123+ sentryMetrics ?. increment ( "upload_bundle_stats.error" , 1 ) ;
141124 handleRecoverableError ( error ) ;
142125 return ;
143126 } finally {
144- sentryClient ?. metricsAggregator ?. add (
145- "d" ,
127+ sentryMetrics ?. distribution (
146128 "upload_bundle_stats" ,
147129 Date . now ( ) - uploadStart ,
148130 "millisecond" ,
0 commit comments