Skip to content

Commit

Permalink
fix(tasks): update tasks upsell provider client version (#6413)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin authored and RitaDias committed Apr 19, 2024
1 parent 68d81fa commit c19ae59
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import {
UpsellDialogViewed,
type UpsellDialogViewedInfo,
} from '../../../studio'
import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../../studioClient'
import {TasksUpsellContext} from './TasksUpsellContext'
import {type TasksUpsellContextValue} from './types'

const FEATURE = 'tasks'
const TEMPLATE_OPTIONS = {interpolate: /{{([\s\S]+?)}}/g}
const BASE_URL = 'www.sanity.io'
// Date when the change from array to object in the data returned was introduced.
const API_VERSION = '2024-04-19'

/**
* @beta
Expand All @@ -28,7 +29,7 @@ export function TasksUpsellProvider(props: {children: React.ReactNode}) {
const [upsellData, setUpsellData] = useState<UpsellData | null>(null)
const projectId = useProjectId()
const telemetry = useTelemetry()
const client = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)
const client = useClient({apiVersion: API_VERSION})

const telemetryLogs = useMemo(
(): TasksUpsellContextValue['telemetryLogs'] => ({
Expand Down Expand Up @@ -84,13 +85,12 @@ export function TasksUpsellProvider(props: {children: React.ReactNode}) {
}, [telemetry])

useEffect(() => {
const data$ = client.observable.request<UpsellData[] | null>({
const data$ = client.observable.request<UpsellData | null>({
uri: '/journey/tasks',
})

const sub = data$.subscribe({
next: (response) => {
const data = response?.[0]
next: (data) => {
if (!data) return
try {
const ctaUrl = template(data.ctaButton.url, TEMPLATE_OPTIONS)
Expand Down

0 comments on commit c19ae59

Please sign in to comment.