Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/containers/LoginServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import OrSeparator from './OrSeparator';
import Touch from '../utils/touch';
import I18n from '../i18n';
import random from '../utils/random';
import { trackUserEvent } from '../utils/log';
import {
LOGIN_WITH_GITHUB, LOGIN_WITH_GITLAB, LOGIN_WITH_GOOGLE, LOGIN_WITH_FACEBOOK, LOGIN_WITH_METEOR, LOGIN_WITH_LINKEDIN, LOGIN_WITH_TWITTER
} from '../utils/trackableEvents';

const SERVICE_HEIGHT = 58;
const SERVICES_COLLAPSED_HEIGHT = 174;
Expand Down Expand Up @@ -83,6 +87,7 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&scope=${ scope }&state=${ state }&display=touch`;
this.openOAuth({ url: `${ endpoint }${ params }` });
trackUserEvent({ eventName: LOGIN_WITH_FACEBOOK });
}

onPressGithub = () => {
Expand All @@ -94,6 +99,7 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&scope=${ scope }&state=${ state }`;
this.openOAuth({ url: `${ endpoint }${ encodeURIComponent(params) }` });
trackUserEvent({ eventName: LOGIN_WITH_GITHUB });
}

onPressGitlab = () => {
Expand All @@ -106,6 +112,7 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&scope=${ scope }&state=${ state }&response_type=code`;
this.openOAuth({ url: `${ endpoint }${ params }` });
trackUserEvent({ eventName: LOGIN_WITH_GITLAB });
}

onPressGoogle = () => {
Expand All @@ -117,6 +124,7 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&scope=${ scope }&state=${ state }&response_type=code`;
this.openOAuth({ url: `${ endpoint }${ params }` });
trackUserEvent({ eventName: LOGIN_WITH_GOOGLE });
}

