Stringify event extra values in server JS template

This commit is contained in:
Arkadiusz Komarzewski 2024-07-26 17:57:24 +02:00 коммит произвёл Jan-Erik Rediger
Родитель a445de7f4c
Коммит f31535f28c
8 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -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))

Просмотреть файл

@ -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 %}

Просмотреть файл

@ -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,
},

Просмотреть файл

@ -103,6 +103,7 @@ module Glean
# 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
@ -116,8 +117,9 @@ module Glean
'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,
}},
]

Просмотреть файл

@ -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

Просмотреть файл

@ -13,4 +13,5 @@ logger.record_backend_object_update(
identifiers_fxa_account_id="test-py-project",
object_type="some_object_type",
object_state="some_object_state",
linking=True,
)

Просмотреть файл

@ -161,6 +161,7 @@ eventLogger.recordBackendObjectUpdate({
identifiers_fxa_account_id: 'abc',
object_type: 'unknown',
object_state: 'great',
linking: true,
});
"""

Просмотреть файл

@ -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"