Skip to content

Commit 4d24c58

Browse files
committed
Address PR comments
1 parent b60ee84 commit 4d24c58

File tree

7 files changed

+25
-144
lines changed

7 files changed

+25
-144
lines changed

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Analytics } from '@firebase/analytics-types-exp';
88
import { AnalyticsCallOptions } from '@firebase/analytics-types-exp';
99
import { ControlParams } from '@firebase/analytics-types-exp';
1010
import { CustomParams } from '@firebase/analytics-types-exp';
11-
import { DataLayer } from '@firebase/analytics-types-exp';
1211
import { EventNameString } from '@firebase/analytics-types-exp';
1312
import { EventParams } from '@firebase/analytics-types-exp';
1413
import { FirebaseApp } from '@firebase/app-types-exp';
@@ -27,66 +26,6 @@ export type CustomEventName<T> = T extends EventNameString ? never : T;
2726

2827
export { CustomParams }
2928

30-
export { DataLayer }
31-
32-
// @public
33-
export enum EventName {
34-
// (undocumented)
35-
ADD_PAYMENT_INFO = "add_payment_info",
36-
// (undocumented)
37-
ADD_SHIPPING_INFO = "add_shipping_info",
38-
// (undocumented)
39-
ADD_TO_CART = "add_to_cart",
40-
// (undocumented)
41-
ADD_TO_WISHLIST = "add_to_wishlist",
42-
// (undocumented)
43-
BEGIN_CHECKOUT = "begin_checkout",
44-
// @deprecated (undocumented)
45-
CHECKOUT_PROGRESS = "checkout_progress",
46-
// (undocumented)
47-
EXCEPTION = "exception",
48-
// (undocumented)
49-
GENERATE_LEAD = "generate_lead",
50-
// (undocumented)
51-
LOGIN = "login",
52-
// (undocumented)
53-
PAGE_VIEW = "page_view",
54-
// (undocumented)
55-
PURCHASE = "purchase",
56-
// (undocumented)
57-
REFUND = "refund",
58-
// (undocumented)
59-
REMOVE_FROM_CART = "remove_from_cart",
60-
// (undocumented)
61-
SCREEN_VIEW = "screen_view",
62-
// (undocumented)
63-
SEARCH = "search",
64-
// (undocumented)
65-
SELECT_CONTENT = "select_content",
66-
// (undocumented)
67-
SELECT_ITEM = "select_item",
68-
// (undocumented)
69-
SELECT_PROMOTION = "select_promotion",
70-
// @deprecated (undocumented)
71-
SET_CHECKOUT_OPTION = "set_checkout_option",
72-
// (undocumented)
73-
SHARE = "share",
74-
// (undocumented)
75-
SIGN_UP = "sign_up",
76-
// (undocumented)
77-
TIMING_COMPLETE = "timing_complete",
78-
// (undocumented)
79-
VIEW_CART = "view_cart",
80-
// (undocumented)
81-
VIEW_ITEM = "view_item",
82-
// (undocumented)
83-
VIEW_ITEM_LIST = "view_item_list",
84-
// (undocumented)
85-
VIEW_PROMOTION = "view_promotion",
86-
// (undocumented)
87-
VIEW_SEARCH_RESULTS = "view_search_results"
88-
}
89-
9029
export { EventParams }
9130

9231
// @public

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

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

5151
export { settings } from './factory';
52-
export { EventName } from './constants';
5352

