Skip to content

Commit 4a5d837

Browse files
committed
Allow number for timetamps and fix last request spelling
1 parent 5d6729e commit 4a5d837

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export const IntercomProvider: React.FC<React.PropsWithChildren<
150150

151151
const refresh = React.useCallback(() => {
152152
ensureIntercom('update', () => {
153-
const lastRequestedAt = new Date().getTime();
154-
IntercomAPI('update', { last_requested_at: lastRequestedAt });
153+
const last_request_at = Math.floor(new Date().getTime() / 1000);
154+
IntercomAPI('update', { last_request_at });
155155
});
156156
}, [ensureIntercom]);
157157

src/types.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type MessengerAttributes = {
6262
export type RawDataAttributesCompany = {
6363
company_id: string;
6464
name?: string;
65-
created_at?: string;
65+
created_at?: string | number;
6666
plan?: string;
6767
monthly_spend?: number;
6868
user_count?: number;
@@ -77,7 +77,7 @@ export type DataAttributesCompany = {
7777
/** The name of the company */
7878
name?: string;
7979
/** The time the company was created in your system */
80-
createdAt?: string;
80+
createdAt?: string | number;
8181
/** The name of the plan the company is on */
8282
plan?: string;
8383
/** How much revenue the company generates for your business */
@@ -114,10 +114,10 @@ export type DataAttributesAvatar = {
114114
export type RawDataAttributes = {
115115
email?: string;
116116
user_id?: string;
117-
created_at?: string;
117+
created_at?: string | number;
118118
name?: string;
119119
phone?: string;
120-
last_request_at?: string;
120+
last_request_at?: string | number;
121121
unsubscribed_from_emails?: boolean;
122122
language_override?: string;
123123
utm_campaign?: string;
@@ -146,8 +146,10 @@ export type DataAttributes = {
146146
/** The Unix timestamp (in seconds) when the user signed up to your app
147147
*
148148
* @remarks Only applicable to users
149+
*
150+
* @see {@link https://www.intercom.com/help/en/articles/3605703-how-dates-work-in-intercom}
149151
*/
150-
createdAt?: string;
152+
createdAt?: string | number;
151153
/** Name of the current user/lead */
152154
name?: string;
153155
/** Name of the current user/lead */
@@ -156,7 +158,7 @@ export type DataAttributes = {
156158
*
157159
* @remarks It automatically uses the time of the last request but is a this is a reserved attribute
158160
*/
159-
lastRequestAt?: string;
161+
lastRequestAt?: string | number;
160162
/** Sets the unsubscribe status of the record
161163
*
162164
* @see {@link https://www.intercom.com/help/en/articles/270-how-do-i-unsubscribe-users-from-receiving-emails}

0 commit comments

Comments
 (0)