feat(analytics): add & deprecate pre-defined analytics events (#3385)

* updating analytics types

* further type updates

* update log events for analytics

* update validation

* feat(analytics): update events & tests

* tests(analytics): update

* build(analytics): types & type tests

* chore(analytics): update to revised api

* feat(analytics): further updates for package

* Apply suggestions from code review

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>

* tests(analytics): update tests

* tests(ml-vision): stop testing ml-vision

* chore(*): spelling

* chore(*): spelling

* chore(analytics): update ts docs

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
[publish]
This commit is contained in:
Russell Wheatley
2020-07-09 09:18:48 +01:00
committed by GitHub
parent f0959f2054
commit 6c53f479d9
10 changed files with 11409 additions and 10692 deletions

View File

@@ -97,6 +97,7 @@ Realtime
remarketing
RN60
RN61
RNFB
RNFirebase
Salakar
scalable

19840
docs/typedoc.json vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -17,7 +17,7 @@ describe('Analytics', () => {
'Ensure the app provided is the default Firebase app only and not the "secondaryFromNative" app.',
].join('\r\n');
// @ts-ignore
// @ts-ignore test
expect(() => firebase.analytics(app)).toThrowError(expectedError);
});
@@ -36,7 +36,7 @@ describe('Analytics', () => {
// TODO in app/registry/namespace.js - if (!hasCustomUrlOrRegionSupport)
xit('throws if args provided to firebase.app().analytics(ARGS)', () => {
try {
// @ts-ignore
// @ts-ignore test
firebase.app().analytics('foo', 'arg2');
return Promise.reject(new Error('Did not throw'));
} catch (e) {
@@ -46,16 +46,121 @@ describe('Analytics', () => {
});
});
it('errors if screenName not a string', () => {
// @ts-ignore test
expect(() => firebase.analytics().setCurrentScreen(666.1337)).toThrowError(
"'screenName' expected a string value",
);
});
it('errors if screenClassOverride not a string', () => {
// @ts-ignore test
expect(() => firebase.analytics().setCurrentScreen('invertase screen', 666.1337)).toThrowError(
"'screenClassOverride' expected a string value",
);
});
it('errors if milliseconds not a number', () => {
// @ts-ignore test
expect(() => firebase.analytics().setMinimumSessionDuration('123')).toThrowError(
"'milliseconds' expected a number value",
);
});
it('errors if milliseconds is less than 0', () => {
// @ts-ignore test
expect(() => firebase.analytics().setMinimumSessionDuration(-100)).toThrowError(
"'milliseconds' expected a positive number value",
);
});
it('errors if milliseconds not a number', () => {
// @ts-ignore test
expect(() => firebase.analytics().setSessionTimeoutDuration('123')).toThrowError(
"'milliseconds' expected a number value",
);
});
it('throws if none string none null values', () => {
// @ts-ignore test
expect(() => firebase.analytics().setUserId(123)).toThrowError("'id' expected a string value");
});
it('throws if name is not a string', () => {
// @ts-ignore test
expect(() => firebase.analytics().setUserProperty(1337, 'invertase')).toThrowError(
"'name' expected a string value",
);
});
it('throws if value is invalid', () => {
// @ts-ignore test
expect(() => firebase.analytics().setUserProperty('invertase3', 33.3333)).toThrowError(
"'value' expected a string value",
);
});
it('throws if properties is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().setUserProperties(1337)).toThrowError(
"'properties' expected an object of key/value pairs",
);
});
it('throws if property value is invalid', () => {
const props = {
test: '123',
foo: {
bar: 'baz',
},
};
// @ts-ignore test
expect(() => firebase.analytics().setUserProperties(props)).toThrowError(
"'properties' value for parameter 'foo' is invalid",
);
});
it('throws if value is a number', () => {
// @ts-ignore test
expect(() => firebase.analytics().setUserProperties({ invertase1: 123 })).toThrowError(
"'properties' value for parameter 'invertase1' is invalid, expected a string.",
);
});
it('errors when no parameters are set', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSearch()).toThrowError(
'The supplied arg must be an object of key/values',
);
});
it('call methods, getters & setters that fire a console.warn() & have no return value', () => {
const analytics = firebase.analytics();
// @ts-ignore test
const logEcommercePurchaseSpy = jest.spyOn(analytics, 'logEcommercePurchase');
// @ts-ignore test
const logPresentOfferSpy = jest.spyOn(analytics, 'logPresentOffer');
// @ts-ignore test
const logPurchaseRefundSpy = jest.spyOn(analytics, 'logPurchaseRefund');
// @ts-ignore test
analytics.logEcommercePurchase();
// @ts-ignore test
analytics.logPresentOffer();
// @ts-ignore test
analytics.logPurchaseRefund();
expect(logEcommercePurchaseSpy).toBeCalled();
expect(logPresentOfferSpy).toBeCalled();
expect(logPurchaseRefundSpy).toBeCalled();
});
describe('logEvent()', () => {
it('errors if name is not a string', () => {
// @ts-ignore
// @ts-ignore test
expect(() => firebase.analytics().logEvent(123)).toThrowError(
"firebase.analytics().logEvent(*) 'name' expected a string value.",
);
});
it('errors if params is not an object', () => {
// @ts-ignore
// @ts-ignore test
expect(() => firebase.analytics().logEvent('invertase_event', 'foobar')).toThrowError(
"firebase.analytics().logEvent(_, *) 'params' expected an object value.",
);
@@ -81,13 +186,370 @@ describe('Analytics', () => {
);
});
describe('setAnalyticsCollectionEnabled()', () => {
it('throws if not a boolean', () => {
// @ts-ignore
expect(() => firebase.analytics().setAnalyticsCollectionEnabled('foo')).toThrowError(
"firebase.analytics().setAnalyticsCollectionEnabled(*) 'enabled' expected a boolean value.",
describe('logAddPaymentInfo()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logAddPaymentInfo(123)).toThrowError(
'firebase.analytics().logAddPaymentInfo(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logAddPaymentInfo({
value: 123,
}),
).toThrowError('firebase.analytics().logAddPaymentInfo(*):');
});
});
});
describe('logAddToCart()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logAddToCart(123)).toThrowError(
'firebase.analytics().logAddToCart(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logAddToCart({
value: 123,
}),
).toThrowError('firebase.analytics().logAddToCart(*):');
});
});
describe('logAddShippingInfo()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logAddShippingInfo(123)).toThrowError(
'firebase.analytics().logAddShippingInfo(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logAddShippingInfo({
value: 123,
}),
).toThrowError('firebase.analytics().logAddShippingInfo(*):');
});
});
describe('logAddToWishlist()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logAddToWishlist(123)).toThrowError(
'firebase.analytics().logAddToWishlist(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logAddToWishlist({
value: 123,
}),
).toThrowError('firebase.analytics().logAddToWishlist(*):');
});
});
describe('logBeginCheckout()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logBeginCheckout(123)).toThrowError(
'firebase.analytics().logBeginCheckout(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logBeginCheckout({
value: 123,
}),
).toThrowError('firebase.analytics().logBeginCheckout(*):');
});
});
describe('logGenerateLead()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logGenerateLead(123)).toThrowError(
'firebase.analytics().logGenerateLead(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logGenerateLead({
value: 123,
}),
).toThrowError('firebase.analytics().logGenerateLead(*):');
});
});
describe('logCampaignDetails()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logCampaignDetails(123)).toThrowError(
'firebase.analytics().logCampaignDetails(*):',
);
});
});
describe('logEarnVirtualCurrency()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logEarnVirtualCurrency(123)).toThrowError(
'firebase.analytics().logEarnVirtualCurrency(*):',
);
});
});
describe('logJoinGroup()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logJoinGroup(123)).toThrowError(
'firebase.analytics().logJoinGroup(*):',
);
});
});
describe('logLevelEnd()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logLevelEnd(123)).toThrowError(
'firebase.analytics().logLevelEnd(*):',
);
});
});
describe('logLevelStart()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logLevelStart(123)).toThrowError(
'firebase.analytics().logLevelStart(*):',
);
});
});
describe('logLevelUp()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logLevelUp(123)).toThrowError(
'firebase.analytics().logLevelUp(*):',
);
});
});
describe('logLogin()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logLogin(123)).toThrowError(
'firebase.analytics().logLogin(*):',
);
});
});
describe('logPostScore()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logPostScore(123)).toThrowError(
'firebase.analytics().logPostScore(*):',
);
});
});
describe('logSelectContent()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSelectContent(123)).toThrowError(
'firebase.analytics().logSelectContent(*):',
);
});
});
describe('logSearch()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSearch(123)).toThrowError(
'firebase.analytics().logSearch(*):',
);
});
});
describe('logSelectItem()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSelectItem(123)).toThrowError(
'firebase.analytics().logSelectItem(*):',
);
});
});
describe('logSetCheckoutOption()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSetCheckoutOption(123)).toThrowError(
'firebase.analytics().logSetCheckoutOption(*):',
);
});
});
describe('logShare()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logShare(123)).toThrowError(
'firebase.analytics().logShare(*):',
);
});
});
describe('logSignUp()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSignUp(123)).toThrowError(
'firebase.analytics().logSignUp(*):',
);
});
});
describe('logSelectPromotion()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSelectPromotion(123)).toThrowError(
'firebase.analytics().logSelectPromotion(*):',
);
});
});
describe('logSpendVirtualCurrency()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logSpendVirtualCurrency(123)).toThrowError(
'firebase.analytics().logSpendVirtualCurrency(*):',
);
});
});
describe('logUnlockAchievement()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logUnlockAchievement(123)).toThrowError(
'firebase.analytics().logUnlockAchievement(*):',
);
});
});
describe('logPurchase()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logPurchase(123)).toThrowError(
'firebase.analytics().logPurchase(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logPurchase({
value: 123,
}),
).toThrowError('firebase.analytics().logPurchase(*):');
});
});
describe('logRefund()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logRefund(123)).toThrowError(
'firebase.analytics().logRefund(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logRefund({
value: 123,
}),
).toThrowError('firebase.analytics().logRefund(*):');
});
});
describe('logViewCart()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logViewCart(123)).toThrowError(
'firebase.analytics().logViewCart(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logViewCart({
value: 123,
}),
).toThrowError('firebase.analytics().logViewCart(*):');
});
});
describe('logViewItem()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logViewItem(123)).toThrowError(
'firebase.analytics().logViewItem(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logViewItem({
value: 123,
}),
).toThrowError('firebase.analytics().logViewItem(*):');
});
});
describe('logViewItemList()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logViewItemList(123)).toThrowError(
'firebase.analytics().logViewItemList(*):',
);
});
});
describe('logRemoveFromCart()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logRemoveFromCart(123)).toThrowError(
'firebase.analytics().logRemoveFromCart(*):',
);
});
it('errors when compound values are not set', () => {
expect(() =>
firebase.analytics().logRemoveFromCart({
value: 123,
}),
).toThrowError('firebase.analytics().logRemoveFromCart(*):');
});
});
describe('logViewPromotion()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logViewPromotion(123)).toThrowError(
'firebase.analytics().logViewPromotion(*):',
);
});
});
describe('logViewSearchResults()', () => {
it('errors if param is not an object', () => {
// @ts-ignore test
expect(() => firebase.analytics().logViewSearchResults(123)).toThrowError(
'firebase.analytics().logViewSearchResults(*):',
);
});
});
describe('setAnalyticsCollectionEnabled()', () => {
it('throws if not a boolean', () => {
// @ts-ignore
expect(() => firebase.analytics().setAnalyticsCollectionEnabled('foo')).toThrowError(
"firebase.analytics().setAnalyticsCollectionEnabled(*) 'enabled' expected a boolean value.",
);
});
});
});

