about summary refs log tree commit diff
path: root/src/lib/analytics.web.tsx
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-06-15 14:45:14 -0700
committerGitHub <noreply@github.com>2023-06-15 16:45:14 -0500
commit17e7590bcd36f9ec3433cb2714a9319fac4aeebf (patch)
tree71edb7056abedd460d275944711e4fc001a2ffe6 /src/lib/analytics.web.tsx
parent1695ae34dbd08432f21f524ed32ad7012bfb201e (diff)
downloadvoidsky-17e7590bcd36f9ec3433cb2714a9319fac4aeebf.tar.zst
[APP-511] metrics overhaul: frontend work (#506)
* WIP

* fix types and update imports

* wip

* tagged events that should be server side

* remove server-side analytics

* remove useless import

* add additional profile header events

* remove useless import

* track follow/unfollow clicks

* add missing types
Diffstat (limited to 'src/lib/analytics.web.tsx')
-rw-r--r--src/lib/analytics.web.tsx65
1 files changed, 0 insertions, 65 deletions
diff --git a/src/lib/analytics.web.tsx b/src/lib/analytics.web.tsx
deleted file mode 100644
index 467ae278b..000000000
--- a/src/lib/analytics.web.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import React from 'react'
-import {
-  createClient,
-  AnalyticsProvider,
-  useAnalytics as useAnalyticsOrig,
-} from '@segment/analytics-react'
-import {RootStoreModel} from 'state/models/root-store'
-import {useStores} from 'state/models/root-store'
-import {sha256} from 'js-sha256'
-
-const segmentClient = createClient(
-  {
-    writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI',
-  },
-  {
-    integrations: {
-      'Segment.io': {
-        apiHost: 'api.evt.bsky.app/v1',
-      },
-    },
-  },
-)
-export const track = segmentClient?.track?.bind?.(segmentClient)
-
-export function useAnalytics() {
-  const store = useStores()
-  const methods = useAnalyticsOrig()
-  return React.useMemo(() => {
-    if (store.session.hasSession) {
-      return methods
-    }
-    // dont send analytics pings for anonymous users
-    return {
-      screen: () => {},
-      track: () => {},
-      identify: () => {},
-      flush: () => {},
-      group: () => {},
-      alias: () => {},
-      reset: () => {},
-    }
-  }, [store, methods])
-}
-
-export function init(store: RootStoreModel) {
-  store.onSessionLoaded(() => {
-    const sess = store.session.currentSession
-    if (sess) {
-      if (sess.email) {
-        store.log.debug('Ping w/hash')
-        const email_hashed = sha256(sess.email)
-        segmentClient.identify(email_hashed, {email_hashed})
-      } else {
-        store.log.debug('Ping w/o hash')
-        segmentClient.identify()
-      }
-    }
-  })
-}
-
-export function Provider({children}: React.PropsWithChildren<{}>) {
-  return (
-    <AnalyticsProvider client={segmentClient}>{children}</AnalyticsProvider>
-  )
-}