Skip to content

Commit 03e97b8

Browse files
authored
Expose addFrameworkForLogging. (#4786)
1 parent 31126af commit 03e97b8

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

packages-exp/auth-compat-exp/src/auth.ts

+8
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ export class Auth
170170
}
171171
return convertCredential(this._delegate, Promise.resolve(credential));
172172
}
173+
174+
// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
175+
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it
176+
// out of autogenerated documentation pages to reduce accidental misuse.
177+
addFrameworkForLogging(framework: string): void {
178+
exp.addFrameworkForLogging(this._delegate, framework);
179+
}
180+
173181
onAuthStateChanged(
174182
nextOrObserver: Observer<unknown> | ((a: compat.User | null) => unknown),
175183
errorFn?: (error: compat.Error) => unknown,

packages-exp/auth-exp/internal/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { _castAuth } from '../src/core/auth/auth_impl';
19+
import { Auth } from '../src/model/public_types';
20+
1821
/**
1922
* This interface is intended only for use by @firebase/auth-compat-exp, do not use directly
2023
*/
@@ -45,3 +48,10 @@ export { _getRedirectResult } from '../src/platform_browser/strategies/redirect'
4548
export { cordovaPopupRedirectResolver } from '../src/platform_cordova/popup_redirect/popup_redirect';
4649
export { FetchProvider } from '../src/core/util/fetch_provider';
4750
export { SAMLAuthCredential } from '../src/core/credentials/saml';
51+
52+
// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
53+
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it out
54+
// of autogenerated documentation pages to reduce accidental misuse.
55+
export function addFrameworkForLogging(auth: Auth, framework: string): void {
56+
_castAuth(auth)._logFramework(framework);
57+
}

packages-exp/auth-exp/src/core/auth/auth_impl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
562562
private frameworks: string[] = [];
563563
private clientVersion: string;
564564
_logFramework(framework: string): void {
565-
if (this.frameworks.includes(framework)) {
565+
if (!framework || this.frameworks.includes(framework)) {
566566
return;
567567
}
568568
this.frameworks.push(framework);

packages-exp/auth-exp/src/core/util/version.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,8 @@ export const enum ClientPlatform {
3131
WORKER = 'Worker'
3232
}
3333

34-
const enum ClientFramework {
35-
// No other framework used.
36-
DEFAULT = 'FirebaseCore-web',
37-
// Firebase Auth used with FirebaseUI-web.
38-
// TODO: Pass this in when used in conjunction with FirebaseUI
39-
FIREBASEUI = 'FirebaseUI-web'
40-
}
41-
4234
/*
4335
* Determine the SDK version string
44-
*
45-
* TODO: This should be set on the Auth object during initialization
4636
*/
4737
export function _getClientVersion(
4838
clientPlatform: ClientPlatform,
@@ -65,6 +55,6 @@ export function _getClientVersion(
6555
}
6656
const reportedFrameworks = frameworks.length
6757
? frameworks.join(',')
68-
: ClientFramework.DEFAULT;
58+
: 'FirebaseCore-web'; /* default value if no other framework is used */
6959
return `${reportedPlatform}/${ClientImplementation.CORE}/${SDK_VERSION}/${reportedFrameworks}`;
7060
}

0 commit comments

Comments
 (0)