1 line
4.5 KiB
Plaintext
1 line
4.5 KiB
Plaintext
|
{"version":3,"sources":["Intercom.js"],"names":["async","user","_isWindowDefined","let","deviceInfo","await","Diagnostics","getDeviceInfoAsync","limitLengthForIntercom","e","console","error","username","intercomUserHash","api","ApiV2Client","clientForUser","getAsync","data","app_id","user_id","user_hash","_version","version","_isBooted","window","Intercom","IntercomUpdateStyle","update","trackEvent","showNewMessage","setVersionName","name","metadata","message"],"mappings":";;;;;;;;;;+BAgBOA,WAAsBC,IAAtBD,EAAmC;AACxC,QAAI;AACF,UAAIE,kBAAJ,EAAwB;AACtBC,YAAIC,aAAa,EAAjBD;;AAEA,YAAI;AACFC,uBAAaC,MAAMC,sCAAYC,kBAAZD,CAA+B;AAChDE,oCAAwB;AADwB,WAA/BF,CAAnBF;AAGF,SAJA,CAIE,OAAOK,CAAP,EAAU;AACVC,kBAAQC,KAARD,CAAcD,CAAdC;AACF;;AAEA;AACA;AACA,cAAME,WAAWX,OAAOA,KAAKW,QAAZX,GAAuB,IAAxC;AACAE,YAAIU,mBAAmB,IAAvBV;AACA,YAAIF,IAAJ,EAAU;AACR,gBAAMa,MAAMC,gCAAYC,aAAZD,CAA0Bd,IAA1Bc,CAAZ;AACA,WAAC,EAAEF,gBAAF,KAAuBR,MAAMS,IAAIG,QAAJH,CAAa,uBAAbA,CAA9B;AACF;;AAEAX,YAAIe;AACFC,kBAAQ,UADND;AAEFE,mBAASR,QAFPM;AAGFG,qBAAWR;AAHTK,WAICd,UAJDc,CAAJf;;AAOA,YAAImB,QAAJ,EAAc;AACZJ,8BACKA,IADLA;AAEEK,qBAASD;AAFXJ;AAIF;;AAEA,YAAIM,SAAJ,EAAe;AACb,cAAIZ,QAAJ,EAAc;AACZ;AACA;AACAa,mBAAOC,QAAPD,CAAgB,QAAhBA,EAA0BP,IAA1BO;AACF,WAJA,MAIO;AACL;AACAA,mBAAOC,QAAPD,CAAgB,UAAhBA;AACAA,mBAAOC,QAAPD,CAAgB,MAAhBA,EAAwBP,IAAxBO;AACF;AACF,SAVA,MAUO;AACLA,iBAAOC,QAAPD,CAAgB,MAAhBA,EAAwBP,IAAxBO;AACAD,sBAAY,IAAZA;AACF;AACAC,eAAOE,mBAAPF;AACF;AACF,KAnDA,CAmDE,OAAOhB,CAAP,EAAU;AACVC,cAAQC,KAARD,CAAcD,CAAdC;AACF;AACF,G;;kBAvDsBkB,M;;;;;QAyDNC,U,GAAAA,U;QAUAC,c,GAAAA,c;QAUAC,c,GAAAA,c;;;;AAzFhB;AAAA;AAAA;;;;AACA;AAAA;AAAA;;;;;;;;AAIA5B,IAAImB,QAAJnB;AACAA,IAAIqB,YAAY,KAAhBrB;;AAEA,SAASD,gBAAT,GAA4B;AAC1B,SAAO,OAAOuB,MAAP,KAAkB,WAAlB,IAAiCA,MAAjC,IAA2CA,OAAOC,QAAzD;AACF;;AA2DO,SAASG,UAAT,CAAoBG,IAApB,EAAkCC,QAAlC,EAAiD;AACtD,MAAI;AACF,QAAI/B,kBAAJ,EAAwB;AACtBuB,aAAOC,QAAPD,CAAgB,YAAhBA,EAA8BO,IAA9BP,EAAoCQ,QAApCR;AACF;AACF,GAJA,CAIE,OAAOhB,CAAP,EAAU;AACVC,YAAQC,KAARD,CAAcD,CAAdC;AACF;AACF;;AAEO,SAASoB,cAAT,CAAwBI,OAAxB,EAAyC;AAC9C,MAAI;AACF,QAAIhC,kBAAJ,EAAwB;AACtBuB,aAAOC,QAAPD,CAAgB,gBAAhBA,EAAkCS,OAAlCT;AACF;AACF,GAJA,CAIE,OAAOhB,CAAP,EAAU;AACVC,YAAQC,KAARD,CAAcD,CAAdC;AACF;AACF;;AAEO,SAASqB,cAAT,CAAwBC,IAAxB,EAAsC;AAC3CV,aAAWU,IAAXV;AACF","file":"../Intercom.js","sourcesContent":["/**\n * @flow\n */\n\nimport ApiV2Client from './ApiV2';\nimport * as Diagnostics from './Diagnostics';\n\nimport type { User } from './User';\n\nlet _version;\nlet _isBooted = false;\n\nfunction _isWindowDefined() {\n return typeof window !== 'undefined' && window && window.Intercom;\n}\n\nexport async function update(user: ?User) {\n try {\n if (_isWindowDefined()) {\n let deviceInfo = {};\n\n try {\n deviceInfo = await Diagnostics.getDeviceInfoAsync({\n limitLengthForIntercom: true,\n });\n } catch (e) {\n console.error(e);\n }\n\n // Fetch intercomUserHash from www in order to make sure it's\n // always fresh and generated from the correct Intercom secret.\n const username = user ? user.username : null;\n let intercomUserHash = null;\n if (user) {\n const api = ApiV2Client.clientForUser(user);\n ({ intercomUserHash } = await api.getAsync('auth/intercomUserHash'));\n }\n\n let data = {\n app_id: 'beew3st8',\n user_id: username,\n user_hash: intercomUserHash,\n ...deviceInfo,\n };\n\n if (_version) {\n data = {\n ...data,\n version: _version,\n };\n }\n\n if (_isBooted) {\n if (username) {\n // Call update so that any conversations carry over from the logged out to\n // the logged in user.\n window.Intercom('update', data);\n } else {\n // Was logged in and is now logging out, restart intercom.\n window.Intercom('shutdown');\n window.Intercom('boot', data);\n }\n } else {\n window.Intercom('boot', data);\n _isBooted = true;\n }\n window.IntercomUpdateStyle();\n }\n } catch (e) {\n console.error(e);\n }\
|