Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased (develop)

- fixed: Fixed broken `logEvent` tracking calls by adding the needed `dispatch`.
- removed: Remove change quote tracking.

## 4.38.0 (staging)
Expand Down
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ export default [
'src/components/themed/TransactionListTop.tsx',
'src/components/themed/VectorIcon.tsx',
'src/components/themed/WalletList.tsx',
'src/components/themed/WalletListCreateRow.tsx',

'src/components/themed/WalletListErrorRow.tsx',
'src/components/themed/WalletListHeader.tsx',
Expand Down
6 changes: 3 additions & 3 deletions src/actions/AccountReferralActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ function createAccountReferral(): ThunkAction<Promise<void>> {
referral.accountAppleAdsAttribution = isFirstOpenEmpty
? await getAppleAdsAttribution()
: firstOpenAttrib
logEvent('AAA_Success')
dispatch(logEvent('AAA_Success'))
} else {
referral.accountAppleAdsAttribution = await getAppleAdsAttribution()
if (referral.accountAppleAdsAttribution == null) {
logEvent('AAA_Failed')
dispatch(logEvent('AAA_Failed'))
} else {
logEvent('AAA_Success')
dispatch(logEvent('AAA_Success'))
}
}
} catch (e) {}
Expand Down
6 changes: 4 additions & 2 deletions src/components/scenes/RampCreateScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {

// Log the quote event only when the scene is focused
useFocusEffect(() => {
logEvent(direction === 'buy' ? 'Buy_Quote' : 'Sell_Quote')
dispatch(logEvent(direction === 'buy' ? 'Buy_Quote' : 'Sell_Quote'))
})

//
Expand Down Expand Up @@ -619,7 +619,9 @@ export const RampCreateScene: React.FC<Props> = (props: Props) => {
}
}

logEvent(direction === 'buy' ? 'Buy_Quote_Next' : 'Sell_Quote_Next')
dispatch(
logEvent(direction === 'buy' ? 'Buy_Quote_Next' : 'Sell_Quote_Next')
)

