Skip to content

Commit e34caac

Browse files
Regan HsuChromium LUCI CQ
Regan Hsu
authored and
Chromium LUCI CQ
committed
[CrOS Cellular] Add Network.Cellular.PSim.SetupFlowResult.
Provides insight into what issues stop users from successfully activating their physical SIM cards. See go/cros-cellular-success-metrics Bug: 1183573, 1186344 Change-Id: Id9fafbae92cd0c08a091dc67c051f785e9298032 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2740118 Reviewed-by: Steven Holte <holte@chromium.org> Reviewed-by: Azeem Arshad <azeemarshad@chromium.org> Commit-Queue: Regan Hsu <hsuregan@chromium.org> Cr-Commit-Position: refs/heads/master@{#862124}
1 parent dae6008 commit e34caac

File tree

5 files changed

+158
-2
lines changed

5 files changed

+158
-2
lines changed

chrome/test/data/webui/cr_components/chromeos/cellular_setup/psim_flow_ui_test.js

+65-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// #import 'chrome://os-settings/strings.m.js';
77
// #import 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js';
88

9-
// #import {PSimUIState, PSimPageName} from 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js';
9+
// #import {PSimUIState, PSimPageName, PSimSetupFlowResult} from 'chrome://resources/cr_components/chromeos/cellular_setup/psim_flow_ui.m.js';
1010
// #import {setCellularSetupRemoteForTesting} from 'chrome://resources/cr_components/chromeos/cellular_setup/mojo_interface_provider.m.js';
1111
// #import {flush, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
1212
// #import {assertTrue} from '../../../chai_assert.js';
@@ -16,6 +16,28 @@
1616
// clang-format on
1717

1818
suite('CrComponentsPsimFlowUiTest', function() {
19+
class MockMetricsPrivate {
20+
constructor() {
21+
this.cellularSetupResultDict = {};
22+
}
23+
24+
recordEnumerationValue(histogramName, pSimSetupFlowResult, enumSize) {
25+
assertEquals(histogramName, 'Network.Cellular.PSim.CellularSetupResult');
26+
if (pSimSetupFlowResult in this.cellularSetupResultDict) {
27+
this.cellularSetupResultDict[pSimSetupFlowResult]++;
28+
return;
29+
}
30+
this.cellularSetupResultDict[pSimSetupFlowResult] = 1;
31+
}
32+
33+
getSetupResultMetricCount(metricEnum) {
34+
if (metricEnum in this.cellularSetupResultDict) {
35+
return this.cellularSetupResultDict[metricEnum];
36+
}
37+
return 0;
38+
}
39+
}
40+
1941
let pSimPage;
2042

2143
/** @type {?chromeos.cellularSetup.mojom.CellularSetupRemote} */
@@ -33,12 +55,24 @@ suite('CrComponentsPsimFlowUiTest', function() {
3355
return new Promise(resolve => setTimeout(resolve));
3456
}
3557

58+
/** @param {PSimSetupFlowResult} pSimSetupFlowResult */
59+
function endFlowAndVerifyResult(pSimSetupFlowResult) {
60+
const resultCount =
61+
chrome.metricsPrivate.getSetupResultMetricCount(pSimSetupFlowResult);
62+
pSimPage.remove();
63+
Polymer.dom.flush();
64+
assertEquals(
65+
chrome.metricsPrivate.getSetupResultMetricCount(pSimSetupFlowResult),
66+
resultCount + 1);
67+
}
68+
3669
setup(function() {
3770
cellularCarrierHandler =
3871
new cellular_setup.FakeCarrierPortalHandlerRemote();
3972
cellularSetupRemote =
4073
new cellular_setup.FakeCellularSetupRemote(cellularCarrierHandler);
4174
cellular_setup.setCellularSetupRemoteForTesting(cellularSetupRemote);
75+
chrome.metricsPrivate = new MockMetricsPrivate();
4276

4377
pSimPage = document.createElement('psim-flow-ui');
4478
pSimPage.delegate = new cellular_setup.FakeCellularSetupDelegate();
@@ -66,6 +100,8 @@ suite('CrComponentsPsimFlowUiTest', function() {
66100
assertTrue(
67101
pSimPage.selectedPSimPageName_ ===
68102
cellularSetup.PSimPageName.PROVISIONING);
103+
104+
endFlowAndVerifyResult(PSimSetupFlowResult.SUCCESS);
69105
});
70106

71107
test('Sim detection failure with retries', async function() {
@@ -136,8 +172,9 @@ suite('CrComponentsPsimFlowUiTest', function() {
136172
.kPortalLoadedWithoutPaidUser);
137173

138174
await flushAsync();
139-
140175
assertTrue(pSimPage.nameOfCarrierPendingSetup === 'Verizon wireless');
176+
177+
endFlowAndVerifyResult(PSimSetupFlowResult.CANCELLED);
141178
});
142179

143180
test('forward navigation and finish cellular setup test', async function() {
@@ -159,5 +196,31 @@ suite('CrComponentsPsimFlowUiTest', function() {
159196

160197
await flushAsync();
161198
assertTrue(exitCellularSetupEventFired);
199+
200+
endFlowAndVerifyResult(PSimSetupFlowResult.SUCCESS);
201+
});
202+
203+
test('Activation failure metric logged', async () => {
204+
cellularActivationDelegate =
205+
cellularSetupRemote.getLastActivationDelegate();
206+
207+
let provisioningPage = pSimPage.$$('#provisioningPage');
208+
assertTrue(!!provisioningPage);
209+
assertFalse(
210+
pSimPage.selectedPSimPageName_ ===
211+
cellularSetup.PSimPageName.provisioningPage);
212+
213+
cellularActivationDelegate.onActivationFinished(
214+
chromeos.cellularSetup.mojom.ActivationResult.kFailedToActivate);
215+
216+
await flushAsync();
217+
endFlowAndVerifyResult(PSimSetupFlowResult.NETWORK_ERROR);
218+
});
219+
220+
test('Portal error metric logged', () => {
221+
let provisioningPage = pSimPage.$$('#provisioningPage');
222+
provisioningPage.fire('carrier-portal-result', false);
223+
224+
endFlowAndVerifyResult(PSimSetupFlowResult.CANCELLED_PORTAL_ERROR);
162225
});
163226
});

tools/metrics/histograms/enums.xml

+12
Original file line numberDiff line numberDiff line change
@@ -63715,6 +63715,18 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
6371563715
<int value="4" label="PROXY_HAS_RULES"/>
6371663716
</enum>
6371763717

63718+
<enum name="PSimSetupFlowResult">
63719+
<int value="0" label="SUCCESS"/>
63720+
<int value="1" label="CANCELLED"/>
63721+
<int value="2" label="CANCELLED_NO_SIM"/>
63722+
<int value="3" label="CANCELLED_COLD_SIM_DEFER"/>
63723+
<int value="4" label="CANCELLED_CARRIER_PORTAL"/>
63724+
<int value="5" label="CANCELLED_PORTAL_ERROR"/>
63725+
<int value="6" label="CARRIER_PORTAL_TIMEOUT"/>
63726+
<int value="7" label="TIMEOUT_FINISH_ACTIVATION"/>
63727+
<int value="8" label="NETWORK_ERROR"/>
63728+
</enum>
63729+
6371863730
<enum name="PsmHashDanceDifferentResultsComparison">
6371963731
<int value="0" label="Hash dance true and PSM false"/>
6372063732
<int value="1" label="PSM true and Hash dance false"/>

tools/metrics/histograms/histograms_xml/network/histograms.xml

+11
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
158158
</summary>
159159
</histogram>
160160

161+
<histogram name="Network.Cellular.PSim.SetupFlowResult"
162+
enum="PSimSetupFlowResult" expires_after="2022-03-01">
163+
<owner>azeemarshad@chromium.org</owner>
164+
<owner>cros-connectivity@google.com</owner>
165+
<owner>hsuregan@chromium.org</owner>
166+
<summary>
167+
Tracks the result of the physical SIM card setup flow when the setup dialog
168+
closes.
169+
</summary>
170+
</histogram>
171+
161172
<histogram name="Network.Cellular.PSim.Usage.Count" enum="NetworkCellularUsage"
162173
expires_after="2022-03-01">
163174
<owner>azeemarshad@chromium.org</owner>

ui/webui/resources/cr_components/chromeos/cellular_setup/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ js_library("psim_flow_ui.m") {
195195
"//ui/webui/resources/js:i18n_behavior.m",
196196
]
197197
extra_deps = [ ":psim_flow_ui_module" ]
198+
externs_list = [ "$externs_path/metrics_private.js" ]
198199
}
199200

200201
js_library("esim_flow_ui.m") {

ui/webui/resources/cr_components/chromeos/cellular_setup/psim_flow_ui.js

+69
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ cr.define('cellularSetup', function() {
2626
ACTIVATION_FAILURE: 'activation-failure',
2727
};
2828

29+
/**
30+
* The reason that caused the user to exit the PSim Setup flow.
31+
* These values are persisted to logs. Entries should not be renumbered
32+
* and numeric values should never be reused.
33+
* @enum{number}
34+
*/
35+
/* #export */ const PSimSetupFlowResult = {
36+
SUCCESS: 0,
37+
CANCELLED: 1,
38+
CANCELLED_NO_SIM: 2,
39+
CANCELLED_COLD_SIM_DEFER: 3,
40+
CANCELLED_CARRIER_PORTAL: 4,
41+
CANCELLED_PORTAL_ERROR: 5,
42+
CARRIER_PORTAL_TIMEOUT: 6,
43+
NETWORK_ERROR: 7,
44+
};
45+
2946
/**
3047
* @param {!cellularSetup.PSimUIState} state
3148
* @return {?number} The time delta, in ms, for the timeout corresponding to
@@ -179,11 +196,62 @@ cr.define('cellularSetup', function() {
179196
*/
180197
carrierPortalHandler_: null,
181198

199+
200+
/**
201+
* Whether there was a carrier portal error.
202+
* @private {boolean}
203+
*/
204+
didCarrierPortalResultFail_: false,
205+
182206
/** @override */
183207
created() {
184208
this.cellularSetupRemote_ = cellular_setup.getCellularSetupRemote();
185209
},
186210

211+
/** @override */
212+
detached() {
213+
let resultCode = null;
214+
switch (this.state_) {
215+
case PSimUIState.IDLE:
216+
case PSimUIState.STARTING_ACTIVATION:
217+
resultCode = PSimSetupFlowResult.CANCELLED;
218+
break;
219+
case PSimUIState.WAITING_FOR_ACTIVATION_TO_START:
220+
resultCode = PSimSetupFlowResult.CANCELLED_COLD_SIM_DEFER;
221+
break;
222+
case PSimUIState.TIMEOUT_START_ACTIVATION:
223+
resultCode = PSimSetupFlowResult.CANCELLED_NO_SIM;
224+
break;
225+
case PSimUIState.WAITING_FOR_PORTAL_TO_LOAD:
226+
resultCode = PSimSetupFlowResult.CANCELLED;
227+
break;
228+
case PSimUIState.TIMEOUT_PORTAL_LOAD:
229+
resultCode = PSimSetupFlowResult.CARRIER_PORTAL_TIMEOUT;
230+
break;
231+
case PSimUIState.WAITING_FOR_USER_PAYMENT:
232+
resultCode = PSimSetupFlowResult.CANCELLED_CARRIER_PORTAL;
233+
break;
234+
case PSimUIState.ACTIVATION_SUCCESS:
235+
case PSimUIState.WAITING_FOR_ACTIVATION_TO_FINISH:
236+
case PSimUIState.TIMEOUT_FINISH_ACTIVATION:
237+
case PSimUIState.ALREADY_ACTIVATED:
238+
resultCode = PSimSetupFlowResult.SUCCESS;
239+
break;
240+
case PSimUIState.ACTIVATION_FAILURE:
241+
resultCode = this.didCarrierPortalResultFail_ ?
242+
PSimSetupFlowResult.CANCELLED_PORTAL_ERROR :
243+
PSimSetupFlowResult.NETWORK_ERROR;
244+
break;
245+
default:
246+
assertNotReached();
247+
}
248+
249+
assert(resultCode !== null);
250+
chrome.metricsPrivate.recordEnumerationValue(
251+
'Network.Cellular.PSim.CellularSetupResult', resultCode,
252+
Object.keys(PSimSetupFlowResult).length);
253+
},
254+
187255
/**
188256
* Overrides chromeos.cellularSetup.mojom.ActivationDelegateInterface.
189257
* @param {!chromeos.cellularSetup.mojom.CellularMetadata} metadata
@@ -459,6 +527,7 @@ cr.define('cellularSetup', function() {
459527
*/
460528
onCarrierPortalResult_(event) {
461529
const success = event.detail;
530+
this.didCarrierPortalResultFail_ = !success;
462531
this.state_ = success ? PSimUIState.ACTIVATION_SUCCESS :
463532
PSimUIState.ACTIVATION_FAILURE;
464533
},

0 commit comments

Comments
 (0)