5453
declare module '@firebase/component' {
5554
interface NameServiceMapping {

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

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,3 @@ export const enum GtagCommand {
3636
SET = 'set',
3737
CONFIG = 'config'
3838
}
39-
40-
/**
41-
* Officially recommended event names for gtag.js
42-
* Any other string is also allowed.
43-
*
44-
* @public
45-
*/
46-
export enum EventName {
47-
ADD_SHIPPING_INFO = 'add_shipping_info',
48-
ADD_PAYMENT_INFO = 'add_payment_info',
49-
ADD_TO_CART = 'add_to_cart',
50-
ADD_TO_WISHLIST = 'add_to_wishlist',
51-
BEGIN_CHECKOUT = 'begin_checkout',
52-
/**
53-
* @deprecated This event name is deprecated and is unsupported in updated
54-
* Enhanced Ecommerce reports.
55-
*/
56-
CHECKOUT_PROGRESS = 'checkout_progress',
57-
EXCEPTION = 'exception',
58-
GENERATE_LEAD = 'generate_lead',
59-
LOGIN = 'login',
60-
PAGE_VIEW = 'page_view',
61-
PURCHASE = 'purchase',
62-
REFUND = 'refund',
63-
REMOVE_FROM_CART = 'remove_from_cart',
64-
SCREEN_VIEW = 'screen_view',
65-
SEARCH = 'search',
66-
SELECT_CONTENT = 'select_content',
67-
SELECT_ITEM = 'select_item',
68-
SELECT_PROMOTION = 'select_promotion',
69-
/**
70-
* @deprecated This event name is deprecated and is unsupported in updated
71-
* Enhanced Ecommerce reports.
72-
*/
73-
SET_CHECKOUT_OPTION = 'set_checkout_option',
74-
SHARE = 'share',
75-
SIGN_UP = 'sign_up',
76-
TIMING_COMPLETE = 'timing_complete',
77-
VIEW_CART = 'view_cart',
78-
VIEW_ITEM = 'view_item',
79-
VIEW_ITEM_LIST = 'view_item_list',
80-
VIEW_PROMOTION = 'view_promotion',
81-
VIEW_SEARCH_RESULTS = 'view_search_results'
82-
}

packages-exp/analytics-exp/src/functions.test.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
setUserProperties,
2626
setAnalyticsCollectionEnabled
2727
} from './functions';
28-
import { GtagCommand, EventName } from './constants';
28+
import { GtagCommand } from './constants';
2929

3030
const fakeMeasurementId = 'abcd-efgh-ijkl';
3131
const fakeInitializationPromise = Promise.resolve(fakeMeasurementId);
@@ -38,57 +38,45 @@ describe('FirebaseAnalytics methods', () => {
3838
});
3939

4040
it('logEvent() calls gtag function correctly', async () => {
41-
await logEvent(gtagStub, fakeInitializationPromise, EventName.ADD_TO_CART, {
41+
await logEvent(gtagStub, fakeInitializationPromise, 'add_to_cart', {
4242
currency: 'USD'
4343
});
4444

45-
expect(gtagStub).to.have.been.calledWith(
46-
GtagCommand.EVENT,
47-
EventName.ADD_TO_CART,
48-
{
49-
'send_to': fakeMeasurementId,
50-
currency: 'USD'
51-
}
52-
);
45+
expect(gtagStub).to.have.been.calledWith(GtagCommand.EVENT, 'add_to_cart', {
46+
'send_to': fakeMeasurementId,
47+
currency: 'USD'
48+
});
5349
});
5450

5551
it('logEvent() with no event params calls gtag function correctly', async () => {
56-
await logEvent(gtagStub, fakeInitializationPromise, EventName.VIEW_ITEM);
52+
await logEvent(gtagStub, fakeInitializationPromise, 'view_item');
5753

58-
expect(gtagStub).to.have.been.calledWith(
59-
GtagCommand.EVENT,
60-
EventName.VIEW_ITEM,
61-
{
62-
'send_to': fakeMeasurementId
63-
}
64-
);
54+
expect(gtagStub).to.have.been.calledWith(GtagCommand.EVENT, 'view_item', {
55+
'send_to': fakeMeasurementId
56+
});
6557
});
6658

6759
it('logEvent() globally calls gtag function correctly', async () => {
6860
await logEvent(
6961
gtagStub,
7062
fakeInitializationPromise,
71-
EventName.ADD_TO_CART,
63+
'add_to_cart',
7264
{
7365
currency: 'USD'
7466
},
7567
{ global: true }
7668
);
7769

78-
expect(gtagStub).to.have.been.calledWith(
79-
GtagCommand.EVENT,
80-
EventName.ADD_TO_CART,
81-
{
82-
currency: 'USD'
83-
}
84-
);
70+
expect(gtagStub).to.have.been.calledWith(GtagCommand.EVENT, 'add_to_cart', {
71+
currency: 'USD'
72+
});
8573
});
8674

8775
it('logEvent() with no event params globally calls gtag function correctly', async () => {
8876
await logEvent(
8977
gtagStub,
9078
fakeInitializationPromise,
91-
EventName.ADD_TO_CART,
79+
'add_to_cart',
9280
undefined,
9381
{
9482
global: true
@@ -97,7 +85,7 @@ describe('FirebaseAnalytics methods', () => {
9785

9886
expect(gtagStub).to.have.been.calledWith(
9987
GtagCommand.EVENT,
100-
EventName.ADD_TO_CART,
88+
'add_to_cart',
10189
undefined
10290
);
10391
});

packages-exp/analytics-exp/src/index.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
getFakeInstallations
2525
} from '../testing/get-fake-firebase-services';
2626
import { FirebaseApp } from '@firebase/app-types-exp';
27-
import { GtagCommand, EventName } from './constants';
27+
import { GtagCommand } from './constants';
2828
import { findGtagScriptOnPage } from './helpers';
2929
import { removeGtagScript } from '../testing/gtag-script-util';
3030
import { Deferred } from '@firebase/util';
@@ -157,7 +157,7 @@ describe('FirebaseAnalytics instance tests', () => {
157157
expect(analyticsInstance.app).to.equal(app);
158158
});
159159
it('Calls gtag correctly on logEvent (instance)', async () => {
160-
logEvent(analyticsInstance, EventName.ADD_PAYMENT_INFO, {
160+
logEvent(analyticsInstance, 'add_payment_info', {
161161
currency: 'USD'
162162
});
163163
// Clear promise chain started by logEvent.
@@ -174,7 +174,7 @@ describe('FirebaseAnalytics instance tests', () => {
174174
);
175175
expect(gtagStub).to.have.been.calledWith(
176176
GtagCommand.EVENT,
177-
EventName.ADD_PAYMENT_INFO,
177+
'add_payment_info',
178178
{
179179
'send_to': 'abcd-efgh',
180180
currency: 'USD'
@@ -237,7 +237,7 @@ describe('FirebaseAnalytics instance tests', () => {
237237
it('Warns on logEvent if indexedDB API not available', async () => {
238238
const idbStub = stub(window, 'indexedDB').value(undefined);
239239
analyticsInstance = analyticsFactory(app, fakeInstallations);
240-
logEvent(analyticsInstance, EventName.ADD_PAYMENT_INFO, {
240+
logEvent(analyticsInstance, 'add_payment_info', {
241241
currency: 'USD'
242242
});
243243
// Clear promise chain started by logEvent.
@@ -257,7 +257,7 @@ describe('FirebaseAnalytics instance tests', () => {
257257
idbOpenStub.restore();
258258
idbOpenStub = stub(indexedDB, 'open').throws('idb open error test');
259259
analyticsInstance = analyticsFactory(app, fakeInstallations);
260-
logEvent(analyticsInstance, EventName.ADD_PAYMENT_INFO, {
260+
logEvent(analyticsInstance, 'add_payment_info', {
261261
currency: 'USD'
262262
});
263263
// Clear promise chain started by logEvent.
@@ -307,7 +307,7 @@ describe('FirebaseAnalytics instance tests', () => {
307307
idbOpenStub.restore();
308308
});
309309
it('Calls gtag correctly on logEvent (instance)', async () => {
310-
logEvent(analyticsInstance, EventName.ADD_PAYMENT_INFO, {
310+
logEvent(analyticsInstance, 'add_payment_info', {
311311
currency: 'USD'
312312
});
313313
// Clear promise chain started by logEvent.
@@ -324,7 +324,7 @@ describe('FirebaseAnalytics instance tests', () => {
324324
);
325325
expect(gtagStub).to.have.been.calledWith(
326326
GtagCommand.EVENT,
327-
EventName.ADD_PAYMENT_INFO,
327+
'add_payment_info',
328328
{
329329
'send_to': 'abcd-efgh',
330330
currency: 'USD'

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ registerAnalytics();
8383
export * from './api';
8484

8585
export {
86-
DataLayer,
8786
Analytics,
8887
AnalyticsCallOptions,
8988
SettingsOptions,

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, EventName } from '../../src/index';
20+
import { getAnalytics, logEvent } 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), EventName.LOGIN, { method: 'email' });
43+
logEvent(getAnalytics(app), 'login', { method: 'email' });
4444
async function checkForEventCalls(): Promise<number> {
4545
await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
4646
const resources = performance.getEntriesByType('resource');

0 commit comments

Comments
 (0)