react-use-intercom
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -292,5 +292,5 @@ 'use strict'; | ||
ensureIntercom('update', function () { | ||
var lastRequestedAt = new Date().getTime(); | ||
var last_request_at = Math.floor(new Date().getTime() / 1000); | ||
IntercomAPI('update', { | ||
last_requested_at: lastRequestedAt | ||
last_request_at: last_request_at | ||
}); | ||
@@ -297,0 +297,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var n="undefined"==typeof window,o=function(e){if(!n&&window.Intercom){for(var t=arguments.length,o=new Array(t>1?t-1:0),a=1;a<t;a++)o[a-1]=arguments[a];return window.Intercom.apply(null,[e].concat(o))}},a=e.createContext(void 0),r=function(e){return t({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},e.customAttributes)},i=function(e){return{type:e.type,image_url:e.imageUrl}},u=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({},{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&&r(e.company),companies:null==(n=e.companies)?void 0:n.map(r)},e.customAttributes)}(e)));var n},c=["appId","autoBoot","autoBootProps","children","onHide","onShow","onUnreadCountChange","shouldInitialize","apiBase","initializeDelay"];exports.IntercomProvider=function(r){var i=r.appId,s=r.autoBoot,l=void 0!==s&&s,d=r.autoBootProps,m=r.children,f=r.onHide,p=r.onShow,h=r.onUnreadCountChange,w=r.shouldInitialize,g=void 0===w?!n:w,v=r.apiBase,b=r.initializeDelay,_=(function(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)t.indexOf(n=r[o])>=0||(a[n]=e[n])}(r,c),e.useRef(!1)),C=e.useRef(!1),y=e.useCallback((function(e){if((window.Intercom||g)&&!_.current){var n=t({app_id:i},v&&{api_base:v},e&&u(e));window.intercomSettings=n,o("boot",n),_.current=!0}}),[v,i,g]),k=e.useState(!1),I=k[0],S=k[1],E=e.useCallback((function(){S(!1),f&&f()}),[f,S]),M=e.useCallback((function(){S(!0),p&&p()}),[p,S]);n||!g||C.current||(function(e,t){void 0===t&&(t=0);var n=window,o=n.Intercom;if("function"==typeof o)o("reattach_activator"),o("update",n.intercomSettings);else{var a=document,r=function e(){e.c(arguments)};r.q=[],r.c=function(e){r.q.push(e)},n.Intercom=r;var i=function(){setTimeout((function(){var t=a.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://widget.intercom.io/widget/"+e;var n=a.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)}),t)};"complete"===document.readyState?i():n.attachEvent?n.attachEvent("onload",i):n.addEventListener("load",i,!1)}}(i,b),o("onHide",E),o("onShow",M),h&&o("onUnreadCountChange",h),l&&y(d),C.current=!0);var O=e.useCallback((function(e,t){if((window.Intercom||g)&&_.current)return t()}),[g]),A=e.useCallback((function(){_.current&&(o("shutdown"),delete window.intercomSettings,_.current=!1)}),[]),j=e.useCallback((function(){_.current&&(o("shutdown"),delete window.Intercom,delete window.intercomSettings,_.current=!1)}),[]),z=e.useCallback((function(){O("update",(function(){var e=(new Date).getTime();o("update",{last_requested_at:e})}))}),[O]),B=e.useCallback((function(e){O("update",(function(){if(e){var n=u(e);window.intercomSettings=t({},window.intercomSettings,n),o("update",n)}else z()}))}),[O,z]),P=e.useCallback((function(){O("hide",(function(){o("hide")}))}),[O]),x=e.useCallback((function(){O("show",(function(){return o("show")}))}),[O]),T=e.useCallback((function(){O("showMessages",(function(){o("showMessages")}))}),[O]),q=e.useCallback((function(e){O("showNewMessage",(function(){e?o("showNewMessage",e):o("showNewMessage")}))}),[O]),N=e.useCallback((function(){return O("getVisitorId",(function(){return o("getVisitorId")}))}),[O]),D=e.useCallback((function(e){O("startTour",(function(){o("startTour",e)}))}),[O]),H=e.useCallback((function(e,t){O("trackEvent",(function(){t?o("trackEvent",e,t):o("trackEvent",e)}))}),[O]),U=e.useCallback((function(e){return O("showArticle",(function(){o("showArticle",e)}))}),[O]),L=e.useMemo((function(){return{boot:y,shutdown:A,hardShutdown:j,update:B,hide:P,show:x,isOpen:I,showMessages:T,showNewMessage:q,getVisitorId:N,startTour:D,trackEvent:H,showArticle:U}}),[y,A,j,B,P,x,I,T,q,N,D,H,U]);return e.createElement(a.Provider,{value:L},m)},exports.useIntercom=function(){return e.useContext(a)}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var n="undefined"==typeof window,o=function(e){if(!n&&window.Intercom){for(var t=arguments.length,o=new Array(t>1?t-1:0),a=1;a<t;a++)o[a-1]=arguments[a];return window.Intercom.apply(null,[e].concat(o))}},a=e.createContext(void 0),r=function(e){return t({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},e.customAttributes)},i=function(e){return{type:e.type,image_url:e.imageUrl}},u=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({},{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&&r(e.company),companies:null==(n=e.companies)?void 0:n.map(r)},e.customAttributes)}(e)));var n},c=["appId","autoBoot","autoBootProps","children","onHide","onShow","onUnreadCountChange","shouldInitialize","apiBase","initializeDelay"];exports.IntercomProvider=function(r){var i=r.appId,s=r.autoBoot,l=void 0!==s&&s,d=r.autoBootProps,m=r.children,f=r.onHide,p=r.onShow,h=r.onUnreadCountChange,w=r.shouldInitialize,g=void 0===w?!n:w,v=r.apiBase,b=r.initializeDelay,_=(function(e,t){if(null==e)return{};var n,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)t.indexOf(n=r[o])>=0||(a[n]=e[n])}(r,c),e.useRef(!1)),C=e.useRef(!1),y=e.useCallback((function(e){if((window.Intercom||g)&&!_.current){var n=t({app_id:i},v&&{api_base:v},e&&u(e));window.intercomSettings=n,o("boot",n),_.current=!0}}),[v,i,g]),k=e.useState(!1),I=k[0],S=k[1],E=e.useCallback((function(){S(!1),f&&f()}),[f,S]),M=e.useCallback((function(){S(!0),p&&p()}),[p,S]);n||!g||C.current||(function(e,t){void 0===t&&(t=0);var n=window,o=n.Intercom;if("function"==typeof o)o("reattach_activator"),o("update",n.intercomSettings);else{var a=document,r=function e(){e.c(arguments)};r.q=[],r.c=function(e){r.q.push(e)},n.Intercom=r;var i=function(){setTimeout((function(){var t=a.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://widget.intercom.io/widget/"+e;var n=a.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)}),t)};"complete"===document.readyState?i():n.attachEvent?n.attachEvent("onload",i):n.addEventListener("load",i,!1)}}(i,b),o("onHide",E),o("onShow",M),h&&o("onUnreadCountChange",h),l&&y(d),C.current=!0);var O=e.useCallback((function(e,t){if((window.Intercom||g)&&_.current)return t()}),[g]),A=e.useCallback((function(){_.current&&(o("shutdown"),delete window.intercomSettings,_.current=!1)}),[]),j=e.useCallback((function(){_.current&&(o("shutdown"),delete window.Intercom,delete window.intercomSettings,_.current=!1)}),[]),z=e.useCallback((function(){O("update",(function(){var e=Math.floor((new Date).getTime()/1e3);o("update",{last_request_at:e})}))}),[O]),B=e.useCallback((function(e){O("update",(function(){if(e){var n=u(e);window.intercomSettings=t({},window.intercomSettings,n),o("update",n)}else z()}))}),[O,z]),P=e.useCallback((function(){O("hide",(function(){o("hide")}))}),[O]),x=e.useCallback((function(){O("show",(function(){return o("show")}))}),[O]),T=e.useCallback((function(){O("showMessages",(function(){o("showMessages")}))}),[O]),q=e.useCallback((function(e){O("showNewMessage",(function(){e?o("showNewMessage",e):o("showNewMessage")}))}),[O]),N=e.useCallback((function(){return O("getVisitorId",(function(){return o("getVisitorId")}))}),[O]),D=e.useCallback((function(e){O("startTour",(function(){o("startTour",e)}))}),[O]),H=e.useCallback((function(e,t){O("trackEvent",(function(){t?o("trackEvent",e,t):o("trackEvent",e)}))}),[O]),U=e.useCallback((function(e){return O("showArticle",(function(){o("showArticle",e)}))}),[O]),L=e.useMemo((function(){return{boot:y,shutdown:A,hardShutdown:j,update:B,hide:P,show:x,isOpen:I,showMessages:T,showNewMessage:q,getVisitorId:N,startTour:D,trackEvent:H,showArticle:U}}),[y,A,j,B,P,x,I,T,q,N,D,H,U]);return e.createElement(a.Provider,{value:L},m)},exports.useIntercom=function(){return e.useContext(a)}; | ||
//# sourceMappingURL=react-use-intercom.cjs.production.min.js.map |
@@ -288,5 +288,5 @@ import { createContext, useRef, useCallback, useState, useMemo, createElement, useContext } from 'react'; | ||
ensureIntercom('update', function () { | ||
var lastRequestedAt = new Date().getTime(); | ||
var last_request_at = Math.floor(new Date().getTime() / 1000); | ||
IntercomAPI('update', { | ||
last_requested_at: lastRequestedAt | ||
last_request_at: last_request_at | ||
}); | ||
@@ -293,0 +293,0 @@ }); |
@@ -63,3 +63,3 @@ export declare type RawMessengerAttributes = { | ||
name?: string; | ||
created_at?: string; | ||
created_at?: string | number; | ||
plan?: string; | ||
@@ -78,3 +78,3 @@ monthly_spend?: number; | ||
/** The time the company was created in your system */ | ||
createdAt?: string; | ||
createdAt?: string | number; | ||
/** The name of the plan the company is on */ | ||
@@ -113,6 +113,6 @@ plan?: string; | ||
user_id?: string; | ||
created_at?: string; | ||
created_at?: string | number; | ||
name?: string; | ||
phone?: string; | ||
last_request_at?: string; | ||
last_request_at?: string | number; | ||
unsubscribed_from_emails?: boolean; | ||
@@ -145,4 +145,6 @@ language_override?: string; | ||
* @remarks Only applicable to users | ||
* | ||
* @see {@link https://www.intercom.com/help/en/articles/3605703-how-dates-work-in-intercom} | ||
*/ | ||
createdAt?: string; | ||
createdAt?: string | number; | ||
/** Name of the current user/lead */ | ||
@@ -156,3 +158,3 @@ name?: string; | ||
*/ | ||
lastRequestAt?: string; | ||
lastRequestAt?: string | number; | ||
/** Sets the unsubscribe status of the record | ||
@@ -159,0 +161,0 @@ * |
@@ -7,3 +7,3 @@ { | ||
"homepage": "https://github.com/devrnt/react-use-intercom#readme", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "main": "dist/index.js", |
@@ -65,3 +65,3 @@ export type RawMessengerAttributes = { | ||
name?: string; | ||
created_at?: string; | ||
created_at?: string | number; | ||
plan?: string; | ||
@@ -81,3 +81,3 @@ monthly_spend?: number; | ||
/** The time the company was created in your system */ | ||
createdAt?: string; | ||
createdAt?: string | number; | ||
/** The name of the plan the company is on */ | ||
@@ -119,6 +119,6 @@ plan?: string; | ||
user_id?: string; | ||
created_at?: string; | ||
created_at?: string | number; | ||
name?: string; | ||
phone?: string; | ||
last_request_at?: string; | ||
last_request_at?: string | number; | ||
unsubscribed_from_emails?: boolean; | ||
@@ -152,4 +152,6 @@ language_override?: string; | ||
* @remarks Only applicable to users | ||
* | ||
* @see {@link https://www.intercom.com/help/en/articles/3605703-how-dates-work-in-intercom} | ||
*/ | ||
createdAt?: string; | ||
createdAt?: string | number; | ||
/** Name of the current user/lead */ | ||
@@ -163,3 +165,3 @@ name?: string; | ||
*/ | ||
lastRequestAt?: string; | ||
lastRequestAt?: string | number; | ||
/** Sets the unsubscribe status of the record | ||
@@ -166,0 +168,0 @@ * |
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
171819
2134