Skip to content

Commit 757fa95

Browse files
MichaelVerdonmikehardy
authored andcommitted
chore(app-distribution): deprecations for v8 API ahead of future major release
1 parent f739059 commit 757fa95

File tree

3 files changed

+159
-76
lines changed

3 files changed

+159
-76
lines changed

packages/app-distribution/__tests__/app-distribution.test.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
1+
import { afterAll, beforeAll, describe, expect, it, beforeEach, jest } from '@jest/globals';
22

33
import {
44
firebase,
@@ -9,6 +9,22 @@ import {
99
signOutTester,
1010
} from '../lib';
1111

12+
import {
13+
createCheckV9Deprecation,
14+
CheckV9DeprecationFunction,
15+
} from '../../app/lib/common/unitTestUtils';
16+
17+
// @ts-ignore test
18+
import FirebaseModule from '../../app/lib/internal/FirebaseModule';
19+
20+
// Mock isIOS to be true so the app distribution methods work in tests
21+
jest.mock('@react-native-firebase/app/lib/common', () => {
22+
const actualCommon = jest.requireActual('@react-native-firebase/app/lib/common');
23+
return Object.assign({}, actualCommon, {
24+
isIOS: true,
25+
});
26+
});
27+
1228
describe('appDistribution()', function () {
1329
describe('namespace', function () {
1430
beforeAll(async function () {
@@ -49,4 +65,63 @@ describe('appDistribution()', function () {
4965
expect(signOutTester).toBeDefined();
5066
});
5167
});
68+
69+
describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () {
70+
let appDistributionV9Deprecation: CheckV9DeprecationFunction;
71+
72+
beforeEach(function () {
73+
appDistributionV9Deprecation = createCheckV9Deprecation(['appDistribution']);
74+
75+
// @ts-ignore test
76+
jest.spyOn(FirebaseModule.prototype, 'native', 'get').mockImplementation(() => {
77+
return new Proxy(
78+
{},
79+
{
80+
get: () =>
81+
jest.fn().mockResolvedValue({
82+
constants: {
83+
isTesterSignedIn: true,
84+
},
85+
} as never),
86+
},
87+
);
88+
});
89+
});
90+
91+
it('isTesterSignedIn', function () {
92+
const appDistribution = getAppDistribution();
93+
appDistributionV9Deprecation(
94+
() => isTesterSignedIn(appDistribution),
95+
() => appDistribution.isTesterSignedIn(),
96+
'isTesterSignedIn',
97+
);
98+
});
99+
100+
it('signInTester', function () {
101+
const appDistribution = getAppDistribution();
102+
appDistributionV9Deprecation(
103+
() => signInTester(appDistribution),
104+
() => appDistribution.signInTester(),
105+
'signInTester',
106+
);
107+
});
108+
109+
it('checkForUpdate', function () {
110+
const appDistribution = getAppDistribution();
111+
appDistributionV9Deprecation(
112+
() => checkForUpdate(appDistribution),
113+
() => appDistribution.checkForUpdate(),
114+
'checkForUpdate',
115+
);
116+
});
117+
118+
it('signOutTester', function () {
119+
const appDistribution = getAppDistribution();
120+
appDistributionV9Deprecation(
121+
() => signOutTester(appDistribution),
122+
() => appDistribution.signOutTester(),
123+
'signOutTester',
124+
);
125+
});
126+
});
52127
});

packages/app-distribution/lib/modular/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getApp } from '@react-native-firebase/app';
2-
2+
import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
33
/**
44
* @typedef {import("..").FirebaseApp} FirebaseApp
55
* @typedef {import("..").FirebaseAppDistributionTypes.AppDistributionRelease} AppDistributionRelease
@@ -22,29 +22,29 @@ export function getAppDistribution(app) {
2222
* @returns {Promise<boolean>}
2323
*/
2424
export function isTesterSignedIn(appDistribution) {
25-
return appDistribution.isTesterSignedIn();
25+
return appDistribution.isTesterSignedIn.call(appDistribution, MODULAR_DEPRECATION_ARG);
2626
}
2727

2828
/**
2929
* @param {FirebaseAppDistribution} appDistribution
3030
* @returns {Promise<void>}
3131
*/
3232
export function signInTester(appDistribution) {
33-
return appDistribution.signInTester();
33+
return appDistribution.signInTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
3434
}
3535

3636
/**
3737
* @param {FirebaseAppDistribution} appDistribution
3838
* @returns {AppDistributionRelease>}
3939
*/
4040
export function checkForUpdate(appDistribution) {
41-
return appDistribution.checkForUpdate();
41+
return appDistribution.checkForUpdate.call(appDistribution, MODULAR_DEPRECATION_ARG);
4242
}
4343

4444
/**
4545
* @param {FirebaseAppDistribution} appDistribution
4646
* @returns {Promise<void>}
4747
*/
4848
export function signOutTester(appDistribution) {
49-
return appDistribution.signOutTester();
49+
return appDistribution.signOutTester.call(appDistribution, MODULAR_DEPRECATION_ARG);
5050
}

packages/app/lib/common/index.js

Lines changed: 78 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,84 @@ export function tryJSONStringify(data) {
107107
const NO_REPLACEMENT = true;
108108

109109
const mapOfDeprecationReplacements = {
110+
analytics: {
111+
default: {
112+
logEvent: 'logEvent()',
113+
setAnalyticsCollectionEnabled: 'setAnalyticsCollectionEnabled()',
114+
setSessionTimeoutDuration: 'setSessionTimeoutDuration()',
115+
getAppInstanceId: 'getAppInstanceId()',
116+
getSessionId: 'getSessionId()',
117+
setUserId: 'setUserId()',
118+
setUserProperty: 'setUserProperty()',
119+
setUserProperties: 'setUserProperties()',
120+
resetAnalyticsData: 'resetAnalyticsData()',
121+
setDefaultEventParameters: 'setDefaultEventParameters()',
122+
initiateOnDeviceConversionMeasurementWithEmailAddress:
123+
'initiateOnDeviceConversionMeasurementWithEmailAddress()',
124+
initiateOnDeviceConversionMeasurementWithHashedEmailAddress:
125+
'initiateOnDeviceConversionMeasurementWithHashedEmailAddress()',
126+
initiateOnDeviceConversionMeasurementWithPhoneNumber:
127+
'initiateOnDeviceConversionMeasurementWithPhoneNumber()',
128+
initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:
129+
'initiateOnDeviceConversionMeasurementWithHashedPhoneNumber()',
130+
setConsent: 'setConsent()',
131+
// We're deprecating all helper methods for event. e.g. `logAddPaymentInfo()` from namespaced and modular.
132+
logAddPaymentInfo: 'logEvent()',
133+
logScreenView: 'logEvent()',
134+
logAddShippingInfo: 'logEvent()',
135+
logAddToCart: 'logEvent()',
136+
logAddToWishlist: 'logEvent()',
137+
logAppOpen: 'logEvent()',
138+
logBeginCheckout: 'logEvent()',
139+
logCampaignDetails: 'logEvent()',
140+
logEarnVirtualCurrency: 'logEvent()',
141+
logGenerateLead: 'logEvent()',
142+
logJoinGroup: 'logEvent()',
143+
logLevelEnd: 'logEvent()',
144+
logLevelStart: 'logEvent()',
145+
logLevelUp: 'logEvent()',
146+
logLogin: 'logEvent()',
147+
logPostScore: 'logEvent()',
148+
logSelectContent: 'logEvent()',
149+
logPurchase: 'logEvent()',
150+
logRefund: 'logEvent()',
151+
logRemoveFromCart: 'logEvent()',
152+
logSearch: 'logEvent()',
153+
logSelectItem: 'logEvent()',
154+
logSetCheckoutOption: 'logEvent()',
155+
logSelectPromotion: 'logEvent()',
156+
logShare: 'logEvent()',
157+
logSignUp: 'logEvent()',
158+
logSpendVirtualCurrency: 'logEvent()',
159+
logTutorialBegin: 'logEvent()',
160+
logTutorialComplete: 'logEvent()',
161+
logUnlockAchievement: 'logEvent()',
162+
logViewCart: 'logEvent()',
163+
logViewItem: 'logEvent()',
164+
logViewPromotion: 'logEvent()',
165+
logViewSearchResults: 'logEvent()',
166+
},
167+
},
168+
appCheck: {
169+
default: {
170+
activate: 'initializeAppCheck()',
171+
setTokenAutoRefreshEnabled: 'setTokenAutoRefreshEnabled()',
172+
getToken: 'getToken()',
173+
getLimitedUseToken: 'getLimitedUseToken()',
174+
onTokenChanged: 'onTokenChanged()',
175+
},
176+
statics: {
177+
CustomProvider: 'CustomProvider',
178+
},
179+
},
180+
appDistribution: {
181+
default: {
182+
isTesterSignedIn: 'isTesterSignedIn()',
183+
signInTester: 'signInTester()',
184+
checkForUpdate: 'checkForUpdate()',
185+
signOutTester: 'signOutTester()',
186+
},
187+
},
110188
auth: {
111189
default: {
112190
applyActionCode: 'applyActionCode()',
@@ -175,76 +253,6 @@ const mapOfDeprecationReplacements = {
175253
multiFactor: 'multiFactor()',
176254
},
177255
},
178-
appCheck: {
179-
default: {
180-
activate: 'initializeAppCheck()',
181-
setTokenAutoRefreshEnabled: 'setTokenAutoRefreshEnabled()',
182-
getToken: 'getToken()',
183-
getLimitedUseToken: 'getLimitedUseToken()',
184-
onTokenChanged: 'onTokenChanged()',
185-
},
186-
statics: {
187-
CustomProvider: 'CustomProvider',
188-
},
189-
},
190-
analytics: {
191-
default: {
192-
logEvent: 'logEvent()',
193-
setAnalyticsCollectionEnabled: 'setAnalyticsCollectionEnabled()',
194-
setSessionTimeoutDuration: 'setSessionTimeoutDuration()',
195-
getAppInstanceId: 'getAppInstanceId()',
196-
getSessionId: 'getSessionId()',
197-
setUserId: 'setUserId()',
198-
setUserProperty: 'setUserProperty()',
199-
setUserProperties: 'setUserProperties()',
200-
resetAnalyticsData: 'resetAnalyticsData()',
201-
setDefaultEventParameters: 'setDefaultEventParameters()',
202-
initiateOnDeviceConversionMeasurementWithEmailAddress:
203-
'initiateOnDeviceConversionMeasurementWithEmailAddress()',
204-
initiateOnDeviceConversionMeasurementWithHashedEmailAddress:
205-
'initiateOnDeviceConversionMeasurementWithHashedEmailAddress()',
206-
initiateOnDeviceConversionMeasurementWithPhoneNumber:
207-
'initiateOnDeviceConversionMeasurementWithPhoneNumber()',
208-
initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:
209-
'initiateOnDeviceConversionMeasurementWithHashedPhoneNumber()',
210-
setConsent: 'setConsent()',
211-
// We're deprecating all helper methods for event. e.g. `logAddPaymentInfo()` from namespaced and modular.
212-
logAddPaymentInfo: 'logEvent()',
213-
logScreenView: 'logEvent()',
214-
logAddShippingInfo: 'logEvent()',
215-
logAddToCart: 'logEvent()',
216-
logAddToWishlist: 'logEvent()',
217-
logAppOpen: 'logEvent()',
218-
logBeginCheckout: 'logEvent()',
219-
logCampaignDetails: 'logEvent()',
220-
logEarnVirtualCurrency: 'logEvent()',
221-
logGenerateLead: 'logEvent()',
222-
logJoinGroup: 'logEvent()',
223-
logLevelEnd: 'logEvent()',
224-
logLevelStart: 'logEvent()',
225-
logLevelUp: 'logEvent()',
226-
logLogin: 'logEvent()',
227-
logPostScore: 'logEvent()',
228-
logSelectContent: 'logEvent()',
229-
logPurchase: 'logEvent()',
230-
logRefund: 'logEvent()',
231-
logRemoveFromCart: 'logEvent()',
232-
logSearch: 'logEvent()',
233-
logSelectItem: 'logEvent()',
234-
logSetCheckoutOption: 'logEvent()',
235-
logSelectPromotion: 'logEvent()',
236-
logShare: 'logEvent()',
237-
logSignUp: 'logEvent()',
238-
logSpendVirtualCurrency: 'logEvent()',
239-
logTutorialBegin: 'logEvent()',
240-
logTutorialComplete: 'logEvent()',
241-
logUnlockAchievement: 'logEvent()',
242-
logViewCart: 'logEvent()',
243-
logViewItem: 'logEvent()',
244-
logViewPromotion: 'logEvent()',
245-
logViewSearchResults: 'logEvent()',
246-
},
247-
},
248256
crashlytics: {
249257
default: {
250258
checkForUnsentReports: 'checkForUnsentReports()',

0 commit comments

Comments
 (0)