navigation.navigate('rampSelectOption', {
rampQuoteRequest
Expand Down
16 changes: 9 additions & 7 deletions src/components/themed/WalletListCreateRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface WalletListCreateRowProps {

export const WalletListCreateRowComponent = (
props: WalletListCreateRowProps
) => {
): React.ReactElement => {
const {
createItem,
createWalletId,
Expand Down Expand Up @@ -88,7 +88,7 @@ export const WalletListCreateRowComponent = (
if (walletType != null) {
await dispatch(createAndSelectWallet(pluginId, keyOptions))
.then(handleRes)
.catch(err => {
.catch((err: unknown) => {
showError(err)
})
.finally(() => (pressMutexRef.current = false))
Expand All @@ -104,13 +104,15 @@ export const WalletListCreateRowComponent = (
})
)
.then(handleRes)
.catch(err => {
.catch((err: unknown) => {
showError(err)
})
.finally(() => (pressMutexRef.current = false))
} else {
await Airship.show(bridge => {
const renderRow = (wallet: EdgeCurrencyWallet) => (
const renderRow = (
wallet: EdgeCurrencyWallet
): React.ReactElement => (
<WalletListCurrencyRow
tokenId={null}
wallet={wallet}
Expand Down Expand Up @@ -149,7 +151,7 @@ export const WalletListCreateRowComponent = (
/>
)
})
.catch(err => {
.catch((err: unknown) => {
showError(err)
})
.finally(() => (pressMutexRef.current = false))
Expand Down Expand Up @@ -238,12 +240,12 @@ function createAndSelectToken({
)

await wallet.changeEnabledTokenIds([...wallet.enabledTokenIds, tokenId])
if (trackingEventSuccess != null) logEvent(trackingEventSuccess)
if (trackingEventSuccess != null) dispatch(logEvent(trackingEventSuccess))
return wallet
} catch (error: any) {
showError(error)
if (trackingEventFailed != null)
logEvent(trackingEventFailed, { error: String(error) })
dispatch(logEvent(trackingEventFailed, { error: String(error) }))
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions src/plugins/gui/amountQuotePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from '../../util/CurrencyInfoHelpers'
import { getHistoricalFiatRate } from '../../util/exchangeRates'
import { infoServerData } from '../../util/network'
import { logEvent } from '../../util/tracking'
import {
DECIMAL_PRECISION,
fuzzyTimeout,
Expand Down Expand Up @@ -134,7 +133,14 @@ async function getInitialFiatValue(
export const amountQuoteFiatPlugin: FiatPluginFactory = async (
params: FiatPluginFactoryArgs
) => {
const { account, guiPlugin, longPress = false, pluginUtils, showUi } = params
const {
account,
guiPlugin,
longPress = false,
pluginUtils,
showUi,
onLogEvent
} = params
const { pluginId } = guiPlugin
const isLightAccount = account.username == null

Expand Down Expand Up @@ -352,7 +358,7 @@ export const amountQuoteFiatPlugin: FiatPluginFactory = async (
const isBuy = direction === 'buy'
const disableInput = requireCrypto ? 1 : requireFiat ? 2 : undefined

logEvent(isBuy ? 'Buy_Quote' : 'Sell_Quote')
onLogEvent(isBuy ? 'Buy_Quote' : 'Sell_Quote')

const startingFiatAmount = isLightAccount
? DEFAULT_FIAT_AMOUNT_LIGHT_ACCOUNT
Expand Down Expand Up @@ -776,7 +782,7 @@ export const amountQuoteFiatPlugin: FiatPluginFactory = async (
}
}

logEvent(isBuy ? 'Buy_Quote_Next' : 'Sell_Quote_Next')
onLogEvent(isBuy ? 'Buy_Quote_Next' : 'Sell_Quote_Next')
await bestQuote.approveQuote({ showUi, coreWallet })
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/gui/fiatPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ export const executePlugin = async (params: {
longPress,
guiPlugin,
pluginUtils,
showUi
showUi,
onLogEvent
})
if (plugin == null) {
throw new Error(`pluginId ${pluginId} not found`)
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/gui/fiatPluginTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import type {
import type {
BuyConversionValues,
SellConversionValues,
TrackingEventName
TrackingEventName,
TrackingValues
} from '../../util/tracking'
import type { FiatPluginAddressFormParams } from './scenes/AddressFormScene'
import type { FiatPluginOpenWebViewParams } from './scenes/FiatPluginWebView'
Expand Down Expand Up @@ -220,6 +221,7 @@ export interface FiatPluginFactoryArgs {
guiPlugin: GuiPlugin
showUi: FiatPluginUi
pluginUtils: FiatPluginUtils
onLogEvent: (event: TrackingEventName, values?: TrackingValues) => void
}

export interface FiatPluginRegionCode {
Expand Down
8 changes: 8 additions & 0 deletions src/types/posthog.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { PostHog } from 'posthog-react-native'

declare global {
// Expose the analytics instance on the global scope for app-wide use
// The PostHog instance is initialized at runtime
// See src/util/tracking.ts for initialization
var posthog: PostHog | undefined
}
3 changes: 0 additions & 3 deletions src/util/tracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ if (ENV.POSTHOG_INIT != null) {

posthogAsync
.then(client => {
// @ts-expect-error Attach PostHog instance to global for analytics access
global.posthog = client
})
.catch((e: unknown) => {
Expand Down Expand Up @@ -408,10 +407,8 @@ async function logToPosthog(
event: TrackingEventName,
values: TrackingValues
): Promise<void> {
// @ts-expect-error PostHog is attached to global at runtime
if (global.posthog == null) return

// @ts-expect-error PostHog is attached to global at runtime
global.posthog.capture(event, values)
}

Expand Down
Loading