File tree Expand file tree Collapse file tree 7 files changed +69
-5
lines changed
anytime-action/tax-clearance-certificate/steps Expand file tree Collapse file tree 7 files changed +69
-5
lines changed Original file line number Diff line number Diff line change @@ -122,12 +122,21 @@ export const Review = (props: Props): ReactElement => {
122122 const taxClearanceResponse = await api . postTaxClearanceCertificate ( userData ) ;
123123 if ( "error" in taxClearanceResponse ) {
124124 analytics . event . tax_clearance . submit . validation_error ( ) ;
125+ analytics . event . api_submit . error (
126+ "treasury.taxation.tax_clearance_submission" ,
127+ taxClearanceResponse . error . message ,
128+ ) ;
125129 props . setResponseErrorType ( taxClearanceResponse . error . type ) ;
126130 return ;
127131 }
128132
129133 if ( taxClearanceResponse . certificatePdfArray ) {
130134 analytics . event . tax_clearance . appears . validation_success ( ) ;
135+ analytics . event . api_submit . success (
136+ "treasury.taxation.tax_clearance_submission" ,
137+ "successfully submitted tax clearance certificate" ,
138+ ) ;
139+
131140 const blob = new Blob (
132141 [
133142 new Uint8Array (
@@ -144,6 +153,10 @@ export const Review = (props: Props): ReactElement => {
144153 }
145154 } catch {
146155 analytics . event . tax_clearance . submit . validation_error ( ) ;
156+ analytics . event . api_submit . error (
157+ "treasury.taxation.tax_clearance_submission" ,
158+ "there was an issue submitting tax clearance" ,
159+ ) ;
147160 props . setResponseErrorType ( "SYSTEM_ERROR" ) ;
148161 } finally {
149162 setIsLoading ( false ) ;
Original file line number Diff line number Diff line change @@ -335,9 +335,17 @@ export const BusinessFormationPaginator = (): ReactElement => {
335335 router
336336 ) {
337337 analytics . event . business_formation . submit . go_to_NIC_formation_processing ( ) ;
338+ analytics . event . api_submit . success (
339+ "treasury.revenue.formation_submission" ,
340+ "successfully submitted formation" ,
341+ ) ;
338342 await router . replace ( newBusiness . formationData . formationResponse . redirect ) ;
339343 } else {
340344 analytics . event . business_formation . submit . error_remain_at_formation ( ) ;
345+ analytics . event . api_submit . error (
346+ "treasury.revenue.formation_submission" ,
347+ "error submitting formation" ,
348+ ) ;
341349 setIsLoading ( false ) ;
342350 }
343351 } ;
Original file line number Diff line number Diff line change @@ -257,12 +257,20 @@ export const CigaretteLicenseReview = (props: Props): ReactElement => {
257257 } ,
258258 } )
259259 . update ( ) ;
260+ analytics . event . api_submit . success (
261+ "treasury.revenue.cigarette_prepare_payment" ,
262+ "successfully prepared payment for cigarette license" ,
263+ ) ;
260264 await router . replace ( cigaretteLicenseResponse . paymentInfo ?. htmL5RedirectUrl ) ;
261265 }
262266 }
263267 } catch {
264268 setLoading ( false ) ;
265269 analytics . event . cigarette_license . submit . service_error ( ) ;
270+ analytics . event . api_submit . error (
271+ "treasury.revenue.cigarette_prepare_payment" ,
272+ "error preparing payment for cigarette license" ,
273+ ) ;
266274 props . setSubmissionError ( "UNAVAILABLE" ) ;
267275 setTimeout ( ( ) => {
268276 if ( props . errorAlertRef . current ) {
Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ export const ConfirmationPage = (props: Props): ReactElement => {
115115
116116 if ( status === "CONFIRMED" ) {
117117 analytics . event . cigarette_license . appears . validation_success ( ) ;
118+ analytics . event . api_submit . success (
119+ "treasury.revenue.cigarette_submission" ,
120+ "successfully submitted cigarette license" ,
121+ ) ;
118122 return (
119123 < >
120124 < div className = "maxw-tablet margin-x-auto" >
Original file line number Diff line number Diff line change @@ -130,16 +130,18 @@ export const useBusinessNameSearch = ({
130130 } ) ;
131131 }
132132 setNameAvailability ( { ...result } ) ;
133+ analytics . event . api_submit . success (
134+ "treasury.revenue.formation_submission" ,
135+ "name is available" ,
136+ ) ;
133137 return { nameAvailability : result , submittedName : currentName } ;
134138 } )
135139 . catch ( ( api_error ) => {
136140 resetState ( ) ;
137141 setIsLoading ( false ) ;
138- if ( api_error === 400 ) {
139- setError ( "BAD_INPUT" ) ;
140- } else {
141- setError ( "SEARCH_FAILED" ) ;
142- }
142+ const errorMessage = api_error === 400 ? "BAD_INPUT" : "SEARCH_FAILED" ;
143+ setError ( errorMessage ) ;
144+ analytics . event . api_submit . error ( "treasury.revenue.formation_submission" , errorMessage ) ;
143145 throw new Error ( "ERROR" ) ;
144146 } ) ;
145147 } ;
Original file line number Diff line number Diff line change 1+ export type LegacyEventApiName =
2+ | "treasury.revenue.check_name"
3+ | "treasury.revenue.formation_submission"
4+ | "treasury.taxation.tax_clearance_submission"
5+ | "treasury.revenue.cigarette_prepare_payment"
6+ | "treasury.revenue.cigarette_submission" ;
7+
18export type LegacyEventCategory =
9+ | LegacyEventApiName
210 | "account_menu_myNJ_account"
311 | "account_menu_my_profile"
412 | "account_name"
@@ -193,6 +201,8 @@ export type LegacyEventAction =
193201 | "response"
194202 | "scroll"
195203 | "submit"
204+ | "api_submit_success"
205+ | "api_submit_error"
196206 | string ;
197207
198208export type LegacyEventLabel =
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/explicit-function-return-type */
22import {
33 LegacyEventAction ,
4+ LegacyEventApiName ,
45 LegacyEventCategory ,
56 LegacyEventLabel ,
67} from "@/lib/utils/analytics-legacy" ;
@@ -885,6 +886,24 @@ export default {
885886 } ,
886887 } ,
887888 } ,
889+ api_submit : {
890+ success : ( apiName : LegacyEventApiName , apiDetails ?: string ) => {
891+ eventRunner . track ( {
892+ event : "form_submits" ,
893+ legacy_event_category : apiName ,
894+ legacy_event_action : "api_submit_success" ,
895+ legacy_event_label : apiDetails ,
896+ } ) ;
897+ } ,
898+ error : ( api_name : string , api_details ?: string ) => {
899+ eventRunner . track ( {
900+ event : "form_submits" ,
901+ legacy_event_category : api_name ,
902+ legacy_event_action : "api_submit_error" ,
903+ legacy_event_label : api_details ,
904+ } ) ;
905+ } ,
906+ } ,
888907 profile_save : {
889908 click : {
890909 save_profile_changes : ( ) => {
You can’t perform that action at this time.
0 commit comments