Skip to main content

Crm Visibility

This package contains functions to encapsulate the logic for displaying UI components based on a team's attributes such as crm_type, feature flags, settings, etc...

These questions should always be boolean, Promise responses.

Usage

Example plain usage

import { canViewDownloadInsights } from '@shared/crm-visibility'

canViewDownloadInsights().then(answer => useAnswer(answer))

Example useQuery usage

import { canViewLinkAccounts } from '@shared/crm-visibility'

const { data: canLinkAccounts = false } = useQuery(
KEY_CAN_LINK_ACCOUNTS,
canViewLinkAccounts
)

Development

The primary input to these questions is the team's crmtype (salesforce, dynamics, etc...). We use constants representing visible feature that are added to static lists of _hidden features for a given crm_type.

For example the api limits feature would be hidden for dynamics teams but not salesforce teams below.

const API_LIMITS = 'api_limits'
const HIDE_FOR_HUBSPOT_TEAMS: string[] = [API_LIMITS]
const HIDE_FOR_SALESFORCE_TEAMS: string[] = []

You can also use Feature Flags, Settings, user type, and permissions to determine if something should be visibile

export const canViewLinkAccounts = async () => {
const { team } = getAuthContext()
const canView = await canViewForCrmType(LINK_ACCOUNTS)
return (
canView &&
team.planFeatures.sfdc_sync &&
hasPermission('manage_company_management_settings') &&
!team.aclsEnforced
)
}
export const canViewGoalManagementPage = async () => {
const canView = await canViewForCrmType(GOAL_MANAGEMENT)
return (
canView &&
hasFeatureFlag('goal_management') &&
hasPermission('manage_team_goals')
)
}