Skip to content

Commit

Permalink
Merge branch 'master' into AUT-15088-business-accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerGery committed Jan 15, 2024
2 parents dd22a5a + 4945961 commit a382c34
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const ServiceCard = ({ service, withBorder }) => {
)
: getDescription(isFutureRide)}

{service.isPriceEstimated ? (
{service.isPriceEstimated && showPrice ? (
<EstimatedText>
{i18n.t('rideDetails.estimatedFare')}
</EstimatedText>
Expand All @@ -181,7 +181,7 @@ const ServiceCard = ({ service, withBorder }) => {
{!isFutureRide && (
<Row>
{getDescription()}
{service.isPriceEstimated ? (
{service.isPriceEstimated && showPrice ? (
<Capacity>
<AvailableSeats>
{service.availableSeats}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EmptyState from '../../../../../Components/EmptyState';
import { getCouponText } from '../../../../../context/newRideContext/utils';
import { RidePageContext } from '../../../../../context/newRideContext';
import { UserContext } from '../../../../../context/user';
import SettingsContext from '../../../../../context/settings';
import ServiceCard from './ServiceCard';
import { ServiceOptionsContainer } from './styles';
import { serviceCardSkeleton } from './ServiceCard/skeleton';
Expand All @@ -15,11 +16,16 @@ const SUCCESS_COLOR = '#25B861';

const ServiceOptions = () => {
const { serviceEstimations, stopRequestInterval } = useContext(RidePageContext);
const { showPrice, loadShowPrice } = SettingsContext.useContainer();

const { coupon } = useContext(UserContext);
const isDebuggingEnabled = (typeof atob !== 'undefined');
const { setTopBarProps } = useContext(BottomSheetContext);

useEffect(() => () => stopRequestInterval(), []);
useEffect(() => {
loadShowPrice();
}, []);

const clearTopBar = () => {
setTopBarProps(INITIAL_TOP_BAR_PROPS);
Expand All @@ -44,7 +50,8 @@ const ServiceOptions = () => {
useEffect(() => {
if (coupon && coupon.status !== 'error') {
setCouponTopBar();
} else if ((serviceEstimations || []).some(estimation => estimation.isPriceEstimated)) {
} else if (showPrice
&& (serviceEstimations || []).some(estimation => estimation.isPriceEstimated)) {
setEstimateFareTopBar();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { PaymentMethodInterface } from '../../context/payments/interface';
import * as navigationService from '../../services/navigation';
import PriceBreakdown from '../../Components/PriceBreakdown';
import SettingsContext from '../../context/settings';

type RidePriceBreakdownParams = {
rideId: string,
Expand All @@ -38,6 +39,8 @@ const RidePriceBreakDown = () => {
getRidePriceCalculation,
getRideFromApi,
} = useContext(RidePageContext);
const { showPrice, loadShowPrice } = SettingsContext.useContainer();


const updatePriceCalculation = async () => {
try {
Expand Down Expand Up @@ -74,6 +77,9 @@ const RidePriceBreakDown = () => {
useEffect(() => {
updateRideFromApi();
}, []);
useEffect(() => {
loadShowPrice();
}, []);

return (
<PageContainer>
Expand All @@ -100,7 +106,8 @@ const RidePriceBreakDown = () => {
</CreditCardRowContainer>
{
(priceCalculation && isPriceEstimated(priceCalculation.calculationBasis)
&& !RIDE_FINAL_STATES.includes(localRide?.state || ''))
&& !RIDE_FINAL_STATES.includes(localRide?.state || '')
&& showPrice)
? (
<EstimationContainer>
<EstimationText>{i18n.t('ridePriceBreakdown.estimatedText')}</EstimationText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ const FareBreakdownPopup = ({
<InnerContainer>
<CloseButton onPress={onClose} containerStyles={{ alignSelf: 'flex-end' }} />
<ServiceCard service={service} />
{service.isPriceEstimated && (
{service.isPriceEstimated && showPrice && (
<EstimatedTextContainer>
<EstimatedText>
{`${i18n.t('ridePriceBreakdown.estimatedText')}`}
</EstimatedText>
</EstimatedTextContainer>
)}
</InnerContainer>
{service.isPriceEstimated && <Line />}
{service.isPriceEstimated && showPrice && <Line />}
{showPrice
&& (
<PriceBreakdown
Expand Down
38 changes: 37 additions & 1 deletion examples/client/Locomotion/src/services/Mixpanel.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,62 @@
/* eslint-disable class-methods-use-this */
import Config from 'react-native-config';
import { Mixpanel } from 'mixpanel-react-native';
import { getUniqueId } from 'react-native-device-info';
import { getDeviceId } from './device';

const { MIXPANEL_EVENTS_NUMBER } = Config;

export const getElementName = props => props.testID || props.id;

const getRandomNumberByUuid = (uuid) => {
try {
const decimalValue = parseInt(uuid.substr(0, 8), 16);
const mappedNumber = (decimalValue % 100) + 1;
return mappedNumber;
} catch (err) {
console.log('getRandomNumberByUuid error', err);
return 0;
}
};

const shouldTrackEvents = () => {
if (!MIXPANEL_EVENTS_NUMBER) {
return true;
}
const deviceUuid = getUniqueId();
const number = getRandomNumberByUuid(deviceUuid);
return number <= parseInt(MIXPANEL_EVENTS_NUMBER, 10);
};

class MixpanelService {
constructor() {
this.isInit = false;
this.mixpanel = {};
this.shouldTrackEvents = shouldTrackEvents();
this.init();
}

init = async () => {
if (!this.shouldTrackEvents) {
return;
}

if (!this.isInit && Config.MIXPANEL_TOKEN) {
const trackAutomaticEvents = true;
this.mixpanel = new Mixpanel(Config.MIXPANEL_TOKEN, trackAutomaticEvents);

this.mixpanel.init();
this.mixpanel.setLoggingEnabled(true);
this.isInit = true;
}
};

setUser = async (user) => {
if (!this.isInit) return;

const uniqueId = (user && user.id) || getDeviceId();
this.user = user;
if (user && user.id) {
if (user && user.id && this.isInit) {
this.mixpanel.optInTracking();
this.mixpanel.identify(uniqueId);
this.mixpanel.getPeople().set({
Expand All @@ -37,6 +68,7 @@ class MixpanelService {
};

trackWithProperties = (event, props) => {
if (!this.isInit) return;
if (this.isInit && this.mixpanel) {
this.mixpanel.track(event,
{
Expand Down Expand Up @@ -64,6 +96,7 @@ class MixpanelService {
};

trackElementClick = (props, properties = {}) => {
if (!this.isInit) return;
const elmName = getElementName(props);
const eventName = `${elmName}`;
if (elmName) {
Expand All @@ -72,15 +105,18 @@ class MixpanelService {
};

resetIdentifier = async () => {
if (!this.isInit) return;
await this.mixpanel.clearSuperProperties();
await this.mixpanel.reset();
};

registerSuperProperties = (properties) => {
if (!this.isInit) return;
this.mixpanel.registerSuperProperties(properties);
};

demoMode = (isDemoUser) => {
if (!this.isInit) return;
if (isDemoUser) {
this.mixpanel.optOutTracking();
} else {
Expand Down

0 comments on commit a382c34

Please sign in to comment.