Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions frontend/common/loadChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ declare global {
import flagsmith from '@flagsmith/flagsmith'
import AccountStore from './stores/account-store'
import getUserDisplayName from './utils/getUserDisplayName'
import Utils, { planNames } from './utils/utils'
import Utils from './utils/utils'
import { AccountModel } from './types/responses'
import Project from './project'

const defaultPylonID = '028babb7-d93f-4e32-be6a-59db190a084f'

function isFreePlan(): boolean {
const plan = AccountStore.getActiveOrgPlan()
return Utils.getPlanName(plan) === planNames.free
}

async function loadPylon(pylonAppId: string) {
if (window.Pylon) {
return
Expand Down Expand Up @@ -69,7 +64,7 @@ export function hidePylon() {
}

export function identifyChatUser() {
if (flagsmith.hasFeature('pylon_chat') && !isFreePlan()) {
if (flagsmith.hasFeature('pylon_chat') && !Utils.isOrgOnFreePlan()) {
setupPylon()
if (typeof window.Pylon !== 'undefined') {
window.Pylon('showChatBubble')
Expand All @@ -82,7 +77,7 @@ export function identifyChatUser() {
export function openChat() {
if (
flagsmith.hasFeature('pylon_chat') &&
!isFreePlan() &&
!Utils.isOrgOnFreePlan() &&
typeof window.Pylon !== 'undefined'
) {
window.Pylon('show')
Expand All @@ -95,7 +90,7 @@ export default async function loadChat(forceDefaultAPIKey?: boolean) {
const isWidget = document.location.href.includes('/widget')
if (isWidget) return

if (flagsmith.hasFeature('pylon_chat') && !isFreePlan()) {
if (flagsmith.hasFeature('pylon_chat') && !Utils.isOrgOnFreePlan()) {
const pylonId = forceDefaultAPIKey ? defaultPylonID : Project.pylonAppId
if (pylonId) {
await loadPylon(pylonId)
Expand Down
6 changes: 6 additions & 0 deletions frontend/common/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ const Utils = Object.assign({}, BaseUtils, {
}
}
},

getPlanName: (_plan: string) => {
const plan = (_plan || '')?.toLowerCase()
if (plan.includes('free')) {
Expand All @@ -489,6 +490,7 @@ const Utils = Object.assign({}, BaseUtils, {
}
return planNames.free
},

getPlanPermission: (plan: string, feature: PaidFeature) => {
const planName = Utils.getPlanName(plan)
if (!plan || planName === planNames.free) {
Expand All @@ -508,6 +510,7 @@ const Utils = Object.assign({}, BaseUtils, {
}
return true
},

getPlansPermission: (feature: PaidFeature) => {
const isOrgPermission = feature !== '2FA'
let plans
Expand All @@ -527,6 +530,7 @@ const Utils = Object.assign({}, BaseUtils, {
)
return !!found
},

getProjectColour(index: number) {
return Constants.projectColors[index % (Constants.projectColors.length - 1)]
},
Expand Down Expand Up @@ -692,6 +696,8 @@ const Utils = Object.assign({}, BaseUtils, {
}
return false
},
isOrgOnFreePlan: (): boolean =>
Utils.getPlanName(AccountStore.getActiveOrgPlan()) === planNames.free,
isSaas: () => selectBuildVersion(getStore().getState())?.backend?.is_saas,

isValidNumber(value: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ const ExperimentsFakeDoor: FC = () => {
I would like to participate in beta testing
</span>
<span className='experiments-fake-door__cta-subtitle'>
Get early access to Experiments and help shape the feature
Get early access to Experiments and help shape the feature.{' '}
<a
href='https://docs.flagsmith.com/experiment-statistics'
target='_blank'
rel='noreferrer'
Comment thread
Zaimwa9 marked this conversation as resolved.
>
Learn more
</a>
</span>
</div>
{signedUp ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const EnvironmentNavbar: FC<EnvironmentNavType> = ({
Experiments
</SidebarLink>
) : (
!Utils.isOrgOnFreePlan() &&
Utils.getFlagsmithHasFeature('experiments_fake_door') && (
<SidebarLink
id={mobile ? undefined : 'experiments-link'}
Expand Down
2 changes: 1 addition & 1 deletion frontend/web/components/pages/ExperimentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ExperimentsPage: FC = () => {
const hasExperiments = Utils.getFlagsmithHasFeature('experimental_flags')
const hasFakeDoor = Utils.getFlagsmithHasFeature('experiments_fake_door')

if (!hasExperiments && hasFakeDoor) {
if (!Utils.isOrgOnFreePlan() && !hasExperiments && hasFakeDoor) {
return (
<div data-test='experiments-page' className='app-container container'>
<PageTitle title='Experiments' />
Expand Down
Loading