Skip to content

Commit 2caeab1

Browse files
committed
Update docs
1 parent d0dae52 commit 2caeab1

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Place the `IntercomProvider` as high as possible in your application. This will
7979
| onHide | () => void | triggered when the Messenger hides | false | |
8080
| onShow | () => void | triggered when the Messenger shows | false | |
8181
| onUnreadCountChange | (number) => void | triggered when the current number of unread messages changes | false | |
82+
| onUserEmailSupplied | () => void | triggered when a visitor enters their email into the Messenger | false | |
8283
| shouldInitialize | boolean | indicates if the Intercom should be initialized. Can be used in multistaged environment | false | true |
8384
| apiBase | string | If you need to route your Messenger requests through a different endpoint than the default. Generally speaking, this is not needed.<br/> Format: `https://${INTERCOM_APP_ID}.intercom-messenger.com` (See: [https://github.com/devrnt/react-use-intercom/pull/96](https://github.com/devrnt/react-use-intercom/pull/96)) | false | |
8485
| initializeDelay | number | Indicates if the intercom initialization should be delayed, delay is in ms, defaults to 0. See https://github.com/devrnt/react-use-intercom/pull/236 | false | |
@@ -95,13 +96,17 @@ const App = () => {
9596
console.log('Intercom has a new unread message');
9697
setUnreadMessagesCount(amount);
9798
};
99+
const onUserEmailSupplied = () => {
100+
console.log('Visitor has entered email');
101+
};
98102

99103
return (
100104
<IntercomProvider
101105
appId={INTERCOM_APP_ID}
102106
onHide={onHide}
103107
onShow={onShow}
104108
onUnreadCountChange={onUnreadCountChange}
109+
onUserEmailSupplied={onUserEmailSupplied}
105110
autoBoot
106111
>
107112
<p>Hi there, I am a child of the IntercomProvider</p>
@@ -134,6 +139,7 @@ Used to retrieve all methods bundled with Intercom. These are based on the offic
134139
| startTour | (tourId: number) => void | starts a tour based on the `tourId` |
135140
| trackEvent | (event: string, metaData?: object) => void | submits an `event` with optional `metaData`
136141
| showArticle | (articleId: string) => void | opens the Messenger with the specified article by `articleId`
142+
| startSurvey | (surveyId: number) => void | Trigger a survey in the Messenger by `surveyId`
137143

138144
#### Example
139145
```javascript
@@ -162,7 +168,8 @@ const HomePage = () => {
162168
getVisitorId,
163169
startTour,
164170
trackEvent,
165-
showArticle
171+
showArticle,
172+
startSurvey
166173
} = useIntercom();
167174

168175
const bootWithProps = () => boot({ name: 'Russo' });
@@ -177,6 +184,7 @@ const HomePage = () => {
177184
name: 'Russo',
178185
});
179186
const handleShowArticle = () => showArticle(123456);
187+
const handleStartSurvey = () => startSurvey(123456);
180188

181189
return (
182190
<>
@@ -200,6 +208,7 @@ const HomePage = () => {
200208
Track event with metadata
201209
</button>
202210
<button onClick={handleShowArticle}>Open article in Messenger</button>
211+
<button onClick={handleStartSurvey}>Start survey in Messenger</button>
203212
</>
204213
);
205214
};

packages/react-use-intercom/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Place the `IntercomProvider` as high as possible in your application. This will
7979
| onHide | () => void | triggered when the Messenger hides | false | |
8080
| onShow | () => void | triggered when the Messenger shows | false | |
8181
| onUnreadCountChange | (number) => void | triggered when the current number of unread messages changes | false | |
82+
| onUserEmailSupplied | () => void | triggered when a visitor enters their email into the Messenger | false | |
8283
| shouldInitialize | boolean | indicates if the Intercom should be initialized. Can be used in multistaged environment | false | true |
8384
| apiBase | string | If you need to route your Messenger requests through a different endpoint than the default. Generally speaking, this is not needed.<br/> Format: `https://${INTERCOM_APP_ID}.intercom-messenger.com` (See: [https://github.com/devrnt/react-use-intercom/pull/96](https://github.com/devrnt/react-use-intercom/pull/96)) | false | |
8485
| initializeDelay | number | Indicates if the intercom initialization should be delayed, delay is in ms, defaults to 0. See https://github.com/devrnt/react-use-intercom/pull/236 | false | |
@@ -95,13 +96,17 @@ const App = () => {
9596
console.log('Intercom has a new unread message');
9697
setUnreadMessagesCount(amount);
9798
};
99+
const onUserEmailSupplied = () => {
100+
console.log('Visitor has entered email');
101+
};
98102

99103
return (
100104
<IntercomProvider
101105
appId={INTERCOM_APP_ID}
102106
onHide={onHide}
103107
onShow={onShow}
104108
onUnreadCountChange={onUnreadCountChange}
109+
onUserEmailSupplied={onUserEmailSupplied}
105110
autoBoot
106111
>
107112
<p>Hi there, I am a child of the IntercomProvider</p>
@@ -134,6 +139,7 @@ Used to retrieve all methods bundled with Intercom. These are based on the offic
134139
| startTour | (tourId: number) => void | starts a tour based on the `tourId` |
135140
| trackEvent | (event: string, metaData?: object) => void | submits an `event` with optional `metaData`
136141
| showArticle | (articleId: string) => void | opens the Messenger with the specified article by `articleId`
142+
| startSurvey | (surveyId: number) => void | Trigger a survey in the Messenger by `surveyId`
137143

138144
#### Example
139145
```javascript
@@ -162,7 +168,8 @@ const HomePage = () => {
162168
getVisitorId,
163169
startTour,
164170
trackEvent,
165-
showArticle
171+
showArticle,
172+
startSurvey
166173
} = useIntercom();
167174

168175
const bootWithProps = () => boot({ name: 'Russo' });
@@ -177,6 +184,7 @@ const HomePage = () => {
177184
name: 'Russo',
178185
});
179186
const handleShowArticle = () => showArticle(123456);
187+
const handleStartSurvey = () => startSurvey(123456);
180188

181189
return (
182190
<>
@@ -200,6 +208,7 @@ const HomePage = () => {
200208
Track event with metadata
201209
</button>
202210
<button onClick={handleShowArticle}>Open article in Messenger</button>
211+
<button onClick={handleStartSurvey}>Start survey in Messenger</button>
203212
</>
204213
);
205214
};

0 commit comments

Comments
 (0)