Skip to content

Commit

Permalink
Stringify event extra values in server JS template
Browse files Browse the repository at this point in the history
  • Loading branch information
akkomar authored and badboy committed Jul 30, 2024
1 parent a445de7 commit f31535f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix JS and Ruby server templates to correctly send event extra values as strings ([DENG-4405](https://mozilla-hub.atlassian.net/browse/DENG-4405))

## 14.3.0

- Add the `module_spec` option to the javascript_server outputter ([#726](https://github.com/mozilla/glean_parser/pull/726))
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/javascript_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class {{ ping|event_class_name(metrics_by_type) }} {
{% if event.extra_keys %}
extra: {
{% for extra, metadata in event.extra_keys.items() %}
{{ extra }}: {{ extra }},
{{ extra }}: String({{ extra }}),
{% endfor %}
},
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/templates/ruby_server.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module Glean
'timestamp' => (Time.now.utc.to_f * 1000).to_i,
'extra' => [
{% for extra, metadata in event.extra_keys.items() %}
['{{ extra }}', {{ extra }}],
['{{ extra }}', {{ extra }}.to_s],
{% endfor %}
].to_h,
},
Expand Down
6 changes: 4 additions & 2 deletions tests/data/server_events_compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def record(
# extras to pass into event detail
object_type:,
object_state:,
linking:,
# The user's FxA account ID, if available.
identifiers_fxa_account_id:,
# full user_agent value from controller context
Expand All @@ -116,8 +117,9 @@ def record(
'name' => 'object_update',
'timestamp' => (Time.now.utc.to_f * 1000).to_i,
'extra' => [
['object_type', object_type],
['object_state', object_state],
['object_type', object_type.to_s],
['object_state', object_state.to_s],
['linking', linking.to_s],
].to_h,
}},
]
Expand Down
5 changes: 5 additions & 0 deletions tests/data/server_metrics_with_event.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ backend:
description: >
A JSON representation of the latest state of the object.
type: string
linking:
description: >
Indicates the initial linking of the Mozilla account and
the third-party account.
type: boolean
1 change: 1 addition & 0 deletions tests/test-py/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
identifiers_fxa_account_id="test-py-project",
object_type="some_object_type",
object_state="some_object_state",
linking=True,
)
1 change: 1 addition & 0 deletions tests/test_javascript_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def test_logging_events_ping_with_event_metrics(tmp_path):
identifiers_fxa_account_id: 'abc',
object_type: 'unknown',
object_state: 'great',
linking: true,
});
"""

Expand Down
1 change: 1 addition & 0 deletions tests/test_ruby_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def test_run_logging(tmp_path):
events.backend_object_update.record(
object_type: "type",
object_state: "state",
linking: true,
identifiers_fxa_account_id: nil,
user_agent: "glean-test/1.0",
ip_address: "127.0.0.1"
Expand Down

0 comments on commit f31535f

Please sign in to comment.