@@ -10,6 +10,7 @@ import {
1010} from '../middleware'
1111import { Context , ContextCancelation } from '../../core/context'
1212import { Analytics } from '../../core/analytics'
13+ import { recordIntegrationMetric } from '../../core/stats/metric-helpers'
1314
1415export interface RemotePlugin {
1516 /** The name of the remote plugin */
@@ -80,18 +81,19 @@ export class ActionDestination implements DestinationPlugin {
8081 }
8182
8283 try {
83- ctx . stats . increment ( 'analytics_js.action_plugin.invoke' , 1 , [
84- `method: ${ methodName } ` ,
85- `action_plugin_name: ${ this . action . name } ` ,
86- ] )
87-
84+ recordIntegrationMetric ( ctx , {
85+ integrationName : this . action . name ,
86+ methodName ,
87+ type : 'action' ,
88+ } )
8889 await this . action [ methodName ] ! ( transformedContext )
8990 } catch ( error ) {
90- ctx . stats . increment ( 'analytics_js.action_plugin.invoke.error' , 1 , [
91- `method:${ methodName } ` ,
92- `action_plugin_name:${ this . action . name } ` ,
93- ] )
94-
91+ recordIntegrationMetric ( ctx , {
92+ integrationName : this . action . name ,
93+ methodName,
94+ type : 'action' ,
95+ didError : true ,
96+ } )
9597 throw error
9698 }
9799
@@ -117,18 +119,19 @@ export class ActionDestination implements DestinationPlugin {
117119
118120 async load ( ctx : Context , analytics : Analytics ) : Promise < unknown > {
119121 try {
120- ctx . stats . increment ( 'analytics_js.action_plugin.invoke' , 1 , [
121- `method:load` ,
122- `action_plugin_name: ${ this . action . name } ` ,
123- ] )
124-
122+ recordIntegrationMetric ( ctx , {
123+ integrationName : this . action . name ,
124+ methodName : 'load' ,
125+ type : 'action' ,
126+ } )
125127 return await this . action . load ( ctx , analytics )
126128 } catch ( error ) {
127- ctx . stats . increment ( 'analytics_js.action_plugin.invoke.error' , 1 , [
128- `method:load` ,
129- `action_plugin_name:${ this . action . name } ` ,
130- ] )
131-
129+ recordIntegrationMetric ( ctx , {
130+ integrationName : this . action . name ,
131+ methodName : 'load' ,
132+ type : 'action' ,
133+ didError : true ,
134+ } )
132135 throw error
133136 }
134137 }
0 commit comments