Add FXIOS-14919 [Nimbus] Submit nimbus-targeting-context ping#32150
Merged
Foxbolts merged 3 commits intomozilla-mobile:mainfrom Feb 23, 2026
Merged
Add FXIOS-14919 [Nimbus] Submit nimbus-targeting-context ping#32150Foxbolts merged 3 commits intomozilla-mobile:mainfrom
Foxbolts merged 3 commits intomozilla-mobile:mainfrom
Conversation
7 tasks
relud
commented
Feb 17, 2026
| XCTAssertEqual("US", calculatedAttributes.region) | ||
| } | ||
|
|
||
| func testRecordEnrollmentStatuses() throws { |
Contributor
Author
There was a problem hiding this comment.
I can't seem to figure out how to run any tests in this package 🙃
Contributor
Author
There was a problem hiding this comment.
I worked around this by applying the following patch to run an equivalent test in firefox-ios-tests:
test.patch
diff --git a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift
index 3d36de1bd8..d610d3a344 100644
--- a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift
+++ b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift
@@ -166,4 +166,43 @@ public extension Nimbus {
customTargetingAttributes: try? appSettings.customTargetingAttributes.stringify()
)
}
+
+ static func resetGlean() {
+ Glean.shared.resetGlean(clearStores: true)
+ }
+
+ static func serverKnobs() {
+ let metricConfig = """
+ {
+ "metrics_enabled": {
+ "nimbus_events.enrollment_status": true
+ }
+ }
+ """
+ Glean.shared.applyServerKnobsConfig(metricConfig)
+ }
+
+ static func testBeforeNextSubmit(cb: @escaping (NoReasonCodes?) throws -> Void) {
+ GleanMetrics.Pings.shared.nimbusTargetingContext.testBeforeNextSubmit(cb: cb)
+ }
+
+ static func recordStatuses() {
+ let metricsHandler = GleanMetricsHandler()
+ metricsHandler.recordEnrollmentStatuses(enrollmentStatusExtras: [
+ EnrollmentStatusExtraDef(
+ branch: "branch",
+ conflictSlug: "conflictSlug",
+ errorString: "errorString",
+ reason: "reason",
+ slug: "slug",
+ status: "status",
+ prevGeckoPrefStates: nil
+ )
+ ])
+ metricsHandler.submitTargetingContext()
+ }
+
+ static func getEvents() -> [RecordedEvent]? {
+ return GleanMetrics.NimbusEvents.enrollmentStatus.testGetValue()
+ }
}
diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Nimbus/NimbusExposedTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Nimbus/NimbusExposedTests.swift
index e69de29bb2..3d97bd6c28 100644
--- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/Nimbus/NimbusExposedTests.swift
+++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/Nimbus/NimbusExposedTests.swift
@@ -0,0 +1,41 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/
+
+import Glean
+import MozillaAppServices
+import UIKit
+import XCTest
+
+class NimbusExposedTests: XCTestCase {
+ override func setUp() {
+ Nimbus.resetGlean()
+ }
+
+ func testRecordEnrollmentStatuses() throws {
+ Nimbus.serverKnobs()
+
+ var events: [RecordedEvent]?
+ let expectation = expectation(description: "The nimbus targeting context ping was sent")
+ Nimbus.testBeforeNextSubmit { e in
+ events = Nimbus.getEvents()
+ expectation.fulfill()
+ }
+
+ Nimbus.recordStatuses()
+
+ wait(for: [expectation], timeout: 5.0)
+
+ XCTAssertEqual(
+ events?.map { $0.extra },
+ [[
+ "branch": "branch",
+ "conflict_slug": "conflictSlug",
+ "error_string": "errorString",
+ "reason": "reason",
+ "slug": "slug",
+ "status": "status"
+ ]]
+ )
+ }
+}
5 tasks
adudenamedruby
approved these changes
Feb 19, 2026
Contributor
|
Bitrise failed with: |
c7caa9b to
f45c817
Compare
💪 Quality guardian1 tests files modified. You're a champion of test coverage! 🚀 🧩 Neat PieceThis PR changes 410 lines. It's a substantial update, 💬 Description craftsmanGreat PR description! Reviewers salute you 🫡 ✅ New file code coverageNo new file detected so code coverage gate wasn't ran. Generated by 🚫 Danger Swift against f45c817 |
Contributor
|
🚀 PR merged to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Tickets
Jira ticket
Github issue
💡 Description
Application-services is adding a
nimbus-targeting-contextping fornimbus_events.enrollment_statusin mozilla/application-services#7225In order to submit the new ping,
MozillaRustComponentsandFocusRustComponentsmust implement the new interface methodMetricsHandler.submitTargetingContextto submit the new ping.This is a breaking change, so it must be merged/tested in conjunction with updating application-services or an appropriate local build:
Test instructions for locally built application-services:
taskcluster/scripts/build-and-test-swift.shMozillaRustComponentsinMozillaRustComponents/Package.swift:urlandchecksumFocusRustComponentsinMozillaRustComponents/Package.swift:urlandchecksum🎥 Demos
This change should only impact events being recorded by glean, as demonstrated in the new test case.
📝 Checklist