onPressLinkedin = () => {
Expand All @@ -128,6 +136,7 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&scope=${ scope }&state=${ state }&response_type=code`;
this.openOAuth({ url: `${ endpoint }${ params }` });
trackUserEvent({ eventName: LOGIN_WITH_LINKEDIN });
}

onPressMeteor = () => {
Expand All @@ -138,13 +147,15 @@ class LoginServices extends React.PureComponent {
const state = this.getOAuthState();
const params = `?client_id=${ clientId }&redirect_uri=${ redirect_uri }&state=${ state }&response_type=code`;
this.openOAuth({ url: `${ endpoint }${ params }` });
trackUserEvent({ eventName: LOGIN_WITH_METEOR });
}

onPressTwitter = () => {
const { server } = this.props;
const state = this.getOAuthState();
const url = `${ server }/_oauth/twitter/?requestTokenAndRedirect=true&state=${ state }`;
this.openOAuth({ url });
trackUserEvent({ eventName: LOGIN_WITH_TWITTER });
}

onPressWordpress = () => {
Comment thread
youssef-md marked this conversation as resolved.
Expand Down
4 changes: 4 additions & 0 deletions app/utils/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const { leaveBreadcrumb } = bugsnag;

let metadata = {};

export const trackUserEvent = ({ eventName, payload }) => {
Comment thread
youssef-md marked this conversation as resolved.
Outdated
analytics().logEvent(eventName, { ...payload });
};

export const logServerVersion = (serverVersion) => {
metadata = {
serverVersion
Expand Down
15 changes: 15 additions & 0 deletions app/utils/trackableEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const JOIN_A_WORKSPACE = 'join_a_workspace';
Comment thread
youssef-md marked this conversation as resolved.
Outdated
Comment thread
youssef-md marked this conversation as resolved.
Outdated
Comment thread
diegolmello marked this conversation as resolved.
Outdated
export const CREATE_NEW_WORKSPACE = 'create_new_workspace';
export const CONNECT_TO_WORKSPACE = 'connect_to_workspace';
export const JOIN_OPEN_WORKSPACE = 'join_open_workspace';
export const DEFAULT_LOGIN = 'default_login';
export const DEFAULT_SIGN_UP = 'default_sign_up';
export const FORGOT_PASSWORD = 'forgot_password';
export const LOGIN_WITH_FACEBOOK = 'login_with_facebook';
export const LOGIN_WITH_GITHUB = 'login_with_github';
export const LOGIN_WITH_GITLAB = 'login_with_gitlab';
export const LOGIN_WITH_LINKEDIN = 'login_with_linkedin';
export const LOGIN_WITH_GOOGLE = 'login_with_google';
export const LOGIN_WITH_METEOR = 'login_with_meteor';
export const LOGIN_WITH_TWITTER = 'login_with_twitter';
export const LOGIN_WITH_WORDPRESS = 'login_with_wordpress';
6 changes: 4 additions & 2 deletions app/views/LoginView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { connect } from 'react-redux';
import equal from 'deep-equal';

import { analytics } from '../utils/log';
import { trackUserEvent } from '../utils/log';
import sharedStyles from './Styles';
import Button from '../containers/Button';
import I18n from '../i18n';
Expand All @@ -18,6 +18,7 @@ import FormContainer, { FormContainerInner } from '../containers/FormContainer';
import TextInput from '../containers/TextInput';
import { loginRequest as loginRequestAction } from '../actions/login';
import LoginServices from '../containers/LoginServices';
import { DEFAULT_LOGIN, FORGOT_PASSWORD } from '../utils/trackableEvents';

const styles = StyleSheet.create({
registerDisabled: {
Expand Down Expand Up @@ -104,6 +105,7 @@ class LoginView extends React.Component {
forgotPassword = () => {
const { navigation, Site_Name } = this.props;
navigation.navigate('ForgotPasswordView', { title: Site_Name });
trackUserEvent({ eventName: FORGOT_PASSWORD });
}

valid = () => {
Expand All @@ -120,7 +122,7 @@ class LoginView extends React.Component {
const { loginRequest } = this.props;
Keyboard.dismiss();
loginRequest({ user, password });
analytics().logEvent('login');
trackUserEvent({ eventName: DEFAULT_LOGIN });
}

renderUserForm = () => {
Expand Down
6 changes: 5 additions & 1 deletion app/views/NewServerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import FormContainer, { FormContainerInner } from '../containers/FormContainer';
import I18n from '../i18n';
import { isIOS } from '../utils/deviceInfo';
import { themes } from '../constants/colors';
import log from '../utils/log';
import log, { trackUserEvent } from '../utils/log';
import { animateNextTransition } from '../utils/layoutAnimation';
import { withTheme } from '../theme';
import { setBasicAuth, BASIC_AUTH_KEY } from '../utils/fetch';
import { themedHeader } from '../utils/navigation';
import { CloseModalButton } from '../containers/HeaderButton';
import { CONNECT_TO_WORKSPACE, JOIN_OPEN_WORKSPACE } from '../utils/trackableEvents';

const styles = StyleSheet.create({
title: {
Expand Down Expand Up @@ -175,12 +176,15 @@ class NewServerView extends React.Component {
await this.basicAuth(server, text);
connectServer(server, cert);
}

trackUserEvent({ eventName: CONNECT_TO_WORKSPACE });
}

connectOpen = () => {
this.setState({ connectingOpen: true });
const { connectServer } = this.props;
connectServer('https://open.rocket.chat');
trackUserEvent({ eventName: JOIN_OPEN_WORKSPACE });
}

basicAuth = async(server, text) => {
Expand Down
4 changes: 4 additions & 0 deletions app/views/OnboardingView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { isTablet } from '../../utils/deviceInfo';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import FormContainer, { FormContainerInner } from '../../containers/FormContainer';
import { trackUserEvent } from '../../utils/log';
import { JOIN_A_WORKSPACE, CREATE_NEW_WORKSPACE } from '../../utils/trackableEvents';

class OnboardingView extends React.Component {
static navigationOptions = () => ({
Expand Down Expand Up @@ -55,11 +57,13 @@ class OnboardingView extends React.Component {
connectServer = () => {
const { navigation } = this.props;
navigation.navigate('NewServerView');
trackUserEvent({ eventName: JOIN_A_WORKSPACE });
}

createWorkspace = async() => {
try {
await Linking.openURL('https://cloud.rocket.chat/trial');
trackUserEvent({ eventName: CREATE_NEW_WORKSPACE });
} catch {
// do nothing
}
Expand Down
4 changes: 3 additions & 1 deletion app/views/RegisterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { connect } from 'react-redux';
import RNPickerSelect from 'react-native-picker-select';

import log from '../utils/log';
import log, { trackUserEvent } from '../utils/log';
import sharedStyles from './Styles';
import Button from '../containers/Button';
import I18n from '../i18n';
Expand All @@ -23,6 +23,7 @@ import { loginRequest as loginRequestAction } from '../actions/login';
import openLink from '../utils/openLink';
import LoginServices from '../containers/LoginServices';
import { getShowLoginButton } from '../selectors/login';
import { DEFAULT_SIGN_UP } from '../utils/trackableEvents';

const styles = StyleSheet.create({
title: {
Expand Down Expand Up @@ -156,6 +157,7 @@ class RegisterView extends React.Component {
showErrorAlert(e.data.error, I18n.t('Oops'));
}
this.setState({ saving: false });
trackUserEvent({ eventName: DEFAULT_SIGN_UP });
}

openContract = (route) => {
Expand Down