7979import com .microsoft .identity .common .java .ui .webview .authorization .IAuthorizationCompletionCallback ;
8080import com .microsoft .identity .common .java .challengehandlers .PKeyAuthChallenge ;
8181import com .microsoft .identity .common .java .challengehandlers .PKeyAuthChallengeFactory ;
82+ import com .microsoft .identity .common .internal .telemetry .OnboardingTelemetryRecorder ;
8283import com .microsoft .identity .common .internal .ui .webview .challengehandlers .PKeyAuthChallengeHandler ;
8384import com .microsoft .identity .common .java .WarningType ;
8485import com .microsoft .identity .common .java .exception .ClientException ;
8586import com .microsoft .identity .common .java .exception .ErrorStrings ;
8687import com .microsoft .identity .common .java .providers .RawAuthorizationResult ;
88+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_AUTHENTICATOR_MFA_LINKING_STARTED ;
89+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_BROKER_INSTALL_PROMPTED ;
90+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_COMPANY_PORTAL_LAUNCHED ;
91+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_GOOGLE_ENROLLMENT_STARTED ;
92+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_MDM_ENROLLMENT_STARTED ;
93+ import static com .microsoft .identity .common .java .telemetry .OnboardingTelemetryConstants .STEP_WEB_CP_ENROLLMENT_STARTED ;
8794import com .microsoft .identity .common .java .util .StringUtil ;
8895import com .microsoft .identity .common .logging .Logger ;
8996
@@ -162,7 +169,7 @@ public class AzureActiveDirectoryWebViewClient extends OAuth2WebViewClient {
162169 * launch, etc.) and {@code lastLoadedDomain} are recorded for the onboarding telemetry blob.
163170 */
164171 @ Nullable
165- private com . microsoft . identity . common . internal . telemetry . OnboardingTelemetryRecorder mOnboardingTelemetryRecorder ;
172+ private OnboardingTelemetryRecorder mOnboardingTelemetryRecorder ;
166173
167174 /**
168175 * Callback for tracking URL load events.
@@ -221,7 +228,7 @@ public void initializeAuthUxJavaScriptApi(@NonNull final WebView view, final Str
221228 * no seed JSON is available — in which case all hooks become no-ops.
222229 */
223230 public void setOnboardingTelemetryRecorder (
224- @ Nullable final com . microsoft . identity . common . internal . telemetry . OnboardingTelemetryRecorder recorder ) {
231+ @ Nullable final OnboardingTelemetryRecorder recorder ) {
225232 mOnboardingTelemetryRecorder = recorder ;
226233 }
227234
@@ -750,7 +757,7 @@ private void processDeviceCaRequest(@NonNull final WebView view, @NonNull final
750757 Logger .info (methodTag , "This is a device CA request." );
751758
752759 // Onboarding telemetry: device CA blocking redirect → MDM enrollment phase.
753- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_MDM_ENROLLMENT_STARTED );
760+ recordOnboardingStep (STEP_MDM_ENROLLMENT_STARTED );
754761
755762 if (shouldLaunchCompanyPortal ()) {
756763 // If CP is installed, redirect to CP.
@@ -862,7 +869,7 @@ private String getHomeTenantIdFromUrl(@NonNull final String url) {
862869 private void processWebCpEnrollmentUrl (@ NonNull final WebView view , @ NonNull final String url ) {
863870 final String methodTag = TAG + ":processWebCpEnrollmentUrl" ;
864871 // Onboarding telemetry: WebCP enrollment is a distinct enrollment path.
865- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_WEB_CP_ENROLLMENT_STARTED );
872+ recordOnboardingStep (STEP_WEB_CP_ENROLLMENT_STARTED );
866873 final Span span = createSpanWithAttributesFromParent (SpanName .ProcessWebCpEnrollmentRedirect .name ());
867874 try (final Scope scope = SpanExtension .makeCurrentSpan (span )) {
868875 view .stopLoading ();
@@ -892,7 +899,7 @@ public void run() {
892899 private void openGoogleEnrollmentUrl (@ NonNull final String url ) {
893900 final String methodTag = TAG + ":openGoogleEnrollmentUrl" ;
894901 // Onboarding telemetry: Google enrollment redirect is a distinct enrollment path.
895- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_GOOGLE_ENROLLMENT_STARTED );
902+ recordOnboardingStep (STEP_GOOGLE_ENROLLMENT_STARTED );
896903 Logger .info (methodTag , "Opening Google enrollment URL" );
897904 try {
898905 final Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (url ));
@@ -917,7 +924,7 @@ private boolean processPlayStoreURL(@NonNull final WebView view, @NonNull final
917924 }
918925 final String appPackageName = getBrokerAppPackageNameFromUrl (url );
919926 Logger .info (methodTag , "Request to open PlayStore to install package : '" + appPackageName + "'" );
920- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_BROKER_INSTALL_PROMPTED );
927+ recordOnboardingStep (STEP_BROKER_INSTALL_PROMPTED );
921928
922929 try {
923930 final Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (PLAY_STORE_INSTALL_PREFIX + appPackageName ));
@@ -937,7 +944,7 @@ private boolean processPlayStoreURLForBrokerApps(@NonNull final WebView view, @N
937944
938945 final String appPackageName = getBrokerAppPackageNameFromUrl (url );
939946 Logger .info (methodTag , "Request to open PlayStore to install package : '" + appPackageName + "'" );
940- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_BROKER_INSTALL_PROMPTED );
947+ recordOnboardingStep (STEP_BROKER_INSTALL_PROMPTED );
941948
942949 try {
943950 final Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (PLAY_STORE_INSTALL_APP_PREFIX + appPackageName ));
@@ -957,7 +964,7 @@ private boolean processPlayStoreURLForBrokerApps(@NonNull final WebView view, @N
957964 private void processAuthAppMFAUrl (String url ) {
958965 final String methodTag = TAG + ":processAuthAppMFAUrl" ;
959966 // Onboarding telemetry: redirect to Authenticator for MFA linking.
960- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_AUTHENTICATOR_MFA_LINKING_STARTED );
967+ recordOnboardingStep (STEP_AUTHENTICATOR_MFA_LINKING_STARTED );
961968 Logger .verbose (methodTag , "Linking Account in Broker for MFA." );
962969 try {
963970 final Intent intent = new Intent (Intent .ACTION_VIEW , Uri .parse (url ));
@@ -1003,7 +1010,7 @@ private void launchCompanyPortal() {
10031010 final String methodTag = TAG + ":launchCompanyPortal" ;
10041011
10051012 // Onboarding telemetry: Company Portal launch is a discrete onboarding step.
1006- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_COMPANY_PORTAL_LAUNCHED );
1013+ recordOnboardingStep (STEP_COMPANY_PORTAL_LAUNCHED );
10071014
10081015 Logger .verbose (methodTag , "Sending intent to launch the CompanyPortal." );
10091016 final Intent intent = new Intent ();
@@ -1094,7 +1101,7 @@ private void processInstallRequest(@NonNull final WebView view, @NonNull final S
10941101
10951102 // Onboarding telemetry: broker install request reached the WebView client. Record the
10961103 // step at method entry so we capture intent regardless of the parsed result code.
1097- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_BROKER_INSTALL_PROMPTED );
1104+ recordOnboardingStep (STEP_BROKER_INSTALL_PROMPTED );
10981105
10991106 final RawAuthorizationResult result = RawAuthorizationResult .fromRedirectUri (url );
11001107
@@ -1154,7 +1161,7 @@ private void processInvalidRedirectUri(@NonNull final WebView view,
11541161 private void processIntentToInstallBrokerApp (@ NonNull final WebView view , @ NonNull final String intentUrl ) {
11551162 final String methodTag = TAG + ":processIntentToInstallBrokerApp" ;
11561163 // Onboarding telemetry: alternate broker install path (intent-scheme).
1157- recordOnboardingStep (com . microsoft . identity . common . java . telemetry . OnboardingTelemetryConstants . STEP_BROKER_INSTALL_PROMPTED );
1164+ recordOnboardingStep (STEP_BROKER_INSTALL_PROMPTED );
11581165 try {
11591166 final Intent intent = Intent .parseUri (intentUrl , Intent .URI_INTENT_SCHEME );
11601167 if (intent != null && intent .getPackage () != null ) {
@@ -1483,7 +1490,7 @@ public void addPasskeyRegistrationJsScript(@NonNull final String script) {
14831490 * if one is present. No-op when no recorder has been attached. Never throws.
14841491 */
14851492 private void recordOnboardingStep (@ NonNull final String stepId ) {
1486- final com . microsoft . identity . common . internal . telemetry . OnboardingTelemetryRecorder recorder = mOnboardingTelemetryRecorder ;
1493+ final OnboardingTelemetryRecorder recorder = mOnboardingTelemetryRecorder ;
14871494 if (recorder == null ) {
14881495 return ;
14891496 }
@@ -1496,18 +1503,20 @@ private void recordOnboardingStep(@NonNull final String stepId) {
14961503
14971504 /**
14981505 * Best-effort onboarding telemetry hook: records the host of the most recently loaded
1499- * page on the attached recorder. No-op when no recorder is attached, no host can be
1500- * extracted, or url is null/blank . Never throws.
1506+ * page on the attached recorder. No-op when no recorder is attached or the URL has no
1507+ * extractable host . Never throws.
15011508 */
1502- private void recordLastLoadedDomain (@ Nullable final String url ) {
1503- final com . microsoft . identity . common . internal . telemetry . OnboardingTelemetryRecorder recorder = mOnboardingTelemetryRecorder ;
1504- if (recorder == null || url == null || url .isEmpty ()) {
1509+ private void recordLastLoadedDomain (@ NonNull final String url ) {
1510+ final OnboardingTelemetryRecorder recorder = mOnboardingTelemetryRecorder ;
1511+ if (recorder == null || url .isEmpty ()) {
15051512 return ;
15061513 }
15071514 try {
15081515 final String host = Uri .parse (url ).getHost ();
15091516 if (host != null && !host .isEmpty ()) {
15101517 recorder .setLastLoadedDomain (host );
1518+ } else {
1519+ Logger .verbose (TAG , "Onboarding telemetry: no host extracted from URL" );
15111520 }
15121521 } catch (final Throwable t ) {
15131522 Logger .warn (TAG , "Onboarding telemetry: failed to record last loaded domain: " + t .getMessage ());
0 commit comments