View File

@@ -64,24 +64,6 @@ describe('analytics()', () => {
it('screenName with screenClassOverride', async () => {
await firebase.analytics().setCurrentScreen('invertase screen', 'invertase class override');
});
it('errors if screenName not a string', async () => {
try {
await firebase.analytics().setCurrentScreen(666.1337);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'screenName' expected a string value");
}
});
it('errors if screenClassOverride not a string', async () => {
try {
await firebase.analytics().setCurrentScreen('invertase screen', 666.1337);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'screenClassOverride' expected a string value");
}
});
});
describe('setMinimumSessionDuration()', () => {
@@ -89,24 +71,6 @@ describe('analytics()', () => {
await firebase.analytics().setMinimumSessionDuration();
});
it('errors if milliseconds not a number', async () => {
try {
await firebase.analytics().setMinimumSessionDuration('123');
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'milliseconds' expected a number value");
}
});
it('errors if milliseconds is less than 0', async () => {
try {
await firebase.analytics().setMinimumSessionDuration(-100);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'milliseconds' expected a positive number value");
}
});
it('custom duration', async () => {
await firebase.analytics().setMinimumSessionDuration(1337);
});
@@ -117,24 +81,6 @@ describe('analytics()', () => {
await firebase.analytics().setSessionTimeoutDuration();
});
it('errors if milliseconds not a number', async () => {
try {
await firebase.analytics().setSessionTimeoutDuration('123');
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'milliseconds' expected a number value");
}
});
it('errors if milliseconds is less than 0', async () => {
try {
await firebase.analytics().setSessionTimeoutDuration(-100);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'milliseconds' expected a positive number value");
}
});
it('custom duration', async () => {
await firebase.analytics().setSessionTimeoutDuration(13371337);
});
@@ -148,15 +94,6 @@ describe('analytics()', () => {
it('accepts string values', async () => {
await firebase.analytics().setUserId('rn-firebase');
});
it('throws if none string none null values', async () => {
try {
await firebase.analytics().setUserId(123);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'id' expected a string value");
}
});
});
describe('setUserProperty()', () => {
@@ -167,61 +104,9 @@ describe('analytics()', () => {
it('accepts string values', async () => {
await firebase.analytics().setUserProperty('invertase2', 'rn-firebase');
});
it('throws if name is not a string', async () => {
try {
await firebase.analytics().setUserProperty(1337, 'invertase');
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'name' expected a string value");
}
});
it('throws if value is invalid', async () => {
try {
await firebase.analytics().setUserProperty('invertase3', 33.3333);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'value' expected a string value");
}
});
});
describe('setUserProperties()', () => {
it('throws if properties is not an object', async () => {
try {
await firebase.analytics().setUserProperties(1337);
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'properties' expected an object of key/value pairs");
}
});
it('throws if property value is invalid', async () => {
try {
await firebase.analytics().setUserProperties({
test: '123',
foo: {
bar: 'baz',
},
});
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql("'properties' value for parameter 'foo' is invalid");
}
});
it('throws if value is a number', async () => {
try {
await firebase.analytics().setUserProperties({ invertase1: 123 });
return Promise.reject(new Error('Did not throw.'));
} catch (e) {
e.message.should.containEql(
"'properties' value for parameter 'invertase1' is invalid, expected a string.",
);
}
});
it('allows null values to be set', async () => {
await firebase.analytics().setUserProperties({ invertase2: null });
});
@@ -232,42 +117,27 @@ describe('analytics()', () => {
});
describe('logAddPaymentInfo()', () => {
it('calls logEvent', async () => {
await firebase.analytics().logAddPaymentInfo();
it('calls logAddPaymentInfo', async () => {
await firebase.analytics().logAddPaymentInfo({
value: 123,
currency: 'USD',
items: [],
});
});
});
describe('logAddToCart()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logAddToCart();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logAddToCart({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
quantity: 1,
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logAddToCart', async () => {
await firebase.analytics().logAddToCart({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
quantity: 1,
item_location_id: 'foo',
start_date: '2019-01-01',
value: 123,
currency: 'GBP',
});
});
});
describe('logAddShippingInfo()', () => {
it('calls logAddShippingInfo', async () => {
await firebase.analytics().logAddShippingInfo({
value: 123,
currency: 'GBP',
});
@@ -275,35 +145,16 @@ describe('analytics()', () => {
});
describe('logAddToWishlist()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logAddToWishlist();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logAddToWishlist({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
quantity: 1,
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logAddToWishlist', async () => {
await firebase.analytics().logAddToWishlist({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
quantity: 1,
item_location_id: 'foo',
items: [
{
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
item_location_id: 'foo',
},
],
value: 123,
currency: 'GBP',
});
@@ -320,27 +171,9 @@ describe('analytics()', () => {
it('calls logBeginCheckout', async () => {
await firebase.analytics().logBeginCheckout();
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logBeginCheckout({
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
});
describe('logCampaignDetails()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logCampaignDetails();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logCampaignDetails', async () => {
await firebase.analytics().logCampaignDetails({
source: 'foo',
@@ -351,14 +184,6 @@ describe('analytics()', () => {
});
describe('logEarnVirtualCurrency()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logEarnVirtualCurrency();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logEarnVirtualCurrency', async () => {
await firebase.analytics().logEarnVirtualCurrency({
virtual_currency_name: 'foo',
@@ -367,26 +192,28 @@ describe('analytics()', () => {
});
});
describe('logEcommercePurchase()', () => {
it('calls logEcommercePurchase with no params', async () => {
await firebase.analytics().logEcommercePurchase();
});
it('calls logEcommercePurchase', async () => {
await firebase.analytics().logEcommercePurchase({
describe('logPurchase()', () => {
it('calls logPurchase', async () => {
await firebase.analytics().logPurchase({
currency: 'USD',
value: 123,
affiliation: 'affiliation',
});
});
});
describe('logViewPromotion()', () => {
it('calls logViewPromotion', async () => {
await firebase.analytics().logViewPromotion({
creative_name: 'creative_name',
creative_slot: 'creative_slot',
});
});
});
describe('logGenerateLead()', () => {
it('calls logGenerateLead with no params', async () => {
await firebase.analytics().logEcommercePurchase();
});
it('calls logGenerateLead', async () => {
await firebase.analytics().logEcommercePurchase({
await firebase.analytics().logGenerateLead({
currency: 'USD',
value: 123,
});
@@ -394,14 +221,6 @@ describe('analytics()', () => {
});
describe('logJoinGroup()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logJoinGroup();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logJoinGroup', async () => {
await firebase.analytics().logJoinGroup({
group_id: '123',
@@ -410,14 +229,6 @@ describe('analytics()', () => {
});
describe('logLevelEnd()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logLevelEnd();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logLevelEnd', async () => {
await firebase.analytics().logLevelEnd({
level: 123,
@@ -427,14 +238,6 @@ describe('analytics()', () => {
});
describe('logLevelStart()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logLevelStart();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logLevelEnd', async () => {
await firebase.analytics().logLevelStart({
level: 123,
@@ -443,14 +246,6 @@ describe('analytics()', () => {
});
describe('logLevelUp()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logLevelUp();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logLevelUp', async () => {
await firebase.analytics().logLevelUp({
level: 123,
@@ -460,14 +255,6 @@ describe('analytics()', () => {
});
describe('logLogin()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logLogin();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logLogin', async () => {
await firebase.analytics().logLogin({
method: 'facebook.com',
@@ -476,14 +263,6 @@ describe('analytics()', () => {
});
describe('logPostScore()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logPostScore();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logPostScore', async () => {
await firebase.analytics().logPostScore({
score: 123,
@@ -491,101 +270,16 @@ describe('analytics()', () => {
});
});
describe('logPresentOffer()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logPresentOffer();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logPresentOffer({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
quantity: 1,
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logPresentOffer', async () => {
await firebase.analytics().logPresentOffer({
item_id: '123',
item_name: '123',
item_category: '123',
quantity: 123,
});
});
});
describe('logPurchaseRefund()', () => {
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logPurchaseRefund({
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logPurchaseRefund with no params', async () => {
await firebase.analytics().logPurchaseRefund();
});
it('calls logPurchaseRefund', async () => {
await firebase.analytics().logPurchaseRefund({
transaction_id: '123',
});
});
});
describe('logRemoveFromCart()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logRemoveFromCart();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logRemoveFromCart({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logRemoveFromCart', async () => {
await firebase.analytics().logRemoveFromCart({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
value: 123,
currency: 'USD',
});
});
});
describe('logSearch()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logSearch();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logSearch', async () => {
await firebase.analytics().logSearch({
search_term: 'foo',
@@ -593,32 +287,7 @@ describe('analytics()', () => {
});
});
describe('logSelectContent()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logSelectContent();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logSelectContent', async () => {
await firebase.analytics().logSelectContent({
content_type: 'foo',
item_id: 'foo',
});
});
});
describe('logSetCheckoutOption()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logSetCheckoutOption();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logSelectContent', async () => {
await firebase.analytics().logSetCheckoutOption({
checkout_step: 123,
@@ -627,32 +296,27 @@ describe('analytics()', () => {
});
});
describe('logShare()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logShare();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
describe('logSelectItem()', () => {
it('calls logSelectItem', async () => {
await firebase.analytics().logSelectItem({
item_list_id: 'foo',
item_list_name: 'foo',
content_type: 'foo',
});
});
});
describe('logShare()', () => {
it('calls logShare', async () => {
await firebase.analytics().logShare({
content_type: 'foo',
item_id: 'foo',
method: 'foo',
});
});
});
describe('logSignUp()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logSignUp();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logSignUp', async () => {
await firebase.analytics().logSignUp({
method: 'facebook.com',
@@ -661,14 +325,6 @@ describe('analytics()', () => {
});
describe('logSpendVirtualCurrency()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logSpendVirtualCurrency();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logSpendVirtualCurrency', async () => {
await firebase.analytics().logSpendVirtualCurrency({
item_name: 'foo',
@@ -691,14 +347,6 @@ describe('analytics()', () => {
});
describe('logUnlockAchievement()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logUnlockAchievement();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logUnlockAchievement', async () => {
await firebase.analytics().logUnlockAchievement({
achievement_id: 'foo',
@@ -706,65 +354,71 @@ describe('analytics()', () => {
});
});
describe('logViewCart()', () => {
it('calls logViewCart', async () => {
await firebase.analytics().logViewCart();
});
});
describe('logViewItem()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logViewItem();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('errors when compound values are not set', async () => {
try {
await firebase.analytics().logViewItem({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
value: 123,
});
} catch (e) {
e.message.should.containEql('parameter, you must also supply the');
}
});
it('calls logUnlockAchievement', async () => {
it('calls logViewItem', async () => {
await firebase.analytics().logViewItem({
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
items: [
{
item_id: 'foo',
item_name: 'foo',
item_category: 'foo',
item_location_id: 'foo',
},
],
value: 123,
currency: 'GBP',
});
});
});
describe('logViewItemList()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logViewItemList();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logViewItemList', async () => {
await firebase.analytics().logViewItemList({
item_category: 'foo',
item_list_name: 'foo',
});
});
});
describe('logRefund()', () => {
it('calls logRefund', async () => {
await firebase.analytics().logRefund({
affiliation: 'affiliation',
coupon: 'coupon',
});
});
});
describe('logSelectContent()', () => {
it('calls logSelectContent', async () => {
await firebase.analytics().logSelectContent({
content_type: 'clothing',
item_id: 'abcd',
});
});
});
describe('logSelectPromotion()', () => {
it('calls logSelectPromotion', async () => {
await firebase.analytics().logSelectPromotion({
creative_name: 'string',
creative_slot: 'string',
location_id: 'string',
promotion_id: 'string',
promotion_name: 'string',
});
});
});
describe('logViewSearchResults()', () => {
it('errors when no parameters are set', async () => {
try {
await firebase.analytics().logViewSearchResults();
} catch (e) {
e.message.should.containEql('The supplied arg must be an object of key/values');
}
});
it('calls logViewSearchResults', async () => {
await firebase.analytics().logViewSearchResults({
search_term: 'foo',
search_term: 'promotion',
});
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -199,11 +199,41 @@ class FirebaseAnalyticsModule extends FirebaseModule {
/** -------------------
* EVENTS
* -------------------- */
logAddPaymentInfo() {
return this.logEvent('add_payment_info');
logAddPaymentInfo(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logAddPaymentInfo(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logAddPaymentInfo(*):');
return this.logEvent(
'add_payment_info',
validateStruct(object, structs.AddPaymentInfo, 'firebase.analytics().logAddPaymentInfo(*):'),
);
}
logAddToCart(object) {
logAddShippingInfo(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logAddShippingInfo(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logAddShippingInfo(*):');
return this.logEvent(
'add_shipping_info',
validateStruct(
object,
structs.AddShippingInfo,
'firebase.analytics().logAddShippingInfo(*):',
),
);
}
logAddToCart(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logAddToCart(*): The supplied arg must be an object of key/values.',
@@ -218,7 +248,7 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logAddToWishlist(object) {
logAddToWishlist(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logAddToWishlist(*): The supplied arg must be an object of key/values.',
@@ -238,6 +268,12 @@ class FirebaseAnalyticsModule extends FirebaseModule {
}
logBeginCheckout(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logBeginCheckout(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logBeginCheckout(*):');
return this.logEvent(
@@ -279,21 +315,24 @@ class FirebaseAnalyticsModule extends FirebaseModule {
),
);
}
logEcommercePurchase(object = {}) {
validateCompound(object, 'value', 'currency', 'firebase.analytics().logEcommercePurchase(*):');
return this.logEvent(
'ecommerce_purchase',
validateStruct(
object,
structs.EcommercePurchase,
'firebase.analytics().logEcommercePurchase(*):',
),
/**
* logEcommercePurchase purchase is now deprecated, use logPurchase instead:
* https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-ecommerce_purchase
*/
logEcommercePurchase() {
// eslint-disable-next-line no-console
console.warn(
'firebase.analytics().logEcommercePurchase(), "ECOMMERCE_PURCHASE" event is now deprecated. Please use firebase.analytics().logPurchase() instead',
);
}
logGenerateLead(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logGenerateLead(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logGenerateLead(*):');
return this.logEvent(
@@ -380,31 +419,72 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logPresentOffer(object) {
/**
* Deprecated, use logRefundEvent instead:
* https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-present_offer
*/
logPresentOffer() {
// eslint-disable-next-line no-console
console.warn(
'firebase.analytics().logPresentOffer(), "PRESENT_OFFER" event is now deprecated. Please use firebase.analytics().logViewPromotion() instead',
);
}
/**
* Deprecated, use logRefundEvent instead:
* https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-purchase_refund
*/
logPurchaseRefund() {
// eslint-disable-next-line no-console
console.warn(
'firebase.analytics().logPurchaseRefund(), "PURCHASE_REFUND" event is now deprecated. Please use firebase.analytics().logRefund() instead',
);
}
logSelectContent(object) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logPresentOffer(*): The supplied arg must be an object of key/values.',
'firebase.analytics().logSelectContent(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logPresentOffer(*):');
return this.logEvent(
'present_offer',
validateStruct(object, structs.PresentOffer, 'firebase.analytics().logPresentOffer(*):'),
'select_content',
validateStruct(object, structs.SelectContent, 'firebase.analytics().logSelectContent(*):'),
);
}
logPurchaseRefund(object = {}) {
validateCompound(object, 'value', 'currency', 'firebase.analytics().logPresentOffer(*):');
logPurchase(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logPurchase(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logPurchase(*):');
return this.logEvent(
'purchase_refund',
validateStruct(object, structs.PurchaseRefund, 'firebase.analytics().logPurchaseRefund(*):'),
'purchase',
validateStruct(object, structs.Purchase, 'firebase.analytics().logPurchaseEvent(*):'),
);
}
logRemoveFromCart(object) {
logRefund(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logRefund(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logRefund(*):');
return this.logEvent(
'refund',
validateStruct(object, structs.Refund, 'firebase.analytics().logRefund(*):'),
);
}
logRemoveFromCart(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logRemoveFromCart(*): The supplied arg must be an object of key/values.',
@@ -432,16 +512,16 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logSelectContent(object) {
logSelectItem(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logSelectContent(*): The supplied arg must be an object of key/values.',
'firebase.analytics().logSelectItem(*): The supplied arg must be an object of key/values.',
);
}
return this.logEvent(
'select_content',
validateStruct(object, structs.SelectContent, 'firebase.analytics().logSelectContent(*):'),
'select_item',
validateStruct(object, structs.SelectItem, 'firebase.analytics().logSelectItem(*):'),
);
}
@@ -462,6 +542,23 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logSelectPromotion(object) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logSelectPromotion(*): The supplied arg must be an object of key/values.',
);
}
return this.logEvent(
'select_promotion',
validateStruct(
object,
structs.SelectPromotion,
'firebase.analytics().logSelectPromotion(*):',
),
);
}
logShare(object) {
if (!isObject(object)) {
throw new Error(
@@ -530,13 +627,27 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logViewItem(object) {
logViewCart(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logViewCart(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logViewCart(*):');
return this.logEvent(
'view_cart',
validateStruct(object, structs.ViewCart, 'firebase.analytics().logViewCart(*):'),
);
}
logViewItem(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logViewItem(*): The supplied arg must be an object of key/values.',
);
}
validateCompound(object, 'value', 'currency', 'firebase.analytics().logViewItem(*):');
return this.logEvent(
@@ -545,7 +656,7 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logViewItemList(object) {
logViewItemList(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logViewItemList(*): The supplied arg must be an object of key/values.',
@@ -558,6 +669,22 @@ class FirebaseAnalyticsModule extends FirebaseModule {
);
}
logViewPromotion(object = {}) {
if (!isObject(object)) {
throw new Error(
'firebase.analytics().logViewPromotion(*): The supplied arg must be an object of key/values.',
);
}
return this.logEvent(
'view_promotion',
validateStruct(object, structs.ViewPromotion, 'firebase.analytics().logViewPromotion(*):'),
);
}
/**
* Unsupported in "Enhanced Ecommerce reports":
* https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event#public-static-final-string-view_search_results
*/
logViewSearchResults(object) {
if (!isObject(object)) {
throw new Error(

View File

@@ -15,44 +15,54 @@
*/
import struct from '@react-native-firebase/app/lib/common/struct';
export const AddToCart = struct({
item_id: 'string',
item_name: 'string',
item_category: 'string',
quantity: 'number',
price: 'number?',
const Item = struct({
item_brand: 'string?',
item_id: 'string?',
item_name: 'string?',
item_category: 'string?',
item_category2: 'string?',
item_category3: 'string?',
item_category4: 'string?',
item_category5: 'string?',
item_list_id: 'string?',
item_list_name: 'string?',
item_location_id: 'string?',
item_variant: 'string?',
});
export const AddPaymentInfo = struct({
items: struct.optional([Item]),
value: 'number?',
currency: 'string?',
coupon: 'string?',
payment_type: 'string?',
});
export const AddShippingInfo = struct({
items: struct.optional([Item]),
value: 'number?',
currency: 'string?',
coupon: 'string?',
shipping_tier: 'string?',
});
export const AddToCart = struct({
items: struct.optional([Item]),
value: 'number?',
currency: 'string?',
origin: 'string?',
item_location_id: 'string?',
destination: 'string?',
start_date: 'shortDate?',
end_date: 'shortDate?',
});
export const AddToWishlist = struct({
item_id: 'string',
item_name: 'string',
item_category: 'string',
quantity: 'number',
price: 'number?',
items: struct.optional([Item]),
value: 'number?',
currency: 'string?',
item_location_id: 'string?',
});
export const BeginCheckout = struct({
items: struct.optional([Item]),
value: 'number?',
currency: 'string?',
transaction_id: 'string?',
number_of_nights: 'number?',
number_of_rooms: 'number?',
number_of_passengers: 'number?',
origin: 'string?',
destination: 'string?',
start_date: 'shortDate?',
end_date: 'shortDate?',
travel_class: 'shortDate?',
coupon: 'string?',
});
export const CampaignDetails = struct({
@@ -70,24 +80,6 @@ export const EarnVirtualCurrency = struct({
value: 'number',
});
export const EcommercePurchase = struct({
currency: 'string?',
value: 'number?',
transaction_id: 'string?',
tax: 'number?',
shipping: 'number?',
coupon: 'string?',
location: 'string?',
number_of_nights: 'number?',
number_of_rooms: 'number?',
number_of_passengers: 'number?',
origin: 'string?',
destination: 'string?',
start_date: 'shortDate?',
end_date: 'shortDate?',
travel_class: 'string?',
});
export const GenerateLead = struct({
currency: 'string?',
value: 'number?',
@@ -121,36 +113,32 @@ export const PostScore = struct({
character: 'string?',
});
export const PresentOffer = struct({
item_id: 'string',
item_name: 'string',
item_category: 'string',
quantity: 'number',
price: 'number?',
value: 'number?',
export const Refund = struct({
affiliation: 'string?',
coupon: 'string?',
currency: 'string?',
item_location_id: 'string?',
items: struct.optional([Item]),
shipping: 'number?',
tax: 'number?',
value: 'number?',
transaction_id: 'string?',
});
export const PurchaseRefund = struct({
export const Purchase = struct({
affiliation: 'string?',
coupon: 'string?',
currency: 'string?',
items: struct.optional([Item]),
shipping: 'number?',
tax: 'number?',
value: 'number?',
transaction_id: 'string?',
});
export const RemoveFromCart = struct({
item_id: 'string',
item_name: 'string',
item_category: 'string',
quantity: 'number?',
value: 'number?',
price: 'number?',
currency: 'string?',
item_location_id: 'string?',
start_date: 'shortDate?',
end_date: 'shortDate?',
origin: 'string?',
destination: 'string?',
items: struct.optional([Item]),
value: 'number?',
});
export const Search = struct({
@@ -170,6 +158,22 @@ export const SelectContent = struct({
item_id: 'string',
});
export const SelectItem = struct({
items: struct.optional([Item]),
item_list_id: 'string?',
item_list_name: 'string?',
content_type: 'string?',
});
export const SelectPromotion = struct({
creative_name: 'string',
creative_slot: 'string',
items: struct.optional([Item]),
location_id: 'string',
promotion_id: 'string',
promotion_name: 'string',
});
export const SetCheckoutOption = struct({
checkout_step: 'number',
checkout_option: 'string',
@@ -178,6 +182,7 @@ export const SetCheckoutOption = struct({
export const Share = struct({
content_type: 'string',
item_id: 'string',
method: 'string',
});
export const SignUp = struct({
@@ -194,29 +199,31 @@ export const UnlockAchievement = struct({
achievement_id: 'string',
});
export const ViewItem = struct({
item_id: 'string',
item_name: 'string',
item_category: 'string',
item_location_id: 'string?',
price: 'number?',
quantity: 'number?',
export const ViewCart = struct({
currency: 'string?',
items: struct.optional([Item]),
value: 'number?',
});
export const ViewItem = struct({
currency: 'string?',
items: struct.optional([Item]),
value: 'number?',
flight_number: 'string?',
number_of_passengers: 'number?',
number_of_nights: 'number?',
number_of_rooms: 'number?',
origin: 'string?',
destination: 'string?',
start_date: 'shortDate?',
end_date: 'shortDate?',
search_term: 'string?',
travel_class: 'string?',
});
export const ViewItemList = struct({
item_category: 'string',
items: struct.optional([Item]),
item_list_id: 'string?',
item_list_name: 'string?',
});
export const ViewPromotion = struct({
items: struct.optional([Item]),
location_id: 'string?',
creative_name: 'string?',
creative_slot: 'string?',
promotion_id: 'string?',
promotion_name: 'string?',
});
export const ViewSearchResults = struct({

View File

@@ -16,11 +16,11 @@ console.log(firebase.SDK_VERSION);
firebase
.analytics()
.logAddPaymentInfo()
.logAddPaymentInfo({ value: 123, currency: 'USD' })
.then();
firebase
.analytics()
.logAddToCart({ item_id: '123', item_category: '123', item_name: '123', quantity: 3 })
.logAddToCart({ value: 123, currency: 'USD' })
.then();
firebase
.analytics()
@@ -33,12 +33,12 @@ firebase
console.log(firebase.analytics().logAddPaymentInfo);
console.log(firebase.analytics().logAddToCart);
console.log(firebase.analytics().logAddShippingInfo);
console.log(firebase.analytics().logAddToWishlist);
console.log(firebase.analytics().logAppOpen);
console.log(firebase.analytics().logBeginCheckout);
console.log(firebase.analytics().logCampaignDetails);
console.log(firebase.analytics().logEarnVirtualCurrency);
console.log(firebase.analytics().logEcommercePurchase);
console.log(firebase.analytics().logEvent);
console.log(firebase.analytics().logGenerateLead);
console.log(firebase.analytics().logJoinGroup);
@@ -46,9 +46,10 @@ console.log(firebase.analytics().logLevelEnd);
console.log(firebase.analytics().logLevelStart);
console.log(firebase.analytics().logLevelUp);
console.log(firebase.analytics().logLogin);
console.log(firebase.analytics().logPresentOffer);
console.log(firebase.analytics().logPurchaseRefund);
console.log(firebase.analytics().logPostScore);
console.log(firebase.analytics().logPurchase);
console.log(firebase.analytics().logRemoveFromCart);
console.log(firebase.analytics().logRefund);
console.log(firebase.analytics().logSearch);
console.log(firebase.analytics().logSelectContent);
console.log(firebase.analytics().logSetCheckoutOption);
@@ -60,24 +61,27 @@ console.log(firebase.analytics().logTutorialComplete);
console.log(firebase.analytics().logUnlockAchievement);
console.log(firebase.analytics().logViewItem);
console.log(firebase.analytics().logViewItemList);
console.log(firebase.analytics().logViewSearchResults);
console.log(firebase.analytics().resetAnalyticsData);
console.log(firebase.analytics().logViewCart);
console.log(firebase.analytics().setAnalyticsCollectionEnabled);
console.log(firebase.analytics().logSelectPromotion);
console.log(firebase.analytics().setCurrentScreen);
console.log(firebase.analytics().logViewPromotion);
console.log(firebase.analytics().setMinimumSessionDuration);
console.log(firebase.analytics().setSessionTimeoutDuration);
console.log(firebase.analytics().setUserId);
console.log(firebase.analytics().setUserProperties);
console.log(firebase.analytics().logViewSearchResults);
console.log(firebase.analytics().setUserProperty);
console.log(analytics().logAddPaymentInfo);
console.log(analytics().logAddToCart);
console.log(analytics().logAddShippingInfo);
console.log(analytics().logAddToWishlist);
console.log(analytics().logAppOpen);
console.log(analytics().logBeginCheckout);
console.log(analytics().logCampaignDetails);
console.log(analytics().logEarnVirtualCurrency);
console.log(analytics().logEcommercePurchase);
console.log(analytics().logEvent);
console.log(analytics().logGenerateLead);
console.log(analytics().logJoinGroup);
@@ -85,9 +89,10 @@ console.log(analytics().logLevelEnd);
console.log(analytics().logLevelStart);
console.log(analytics().logLevelUp);
console.log(analytics().logLogin);
console.log(analytics().logPresentOffer);
console.log(analytics().logPurchaseRefund);
console.log(analytics().logPostScore);
console.log(analytics().logPurchase);
console.log(analytics().logRemoveFromCart);
console.log(analytics().logRefund);
console.log(analytics().logSearch);
console.log(analytics().logSelectContent);
console.log(analytics().logSetCheckoutOption);
@@ -99,12 +104,15 @@ console.log(analytics().logTutorialComplete);
console.log(analytics().logUnlockAchievement);
console.log(analytics().logViewItem);
console.log(analytics().logViewItemList);
console.log(analytics().logViewSearchResults);
console.log(analytics().resetAnalyticsData);
console.log(analytics().logViewCart);
console.log(analytics().setAnalyticsCollectionEnabled);
console.log(analytics().logSelectPromotion);
console.log(analytics().setCurrentScreen);
console.log(analytics().logViewPromotion);
console.log(analytics().setMinimumSessionDuration);
console.log(analytics().setSessionTimeoutDuration);
console.log(analytics().setUserId);
console.log(analytics().setUserProperties);
console.log(analytics().logViewSearchResults);
console.log(analytics().setUserProperty);

View File

@@ -41,7 +41,10 @@ export const validateStruct = (value = {}, struct, prefix = '') => {
};
export const validateCompound = (source = {}, a, b, prefix = '') => {
if (isUndefined(source[a]) && !isUndefined(source[b])) {
if (
(isUndefined(source[a]) && !isUndefined(source[b])) ||
(!isUndefined(source[a]) && isUndefined(source[b]))
) {
throw new Error(
`${prefix} if you supply the '${a}' parameter, you must also supply the '${b}' parameter.`,
);