* Add analytics to the web build (close #233) * Use bsky endpoint for analytics
This commit is contained in:
parent
b100abca0e
commit
f717ff6719
4 changed files with 1010 additions and 20 deletions
|
@ -1,19 +1,29 @@
|
|||
// TODO
|
||||
import React from 'react'
|
||||
import {createClient, AnalyticsProvider} from '@segment/analytics-react'
|
||||
import {RootStoreModel} from 'state/models/root-store'
|
||||
|
||||
const _analytics = {
|
||||
screen(_name: string) {},
|
||||
track(_name: string, _opts: any) {},
|
||||
identify(_userId: string, _userTraits: any) {},
|
||||
}
|
||||
export const track = _analytics.track
|
||||
export function useAnalytics() {
|
||||
return _analytics
|
||||
}
|
||||
const segmentClient = createClient(
|
||||
{
|
||||
writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI',
|
||||
},
|
||||
{
|
||||
integrations: {
|
||||
'Segment.io': {
|
||||
apiHost: 'api.evt.bsky.app/v1',
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
export const track = segmentClient?.track?.bind?.(segmentClient)
|
||||
|
||||
export function init(_store: RootStoreModel) {}
|
||||
export {useAnalytics} from '@segment/analytics-react'
|
||||
|
||||
export function init(_store: RootStoreModel) {
|
||||
// no init needed on web
|
||||
}
|
||||
|
||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
return children
|
||||
return (
|
||||
<AnalyticsProvider client={segmentClient}>{children}</AnalyticsProvider>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue