-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from EveripediaNetwork/adds-posthog
Adds posthog
- Loading branch information
Showing
10 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import config from '@/config' | ||
import posthog from 'posthog-js' | ||
import { PostHogProvider } from 'posthog-js/react' | ||
import { useEffect } from 'react' | ||
import { useAccount } from 'wagmi' | ||
|
||
if (typeof window !== 'undefined') { | ||
posthog.init(config.posthogApikey, { | ||
api_host: '/ingest', | ||
ui_host: 'https://us.posthog.com', | ||
}) | ||
} | ||
|
||
export const CSPostHogProvider = ({ | ||
children, | ||
}: React.PropsWithChildren<{}>) => { | ||
return ( | ||
<PostHogProvider client={posthog}> | ||
<PosthogAuthWrapper>{children}</PosthogAuthWrapper> | ||
</PostHogProvider> | ||
) | ||
} | ||
|
||
function PosthogAuthWrapper({ children }: React.PropsWithChildren<{}>) { | ||
const { address, connector } = useAccount() | ||
|
||
useEffect(() => { | ||
const identifyUser = async () => { | ||
const chainId = await connector?.getChainId() | ||
if (address) { | ||
posthog.identify(address, { | ||
chainId, | ||
connector: connector?.name, | ||
}) | ||
} | ||
} | ||
identifyUser() | ||
}, [address]) | ||
|
||
return <>{children}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5047,6 +5047,11 @@ fetch-ponyfill@^7.1.0: | |
dependencies: | ||
node-fetch "~2.6.1" | ||
|
||
fflate@^0.4.8: | ||
version "0.4.8" | ||
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae" | ||
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA== | ||
|
||
[email protected]: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" | ||
|
@@ -6738,11 +6743,24 @@ [email protected]: | |
picocolors "^1.0.0" | ||
source-map-js "^1.0.2" | ||
|
||
posthog-js@^1.139.3: | ||
version "1.139.5" | ||
resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.139.5.tgz#f6f854374b3bae0d917889081e283aa5b91b3db2" | ||
integrity sha512-awnIAefNa+x5GA481B8j8J6S2xLcvHQ7i5Osyzq1UK6QGtmAaM0ttGFU+oPjpKxo4yXeuF5R1aUo9YE67s4+vA== | ||
dependencies: | ||
fflate "^0.4.8" | ||
preact "^10.19.3" | ||
|
||
preact@^10.12.0, preact@^10.5.9: | ||
version "10.15.1" | ||
resolved "https://registry.yarnpkg.com/preact/-/preact-10.15.1.tgz#a1de60c9fc0c79a522d969c65dcaddc5d994eede" | ||
integrity sha512-qs2ansoQEwzNiV5eAcRT1p1EC/dmEzaATVDJNiB3g2sRDWdA7b7MurXdJjB2+/WQktGWZwxvDrnuRFbWuIr64g== | ||
|
||
preact@^10.19.3: | ||
version "10.22.0" | ||
resolved "https://registry.yarnpkg.com/preact/-/preact-10.22.0.tgz#a50f38006ae438d255e2631cbdaf7488e6dd4e16" | ||
integrity sha512-RRurnSjJPj4rp5K6XoP45Ui33ncb7e4H7WiOHVpjbkvqvA3U+N8Z6Qbo0AE6leGYBV66n8EhEaFixvIu3SkxFw== | ||
|
||
preferred-pm@^3.0.0: | ||
version "3.0.3" | ||
resolved "https://registry.yarnpkg.com/preferred-pm/-/preferred-pm-3.0.3.tgz#1b6338000371e3edbce52ef2e4f65eb2e73586d6" | ||
|