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
27 changes: 21 additions & 6 deletions types/intercom-web/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ declare namespace Intercom_ {
utm_term?: string | undefined;
company?: IntercomCompany | undefined;
companies?: IntercomCompany[] | undefined;
avatar?:
| {
type: 'avatar';
image_url: string;
}
| undefined;
avatar?: IntercomAvatar | undefined;

// Custom attributes
[custom_attribute: string]:
| IntercomCompany
| IntercomCompany[]
| IntercomAvatar
| IntercomCustomAttribute;
}

interface IntercomCommandSignature {
Expand Down Expand Up @@ -84,7 +86,20 @@ declare namespace Intercom_ {
size?: number | undefined;
website?: string | undefined;
industry?: string | undefined;
[custom_attribute: string]: IntercomCustomAttribute;
}

interface IntercomAvatar {
type: 'avatar';
image_url: string;
}

type IntercomCustomAttribute =
| string
| number
| boolean
| null
| undefined;
}

declare var Intercom: Intercom_.IntercomStatic;
Expand Down
18 changes: 17 additions & 1 deletion types/intercom-web/intercom-web-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,21 @@ intercomSettings = {
vertical_padding: 20,
};

/*
From https://www.intercom.com/help/en/articles
/179-send-custom-user-attributes-to-intercom
*/
intercomSettings = {
email: 'bob@example.com',
user_id: '123',
app_id: 'abc1234',
created_at: 1234567890,
subdomain: 'intercom',
teammates: 4,
active_accounts: 12,
last_order_at: 1350466020,
custom_domain: null,
};

// $ExpectError
Intercom('update', { some: 'invalid properties' });
Intercom('update', { some: { value: 'invalid properties' } });