From 27764a7bc7207bf6f809901d4a4f0aeba3485ac4 Mon Sep 17 00:00:00 2001 From: devrnt Date: Tue, 19 May 2020 19:32:55 +0200 Subject: [PATCH 1/3] chore: update tour id in playground --- example/modules/useIntercom/useIntercomTour.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example/modules/useIntercom/useIntercomTour.tsx b/example/modules/useIntercom/useIntercomTour.tsx index 9cd2c78b..f407a5af 100644 --- a/example/modules/useIntercom/useIntercomTour.tsx +++ b/example/modules/useIntercom/useIntercomTour.tsx @@ -29,8 +29,7 @@ const RawUseIntercomStartPagePage = () => { const handleBoot = React.useCallback(() => boot({ name: 'Russo' }), [boot]); const handleStartTour = React.useCallback(() => { - // TODO: update tour id - startTour(122198); + startTour(124247); }, [startTour]); return ( From 34528adadefec2bbf4ebde1fb74bcbf4b96a0900 Mon Sep 17 00:00:00 2001 From: devrnt Date: Tue, 19 May 2020 19:34:45 +0200 Subject: [PATCH 2/3] docs: add tour playground in readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5b9eb125..2718f51c 100644 --- a/README.md +++ b/README.md @@ -181,8 +181,12 @@ const HomePage = () => { ## Playground Example playground to showcase the functionalities of `react-use-intercom`. +### useIntercom [https://devrnt.github.io/react-use-intercom/#/useIntercom](https://devrnt.github.io/react-use-intercom/#/useIntercom) +### useIntercom (with Intercom tour) +[https://devrnt.github.io/react-use-intercom/#/useIntercomTour](https://devrnt.github.io/react-use-intercom/#/useIntercomTour) + ## TypeScript All the possible pre-defined options to pass to the Intercom instance are typed. So whenever you have to pass [IntercomProps](src/types.ts), all the possible properties will be available out of the box. These props are `JavaScript` 'friendly', so [camelCase](https://en.wikipedia.org/wiki/Camel_case). No need to pass the props with [snake_cased](https://en.wikipedia.org/wiki/Snake_case) keys. From 7d844372e9f9bea349b77e8285ad750c4aa1d54a Mon Sep 17 00:00:00 2001 From: devrnt Date: Tue, 19 May 2020 20:22:55 +0200 Subject: [PATCH 3/3] chore: improve error logging in intercom provider --- src/provider.tsx | 11 +++++++++++ src/utils.tsx | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 src/utils.tsx diff --git a/src/provider.tsx b/src/provider.tsx index a148ef2b..b5885630 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -7,6 +7,7 @@ import { IntercomContextValues, IntercomProviderProps } from './contextTypes'; import { IntercomAPI } from './intercom'; import { IntercomProps, RawIntercomBootProps } from './types'; import { mapIntercomPropsToRawIntercomProps } from './mappers'; +import { isEmptyObject } from './utils'; export const IntercomProvider = ({ appId, @@ -15,7 +16,17 @@ export const IntercomProvider = ({ onHide, onShow, onUnreadCountChange, + ...rest }: IntercomProviderProps) => { + if (!isEmptyObject(rest)) + logger.log( + 'error', + [ + 'some invalid props were passed to IntercomProvider. ', + `Please check following props: ${Object.keys(rest).join(', ')}.`, + ].join(''), + ); + const [isBooted, setIsBooted] = useState(autoBoot); if (!window.Intercom) { diff --git a/src/utils.tsx b/src/utils.tsx new file mode 100644 index 00000000..911212b1 --- /dev/null +++ b/src/utils.tsx @@ -0,0 +1,2 @@ +export const isEmptyObject = (obj: object) => + Object.keys(obj).length === 0 && obj.constructor === Object;