Skip to content

Commit ed460ab

Browse files
committed
Address PR comments
1 parent 528311c commit ed460ab

File tree

8 files changed

+85
-12
lines changed

8 files changed

+85
-12
lines changed

common/api-review/analytics-exp.api.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,64 @@ import { SettingsOptions } from '@firebase/analytics-types-exp';
1919
// @public
2020
export function analyticsSettings(options: SettingsOptions): void;
2121

22+
// @public
23+
export const enum EventName {
24+
// (undocumented)
25+
ADD_PAYMENT_INFO = "add_payment_info",
26+
// (undocumented)
27+
ADD_SHIPPING_INFO = "add_shipping_info",
28+
// (undocumented)
29+
ADD_TO_CART = "add_to_cart",
30+
// (undocumented)
31+
ADD_TO_WISHLIST = "add_to_wishlist",
32+
// (undocumented)
33+
BEGIN_CHECKOUT = "begin_checkout",
34+
// @deprecated (undocumented)
35+
CHECKOUT_PROGRESS = "checkout_progress",
36+
// (undocumented)
37+
EXCEPTION = "exception",
38+
// (undocumented)
39+
GENERATE_LEAD = "generate_lead",
40+
// (undocumented)
41+
LOGIN = "login",
42+
// (undocumented)
43+
PAGE_VIEW = "page_view",
44+
// (undocumented)
45+
PURCHASE = "purchase",
46+
// (undocumented)
47+
REFUND = "refund",
48+
// (undocumented)
49+
REMOVE_FROM_CART = "remove_from_cart",
50+
// (undocumented)
51+
SCREEN_VIEW = "screen_view",
52+
// (undocumented)
53+
SEARCH = "search",
54+
// (undocumented)
55+
SELECT_CONTENT = "select_content",
56+
// (undocumented)
57+
SELECT_ITEM = "select_item",
58+
// (undocumented)
59+
SELECT_PROMOTION = "select_promotion",
60+
// @deprecated (undocumented)
61+
SET_CHECKOUT_OPTION = "set_checkout_option",
62+
// (undocumented)
63+
SHARE = "share",
64+
// (undocumented)
65+
SIGN_UP = "sign_up",
66+
// (undocumented)
67+
TIMING_COMPLETE = "timing_complete",
68+
// (undocumented)
69+
VIEW_CART = "view_cart",
70+
// (undocumented)
71+
VIEW_ITEM = "view_item",
72+
// (undocumented)
73+
VIEW_ITEM_LIST = "view_item_list",
74+
// (undocumented)
75+
VIEW_PROMOTION = "view_promotion",
76+
// (undocumented)
77+
VIEW_SEARCH_RESULTS = "view_search_results"
78+
}
79+
2280
// Warning: (ae-forgotten-export) The symbol "AnalyticsService" needs to be exported by the entry point index.d.ts
2381
// Warning: (ae-internal-missing-underscore) The name "factory" should be prefixed with an underscore because the declaration is marked as @internal
2482
//

packages-exp/analytics-exp/src/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
} from './functions';
5050

5151
export { analyticsSettings } from './factory';
52+
export { EventName } from './constants';
5253

