|
1 | | -import { useUser } from '@clerk/shared/react'; |
| 1 | +import { useClerk, useOrganization, useUser } from '@clerk/shared/react'; |
| 2 | +import { eventFlowStepMounted } from '@clerk/shared/telemetry'; |
2 | 3 | import type { OrganizationDomainResource } from '@clerk/shared/types'; |
3 | 4 | import type React from 'react'; |
4 | | -import { useState } from 'react'; |
| 5 | +import { useEffect, useRef, useState } from 'react'; |
5 | 6 |
|
6 | 7 | import { |
7 | 8 | Badge, |
@@ -40,14 +41,35 @@ export const OrganizationDomainsStep = (): JSX.Element => { |
40 | 41 | const { |
41 | 42 | enterpriseConnection, |
42 | 43 | organizationDomains, |
| 44 | + organizationEnterpriseConnection, |
43 | 45 | contentRef, |
44 | 46 | organizationDomainMutations: { createDomain, revalidate }, |
45 | 47 | enterpriseConnectionMutations: { updateConnection }, |
46 | 48 | } = useConfigureSSO(); |
47 | 49 | const { goPrev, goNext, isFirstStep, isLastStep } = useWizard(); |
48 | 50 | const card = useCardState(); |
| 51 | + const clerk = useClerk(); |
| 52 | + const { organization } = useOrganization(); |
49 | 53 | const [domainToRemove, setDomainToRemove] = useState<OrganizationDomainResource | null>(null); |
50 | 54 |
|
| 55 | + const hasRecordedTelemetryEvent = useRef(false); |
| 56 | + useEffect(() => { |
| 57 | + if (hasRecordedTelemetryEvent.current) { |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + hasRecordedTelemetryEvent.current = true; |
| 62 | + clerk.telemetry?.record( |
| 63 | + eventFlowStepMounted('configureSSO', 'verify-domain', { |
| 64 | + timestamp: new Date().toISOString(), |
| 65 | + connectionStatus: organizationEnterpriseConnection.status, |
| 66 | + connectionId: enterpriseConnection?.id ?? null, |
| 67 | + organizationId: organization?.id ?? null, |
| 68 | + }), |
| 69 | + ); |
| 70 | + // eslint-disable-next-line react-hooks/exhaustive-deps |
| 71 | + }, []); |
| 72 | + |
51 | 73 | const handleCreateDomain = async (domain: string) => { |
52 | 74 | card.setError(undefined); |
53 | 75 |
|
|
0 commit comments