Skip to content

Expose addFrameworkForLogging. #4786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages-exp/auth-compat-exp/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ export class Auth
}
return convertCredential(this._delegate, Promise.resolve(credential));
}

// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it
// out of autogenerated documentation pages to reduce accidental misuse.
addFrameworkForLogging(framework: string): void {
exp.addFrameworkForLogging(this._delegate, framework);
}

onAuthStateChanged(
nextOrObserver: Observer<unknown> | ((a: compat.User | null) => unknown),
errorFn?: (error: compat.Error) => unknown,
Expand Down
10 changes: 10 additions & 0 deletions packages-exp/auth-exp/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* limitations under the License.
*/

import { _castAuth } from '../src/core/auth/auth_impl';
import { Auth } from '../src/model/public_types';

/**
* This interface is intended only for use by @firebase/auth-compat-exp, do not use directly
*/
Expand Down Expand Up @@ -45,3 +48,10 @@ export { _getRedirectResult } from '../src/platform_browser/strategies/redirect'
export { cordovaPopupRedirectResolver } from '../src/platform_cordova/popup_redirect/popup_redirect';
export { FetchProvider } from '../src/core/util/fetch_provider';
export { SAMLAuthCredential } from '../src/core/credentials/saml';

// This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
// It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it out
// of autogenerated documentation pages to reduce accidental misuse.
export function addFrameworkForLogging(auth: Auth, framework: string): void {
_castAuth(auth)._logFramework(framework);
}
2 changes: 1 addition & 1 deletion packages-exp/auth-exp/src/core/auth/auth_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
private frameworks: string[] = [];
private clientVersion: string;
_logFramework(framework: string): void {
if (this.frameworks.includes(framework)) {
if (!framework || this.frameworks.includes(framework)) {
return;
}
this.frameworks.push(framework);
Expand Down
12 changes: 1 addition & 11 deletions packages-exp/auth-exp/src/core/util/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,8 @@ export const enum ClientPlatform {
WORKER = 'Worker'
}

const enum ClientFramework {
// No other framework used.
DEFAULT = 'FirebaseCore-web',
// Firebase Auth used with FirebaseUI-web.
// TODO: Pass this in when used in conjunction with FirebaseUI
FIREBASEUI = 'FirebaseUI-web'
}

/*
* Determine the SDK version string
*
* TODO: This should be set on the Auth object during initialization
*/
export function _getClientVersion(
clientPlatform: ClientPlatform,
Expand All @@ -65,6 +55,6 @@ export function _getClientVersion(
}
const reportedFrameworks = frameworks.length
? frameworks.join(',')
: ClientFramework.DEFAULT;
: 'FirebaseCore-web'; /* default value if no other framework is used */
return `${reportedPlatform}/${ClientImplementation.CORE}/${SDK_VERSION}/${reportedFrameworks}`;
}