5354
declare module '@firebase/component' {
5455
interface NameServiceMapping {

packages-exp/analytics-exp/src/constants.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,28 @@ export const DYNAMIC_CONFIG_URL =
3131

3232
export const GTAG_URL = 'https://www.googletagmanager.com/gtag/js';
3333

34-
export enum GtagCommand {
34+
export const enum GtagCommand {
3535
EVENT = 'event',
3636
SET = 'set',
3737
CONFIG = 'config'
3838
}
3939

40-
/*
40+
/**
4141
* Officially recommended event names for gtag.js
4242
* Any other string is also allowed.
43+
*
44+
* @public
4345
*/
4446
export const enum EventName {
4547
ADD_SHIPPING_INFO = 'add_shipping_info',
4648
ADD_PAYMENT_INFO = 'add_payment_info',
4749
ADD_TO_CART = 'add_to_cart',
4850
ADD_TO_WISHLIST = 'add_to_wishlist',
4951
BEGIN_CHECKOUT = 'begin_checkout',
50-
/** @deprecated */
52+
/**
53+
* @deprecated This event name is deprecated and is unsupported in updated
54+
* Enhanced Ecommerce reports.
55+
*/
5156
CHECKOUT_PROGRESS = 'checkout_progress',
5257
EXCEPTION = 'exception',
5358
GENERATE_LEAD = 'generate_lead',
@@ -61,7 +66,10 @@ export const enum EventName {
6166
SELECT_CONTENT = 'select_content',
6267
SELECT_ITEM = 'select_item',
6368
SELECT_PROMOTION = 'select_promotion',
64-
/** @deprecated */
69+
/**
70+
* @deprecated This event name is deprecated and is unsupported in updated
71+
* Enhanced Ecommerce reports.
72+
*/
6573
SET_CHECKOUT_OPTION = 'set_checkout_option',
6674
SHARE = 'share',
6775
SIGN_UP = 'sign_up',

packages-exp/analytics-exp/src/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { AnalyticsError, ERROR_FACTORY } from './errors';
3232
import { _FirebaseInstallationsInternal } from '@firebase/installations-types-exp';
3333
import { areCookiesEnabled, isBrowserExtension } from '@firebase/util';
34-
import { initializeAnalytics } from './initialize-ids';
34+
import { initializeAnalytics } from './initialize-analytics';
3535
import { logger } from './logger';
3636
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
3737

packages-exp/analytics-exp/src/initialize-ids.test.ts renamed to packages-exp/analytics-exp/src/initialize-analytics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import { expect } from 'chai';
1919
import { SinonStub, stub } from 'sinon';
2020
import '../testing/setup';
21-
import { initializeAnalytics } from './initialize-ids';
21+
import { initializeAnalytics } from './initialize-analytics';
2222
import {
2323
getFakeApp,
2424
getFakeInstallations

packages-exp/analytics-exp/testing/integration-tests/integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { initializeApp, deleteApp } from '@firebase/app-exp';
1919
import '@firebase/installations-exp';
20-
import { getAnalytics, logEvent } from '../../src/index';
20+
import { getAnalytics, logEvent, EventName } from '../../src/index';
2121
import '../setup';
2222
import { expect } from 'chai';
2323
import { stub } from 'sinon';
@@ -40,7 +40,7 @@ describe('FirebaseAnalytics Integration Smoke Tests', () => {
4040
afterEach(() => deleteApp(app));
4141
it('logEvent() sends correct network request.', async () => {
4242
app = initializeApp(config);
43-
logEvent(getAnalytics(app), 'login', { method: 'email' });
43+
logEvent(getAnalytics(app), EventName.LOGIN, { method: 'email' });
4444
async function checkForEventCalls(): Promise<number> {
4545
await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
4646
const resources = performance.getEntriesByType('resource');

packages/analytics/src/constants.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,29 @@ export const DYNAMIC_CONFIG_URL =
2626

2727
export const GTAG_URL = 'https://www.googletagmanager.com/gtag/js';
2828

29-
export enum GtagCommand {
29+
export const enum GtagCommand {
3030
EVENT = 'event',
3131
SET = 'set',
3232
CONFIG = 'config'
3333
}
3434

35-
/*
35+
/**
3636
* Officially recommended event names for gtag.js
3737
* Any other string is also allowed.
38+
*
39+
* @public
3840
*/
39-
export enum EventName {
41+
export const enum EventName {
4042
ADD_SHIPPING_INFO = 'add_shipping_info',
4143
ADD_PAYMENT_INFO = 'add_payment_info',
4244
ADD_TO_CART = 'add_to_cart',
4345
ADD_TO_WISHLIST = 'add_to_wishlist',
4446
BEGIN_CHECKOUT = 'begin_checkout',
45-
/** @deprecated */
47+
/**
48+
* @deprecated
49+
* This event name is deprecated and is unsupported in updated
50+
* Enhanced Ecommerce reports.
51+
*/
4652
CHECKOUT_PROGRESS = 'checkout_progress',
4753
EXCEPTION = 'exception',
4854
GENERATE_LEAD = 'generate_lead',

0 commit comments

Comments
 (0)