77require 'code_teams'
88require 'code_ownership'
99require 'pathname'
10+ require 'packs'
1011require 'pack_stats/private'
1112require 'pack_stats/private/source_code_file'
1213require 'pack_stats/private/datadog_reporter'
@@ -27,23 +28,17 @@ module PackStats
2728 ] . freeze , T ::Array [ Pathname ]
2829 )
2930
30- DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS = T . let (
31- [
32- Pathname . new ( 'packs' ) ,
33- Pathname . new ( 'packages' ) ,
34- ] . freeze , T ::Array [ Pathname ]
35- )
36-
3731 sig do
3832 params (
3933 datadog_client : Dogapi ::Client ,
4034 app_name : String ,
4135 source_code_pathnames : T ::Array [ Pathname ] ,
4236 componentized_source_code_locations : T ::Array [ Pathname ] ,
43- packaged_source_code_locations : T ::Array [ Pathname ] ,
4437 report_time : Time ,
4538 verbose : T ::Boolean ,
4639 # See note on get_metrics
40+ packaged_source_code_locations : T . nilable ( T ::Array [ Pathname ] ) ,
41+ # See note on get_metrics
4742 use_gusto_legacy_names : T ::Boolean
4843 ) . void
4944 end
@@ -52,16 +47,15 @@ def self.report_to_datadog!(
5247 app_name :,
5348 source_code_pathnames :,
5449 componentized_source_code_locations : DEFAULT_COMPONENTIZED_SOURCE_CODE_LOCATIONS ,
55- packaged_source_code_locations : DEFAULT_PACKAGED_SOURCE_CODE_LOCATIONS ,
5650 report_time : Time . now , # rubocop:disable Rails/TimeZone
5751 verbose : false ,
52+ packaged_source_code_locations : [ ] ,
5853 use_gusto_legacy_names : false
5954 )
6055
6156 all_metrics = self . get_metrics (
6257 source_code_pathnames : source_code_pathnames ,
6358 componentized_source_code_locations : componentized_source_code_locations ,
64- packaged_source_code_locations : packaged_source_code_locations ,
6559 app_name : app_name ,
6660 use_gusto_legacy_names : use_gusto_legacy_names ,
6761 )
@@ -88,8 +82,9 @@ def self.report_to_datadog!(
8882 params (
8983 source_code_pathnames : T ::Array [ Pathname ] ,
9084 componentized_source_code_locations : T ::Array [ Pathname ] ,
91- packaged_source_code_locations : T ::Array [ Pathname ] ,
9285 app_name : String ,
86+ # This field is deprecated
87+ packaged_source_code_locations : T . nilable ( T ::Array [ Pathname ] ) ,
9388 # It is not recommended to set this to true.
9489 # Gusto uses this to preserve historical trends in Dashboards as the names of
9590 # things changed, but new dashboards can use names that better match current tooling conventions.
@@ -100,15 +95,14 @@ def self.report_to_datadog!(
10095 def self . get_metrics (
10196 source_code_pathnames :,
10297 componentized_source_code_locations :,
103- packaged_source_code_locations :,
10498 app_name :,
99+ packaged_source_code_locations : [ ] ,
105100 use_gusto_legacy_names : false
106101 )
107102 all_metrics = Private ::DatadogReporter . get_metrics (
108103 source_code_files : source_code_files (
109104 source_code_pathnames : source_code_pathnames ,
110105 componentized_source_code_locations : componentized_source_code_locations ,
111- packaged_source_code_locations : packaged_source_code_locations
112106 ) ,
113107 app_name : app_name
114108 )
@@ -124,18 +118,21 @@ def self.get_metrics(
124118 params (
125119 source_code_pathnames : T ::Array [ Pathname ] ,
126120 componentized_source_code_locations : T ::Array [ Pathname ] ,
127- packaged_source_code_locations : T ::Array [ Pathname ]
128121 ) . returns ( T ::Array [ Private ::SourceCodeFile ] )
129122 end
130123 def self . source_code_files (
131124 source_code_pathnames :,
132- componentized_source_code_locations :,
133- packaged_source_code_locations :
125+ componentized_source_code_locations :
134126 )
135127
136128 # Sorbet has the wrong signatures for `Pathname#find`, whoops!
137129 componentized_file_set = Set . new ( componentized_source_code_locations . select ( &:exist? ) . flat_map { |pathname | T . unsafe ( pathname ) . find . to_a } )
138- packaged_file_set = Set . new ( packaged_source_code_locations . select ( &:exist? ) . flat_map { |pathname | T . unsafe ( pathname ) . find . to_a } )
130+
131+ packaged_file_set = Packs . all . flat_map do |pack |
132+ pack . relative_path . find . to_a
133+ end
134+
135+ packaged_file_set = Set . new ( packaged_file_set )
139136
140137 source_code_pathnames . map do |pathname |
141138 componentized_file = componentized_file_set . include? ( pathname )
0 commit comments