@@ -153,7 +153,7 @@ class Dashboard extends Component<Props, State> {
153
153
}
154
154
155
155
componentDidMount ( ) {
156
- const { newWidget} = this . props ;
156
+ const { dashboard , newWidget} = this . props ;
157
157
window . addEventListener ( 'resize' , this . debouncedHandleResize ) ;
158
158
159
159
// Always load organization tags on dashboards
@@ -167,6 +167,7 @@ class Dashboard extends Component<Props, State> {
167
167
this . fetchMemberList ( ) ;
168
168
169
169
connectDashboardCharts ( DASHBOARD_CHART_GROUP ) ;
170
+ this . trackEngagementAnalytics ( dashboard . widgets ) ;
170
171
}
171
172
172
173
componentDidUpdate ( prevProps : Props ) {
@@ -479,6 +480,41 @@ class Dashboard extends Component<Props, State> {
479
480
this . setState ( { isMobile : false } ) ;
480
481
} ;
481
482
483
+ trackEngagementAnalytics ( widgets : Widget [ ] ) {
484
+ // Handle edge-case of dashboard with no widgets.
485
+ if ( ! widgets . length ) return ;
486
+ const { dashboard, organization} = this . props ;
487
+ // For attributing engagement metrics initially track the ratio
488
+ // of widgets reading from Transactions, Spans, Errors, and Issues, and Logs.
489
+ const issuesWidgetTypes = new Set < string | undefined > ( [
490
+ 'error-events' ,
491
+ 'issue' ,
492
+ 'metrics' ,
493
+ ] ) ;
494
+ const logWidgetTypes = new Set < string | undefined > ( [ 'logs' ] ) ;
495
+ const tracingWidgetTypes = new Set < string | undefined > ( [ 'transaction-like' , 'spans' ] ) ;
496
+ let issuesWidgetCount = 0.0 ;
497
+ let logWidgetCount = 0.0 ;
498
+ let tracingWidgetCount = 0.0 ;
499
+ for ( const widget of widgets ) {
500
+ if ( issuesWidgetTypes . has ( widget . widgetType ) ) {
501
+ issuesWidgetCount += 1.0 ;
502
+ } else if ( logWidgetTypes . has ( widget . widgetType ) ) {
503
+ logWidgetCount += 1.0 ;
504
+ } else if ( tracingWidgetTypes . has ( widget . widgetType ) ) {
505
+ tracingWidgetCount += 1.0 ;
506
+ }
507
+ }
508
+ const analyticsPayload = {
509
+ organization,
510
+ title : dashboard . title ,
511
+ tracingRatio : tracingWidgetCount / widgets . length ,
512
+ issuesRatio : issuesWidgetCount / widgets . length ,
513
+ logRatio : logWidgetCount / widgets . length ,
514
+ } ;
515
+ trackAnalytics ( 'dashboards_views.engagement.load' , analyticsPayload ) ;
516
+ }
517
+
482
518
get addWidgetLayout ( ) {
483
519
const { isMobile, layouts} = this . state ;
484
520
let position : Position = BOTTOM_MOBILE_VIEW_POSITION ;
0 commit comments