Object metric not being returned from `testGetValue()` when it is set to send in a ping
Categories
(Data Platform and Tools :: Glean: SDK, defect, P2)
Tracking
(Not tracked)
People
(Reporter: charlie, Assigned: janerik)
Details
In the example below, the object metric recordedNimbusContext
is not returned from testGetValue()
as it should be, seemingly as a result of sendInPings
being set on the entry in the metrics.yaml
file. I've noticed this in Firefox iOS, but am working to validate if it happens in Android as well.
// RecordedNimbusContextTests.swift
func testObjectRecordedToGleanMatchesExpected() throws {
let recordedContext = RecordedNimbusContext(isFirstRun: true, isReviewCheckerEnabled: true, isDefaultBrowser: true)
let expectation = expectation(description: "The Firefox Suggest ping was sent")
GleanMetrics.Pings.shared.nimbus.testBeforeNextSubmit { _ in
let value = GleanMetrics.NimbusSystem.recordedNimbusContext.testGetValue()
XCTAssertNotNil(value) // this is always nil now, whereas before I added `send_in_pings` to the metric it worked as expected
XCTAssertEqual(value?.appVersion, recordedContext.appVersion)
XCTAssertEqual(value?.isFirstRun, recordedContext.isFirstRun)
XCTAssertEqual(value?.isPhone, recordedContext.isPhone)
XCTAssertEqual(value?.isReviewCheckerEnabled, recordedContext.isReviewCheckerEnabled)
XCTAssertEqual(value?.locale, recordedContext.locale)
XCTAssertEqual(value?.region, recordedContext.region)
XCTAssertEqual(value?.language, recordedContext.language)
XCTAssertEqual(value?.daysSinceInstall, recordedContext.daysSinceInstall.toInt64())
XCTAssertEqual(value?.daysSinceUpdate, recordedContext.daysSinceUpdate.toInt64())
XCTAssertEqual(value?.isDefaultBrowser, recordedContext.isDefaultBrowser)
XCTAssertNotNil(value?.eventQueryValues)
XCTAssertEqual(value?.eventQueryValues?.daysOpenedInLast28, 1)
expectation.fulfill()
}
recordedContext.setEventQueryValues(eventQueryValues: [RecordedNimbusContext.DAYS_OPENED_IN_LAST_28: 1.5])
recordedContext.record()
wait(for: [expectation], timeout: 5.0)
}
# metrics.yaml
nimbus_system:
recorded_nimbus_context:
type: object
structure:
type: object
properties:
is_first_run:
type: boolean
...
expires: never
send_in_pings:
- nimbus
# pings.yaml
nimbus:
description: |
This ping is submitted by Nimbus code after the enrollment workflow has completed.
include_client_id: false
send_if_empty: true
bugs:
- https://mozilla-hub.atlassian.net/browse/EXP-5154
data_reviews:
- 'TODO'
notification_emails:
- chumphreys@mozilla.com
- project-nimbus@mozilla.com
metadata:
follows_collection_enabled: false
include_info_sections: false
Assignee | ||
Comment 1•29 days ago
|
||
Are you enabling the ping somewhere before setting metrics that end up in it?
due to follows_collection_enabled: false
it will be disabled by default and no data for it will be recorded until setEnabled(true)
is called on it.
Reporter | ||
Comment 3•29 days ago
|
||
Ahh I didn't realize pings needed to be enabled in that way. Let me try that and see if it resolves the issue.
Reporter | ||
Comment 4•29 days ago
|
||
That did it, so sorry for the misunderstanding. Is there something you'd recommend I do instead of calling setEnabled(true)
or is that the general way you'd recommend enabling the ping?
Assignee | ||
Comment 5•29 days ago
|
||
Your code outside of tests will also need to enable the ping. I don't know which setting its tied to (why is it even follows_collection_enabled: false
?).
I assume that RecordedNimbusContext
probably has the knowledge of whether the ping should be enabled, so calling setEnabled
in there would be the way to go (and then the test should work too).
Updated•28 days ago
|
Reporter | ||
Comment 6•25 days ago
|
||
Thank you so much! That did it and it works as expected now! https://github.com/mozilla-mobile/firefox-ios/pull/24950
Description
•