diff --git a/packages/analytics/__tests__/analytics.test.ts b/packages/analytics/__tests__/analytics.test.ts index 35e66f8a7f..0120ca00ee 100644 --- a/packages/analytics/__tests__/analytics.test.ts +++ b/packages/analytics/__tests__/analytics.test.ts @@ -4,6 +4,7 @@ import { firebase, getAnalytics, initializeAnalytics, + getGoogleAnalyticsClientId, logEvent, setAnalyticsCollectionEnabled, setSessionTimeoutDuration, @@ -711,6 +712,10 @@ describe('Analytics', function () { expect(initializeAnalytics).toBeDefined(); }); + it('`getGoogleAnalyticsClientId` function is properly exposed to end user', function () { + expect(getGoogleAnalyticsClientId).toBeDefined(); + }); + it('`logEvent` function is properly exposed to end user', function () { expect(logEvent).toBeDefined(); }); diff --git a/packages/analytics/lib/modular/index.d.ts b/packages/analytics/lib/modular/index.d.ts index 5cc60dc669..83a66da8fb 100644 --- a/packages/analytics/lib/modular/index.d.ts +++ b/packages/analytics/lib/modular/index.d.ts @@ -23,6 +23,14 @@ export declare function initializeAnalytics( options?: FirebaseAnalyticsTypes.AnalyticsSettings, ): Analytics; +/** + * Retrieves a unique Google Analytics identifier for the web client. + * + * @param analyticsInstance - Instance of analytics (web - only) + * + */ +export declare function getGoogleAnalyticsClientId(analyticsInstance: Analytics): Promise; + /** * Log a custom event with optional params. Note that there are various limits that applied * to event parameters (total parameter count, etc), but analytics applies the limits during @@ -605,10 +613,14 @@ export function getAppInstanceId(analytics: Analytics): Promise; * Gives a user a unique identification. * * @param analytics Analytics instance. - * @param id Set to null to remove a previously assigned ID from analytics - * events + * @param id Set to null to remove a previously assigned ID from analytics events + * @param options Additional options that can be passed to Analytics method calls such as logEvent, etc. */ -export function setUserId(analytics: Analytics, id: string | null): Promise; +export function setUserId( + analytics: Analytics, + id: string | null, + options?: AnalyticsCallOptions, +): Promise; /** * Sets a key/value pair of data on the current user. Each Firebase project can have up to 25 uniquely named (case-sensitive) user properties. diff --git a/packages/analytics/lib/modular/index.js b/packages/analytics/lib/modular/index.js index dd05ed9e4b..0a2e26aa00 100644 --- a/packages/analytics/lib/modular/index.js +++ b/packages/analytics/lib/modular/index.js @@ -64,6 +64,16 @@ export function initializeAnalytics(app, options) { return getApp(app.name).analytics(); } +/** + * Retrieves a unique Google Analytics identifier for the web client. + * + * @param {FirebaseAnalytics} analytics - Instance of analytics (web - only) + * @returns {string} + */ +export function getGoogleAnalyticsClientId(analytics) { + throw new Error('getGoogleAnalyticsClientId is web-only and not yet supported.'); + return analytics; +} /** * Log a custom event with optional params. * @param {FirebaseAnalytics} analytics - Analytics instance.