Skip to content
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

Deprecate analytics function setCurrentScreen #6269

Merged
merged 3 commits into from
May 23, 2022
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
2 changes: 1 addition & 1 deletion common/api-review/analytics.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export interface Promotion {
// @public
export function setAnalyticsCollectionEnabled(analyticsInstance: Analytics, enabled: boolean): void;

// @public
// @public @deprecated
export function setCurrentScreen(analyticsInstance: Analytics, screenName: string, options?: AnalyticsCallOptions): void;

// @public
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics-compat/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ describe('Firebase Analytics > Service', () => {
setUserIdStub.resetHistory();
});

it('setCurrentScreen() calls modular setCurrentScreen()', () => {
it('setCurrentScreen() (deprecated) calls modular setCurrentScreen() (deprecated)', () => {
service = createTestService(app);
service.setCurrentScreen('some_screen');
expect(setCurrentScreenStub).to.be.calledWith(match.any, 'some_screen');
setCurrentScreenStub.resetHistory();
});

it('setCurrentScreen() calls modular setCurrentScreen() with options if provided', () => {
it('setCurrentScreen() (deprecated) calls modular setCurrentScreen() (deprecated) with options if provided', () => {
service = createTestService(app);
service.setCurrentScreen('some_screen', { global: true });
expect(setCurrentScreenStub).to.be.calledWith(match.any, 'some_screen', {
Expand Down
4 changes: 4 additions & 0 deletions packages/analytics-compat/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class AnalyticsService implements FirebaseAnalytics, _FirebaseService {
logEventExp(this._delegate, eventName as '', eventParams, options);
}

/**
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*/
setCurrentScreen(screenName: string, options?: AnalyticsCallOptions): void {
setCurrentScreenExp(this._delegate, screenName, options);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/analytics-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type DataLayer = Array<IArguments>;

/**
* Additional options that can be passed to Firebase Analytics method
* calls such as `logEvent`, `setCurrentScreen`, etc.
* calls such as `logEvent`, etc.
*/
export interface AnalyticsCallOptions {
/**
Expand Down Expand Up @@ -453,6 +453,9 @@ export interface FirebaseAnalytics {

/**
* Use gtag 'config' command to set 'screen_name'.
*
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*/
setCurrentScreen(screenName: string, options?: AnalyticsCallOptions): void;

Expand Down
3 changes: 3 additions & 0 deletions packages/analytics/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ export async function isSupported(): Promise<boolean> {
*
* @public
*
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*
* @param analyticsInstance - The {@link Analytics} instance.
* @param screenName - Screen name to set.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/src/functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('FirebaseAnalytics methods', () => {
);
});

it('setCurrentScreen() calls gtag correctly (instance)', async () => {
it('setCurrentScreen() (deprecated) calls gtag correctly (instance)', async () => {
await setCurrentScreen(gtagStub, fakeInitializationPromise, 'home');
expect(gtagStub).to.have.been.calledWith(
GtagCommand.CONFIG,
Expand All @@ -102,7 +102,7 @@ describe('FirebaseAnalytics methods', () => {
);
});

it('setCurrentScreen() calls gtag correctly (global)', async () => {
it('setCurrentScreen() (deprecated) calls gtag correctly (global)', async () => {
await setCurrentScreen(gtagStub, fakeInitializationPromise, 'home', {
global: true
});
Expand Down
3 changes: 3 additions & 0 deletions packages/analytics/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export async function logEvent(
/**
* Set screen_name parameter for this Google Analytics ID.
*
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*
* @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event
* @param screenName Screen name string to set.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/analytics/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface AnalyticsSettings {

/**
* Additional options that can be passed to Analytics method
* calls such as `logEvent`, `setCurrentScreen`, etc.
* calls such as `logEvent`, etc.
* @public
*/
export interface AnalyticsCallOptions {
Expand Down
3 changes: 3 additions & 0 deletions packages/firebase/compat/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5215,6 +5215,9 @@ declare namespace firebase.analytics {

/**
* Use gtag 'config' command to set 'screen_name'.
*
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*/
setCurrentScreen(
screenName: string,
Expand Down