Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post beta fixes #352

Merged
merged 2 commits into from
Oct 25, 2023
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
2 changes: 1 addition & 1 deletion src/components/AddressCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AddressCard = ({ style, addressHash, onSettingsPress }: AddressCardProps)

const [loading, setLoading] = useState(false)

const totalAddressBalance = BigInt(address?.balance ?? 0) + BigInt(address?.lockedBalance ?? 0)
const totalAddressBalance = BigInt(address?.balance ?? 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't believe we did not notice this mistake... User reported it at #353

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wth!

const { data: price } = useGetPriceQuery(currencies[currency].ticker, {
pollingInterval: 60000,
skip: totalAddressBalance === BigInt(0)
Expand Down
50 changes: 22 additions & 28 deletions src/contexts/AnalyticsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const AnalyticsSetup = ({ children }: { children: JSX.Element }) => {
const networkName = useAppSelector((s) => s.network.name)
const dispatch = useAppDispatch()

const canCaptureUserProperties = settingsLoadedFromStorage && analytics && !!analyticsId
const shouldOptOut = !settingsLoadedFromStorage || __DEV__
const canCaptureUserProperties = !shouldOptOut && analytics && !!analyticsId

useEffect(() => {
if (!settingsLoadedFromStorage || __DEV__) {
if (shouldOptOut) {
posthog?.optOut()
return
}
Expand All @@ -55,7 +56,7 @@ const AnalyticsSetup = ({ children }: { children: JSX.Element }) => {
const newAnalyticsId = nanoid()
dispatch(analyticsIdGenerated(newAnalyticsId))
}
}, [analytics, analyticsId, dispatch, posthog, settingsLoadedFromStorage])
}, [analytics, analyticsId, dispatch, posthog, shouldOptOut])

const captureUserProperties = useCallback(async () => {
if (!canCaptureUserProperties) return
Expand All @@ -74,34 +75,27 @@ const AnalyticsSetup = ({ children }: { children: JSX.Element }) => {

useEffect(() => {
if (canCaptureUserProperties) captureUserProperties()
})
}, [canCaptureUserProperties, captureUserProperties])

return children
}

const AnalyticsProvider = ({ children }: { children: JSX.Element }) => {
const analytics = useAppSelector((s) => s.settings.analytics)
const analyticsId = useAppSelector((s) => s.settings.analyticsId)
const settingsLoadedFromStorage = useAppSelector((s) => s.settings.loadedFromStorage)

return (
<PostHogProvider
apiKey={PUBLIC_POSTHOG_KEY}
options={{
host: PUBLIC_POSTHOG_HOST,
disableGeoip: true,
enable: settingsLoadedFromStorage && analytics && !!analyticsId,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be that this line was the issue? :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs say:

    // If set to false, tracking will be disabled until `optIn` is called

https://posthog.com/docs/libraries/react-native#configuration-options

customAppProperties: (properties) => ({ ...properties, $ip: '', $timezone: '' })
}}
autocapture={{
captureTouches: false,
captureLifecycleEvents: false,
captureScreens: false
}}
>
<AnalyticsSetup>{children}</AnalyticsSetup>
</PostHogProvider>
)
}
const AnalyticsProvider = ({ children }: { children: JSX.Element }) => (
<PostHogProvider
apiKey={PUBLIC_POSTHOG_KEY}
options={{
host: PUBLIC_POSTHOG_HOST,
disableGeoip: true,
customAppProperties: (properties) => ({ ...properties, $ip: '', $timezone: '' })
}}
autocapture={{
captureTouches: false,
captureLifecycleEvents: false,
captureScreens: false
}}
>
<AnalyticsSetup>{children}</AnalyticsSetup>
</PostHogProvider>
)

export default AnalyticsProvider