Skip to content

Commit

Permalink
fix(analytics): BREAKING drop deprecated setMinimumSessionDuration API
Browse files Browse the repository at this point in the history
This is part of the forward port to firebase-android-sdk v26.0.0

BREAKING CHANGE: there is no replacement for the setMinimumSessionDuration API
  • Loading branch information
mikehardy committed Nov 10, 2020
1 parent 1f2a109 commit a675cd7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 114 deletions.
14 changes: 0 additions & 14 deletions packages/analytics/__tests__/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ describe('Analytics', () => {
});
});

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ Task<Void> setAnalyticsCollectionEnabled(Boolean enabled) {
});
}

Task<Void> setMinimumSessionDuration(long milliseconds) {
return Tasks.call(() -> {
FirebaseAnalytics.getInstance(getContext()).setMinimumSessionDuration(milliseconds);
return null;
});
}

Task<Void> setSessionTimeoutDuration(long milliseconds) {
return Tasks.call(() -> {
FirebaseAnalytics.getInstance(getContext()).setSessionTimeoutDuration(milliseconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public void setAnalyticsCollectionEnabled(Boolean enabled, Promise promise) {
});
}

@ReactMethod
public void setMinimumSessionDuration(double milliseconds, Promise promise) {
module.setMinimumSessionDuration((long) milliseconds).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
promise.resolve(task.getResult());
} else {
rejectPromiseWithExceptionMap(promise, task.getException());
}
});
}

@ReactMethod
public void setSessionTimeoutDuration(double milliseconds, Promise promise) {
module.setSessionTimeoutDuration((long) milliseconds).addOnCompleteListener(task -> {
Expand Down
20 changes: 0 additions & 20 deletions packages/analytics/e2e/analytics.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,6 @@ describe('analytics()', () => {
});
});

describe('setCurrentScreen()', () => {
it('screenName only', async () => {
await firebase.analytics().setCurrentScreen('invertase screen');
});

it('screenName with screenClassOverride', async () => {
await firebase.analytics().setCurrentScreen('invertase screen', 'invertase class override');
});
});

describe('setMinimumSessionDuration()', () => {
it('default duration', async () => {
await firebase.analytics().setMinimumSessionDuration();
});

it('custom duration', async () => {
await firebase.analytics().setMinimumSessionDuration(1337);
});
});

describe('setSessionTimeoutDuration()', () => {
it('default duration', async () => {
await firebase.analytics().setSessionTimeoutDuration();
Expand Down
10 changes: 0 additions & 10 deletions packages/analytics/ios/RNFBAnalytics/RNFBAnalyticsModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,6 @@ - (dispatch_queue_t)methodQueue {
return resolve([NSNull null]);
}

RCT_EXPORT_METHOD(setMinimumSessionDuration:
(double) milliseconds
resolver:
(RCTPromiseResolveBlock) resolve
rejecter:
(RCTPromiseRejectBlock) reject) {
// Do nothing - this only exists in android
return resolve([NSNull null]);
}

RCT_EXPORT_METHOD(setSessionTimeoutDuration:
(double) milliseconds
resolver:
Expand Down
33 changes: 0 additions & 33 deletions packages/analytics/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,39 +663,6 @@ export namespace FirebaseAnalyticsTypes {
*/
setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;

/**
* Sets the current screen name.
*
* #### Example
*
* ```js
* await firebase.analytics().setCurrentScreen('ProductScreen', 'ProductScreen');
* ```
*
* > Whilst screenClassOverride is optional, it is recommended it is
* always sent as your current class name. For example on Android it will always
* show as 'MainActivity' if you do not specify it.
*
* @param screenName A screen name, e.g. Product.
* @param screenClassOverride On Android, React Native runs in a single activity called
* 'MainActivity'. Setting this parameter overrides the default name shown on logs.
* @deprecated
*/
setCurrentScreen(screenName: string, screenClassOverride?: string): Promise<void>;
/**
* Sets the minimum engagement time required before starting a session.
*
* #### Example
*
* ```js
* // 20 seconds
* await firebase.analytics().setMinimumSessionDuration(20000);
* ```
*
* @param milliseconds The default value is 10000 (10 seconds).
*/
setMinimumSessionDuration(milliseconds?: number): Promise<void>;

/**
* Sets the duration of inactivity that terminates the current session.
*
Expand Down
30 changes: 13 additions & 17 deletions packages/analytics/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,20 @@ import version from './version';
import * as structs from './structs';

const ReservedEventNames = [
'ad_reward',
'app_background',
'app_clear_data',
'app_uninstall',
'app_exception',
'app_remove',
'app_store_refund',
'app_store_subscription_cancel',
'app_store_subscription_convert',
'app_store_subscription_renew',
'app_update',
'app_upgrade',
'dynamic_link_app_open',
'dynamic_link_app_update',
'dynamic_link_first_open',
'error',
'first_open',
'in_app_purchase',
Expand All @@ -49,6 +60,7 @@ const ReservedEventNames = [
'notification_receive',
'os_update',
'session_start',
'session_start_with_rollout',
'user_engagement',
];

Expand Down Expand Up @@ -113,22 +125,6 @@ class FirebaseAnalyticsModule extends FirebaseModule {
});
}

setMinimumSessionDuration(milliseconds = 10000) {
if (!isNumber(milliseconds)) {
throw new Error(
"firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a number value.",
);
}

if (milliseconds < 0) {
throw new Error(
"firebase.analytics().setMinimumSessionDuration(*) 'milliseconds' expected a positive number value.",
);
}

return this.native.setMinimumSessionDuration(milliseconds);
}

setSessionTimeoutDuration(milliseconds = 1800000) {
if (!isNumber(milliseconds)) {
throw new Error(
Expand Down
2 changes: 0 additions & 2 deletions packages/analytics/type-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ console.log(firebase.analytics().setAnalyticsCollectionEnabled);
console.log(firebase.analytics().logSelectPromotion);
console.log(firebase.analytics().logScreenView);
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);
Expand Down Expand Up @@ -110,7 +109,6 @@ console.log(analytics().setAnalyticsCollectionEnabled);
console.log(analytics().logSelectPromotion);
console.log(analytics().logScreenView);
console.log(analytics().logViewPromotion);
console.log(analytics().setMinimumSessionDuration);
console.log(analytics().setSessionTimeoutDuration);
console.log(analytics().setUserId);
console.log(analytics().setUserProperties);
Expand Down

0 comments on commit a675cd7

Please sign in to comment.