Skip to content

Commit 6b0a985

Browse files
authored
chore: typescript api (#5807)
1 parent 1411f54 commit 6b0a985

File tree

5 files changed

+363
-361
lines changed

5 files changed

+363
-361
lines changed

frontend/common/types/responses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ export type SubscriptionMeta = {
554554
export type Account = {
555555
first_name: string
556556
last_name: string
557+
date_joined: string
557558
sign_up_type: SignupType
558559
id: number
559560
email: string
@@ -800,7 +801,7 @@ export type Webhook = {
800801
updated_at: string
801802
}
802803

803-
export type AccountModel = User & {
804+
export type AccountModel = Account & {
804805
organisations: Organisation[]
805806
}
806807

frontend/common/utils/getUserDisplayName.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { User } from 'common/types/responses'
1+
import { AccountModel, User } from 'common/types/responses'
22

3-
export default function (user: User | undefined, defaultName = 'Unknown') {
3+
export default function (
4+
user: AccountModel | undefined,
5+
defaultName = 'Unknown',
6+
) {
47
if (!user) {
58
return defaultName
69
}

frontend/global.d.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,30 @@ type Crisp = {
1515
// The push method accepts a CrispCommand array.
1616
push: (command: CrispCommand) => void
1717
}
18-
18+
declare namespace UniversalAnalytics {
19+
interface PageviewFieldsObject {
20+
hitType: 'pageview' | 'event'
21+
location?: string
22+
page?: string
23+
title?: string
24+
[key: string]: any
25+
}
26+
}
1927
export declare const openModal: (name?: string) => Promise<void>
2028
declare global {
29+
function ga(
30+
command: 'send',
31+
fields: UniversalAnalytics.PageviewFieldsObject,
32+
): void
2133
const $crisp: Crisp
34+
const delighted: {
35+
survey: (opts: {
36+
createdAt: string
37+
email: string
38+
name: string
39+
properties: Record<string, any>
40+
}) => void
41+
}
2242
const openModal: (
2343
title: ReactNode,
2444
body?: ReactNode,
@@ -52,5 +72,10 @@ declare global {
5272
const Tooltip: FC<TooltipProps>
5373
interface Window {
5474
$crisp: Crisp
75+
engagement: {
76+
init(apiKey: string, options?: InitOptions): void
77+
plugin(): unknown
78+
boot(options: BootOptions): Promise<void>
79+
}
5580
}
5681
}

0 commit comments

Comments
 (0)