Skip to content

Commit e8acd9d

Browse files
committed
Rename meta to metadata in helper API
1 parent fc90b31 commit e8acd9d

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_send_app_size_metrics.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def self.run(params)
3838
split_name = File.basename(apk, '.apk')
3939
file_size = Action.sh(apkanalyzer_bin, 'apk', 'file-size', apk, print_command: false, print_command_output: false).chomp.to_i
4040
download_size = Action.sh(apkanalyzer_bin, 'apk', 'download-size', apk, print_command: false, print_command_output: false).chomp.to_i
41-
metrics_helper.add_metric(name: 'APK File Size', value: file_size, meta: { split: split_name })
42-
metrics_helper.add_metric(name: 'Download Size', value: download_size, meta: { split: split_name })
41+
metrics_helper.add_metric(name: 'APK File Size', value: file_size, metadata: { split: split_name })
42+
metrics_helper.add_metric(name: 'Download Size', value: download_size, metadata: { split: split_name })
4343
end
4444

4545
UI.message('[App Size Metrics] Done computing splits sizes.')

lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_send_app_size_metrics.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def self.run(params)
3030
variant_descriptors = variant['variantDescriptors'] || [{ 'device' => 'Universal' }]
3131
variant_descriptors.each do |desc|
3232
variant_metadata = { device: desc['device'], 'OS Version': desc['os-version'] }
33-
metrics_helper.add_metric(name: 'Download Size', value: variant['sizeCompressedApp'], meta: variant_metadata)
34-
metrics_helper.add_metric(name: 'Install Size', value: variant['sizeUncompressedApp'], meta: variant_metadata)
33+
metrics_helper.add_metric(name: 'Download Size', value: variant['sizeCompressedApp'], metadata: variant_metadata)
34+
metrics_helper.add_metric(name: 'Install Size', value: variant['sizeUncompressedApp'], metadata: variant_metadata)
3535
end
3636
end
3737
end

lib/fastlane/plugin/wpmreleasetoolkit/helper/app_size_metrics_helper.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,37 @@ module Helper
1010
# https://github.com/Automattic/apps-metrics
1111
#
1212
class AppSizeMetricsHelper
13-
# @param [Hash] group_meta Metadata common to all the metrics. Can be any arbitrary set of key/value pairs.
13+
# @param [Hash] metadata Metadata common to all the metrics. Can be any arbitrary set of key/value pairs.
1414
#
15-
def initialize(group_meta = {})
16-
self.meta = group_meta
15+
def initialize(metadata = {})
16+
self.metadata = metadata
1717
@metrics = []
1818
end
1919

2020
# Sets the metadata common to the whole group of metrics in the payload being built by this helper instance
2121
#
2222
# @param [Hash] hash The metadata common to all the metrics of the payload built by that helper instance. Can be any arbitrary set of key/value pairs
2323
#
24-
def meta=(hash)
25-
@meta = (hash.compact || {}).map { |key, value| { name: key.to_s, value: value } }
24+
def metadata=(hash)
25+
@metadata = (hash.compact || {}).map { |key, value| { name: key.to_s, value: value } }
2626
end
2727

2828
# Adds a single metric to the group of metrics
2929
#
3030
# @param [String] name The metric name
3131
# @param [Integer] value The metric value
32-
# @param [Hash] meta The arbitrary dictionary of metadata to associate to that metric entry
32+
# @param [Hash] metadata The arbitrary dictionary of metadata to associate to that metric entry
3333
#
34-
def add_metric(name:, value:, meta: nil)
34+
def add_metric(name:, value:, metadata: nil)
3535
metric = { name: name, value: value }
36-
meta = meta&.compact || {} # Remove nil values if any (and use empty Hash if nil was provided)
37-
metric[:meta] = meta.map { |meta_key, meta_value| { name: meta_key.to_s, value: meta_value } } unless meta.empty?
36+
metadata = metadata&.compact || {} # Remove nil values if any (and use empty Hash if nil was provided)
37+
metric[:meta] = metadata.map { |meta_key, meta_value| { name: meta_key.to_s, value: meta_value } } unless metadata.empty?
3838
@metrics.append(metric)
3939
end
4040

4141
def to_h
4242
{
43-
meta: @meta,
43+
meta: @metadata,
4444
metrics: @metrics
4545
}
4646
end

spec/app_size_metrics_helper_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
'Group Metadata 1': 'Group Value 1',
88
'Group Metadata 2': 'Group Value 2'
99
})
10-
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, meta: { m1a: 'Metric 1 Metadata A' })
10+
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, metadata: { m1a: 'Metric 1 Metadata A' })
1111
metrics_helper.add_metric(name: 'Metric 2', value: 67_890)
12-
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, meta: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
12+
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, metadata: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
1313

1414
expected_hash = {
1515
meta: [
@@ -31,9 +31,9 @@
3131
'Group Metadata 2': nil,
3232
'Group Metadata 3': 'Group Value 3'
3333
})
34-
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, meta: { m1a: 'Metric 1 Metadata A', m1b: nil, m1c: 'Metric 1 Metadata C' })
35-
metrics_helper.add_metric(name: 'Metric 2', value: 67_890, meta: { m2a: nil })
36-
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, meta: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
34+
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, metadata: { m1a: 'Metric 1 Metadata A', m1b: nil, m1c: 'Metric 1 Metadata C' })
35+
metrics_helper.add_metric(name: 'Metric 2', value: 67_890, metadata: { m2a: nil })
36+
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, metadata: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
3737

3838
expected_hash = {
3939
meta: [
@@ -56,9 +56,9 @@
5656
'Group Metadata 1': 'Group Value 1',
5757
'Group Metadata 2': 'Group Value 2'
5858
})
59-
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, meta: { m1a: 'Metric 1 Metadata A' })
59+
metrics_helper.add_metric(name: 'Metric 1', value: 12_345, metadata: { m1a: 'Metric 1 Metadata A' })
6060
metrics_helper.add_metric(name: 'Metric 2', value: 67_890)
61-
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, meta: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
61+
metrics_helper.add_metric(name: 'Metric 3', value: 13_579, metadata: { m3a: 'Metric 3 Metadata A', m3b: 'Metric 3 Metadata B' })
6262
metrics_helper
6363
end
6464
let(:expected_data) do

0 commit comments

Comments
 (0)