2
0

🐛 Fix delete session with client side actions

This commit is contained in:
Baptiste Arnaud
2023-08-29 12:19:50 +02:00
parent b852b4af0b
commit 013c7a6265
10 changed files with 55 additions and 26 deletions

View File

@@ -17,6 +17,9 @@ export const sendWhatsAppInitialMessage = authenticatedProcedure
async ({ input: { to, typebotId, startGroupId }, ctx: { user } }) => {
const apiToken = await prisma.apiToken.findFirst({
where: { ownerId: user.id },
select: {
token: true,
},
})
if (!apiToken)
throw new TRPCError({

View File

@@ -10,7 +10,7 @@ import {
Text,
} from '@chakra-ui/react'
import { runtimes } from '../data'
import { getFeatureFlags } from '@/features/telemetry/posthog'
import { isWhatsAppAvailable } from '@/features/telemetry/posthog'
type Runtime = (typeof runtimes)[number]
@@ -38,9 +38,7 @@ export const RuntimeMenu = ({ selectedRuntime, onSelectRuntime }: Props) => {
{runtimes
.filter((runtime) => runtime.name !== selectedRuntime.name)
.filter((runtime) =>
runtime.name === 'WhatsApp'
? getFeatureFlags().includes('whatsApp')
: true
runtime.name === 'WhatsApp' ? isWhatsAppAvailable() : true
)
.map((runtime) => (
<MenuItem

View File

@@ -42,7 +42,7 @@ import { NextjsModal } from './modals/Nextjs/NextjsModal'
import { WhatsAppLogo } from '@/components/logos/WhatsAppLogo'
import { WhatsAppModal } from './modals/WhatsAppModal/WhatsAppModal'
import { ParentModalProvider } from '@/features/graph/providers/ParentModalProvider'
import { getFeatureFlags } from '@/features/telemetry/posthog'
import { isWhatsAppAvailable } from '@/features/telemetry/posthog'
export type ModalProps = {
publicId: string
@@ -84,7 +84,7 @@ export const EmbedButton = ({
export const integrationsList = [
(props: Pick<ModalProps, 'publicId' | 'isPublished'>) => {
if (getFeatureFlags().includes('whatsApp'))
if (isWhatsAppAvailable())
return (
<ParentModalProvider>
<EmbedButton

View File

@@ -24,11 +24,13 @@ export const identifyUser = (userId: string) => {
posthog.identify(userId)
}
export const getFeatureFlags = () => {
return posthog.__loaded &&
posthog.isFeatureEnabled('whatsApp', { send_event: false })
? ['whatsApp']
: []
export const isWhatsAppAvailable = () => {
if (!env.NEXT_PUBLIC_POSTHOG_KEY || !posthog) return true
const isWhatsAppEnabled = posthog.getFeatureFlag('whatsApp', {
send_event: false,
})
if (isWhatsAppEnabled === undefined) return true
return posthog.__loaded && isWhatsAppEnabled
}
export { posthog }