react-use-intercom
Advanced tools
Comparing version 0.4.0 to 1.0.0
@@ -67,2 +67,22 @@ 'use strict'; | ||
/** | ||
* Safely exposes `window.Intercom` and passes the arguments to the instance | ||
* | ||
* @param method method passed to the `window.Intercom` instance | ||
* @param args arguments passed to the `window.Intercom` instance | ||
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript} | ||
*/ | ||
var IntercomAPI = function IntercomAPI(method) { | ||
if (window.Intercom) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return window.Intercom.apply(null, [method].concat(args)); | ||
} else { | ||
log('error', method + " Intercom instance is not initalized yet"); | ||
} | ||
}; | ||
// @ts-nocheck | ||
@@ -155,21 +175,2 @@ | ||
/** | ||
* Safely exposes `window.Intercom` and passes the arguments to the instance | ||
* | ||
* @param method method passed to the `window.Intercom` instance | ||
* @param args arguments passed to the `window.Intercom` instance | ||
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript} | ||
*/ | ||
var IntercomAPI = function IntercomAPI(method) { | ||
if (window.Intercom) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return window.Intercom.apply(null, [method].concat(args)); | ||
} else { | ||
console.warn('[intercom] Intercom instance is not initialized yet'); | ||
} | ||
}; | ||
/** | ||
* Removes object entries where the value equals to `undefined` | ||
@@ -265,4 +266,5 @@ * | ||
var isBooted = React.useRef(autoBoot); | ||
var memoizedShouldInitialize = React.useRef(shouldInitialize); | ||
if (!window.Intercom && shouldInitialize) { | ||
if (!window.Intercom && memoizedShouldInitialize.current) { | ||
initialize(memoizedAppId.current); // Only add listeners on initialization | ||
@@ -284,3 +286,3 @@ | ||
var ensureIntercomIsBooted = React.useCallback(function (functionName, callback) { | ||
var ensureIntercom = React.useCallback(function (functionName, callback) { | ||
if (functionName === void 0) { | ||
@@ -290,3 +292,6 @@ functionName = 'A function'; | ||
if (!window.Intercom) return; | ||
if (!window.Intercom && !memoizedShouldInitialize.current) { | ||
log('warn', 'Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`'); | ||
return; | ||
} | ||
@@ -301,2 +306,7 @@ if (!isBooted.current) { | ||
var boot = React.useCallback(function (props) { | ||
if (!window.Intercom && !memoizedShouldInitialize.current) { | ||
log('warn', 'Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`'); | ||
return; | ||
} | ||
if (isBooted.current) return; | ||
@@ -325,3 +335,3 @@ | ||
var refresh = React.useCallback(function () { | ||
ensureIntercomIsBooted('update', function () { | ||
ensureIntercom('update', function () { | ||
var lastRequestedAt = new Date().getTime(); | ||
@@ -332,5 +342,5 @@ IntercomAPI('update', { | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var update = React.useCallback(function (props) { | ||
ensureIntercomIsBooted('update', function () { | ||
ensureIntercom('update', function () { | ||
if (!props) { | ||
@@ -345,20 +355,20 @@ refresh(); | ||
}); | ||
}, [ensureIntercomIsBooted, refresh]); | ||
}, [ensureIntercom, refresh]); | ||
var hide = React.useCallback(function () { | ||
ensureIntercomIsBooted('hide', function () { | ||
ensureIntercom('hide', function () { | ||
IntercomAPI('hide'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var show = React.useCallback(function () { | ||
ensureIntercomIsBooted('show', function () { | ||
ensureIntercom('show', function () { | ||
return IntercomAPI('show'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var showMessages = React.useCallback(function () { | ||
ensureIntercomIsBooted('showMessages', function () { | ||
ensureIntercom('showMessages', function () { | ||
IntercomAPI('showMessages'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var showNewMessages = React.useCallback(function (message) { | ||
ensureIntercomIsBooted('showNewMessage', function () { | ||
ensureIntercom('showNewMessage', function () { | ||
if (!message) { | ||
@@ -370,15 +380,15 @@ IntercomAPI('showNewMessage'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var getVisitorId = React.useCallback(function () { | ||
return ensureIntercomIsBooted('getVisitorId', function () { | ||
return ensureIntercom('getVisitorId', function () { | ||
return IntercomAPI('getVisitorId'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var startTour = React.useCallback(function (tourId) { | ||
ensureIntercomIsBooted('startTour', function () { | ||
ensureIntercom('startTour', function () { | ||
IntercomAPI('startTour', tourId); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var trackEvent = React.useCallback(function (event, metaData) { | ||
ensureIntercomIsBooted('trackEvent', function () { | ||
ensureIntercom('trackEvent', function () { | ||
if (metaData) { | ||
@@ -390,3 +400,3 @@ IntercomAPI('trackEvent', event, metaData); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var providerValue = React.useMemo(function () { | ||
@@ -393,0 +403,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e,t){var n="[react-use-intercom]";switch(e){case"info":console.log(n+" "+t);break;case"warn":console.warn(n+" "+t);break;case"error":console.error(n+" "+t);break;default:console.log(n+" "+t)}},r="Please wrap your component with `IntercomProvider`.",o=e.createContext({boot:function(){return n("error",r)},shutdown:function(){return n("error",r)},hardShutdown:function(){return n("error",r)},update:function(){return n("error",r)},hide:function(){return n("error",r)},show:function(){return n("error",r)},showMessages:function(){return n("error",r)},showNewMessages:function(){return n("error",r)},getVisitorId:function(){return n("error",r),""},startTour:function(){return n("error",r)},trackEvent:function(){return n("error",r)}}),a=function(e){if(window.Intercom){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return window.Intercom.apply(null,[e].concat(n))}console.warn("[intercom] Intercom instance is not initialized yet")},u=function(e){return{company_id:e.companyId,name:e.name,created_at:e.createdAt,plan:e.plan,monthly_spend:e.monthlySpend,user_count:e.userCount,size:e.size,website:e.website,industry:e.industry}},i=function(e){return{type:e.type,image_url:e.imageUrl}},c=function(e){return function e(t){return Object.keys(t).forEach((function(n){t[n]&&"object"==typeof t[n]?e(t[n]):void 0===t[n]&&delete t[n]})),t}(t(t({},{custom_launcher_selector:(n=e).customLauncherSelector,alignment:n.alignment,vertical_padding:n.verticalPadding,horizontal_padding:n.horizontalPadding,hide_default_launcher:n.hideDefaultLauncher,session_duration:n.sessionDuration,action_color:n.actionColor,background_color:n.backgroundColor}),function(e){var n;return t({email:e.email,user_id:e.userId,created_at:e.createdAt,name:e.name,phone:e.phone,last_request_at:e.lastRequestAt,unsubscribed_from_emails:e.unsubscribedFromEmails,language_override:e.languageOverride,utm_campaign:e.utmCampaign,utm_content:e.utmContent,utm_medium:e.utmMedium,utm_source:e.utmSource,utm_term:e.utmTerm,avatar:e.avatar&&i(e.avatar),user_hash:e.userHash,company:e.company&&u(e.company),companies:null===(n=e.companies)||void 0===n?void 0:n.map(u)},e.customAttributes)}(e)));var n};exports.IntercomProvider=function(r){var u,i=r.appId,s=r.autoBoot,d=void 0!==s&&s,l=r.children,f=r.onHide,m=r.onShow,h=r.onUnreadCountChange,w=r.shouldInitialize,p=void 0===w||w,g=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(r,["appId","autoBoot","children","onHide","onShow","onUnreadCountChange","shouldInitialize"]);u=g,(0!==Object.keys(u).length||u.constructor!==Object)&&n("error",["some invalid props were passed to IntercomProvider. ","Please check following props: "+Object.keys(g).join(", ")+"."].join(""));var v=e.useRef(i),b=e.useRef(d);!window.Intercom&&p&&(function(e){var t=window,n=t.Intercom;if("function"==typeof n)n("reattach_activator"),n("update",t.intercomSettings);else{var r=document,o=function e(){e.c(arguments)};o.q=[],o.c=function(e){o.q.push(e)},t.Intercom=o;var a=function(){var t=r.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://widget.intercom.io/widget/"+e;var n=r.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)};t.attachEvent?t.attachEvent("onload",a):t.addEventListener("load",a,!1)}}(v.current),f&&a("onHide",f),m&&a("onShow",m),h&&a("onUnreadCountChange",h),d&&(a("boot",{app_id:v.current}),window.intercomSettings={app_id:v.current}));var _=e.useCallback((function(e,t){if(void 0===e&&(e="A function"),window.Intercom){if(b.current)return t();n("warn",["'"+e+"' was called but Intercom has not booted yet. ","Please call 'boot' before calling '"+e+"' or ","set 'autoBoot' to true in the IntercomProvider."].join(""))}}),[]),y=e.useCallback((function(e){if(!b.current){var n=t({app_id:v.current},e&&c(e));window.intercomSettings=n,a("boot",n),b.current=!0}}),[]),k=e.useCallback((function(){b.current&&(a("shutdown"),b.current=!1)}),[]),C=e.useCallback((function(){b.current&&(a("shutdown"),delete window.Intercom,delete window.intercomSettings,b.current=!1)}),[]),I=e.useCallback((function(){_("update",(function(){var e=(new Date).getTime();a("update",{last_requested_at:e})}))}),[_]),S=e.useCallback((function(e){_("update",(function(){if(e){var n=c(e);window.intercomSettings=t(t({},window.intercomSettings),n),a("update",n)}else I()}))}),[_,I]),j=e.useCallback((function(){_("hide",(function(){a("hide")}))}),[_]),E=e.useCallback((function(){_("show",(function(){return a("show")}))}),[_]),M=e.useCallback((function(){_("showMessages",(function(){a("showMessages")}))}),[_]),P=e.useCallback((function(e){_("showNewMessage",(function(){e?a("showNewMessage",e):a("showNewMessage")}))}),[_]),O=e.useCallback((function(){return _("getVisitorId",(function(){return a("getVisitorId")}))}),[_]),x=e.useCallback((function(e){_("startTour",(function(){a("startTour",e)}))}),[_]),z=e.useCallback((function(e,t){_("trackEvent",(function(){t?a("trackEvent",e,t):a("trackEvent",e)}))}),[_]),N=e.useMemo((function(){return{boot:y,shutdown:k,hardShutdown:C,update:S,hide:j,show:E,showMessages:M,showNewMessages:P,getVisitorId:O,startTour:x,trackEvent:z}}),[y,k,C,S,j,E,M,P,O,x,z]),T=e.useMemo((function(){return l}),[l]);return e.createElement(o.Provider,{value:N},T)},exports.useIntercom=function(){return e.useContext(o)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e,t){var n="[react-use-intercom]";switch(e){case"info":console.log(n+" "+t);break;case"warn":console.warn(n+" "+t);break;case"error":console.error(n+" "+t);break;default:console.log(n+" "+t)}},r=function(e){if(window.Intercom){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return window.Intercom.apply(null,[e].concat(r))}n("error",e+" Intercom instance is not initalized yet")},o="Please wrap your component with `IntercomProvider`.",a=e.createContext({boot:function(){return n("error",o)},shutdown:function(){return n("error",o)},hardShutdown:function(){return n("error",o)},update:function(){return n("error",o)},hide:function(){return n("error",o)},show:function(){return n("error",o)},showMessages:function(){return n("error",o)},showNewMessages:function(){return n("error",o)},getVisitorId:function(){return n("error",o),""},startTour:function(){return n("error",o)},trackEvent:function(){return n("error",o)}}),i=function(e){return{company_id:e.companyId,name:e.name,created_at:e.createdAt,plan:e.plan,monthly_spend:e.monthlySpend,user_count:e.userCount,size:e.size,website:e.website,industry:e.industry}},u=function(e){return{type:e.type,image_url:e.imageUrl}},c=function(e){return function e(t){return Object.keys(t).forEach((function(n){t[n]&&"object"==typeof t[n]?e(t[n]):void 0===t[n]&&delete t[n]})),t}(t(t({},{custom_launcher_selector:(n=e).customLauncherSelector,alignment:n.alignment,vertical_padding:n.verticalPadding,horizontal_padding:n.horizontalPadding,hide_default_launcher:n.hideDefaultLauncher,session_duration:n.sessionDuration,action_color:n.actionColor,background_color:n.backgroundColor}),function(e){var n;return t({email:e.email,user_id:e.userId,created_at:e.createdAt,name:e.name,phone:e.phone,last_request_at:e.lastRequestAt,unsubscribed_from_emails:e.unsubscribedFromEmails,language_override:e.languageOverride,utm_campaign:e.utmCampaign,utm_content:e.utmContent,utm_medium:e.utmMedium,utm_source:e.utmSource,utm_term:e.utmTerm,avatar:e.avatar&&u(e.avatar),user_hash:e.userHash,company:e.company&&i(e.company),companies:null===(n=e.companies)||void 0===n?void 0:n.map(i)},e.customAttributes)}(e)));var n};exports.IntercomProvider=function(o){var i,u=o.appId,s=o.autoBoot,d=void 0!==s&&s,l=o.children,f=o.onHide,m=o.onShow,h=o.onUnreadCountChange,w=o.shouldInitialize,p=void 0===w||w,v=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(o,["appId","autoBoot","children","onHide","onShow","onUnreadCountChange","shouldInitialize"]);i=v,(0!==Object.keys(i).length||i.constructor!==Object)&&n("error",["some invalid props were passed to IntercomProvider. ","Please check following props: "+Object.keys(v).join(", ")+"."].join(""));var g=e.useRef(u),b=e.useRef(d),_=e.useRef(p);!window.Intercom&&_.current&&(function(e){var t=window,n=t.Intercom;if("function"==typeof n)n("reattach_activator"),n("update",t.intercomSettings);else{var r=document,o=function e(){e.c(arguments)};o.q=[],o.c=function(e){o.q.push(e)},t.Intercom=o;var a=function(){var t=r.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://widget.intercom.io/widget/"+e;var n=r.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)};t.attachEvent?t.attachEvent("onload",a):t.addEventListener("load",a,!1)}}(g.current),f&&r("onHide",f),m&&r("onShow",m),h&&r("onUnreadCountChange",h),d&&(r("boot",{app_id:g.current}),window.intercomSettings={app_id:g.current}));var I=e.useCallback((function(e,t){if(void 0===e&&(e="A function"),window.Intercom||_.current){if(b.current)return t();n("warn",["'"+e+"' was called but Intercom has not booted yet. ","Please call 'boot' before calling '"+e+"' or ","set 'autoBoot' to true in the IntercomProvider."].join(""))}else n("warn","Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`")}),[]),y=e.useCallback((function(e){if(window.Intercom||_.current){if(!b.current){var o=t({app_id:g.current},e&&c(e));window.intercomSettings=o,r("boot",o),b.current=!0}}else n("warn","Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`")}),[]),k=e.useCallback((function(){b.current&&(r("shutdown"),b.current=!1)}),[]),C=e.useCallback((function(){b.current&&(r("shutdown"),delete window.Intercom,delete window.intercomSettings,b.current=!1)}),[]),P=e.useCallback((function(){I("update",(function(){var e=(new Date).getTime();r("update",{last_requested_at:e})}))}),[I]),S=e.useCallback((function(e){I("update",(function(){if(e){var n=c(e);window.intercomSettings=t(t({},window.intercomSettings),n),r("update",n)}else P()}))}),[I,P]),j=e.useCallback((function(){I("hide",(function(){r("hide")}))}),[I]),E=e.useCallback((function(){I("show",(function(){return r("show")}))}),[I]),M=e.useCallback((function(){I("showMessages",(function(){r("showMessages")}))}),[I]),z=e.useCallback((function(e){I("showNewMessage",(function(){e?r("showNewMessage",e):r("showNewMessage")}))}),[I]),O=e.useCallback((function(){return I("getVisitorId",(function(){return r("getVisitorId")}))}),[I]),x=e.useCallback((function(e){I("startTour",(function(){r("startTour",e)}))}),[I]),N=e.useCallback((function(e,t){I("trackEvent",(function(){t?r("trackEvent",e,t):r("trackEvent",e)}))}),[I]),T=e.useMemo((function(){return{boot:y,shutdown:k,hardShutdown:C,update:S,hide:j,show:E,showMessages:M,showNewMessages:z,getVisitorId:O,startTour:x,trackEvent:N}}),[y,k,C,S,j,E,M,z,O,x,N]),q=e.useMemo((function(){return l}),[l]);return e.createElement(a.Provider,{value:T},q)},exports.useIntercom=function(){return e.useContext(a)}; | ||
//# sourceMappingURL=react-use-intercom.cjs.production.min.js.map |
@@ -63,2 +63,22 @@ import { createContext, useRef, useCallback, useMemo, createElement, useContext } from 'react'; | ||
/** | ||
* Safely exposes `window.Intercom` and passes the arguments to the instance | ||
* | ||
* @param method method passed to the `window.Intercom` instance | ||
* @param args arguments passed to the `window.Intercom` instance | ||
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript} | ||
*/ | ||
var IntercomAPI = function IntercomAPI(method) { | ||
if (window.Intercom) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return window.Intercom.apply(null, [method].concat(args)); | ||
} else { | ||
log('error', method + " Intercom instance is not initalized yet"); | ||
} | ||
}; | ||
// @ts-nocheck | ||
@@ -151,21 +171,2 @@ | ||
/** | ||
* Safely exposes `window.Intercom` and passes the arguments to the instance | ||
* | ||
* @param method method passed to the `window.Intercom` instance | ||
* @param args arguments passed to the `window.Intercom` instance | ||
* @see {@link https://developers.intercom.com/installing-intercom/docs/intercom-javascript} | ||
*/ | ||
var IntercomAPI = function IntercomAPI(method) { | ||
if (window.Intercom) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return window.Intercom.apply(null, [method].concat(args)); | ||
} else { | ||
console.warn('[intercom] Intercom instance is not initialized yet'); | ||
} | ||
}; | ||
/** | ||
* Removes object entries where the value equals to `undefined` | ||
@@ -261,4 +262,5 @@ * | ||
var isBooted = useRef(autoBoot); | ||
var memoizedShouldInitialize = useRef(shouldInitialize); | ||
if (!window.Intercom && shouldInitialize) { | ||
if (!window.Intercom && memoizedShouldInitialize.current) { | ||
initialize(memoizedAppId.current); // Only add listeners on initialization | ||
@@ -280,3 +282,3 @@ | ||
var ensureIntercomIsBooted = useCallback(function (functionName, callback) { | ||
var ensureIntercom = useCallback(function (functionName, callback) { | ||
if (functionName === void 0) { | ||
@@ -286,3 +288,6 @@ functionName = 'A function'; | ||
if (!window.Intercom) return; | ||
if (!window.Intercom && !memoizedShouldInitialize.current) { | ||
log('warn', 'Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`'); | ||
return; | ||
} | ||
@@ -297,2 +302,7 @@ if (!isBooted.current) { | ||
var boot = useCallback(function (props) { | ||
if (!window.Intercom && !memoizedShouldInitialize.current) { | ||
log('warn', 'Intercom instance is not initialized because `shouldInitialize` is set to `false` in `IntercomProvider`'); | ||
return; | ||
} | ||
if (isBooted.current) return; | ||
@@ -321,3 +331,3 @@ | ||
var refresh = useCallback(function () { | ||
ensureIntercomIsBooted('update', function () { | ||
ensureIntercom('update', function () { | ||
var lastRequestedAt = new Date().getTime(); | ||
@@ -328,5 +338,5 @@ IntercomAPI('update', { | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var update = useCallback(function (props) { | ||
ensureIntercomIsBooted('update', function () { | ||
ensureIntercom('update', function () { | ||
if (!props) { | ||
@@ -341,20 +351,20 @@ refresh(); | ||
}); | ||
}, [ensureIntercomIsBooted, refresh]); | ||
}, [ensureIntercom, refresh]); | ||
var hide = useCallback(function () { | ||
ensureIntercomIsBooted('hide', function () { | ||
ensureIntercom('hide', function () { | ||
IntercomAPI('hide'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var show = useCallback(function () { | ||
ensureIntercomIsBooted('show', function () { | ||
ensureIntercom('show', function () { | ||
return IntercomAPI('show'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var showMessages = useCallback(function () { | ||
ensureIntercomIsBooted('showMessages', function () { | ||
ensureIntercom('showMessages', function () { | ||
IntercomAPI('showMessages'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var showNewMessages = useCallback(function (message) { | ||
ensureIntercomIsBooted('showNewMessage', function () { | ||
ensureIntercom('showNewMessage', function () { | ||
if (!message) { | ||
@@ -366,15 +376,15 @@ IntercomAPI('showNewMessage'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var getVisitorId = useCallback(function () { | ||
return ensureIntercomIsBooted('getVisitorId', function () { | ||
return ensureIntercom('getVisitorId', function () { | ||
return IntercomAPI('getVisitorId'); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var startTour = useCallback(function (tourId) { | ||
ensureIntercomIsBooted('startTour', function () { | ||
ensureIntercom('startTour', function () { | ||
IntercomAPI('startTour', tourId); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var trackEvent = useCallback(function (event, metaData) { | ||
ensureIntercomIsBooted('trackEvent', function () { | ||
ensureIntercom('trackEvent', function () { | ||
if (metaData) { | ||
@@ -386,3 +396,3 @@ IntercomAPI('trackEvent', event, metaData); | ||
}); | ||
}, [ensureIntercomIsBooted]); | ||
}, [ensureIntercom]); | ||
var providerValue = useMemo(function () { | ||
@@ -389,0 +399,0 @@ return { |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/devrnt/react-use-intercom#readme", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "main": "dist/index.js", |
@@ -1,11 +0,13 @@ | ||
# react-use-intercom | ||
<p align="center"><img src="./assets/logo.png" alt="Logo" height="120px" style="margin-top: 20px;"/></p> | ||
<h1 align="center">react-use-intercom</h1> | ||
<p align="center">A React <a href="https://www.intercom.com" alt="Intercom">Intercom </a> integration powered by hooks.</p> | ||
 | ||
<p align="center"> | ||
<img alt="ci" src="https://github.com/devrnt/react-use-intercom/workflows/CI/badge.svg?branch=master"> | ||
<img alt="version" src="https://img.shields.io/npm/v/react-use-intercom.svg" /> | ||
<img alt="downloads" src="https://badgen.net/npm/dt/react-use-intercom" /> | ||
<img alt="minzipped size" src="https://badgen.net/bundlephobia/minzip/react-use-intercom"> | ||
[](https://snyk.io/test/github/devrnt/react-use-intercom) | ||
<img alt="known vulnerabilities" src="https://snyk.io/test/github/devrnt/react-use-intercom/badge.svg"> | ||
</p> | ||
A React [Intercom](https://www.intercom.com/) integration powered by hooks. | ||
## Features | ||
@@ -12,0 +14,0 @@ * Hooks |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
181580
2104
1
273