forked from RSSNext/Follow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into dev
Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
36 changed files
with
909 additions
and
239 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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,37 +1,39 @@ | ||
import { useAtomValue } from "jotai" | ||
import PostHog from "posthog-js" | ||
import { useFeatureFlagEnabled } from "posthog-js/react" | ||
// import { useAtomValue } from "jotai" | ||
// import PostHog from "posthog-js" | ||
// import { useFeatureFlagEnabled } from "posthog-js/react" | ||
|
||
import { jotaiStore } from "~/lib/jotai" | ||
import type { FeatureKeys } from "~/modules/ab/atoms" | ||
import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "~/modules/ab/atoms" | ||
import { abPayloadFallback } from "~/modules/ab/fallback" | ||
// import { jotaiStore } from "~/lib/jotai" | ||
// import type { FeatureKeys } from "~/modules/ab/atoms" | ||
// import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "~/modules/ab/atoms" | ||
// import { abPayloadFallback } from "~/modules/ab/fallback" | ||
|
||
export const useAb = (feature: FeatureKeys) => { | ||
const isEnableDebugOverrides = useAtomValue(enableDebugOverrideAtom) | ||
const debugFeatureOverrides = useAtomValue(debugFeaturesAtom) | ||
// export const useAb = (feature: FeatureKeys) => { | ||
// const isEnableDebugOverrides = useAtomValue(enableDebugOverrideAtom) | ||
// const debugFeatureOverrides = useAtomValue(debugFeaturesAtom) | ||
|
||
const isEnabled = useFeatureFlagEnabled(feature) | ||
// const isEnabled = useFeatureFlagEnabled(feature) | ||
|
||
if (IS_DEBUG_ENV && isEnableDebugOverrides) return debugFeatureOverrides[feature] | ||
// if (IS_DEBUG_ENV && isEnableDebugOverrides) return debugFeatureOverrides[feature] | ||
|
||
return isEnabled | ||
} | ||
// return isEnabled | ||
// } | ||
|
||
export const isAbEnabled = (feature: FeatureKeys) => { | ||
const featureFlag = PostHog.getFeatureFlag(feature) | ||
const enabled = typeof featureFlag === "boolean" ? featureFlag : featureFlag === "enabled" | ||
const debugOverride = jotaiStore.get(debugFeaturesAtom) | ||
// export const isAbEnabled = (feature: FeatureKeys) => { | ||
// const featureFlag = PostHog.getFeatureFlag(feature) | ||
// const enabled = typeof featureFlag === "boolean" ? featureFlag : featureFlag === "enabled" | ||
// const debugOverride = jotaiStore.get(debugFeaturesAtom) | ||
|
||
const isEnableOverride = jotaiStore.get(enableDebugOverrideAtom) | ||
// const isEnableOverride = jotaiStore.get(enableDebugOverrideAtom) | ||
|
||
if (isEnableOverride) { | ||
return debugOverride[feature] | ||
} | ||
// if (isEnableOverride) { | ||
// return debugOverride[feature] | ||
// } | ||
|
||
return enabled | ||
} | ||
// return enabled | ||
// } | ||
|
||
export const getAbValue = (feature: FeatureKeys) => { | ||
return PostHog.getFeatureFlagPayload(feature) || abPayloadFallback[feature] | ||
} | ||
// export const getAbValue = (feature: FeatureKeys) => { | ||
// return PostHog.getFeatureFlagPayload(feature) || abPayloadFallback[feature] | ||
// } | ||
|
||
export {} |
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,45 @@ | ||
import { env } from "@follow/shared/env" | ||
import type { TrackProperties } from "@openpanel/web" | ||
|
||
import { getGeneralSettings } from "~/atoms/settings/general" | ||
|
||
import { op } from "./op" | ||
import { initPostHog } from "./posthog" | ||
|
||
declare global { | ||
interface Window { | ||
analytics?: { | ||
capture: (event_name: string, properties?: TrackProperties | null) => void | ||
reset: () => void | ||
} | ||
} | ||
} | ||
export const initAnalytics = () => { | ||
// TODO remove this | ||
initPostHog() | ||
if (env.VITE_OPENPANEL_CLIENT_ID === undefined) return | ||
|
||
op.setGlobalProperties({ | ||
build: ELECTRON ? "electron" : "web", | ||
version: APP_VERSION, | ||
hash: GIT_COMMIT_SHA, | ||
}) | ||
|
||
window.analytics = { | ||
reset: () => { | ||
// op.clear() | ||
|
||
// TODO remove this if op ready | ||
window.posthog?.reset() | ||
}, | ||
capture(event_name: string, properties?: TrackProperties | null) { | ||
if (import.meta.env.DEV) return | ||
if (!getGeneralSettings().sendAnonymousData) { | ||
return | ||
} | ||
// TODO remove this if op ready | ||
window.posthog?.capture(event_name, properties as TrackProperties) | ||
op.track(event_name, properties as TrackProperties) | ||
}, | ||
} | ||
} |
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,19 @@ | ||
import { getAnalytics } from "firebase/analytics" | ||
import { initializeApp } from "firebase/app" | ||
|
||
// See: https://firebase.google.com/docs/web/learn-more#config-object | ||
// For Firebase JavaScript SDK v7.20.0 and later, `measurementId` is an optional field | ||
const firebaseConfig = { | ||
apiKey: "AIzaSyDuM93019tp8VI7wsszJv8ChOs7b1EE5Hk", | ||
authDomain: "follow-428106.firebaseapp.com", | ||
projectId: "follow-428106", | ||
storageBucket: "follow-428106.appspot.com", | ||
messagingSenderId: "194977404578", | ||
appId: "1:194977404578:web:1920bb0c9ea5e2373669fb", | ||
measurementId: "G-SJE57D4F14", | ||
} | ||
// Initialize Firebase | ||
const app = initializeApp(firebaseConfig) | ||
|
||
// Initialize Analytics and get a reference to the service | ||
export const analytics = getAnalytics(app) |
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 |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import type { User } from "@auth/core/types" | ||
|
||
export const setIntegrationIdentify = (user: User) => | ||
Promise.all([ | ||
import("@sentry/react").then(({ setTag }) => { | ||
setTag("user_id", user.id) | ||
setTag("user_name", user.name) | ||
}), | ||
import("posthog-js").then(({ default: posthog }) => { | ||
posthog.identify(user.id, { | ||
name: user.name, | ||
handle: user.handle, | ||
}) | ||
}), | ||
]) | ||
import { op } from "./op" | ||
|
||
export const setIntegrationIdentify = async (user: User) => { | ||
op.identify({ | ||
profileId: user.id, | ||
email: user.email, | ||
avatar: user.image, | ||
lastName: user.name, | ||
properties: { | ||
handle: user.handle, | ||
name: user.name, | ||
}, | ||
}) | ||
await import("@sentry/react").then(({ setTag }) => { | ||
setTag("user_id", user.id) | ||
setTag("user_name", user.name) | ||
}) | ||
} |
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,10 @@ | ||
import { env } from "@follow/shared/env" | ||
import { OpenPanel } from "@openpanel/web" | ||
|
||
export const op = new OpenPanel({ | ||
clientId: env.VITE_OPENPANEL_CLIENT_ID, | ||
trackScreenViews: true, | ||
trackOutgoingLinks: true, | ||
trackAttributes: true, | ||
apiUrl: env.VITE_OPENPANEL_API_URL, | ||
}) |
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
Oops, something went wrong.