diff --git a/app/actions/actionsTypes.js b/app/actions/actionsTypes.js
index bdf124ff8..4e5f9443e 100644
--- a/app/actions/actionsTypes.js
+++ b/app/actions/actionsTypes.js
@@ -53,6 +53,7 @@ export const SNIPPETED_MESSAGES = createRequestTypes('SNIPPETED_MESSAGES', ['OPE
export const DEEP_LINKING = createRequestTypes('DEEP_LINKING', ['OPEN']);
export const SORT_PREFERENCES = createRequestTypes('SORT_PREFERENCES', ['SET_ALL', 'SET']);
export const TOGGLE_CRASH_REPORT = 'TOGGLE_CRASH_REPORT';
+export const TOGGLE_ANALYTICS_EVENTS = 'TOGGLE_ANALYTICS_EVENTS';
export const SET_CUSTOM_EMOJIS = 'SET_CUSTOM_EMOJIS';
export const SET_ACTIVE_USERS = 'SET_ACTIVE_USERS';
export const USERS_TYPING = createRequestTypes('USERS_TYPING', ['ADD', 'REMOVE', 'CLEAR']);
diff --git a/app/actions/crashReport.js b/app/actions/crashReport.js
index 964f57cd2..8577b33e7 100644
--- a/app/actions/crashReport.js
+++ b/app/actions/crashReport.js
@@ -6,3 +6,10 @@ export function toggleCrashReport(value) {
payload: value
};
}
+
+export function toggleAnalyticsEvents(value) {
+ return {
+ type: types.TOGGLE_ANALYTICS_EVENTS,
+ payload: value
+ };
+}
diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js
index edefca34c..18f5f22d4 100644
--- a/app/i18n/locales/en.js
+++ b/app/i18n/locales/en.js
@@ -608,7 +608,7 @@ export default {
You_will_not_be_able_to_recover_this_message: 'You will not be able to recover this message!',
You_will_unset_a_certificate_for_this_server: 'You will unset a certificate for this server',
Change_Language: 'Change Language',
- Crash_report_disclaimer: 'We never track the content of your chats. The crash report only contains relevant information for us in order to identify problems and fix it.',
+ Crash_report_disclaimer: 'We never track the content of your chats. The crash report and analytics events only contains relevant information for us in order to identify and fix issues.',
Type_message: 'Type message',
Room_search: 'Rooms search',
Room_selection: 'Room selection 1...9',
@@ -658,5 +658,6 @@ export default {
Logout_from_other_logged_in_locations: 'Logout from other logged in locations',
You_will_be_logged_out_from_other_locations: 'You\'ll be logged out from other locations.',
Logged_out_of_other_clients_successfully: 'Logged out of other clients successfully',
- Logout_failed: 'Logout failed!'
+ Logout_failed: 'Logout failed!',
+ Log_analytics_events: 'Log analytics events'
};
diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js
index b804c2ba0..9b1c7d861 100644
--- a/app/i18n/locales/pt-BR.js
+++ b/app/i18n/locales/pt-BR.js
@@ -552,7 +552,7 @@ export default {
Write_External_Permission_Message: 'Rocket.Chat precisa de acesso à sua galeria para salvar imagens',
Write_External_Permission: 'Acesso à Galeria',
Yes: 'Sim',
- Crash_report_disclaimer: 'Nós não rastreamos o conteúdo das suas conversas. O relatório de erros apenas contém informações relevantes para identificarmos problemas e corrigí-los.',
+ Crash_report_disclaimer: 'Nós não rastreamos o conteúdo das suas conversas. O relatório de erros e os eventos do analytics apenas contém informações relevantes para identificarmos problemas e corrigí-los.',
Type_message: 'Digitar mensagem',
Room_search: 'Busca de sala',
Room_selection: 'Selecionar sala 1...9',
@@ -601,5 +601,6 @@ export default {
Logout_from_other_logged_in_locations: 'Sair de outros locais logados',
You_will_be_logged_out_from_other_locations: 'Você perderá a sessão de outros clientes',
Logged_out_of_other_clients_successfully: 'Desconectado de outros clientes com sucesso',
- Logout_failed: 'Falha ao desconectar!'
+ Logout_failed: 'Falha ao desconectar!',
+ Log_analytics_events: 'Logar eventos no analytics'
};
diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js
index fdcdd120a..483f183bd 100644
--- a/app/lib/rocketchat.js
+++ b/app/lib/rocketchat.js
@@ -62,6 +62,7 @@ const CURRENT_SERVER = 'currentServer';
const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY';
export const THEME_PREFERENCES_KEY = 'RC_THEME_PREFERENCES_KEY';
export const CRASH_REPORT_KEY = 'RC_CRASH_REPORT_KEY';
+export const ANALYTICS_EVENTS_KEY = 'RC_ANALYTICS_EVENTS_KEY';
const returnAnArray = obj => obj || [];
const MIN_ROCKETCHAT_VERSION = '0.70.0';
@@ -1061,6 +1062,13 @@ const RocketChat = {
}
return JSON.parse(allowCrashReport);
},
+ async getAllowAnalyticsEvents() {
+ const allowAnalyticsEvents = await AsyncStorage.getItem(ANALYTICS_EVENTS_KEY);
+ if (allowAnalyticsEvents === null) {
+ return true;
+ }
+ return JSON.parse(allowAnalyticsEvents);
+ },
async getSortPreferences() {
const prefs = await UserPreferences.getMapAsync(SORT_PREFS_KEY);
return prefs;
diff --git a/app/reducers/crashReport.js b/app/reducers/crashReport.js
index e59848b54..8465897e3 100644
--- a/app/reducers/crashReport.js
+++ b/app/reducers/crashReport.js
@@ -1,7 +1,8 @@
-import { TOGGLE_CRASH_REPORT } from '../actions/actionsTypes';
+import { TOGGLE_CRASH_REPORT, TOGGLE_ANALYTICS_EVENTS } from '../actions/actionsTypes';
const initialState = {
- allowCrashReport: false
+ allowCrashReport: false,
+ allowAnalyticsEvents: false
};
@@ -9,8 +10,15 @@ export default (state = initialState, action) => {
switch (action.type) {
case TOGGLE_CRASH_REPORT:
return {
+ ...state,
allowCrashReport: action.payload
};
+
+ case TOGGLE_ANALYTICS_EVENTS:
+ return {
+ ...state,
+ allowAnalyticsEvents: action.payload
+ };
default:
return state;
}
diff --git a/app/sagas/init.js b/app/sagas/init.js
index 86f4dd26c..a39183348 100644
--- a/app/sagas/init.js
+++ b/app/sagas/init.js
@@ -4,7 +4,7 @@ import RNBootSplash from 'react-native-bootsplash';
import UserPreferences from '../lib/userPreferences';
import { selectServerRequest } from '../actions/server';
import { setAllPreferences } from '../actions/sortPreferences';
-import { toggleCrashReport } from '../actions/crashReport';
+import { toggleCrashReport, toggleAnalyticsEvents } from '../actions/crashReport';
import { APP } from '../actions/actionsTypes';
import RocketChat from '../lib/rocketchat';
import log from '../utils/log';
@@ -18,6 +18,9 @@ export const initLocalSettings = function* initLocalSettings() {
const allowCrashReport = yield RocketChat.getAllowCrashReport();
yield put(toggleCrashReport(allowCrashReport));
+
+ const allowAnalyticsEvents = yield RocketChat.getAllowAnalyticsEvents();
+ yield put(toggleAnalyticsEvents(allowAnalyticsEvents));
};
const restore = function* restore() {
diff --git a/app/utils/log/events.js b/app/utils/log/events.js
index e65b3ca66..89b77848e 100644
--- a/app/utils/log/events.js
+++ b/app/utils/log/events.js
@@ -139,6 +139,7 @@ export default {
SE_COPY_APP_VERSION: 'se_copy_app_version',
SE_COPY_SERVER_VERSION: 'se_copy_server_version',
SE_TOGGLE_CRASH_REPORT: 'se_toggle_crash_report',
+ SE_TOGGLE_ANALYTICS_EVENTS: 'se_toggle_analytics_events',
SE_CLEAR_LOCAL_SERVER_CACHE: 'se_clear_local_server_cache',
SE_LOG_OUT: 'se_log_out',
diff --git a/app/views/SettingsView/index.js b/app/views/SettingsView/index.js
index 4d94bbe17..2b9a9d15e 100644
--- a/app/views/SettingsView/index.js
+++ b/app/views/SettingsView/index.js
@@ -10,7 +10,7 @@ import CookieManager from '@react-native-community/cookies';
import { logout as logoutAction } from '../../actions/login';
import { selectServerRequest as selectServerRequestAction } from '../../actions/server';
-import { toggleCrashReport as toggleCrashReportAction } from '../../actions/crashReport';
+import { toggleCrashReport as toggleCrashReportAction, toggleAnalyticsEvents as toggleAnalyticsEventsAction } from '../../actions/crashReport';
import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors';
import { DrawerButton, CloseModalButton } from '../../containers/HeaderButton';
import StatusBar from '../../containers/StatusBar';
@@ -19,7 +19,7 @@ import ItemInfo from '../../containers/ItemInfo';
import { DisclosureImage } from '../../containers/DisclosureIndicator';
import Separator from '../../containers/Separator';
import I18n from '../../i18n';
-import RocketChat, { CRASH_REPORT_KEY } from '../../lib/rocketchat';
+import RocketChat, { CRASH_REPORT_KEY, ANALYTICS_EVENTS_KEY } from '../../lib/rocketchat';
import {
getReadableVersion, getDeviceModel, isAndroid
} from '../../utils/deviceInfo';
@@ -74,7 +74,9 @@ class SettingsView extends React.Component {
navigation: PropTypes.object,
server: PropTypes.object,
allowCrashReport: PropTypes.bool,
+ allowAnalyticsEvents: PropTypes.bool,
toggleCrashReport: PropTypes.func,
+ toggleAnalyticsEvents: PropTypes.func,
theme: PropTypes.string,
isMasterDetail: PropTypes.bool,
logout: PropTypes.func.isRequired,
@@ -148,7 +150,6 @@ class SettingsView extends React.Component {
toggleCrashReport(value);
if (!isFDroidBuild) {
loggerConfig.autoNotify = value;
- analytics().setAnalyticsCollectionEnabled(value);
if (value) {
loggerConfig.clearBeforeSendCallbacks();
} else {
@@ -157,6 +158,14 @@ class SettingsView extends React.Component {
}
}
+ toggleAnalyticsEvents = (value) => {
+ logEvent(events.SE_TOGGLE_ANALYTICS_EVENTS);
+ const { toggleAnalyticsEvents } = this.props;
+ AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value));
+ toggleAnalyticsEvents(value);
+ analytics().setAnalyticsCollectionEnabled(value);
+ }
+
navigateToScreen = (screen) => {
logEvent(events[`SE_GO_${ screen.replace('View', '').toUpperCase() }`]);
const { navigation } = this.props;
@@ -230,6 +239,17 @@ class SettingsView extends React.Component {
);
}
+ renderAnalyticsEventsSwitch = () => {
+ const { allowAnalyticsEvents } = this.props;
+ return (
+
+ );
+ }
+
render() {
const { server, isMasterDetail, theme } = this.props;
return (
@@ -356,6 +376,13 @@ class SettingsView extends React.Component {
{!isFDroidBuild ? (
<>
+ this.renderAnalyticsEventsSwitch()}
+ theme={theme}
+ />
+
+
>
) : null}
-
({
server: state.server,
user: getUserSelector(state),
allowCrashReport: state.crashReport.allowCrashReport,
+ allowAnalyticsEvents: state.crashReport.allowAnalyticsEvents,
isMasterDetail: state.app.isMasterDetail
});
@@ -406,6 +434,7 @@ const mapDispatchToProps = dispatch => ({
logout: () => dispatch(logoutAction()),
selectServerRequest: params => dispatch(selectServerRequestAction(params)),
toggleCrashReport: params => dispatch(toggleCrashReportAction(params)),
+ toggleAnalyticsEvents: params => dispatch(toggleAnalyticsEventsAction(params)),
appStart: params => dispatch(appStartAction(params))
});