this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Try vite-plugin-html-config for conditional embed of script

Somehow the vite-if thing not working on vite-plugin-html-env. Leaving it installed since the ENV thing works.

+454 -383
-379
index.html
··· 28 28 content="#242526" 29 29 media="(prefers-color-scheme: dark)" 30 30 /> 31 - <script vite-if="import.meta.env.VITE_APP_ENV === production"> 32 - var isDev = /dev\./.test(window.location.hostname); 33 - var _rollbarConfig = { 34 - accessToken: 'ec3e07829d324a29abf6c83472a9740d', 35 - captureUncaught: true, 36 - captureUnhandledRejections: true, 37 - enabled: isDev, 38 - hostSafeList: ['dev.phanpy.social', 'phanpy.social'], 39 - payload: { 40 - environment: isDev ? 'development' : 'production', 41 - }, 42 - }; 43 - // Rollbar Snippet 44 - !(function (r) { 45 - function e(n) { 46 - if (o[n]) return o[n].exports; 47 - var t = (o[n] = { exports: {}, id: n, loaded: !1 }); 48 - return ( 49 - r[n].call(t.exports, t, t.exports, e), (t.loaded = !0), t.exports 50 - ); 51 - } 52 - var o = {}; 53 - return (e.m = r), (e.c = o), (e.p = ''), e(0); 54 - })([ 55 - function (r, e, o) { 56 - 'use strict'; 57 - var n = o(1), 58 - t = o(4); 59 - (_rollbarConfig = _rollbarConfig || {}), 60 - (_rollbarConfig.rollbarJsUrl = 61 - _rollbarConfig.rollbarJsUrl || 62 - 'https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/2.4.6/rollbar.min.js'), 63 - (_rollbarConfig.async = 64 - void 0 === _rollbarConfig.async || _rollbarConfig.async); 65 - var a = n.setupShim(window, _rollbarConfig), 66 - l = t(_rollbarConfig); 67 - (window.rollbar = n.Rollbar), 68 - a.loadFull( 69 - window, 70 - document, 71 - !_rollbarConfig.async, 72 - _rollbarConfig, 73 - l, 74 - ); 75 - }, 76 - function (r, e, o) { 77 - 'use strict'; 78 - function n(r) { 79 - return function () { 80 - try { 81 - return r.apply(this, arguments); 82 - } catch (r) { 83 - try { 84 - console.error('[Rollbar]: Internal error', r); 85 - } catch (r) {} 86 - } 87 - }; 88 - } 89 - function t(r, e) { 90 - (this.options = r), (this._rollbarOldOnError = null); 91 - var o = s++; 92 - (this.shimId = function () { 93 - return o; 94 - }), 95 - 'undefined' != typeof window && 96 - window._rollbarShims && 97 - (window._rollbarShims[o] = { handler: e, messages: [] }); 98 - } 99 - function a(r, e) { 100 - if (r) { 101 - var o = e.globalAlias || 'Rollbar'; 102 - if ('object' == typeof r[o]) return r[o]; 103 - (r._rollbarShims = {}), (r._rollbarWrappedError = null); 104 - var t = new p(e); 105 - return n(function () { 106 - e.captureUncaught && 107 - ((t._rollbarOldOnError = r.onerror), 108 - i.captureUncaughtExceptions(r, t, !0), 109 - i.wrapGlobals(r, t, !0)), 110 - e.captureUnhandledRejections && 111 - i.captureUnhandledRejections(r, t, !0); 112 - var n = e.autoInstrument; 113 - return ( 114 - e.enabled !== !1 && 115 - (void 0 === n || 116 - n === !0 || 117 - ('object' == typeof n && n.network)) && 118 - r.addEventListener && 119 - (r.addEventListener('load', t.captureLoad.bind(t)), 120 - r.addEventListener( 121 - 'DOMContentLoaded', 122 - t.captureDomContentLoaded.bind(t), 123 - )), 124 - (r[o] = t), 125 - t 126 - ); 127 - })(); 128 - } 129 - } 130 - function l(r) { 131 - return n(function () { 132 - var e = this, 133 - o = Array.prototype.slice.call(arguments, 0), 134 - n = { shim: e, method: r, args: o, ts: new Date() }; 135 - window._rollbarShims[this.shimId()].messages.push(n); 136 - }); 137 - } 138 - var i = o(2), 139 - s = 0, 140 - d = o(3), 141 - c = function (r, e) { 142 - return new t(r, e); 143 - }, 144 - p = d.bind(null, c); 145 - (t.prototype.loadFull = function (r, e, o, t, a) { 146 - var l = function () { 147 - var e; 148 - if (void 0 === r._rollbarDidLoad) { 149 - e = new Error('rollbar.js did not load'); 150 - for (var o, n, t, l, i = 0; (o = r._rollbarShims[i++]); ) 151 - for (o = o.messages || []; (n = o.shift()); ) 152 - for (t = n.args || [], i = 0; i < t.length; ++i) 153 - if (((l = t[i]), 'function' == typeof l)) { 154 - l(e); 155 - break; 156 - } 157 - } 158 - 'function' == typeof a && a(e); 159 - }, 160 - i = !1, 161 - s = e.createElement('script'), 162 - d = e.getElementsByTagName('script')[0], 163 - c = d.parentNode; 164 - (s.crossOrigin = ''), 165 - (s.src = t.rollbarJsUrl), 166 - o || (s.async = !0), 167 - (s.onload = s.onreadystatechange = 168 - n(function () { 169 - if ( 170 - !( 171 - i || 172 - (this.readyState && 173 - 'loaded' !== this.readyState && 174 - 'complete' !== this.readyState) 175 - ) 176 - ) { 177 - s.onload = s.onreadystatechange = null; 178 - try { 179 - c.removeChild(s); 180 - } catch (r) {} 181 - (i = !0), l(); 182 - } 183 - })), 184 - c.insertBefore(s, d); 185 - }), 186 - (t.prototype.wrap = function (r, e, o) { 187 - try { 188 - var n; 189 - if ( 190 - ((n = 191 - 'function' == typeof e 192 - ? e 193 - : function () { 194 - return e || {}; 195 - }), 196 - 'function' != typeof r) 197 - ) 198 - return r; 199 - if (r._isWrap) return r; 200 - if ( 201 - !r._rollbar_wrapped && 202 - ((r._rollbar_wrapped = function () { 203 - o && 'function' == typeof o && o.apply(this, arguments); 204 - try { 205 - return r.apply(this, arguments); 206 - } catch (o) { 207 - var e = o; 208 - throw ( 209 - (e && 210 - ('string' == typeof e && (e = new String(e)), 211 - (e._rollbarContext = n() || {}), 212 - (e._rollbarContext._wrappedSource = r.toString()), 213 - (window._rollbarWrappedError = e)), 214 - e) 215 - ); 216 - } 217 - }), 218 - (r._rollbar_wrapped._isWrap = !0), 219 - r.hasOwnProperty) 220 - ) 221 - for (var t in r) 222 - r.hasOwnProperty(t) && (r._rollbar_wrapped[t] = r[t]); 223 - return r._rollbar_wrapped; 224 - } catch (e) { 225 - return r; 226 - } 227 - }); 228 - for ( 229 - var u = 230 - 'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad'.split( 231 - ',', 232 - ), 233 - f = 0; 234 - f < u.length; 235 - ++f 236 - ) 237 - t.prototype[u[f]] = l(u[f]); 238 - r.exports = { setupShim: a, Rollbar: p }; 239 - }, 240 - function (r, e) { 241 - 'use strict'; 242 - function o(r, e, o) { 243 - if (r) { 244 - var t; 245 - 'function' == typeof e._rollbarOldOnError 246 - ? (t = e._rollbarOldOnError) 247 - : r.onerror && 248 - !r.onerror.belongsToShim && 249 - ((t = r.onerror), (e._rollbarOldOnError = t)); 250 - var a = function () { 251 - var o = Array.prototype.slice.call(arguments, 0); 252 - n(r, e, t, o); 253 - }; 254 - (a.belongsToShim = o), (r.onerror = a); 255 - } 256 - } 257 - function n(r, e, o, n) { 258 - r._rollbarWrappedError && 259 - (n[4] || (n[4] = r._rollbarWrappedError), 260 - n[5] || (n[5] = r._rollbarWrappedError._rollbarContext), 261 - (r._rollbarWrappedError = null)), 262 - e.handleUncaughtException.apply(e, n), 263 - o && o.apply(r, n); 264 - } 265 - function t(r, e, o) { 266 - if (r) { 267 - 'function' == typeof r._rollbarURH && 268 - r._rollbarURH.belongsToShim && 269 - r.removeEventListener('unhandledrejection', r._rollbarURH); 270 - var n = function (r) { 271 - var o, n, t; 272 - try { 273 - o = r.reason; 274 - } catch (r) { 275 - o = void 0; 276 - } 277 - try { 278 - n = r.promise; 279 - } catch (r) { 280 - n = '[unhandledrejection] error getting `promise` from event'; 281 - } 282 - try { 283 - (t = r.detail), !o && t && ((o = t.reason), (n = t.promise)); 284 - } catch (r) { 285 - t = '[unhandledrejection] error getting `detail` from event'; 286 - } 287 - o || 288 - (o = 289 - '[unhandledrejection] error getting `reason` from event'), 290 - e && 291 - e.handleUnhandledRejection && 292 - e.handleUnhandledRejection(o, n); 293 - }; 294 - (n.belongsToShim = o), 295 - (r._rollbarURH = n), 296 - r.addEventListener('unhandledrejection', n); 297 - } 298 - } 299 - function a(r, e, o) { 300 - if (r) { 301 - var n, 302 - t, 303 - a = 304 - 'EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split( 305 - ',', 306 - ); 307 - for (n = 0; n < a.length; ++n) 308 - (t = a[n]), r[t] && r[t].prototype && l(e, r[t].prototype, o); 309 - } 310 - } 311 - function l(r, e, o) { 312 - if (e.hasOwnProperty && e.hasOwnProperty('addEventListener')) { 313 - for ( 314 - var n = e.addEventListener; 315 - n._rollbarOldAdd && n.belongsToShim; 316 - 317 - ) 318 - n = n._rollbarOldAdd; 319 - var t = function (e, o, t) { 320 - n.call(this, e, r.wrap(o), t); 321 - }; 322 - (t._rollbarOldAdd = n), 323 - (t.belongsToShim = o), 324 - (e.addEventListener = t); 325 - for ( 326 - var a = e.removeEventListener; 327 - a._rollbarOldRemove && a.belongsToShim; 328 - 329 - ) 330 - a = a._rollbarOldRemove; 331 - var l = function (r, e, o) { 332 - a.call(this, r, (e && e._rollbar_wrapped) || e, o); 333 - }; 334 - (l._rollbarOldRemove = a), 335 - (l.belongsToShim = o), 336 - (e.removeEventListener = l); 337 - } 338 - } 339 - r.exports = { 340 - captureUncaughtExceptions: o, 341 - captureUnhandledRejections: t, 342 - wrapGlobals: a, 343 - }; 344 - }, 345 - function (r, e) { 346 - 'use strict'; 347 - function o(r, e) { 348 - (this.impl = r(e, this)), (this.options = e), n(o.prototype); 349 - } 350 - function n(r) { 351 - for ( 352 - var e = function (r) { 353 - return function () { 354 - var e = Array.prototype.slice.call(arguments, 0); 355 - if (this.impl[r]) return this.impl[r].apply(this.impl, e); 356 - }; 357 - }, 358 - o = 359 - 'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad'.split( 360 - ',', 361 - ), 362 - n = 0; 363 - n < o.length; 364 - n++ 365 - ) 366 - r[o[n]] = e(o[n]); 367 - } 368 - (o.prototype._swapAndProcessMessages = function (r, e) { 369 - this.impl = r(this.options); 370 - for (var o, n, t; (o = e.shift()); ) 371 - (n = o.method), 372 - (t = o.args), 373 - this[n] && 374 - 'function' == typeof this[n] && 375 - ('captureDomContentLoaded' === n || 'captureLoad' === n 376 - ? this[n].apply(this, [t[0], o.ts]) 377 - : this[n].apply(this, t)); 378 - return this; 379 - }), 380 - (r.exports = o); 381 - }, 382 - function (r, e) { 383 - 'use strict'; 384 - r.exports = function (r) { 385 - return function (e) { 386 - if (!e && !window._rollbarInitialized) { 387 - r = r || {}; 388 - for ( 389 - var o, 390 - n, 391 - t = r.globalAlias || 'Rollbar', 392 - a = window.rollbar, 393 - l = function (r) { 394 - return new a(r); 395 - }, 396 - i = 0; 397 - (o = window._rollbarShims[i++]); 398 - 399 - ) 400 - n || (n = o.handler), 401 - o.handler._swapAndProcessMessages(l, o.messages); 402 - (window[t] = n), (window._rollbarInitialized = !0); 403 - } 404 - }; 405 - }; 406 - }, 407 - ]); 408 - // End Rollbar Snippet 409 - </script> 410 31 </head> 411 32 <body> 412 33 <div id="app"></div>
+20
package-lock.json
··· 32 32 "postcss-dark-theme-class": "~0.7.3", 33 33 "twitter-text": "~3.1.0", 34 34 "vite": "~4.0.3", 35 + "vite-plugin-html-config": "~1.0.11", 35 36 "vite-plugin-html-env": "~1.2.7", 36 37 "vite-plugin-pwa": "~0.14.0", 37 38 "workbox-cacheable-response": "~6.5.4", ··· 5407 5408 } 5408 5409 } 5409 5410 }, 5411 + "node_modules/vite-plugin-html-config": { 5412 + "version": "1.0.11", 5413 + "resolved": "https://registry.npmjs.org/vite-plugin-html-config/-/vite-plugin-html-config-1.0.11.tgz", 5414 + "integrity": "sha512-hUybhgI+/LQQ5q6xoMMsTvI4PBuQD/Wv6Z1vtDPVWjanS8weCIexXuLLYNGD/93f0v8W2hpNfXpmxgpZMahJ0g==", 5415 + "dev": true, 5416 + "engines": { 5417 + "node": ">=12.0.0" 5418 + }, 5419 + "peerDependencies": { 5420 + "vite": ">=2.0.0" 5421 + } 5422 + }, 5410 5423 "node_modules/vite-plugin-html-env": { 5411 5424 "version": "1.2.7", 5412 5425 "resolved": "https://registry.npmjs.org/vite-plugin-html-env/-/vite-plugin-html-env-1.2.7.tgz", ··· 9609 9622 "resolve": "^1.22.1", 9610 9623 "rollup": "^3.7.0" 9611 9624 } 9625 + }, 9626 + "vite-plugin-html-config": { 9627 + "version": "1.0.11", 9628 + "resolved": "https://registry.npmjs.org/vite-plugin-html-config/-/vite-plugin-html-config-1.0.11.tgz", 9629 + "integrity": "sha512-hUybhgI+/LQQ5q6xoMMsTvI4PBuQD/Wv6Z1vtDPVWjanS8weCIexXuLLYNGD/93f0v8W2hpNfXpmxgpZMahJ0g==", 9630 + "dev": true, 9631 + "requires": {} 9612 9632 }, 9613 9633 "vite-plugin-html-env": { 9614 9634 "version": "1.2.7",
+1
package.json
··· 34 34 "postcss-dark-theme-class": "~0.7.3", 35 35 "twitter-text": "~3.1.0", 36 36 "vite": "~4.0.3", 37 + "vite-plugin-html-config": "~1.0.11", 37 38 "vite-plugin-html-env": "~1.2.7", 38 39 "vite-plugin-pwa": "~0.14.0", 39 40 "workbox-cacheable-response": "~6.5.4",
+418
rollbar.js
··· 1 + var isDev = /dev\./.test(window.location.hostname); 2 + var _rollbarConfig = { 3 + accessToken: 'ec3e07829d324a29abf6c83472a9740d', 4 + captureUncaught: true, 5 + captureUnhandledRejections: true, 6 + enabled: isDev, 7 + hostSafeList: ['dev.phanpy.social', 'phanpy.social'], 8 + payload: { 9 + environment: isDev ? 'development' : 'production', 10 + }, 11 + }; 12 + 13 + // Rollbar Snippet 14 + !(function (r) { 15 + var e = {}; 16 + function o(n) { 17 + if (e[n]) return e[n].exports; 18 + var t = (e[n] = { i: n, l: !1, exports: {} }); 19 + return r[n].call(t.exports, t, t.exports, o), (t.l = !0), t.exports; 20 + } 21 + (o.m = r), 22 + (o.c = e), 23 + (o.d = function (r, e, n) { 24 + o.o(r, e) || Object.defineProperty(r, e, { enumerable: !0, get: n }); 25 + }), 26 + (o.r = function (r) { 27 + 'undefined' != typeof Symbol && 28 + Symbol.toStringTag && 29 + Object.defineProperty(r, Symbol.toStringTag, { value: 'Module' }), 30 + Object.defineProperty(r, '__esModule', { value: !0 }); 31 + }), 32 + (o.t = function (r, e) { 33 + if ((1 & e && (r = o(r)), 8 & e)) return r; 34 + if (4 & e && 'object' == typeof r && r && r.__esModule) return r; 35 + var n = Object.create(null); 36 + if ( 37 + (o.r(n), 38 + Object.defineProperty(n, 'default', { enumerable: !0, value: r }), 39 + 2 & e && 'string' != typeof r) 40 + ) 41 + for (var t in r) 42 + o.d( 43 + n, 44 + t, 45 + function (e) { 46 + return r[e]; 47 + }.bind(null, t), 48 + ); 49 + return n; 50 + }), 51 + (o.n = function (r) { 52 + var e = 53 + r && r.__esModule 54 + ? function () { 55 + return r.default; 56 + } 57 + : function () { 58 + return r; 59 + }; 60 + return o.d(e, 'a', e), e; 61 + }), 62 + (o.o = function (r, e) { 63 + return Object.prototype.hasOwnProperty.call(r, e); 64 + }), 65 + (o.p = ''), 66 + o((o.s = 0)); 67 + })([ 68 + function (r, e, o) { 69 + 'use strict'; 70 + var n = o(1), 71 + t = o(5); 72 + (_rollbarConfig = _rollbarConfig || {}), 73 + (_rollbarConfig.rollbarJsUrl = 74 + _rollbarConfig.rollbarJsUrl || 75 + 'https://cdn.rollbar.com/rollbarjs/refs/tags/v2.26.0/rollbar.min.js'), 76 + (_rollbarConfig.async = 77 + void 0 === _rollbarConfig.async || _rollbarConfig.async); 78 + var a = n.setupShim(window, _rollbarConfig), 79 + l = t(_rollbarConfig); 80 + (window.rollbar = n.Rollbar), 81 + a.loadFull(window, document, !_rollbarConfig.async, _rollbarConfig, l); 82 + }, 83 + function (r, e, o) { 84 + 'use strict'; 85 + var n = o(2), 86 + t = o(3); 87 + function a(r) { 88 + return function () { 89 + try { 90 + return r.apply(this, arguments); 91 + } catch (r) { 92 + try { 93 + console.error('[Rollbar]: Internal error', r); 94 + } catch (r) {} 95 + } 96 + }; 97 + } 98 + var l = 0; 99 + function i(r, e) { 100 + (this.options = r), (this._rollbarOldOnError = null); 101 + var o = l++; 102 + (this.shimId = function () { 103 + return o; 104 + }), 105 + 'undefined' != typeof window && 106 + window._rollbarShims && 107 + (window._rollbarShims[o] = { handler: e, messages: [] }); 108 + } 109 + var s = o(4), 110 + d = function (r, e) { 111 + return new i(r, e); 112 + }, 113 + c = function (r) { 114 + return new s(d, r); 115 + }; 116 + function u(r) { 117 + return a(function () { 118 + var e = this, 119 + o = Array.prototype.slice.call(arguments, 0), 120 + n = { shim: e, method: r, args: o, ts: new Date() }; 121 + window._rollbarShims[this.shimId()].messages.push(n); 122 + }); 123 + } 124 + (i.prototype.loadFull = function (r, e, o, n, t) { 125 + var l = !1, 126 + i = e.createElement('script'), 127 + s = e.getElementsByTagName('script')[0], 128 + d = s.parentNode; 129 + (i.crossOrigin = ''), 130 + (i.src = n.rollbarJsUrl), 131 + o || (i.async = !0), 132 + (i.onload = i.onreadystatechange = 133 + a(function () { 134 + if ( 135 + !( 136 + l || 137 + (this.readyState && 138 + 'loaded' !== this.readyState && 139 + 'complete' !== this.readyState) 140 + ) 141 + ) { 142 + i.onload = i.onreadystatechange = null; 143 + try { 144 + d.removeChild(i); 145 + } catch (r) {} 146 + (l = !0), 147 + (function () { 148 + var e; 149 + if (void 0 === r._rollbarDidLoad) { 150 + e = new Error('rollbar.js did not load'); 151 + for (var o, n, a, l, i = 0; (o = r._rollbarShims[i++]); ) 152 + for (o = o.messages || []; (n = o.shift()); ) 153 + for (a = n.args || [], i = 0; i < a.length; ++i) 154 + if ('function' == typeof (l = a[i])) { 155 + l(e); 156 + break; 157 + } 158 + } 159 + 'function' == typeof t && t(e); 160 + })(); 161 + } 162 + })), 163 + d.insertBefore(i, s); 164 + }), 165 + (i.prototype.wrap = function (r, e, o) { 166 + try { 167 + var n; 168 + if ( 169 + ((n = 170 + 'function' == typeof e 171 + ? e 172 + : function () { 173 + return e || {}; 174 + }), 175 + 'function' != typeof r) 176 + ) 177 + return r; 178 + if (r._isWrap) return r; 179 + if ( 180 + !r._rollbar_wrapped && 181 + ((r._rollbar_wrapped = function () { 182 + o && 'function' == typeof o && o.apply(this, arguments); 183 + try { 184 + return r.apply(this, arguments); 185 + } catch (o) { 186 + var e = o; 187 + throw ( 188 + (e && 189 + ('string' == typeof e && (e = new String(e)), 190 + (e._rollbarContext = n() || {}), 191 + (e._rollbarContext._wrappedSource = r.toString()), 192 + (window._rollbarWrappedError = e)), 193 + e) 194 + ); 195 + } 196 + }), 197 + (r._rollbar_wrapped._isWrap = !0), 198 + r.hasOwnProperty) 199 + ) 200 + for (var t in r) 201 + r.hasOwnProperty(t) && (r._rollbar_wrapped[t] = r[t]); 202 + return r._rollbar_wrapped; 203 + } catch (e) { 204 + return r; 205 + } 206 + }); 207 + for ( 208 + var p = 209 + 'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,captureEvent,captureDomContentLoaded,captureLoad'.split( 210 + ',', 211 + ), 212 + f = 0; 213 + f < p.length; 214 + ++f 215 + ) 216 + i.prototype[p[f]] = u(p[f]); 217 + r.exports = { 218 + setupShim: function (r, e) { 219 + if (r) { 220 + var o = e.globalAlias || 'Rollbar'; 221 + if ('object' == typeof r[o]) return r[o]; 222 + (r._rollbarShims = {}), (r._rollbarWrappedError = null); 223 + var l = new c(e); 224 + return a(function () { 225 + e.captureUncaught && 226 + ((l._rollbarOldOnError = r.onerror), 227 + n.captureUncaughtExceptions(r, l, !0), 228 + e.wrapGlobalEventHandlers && t(r, l, !0)), 229 + e.captureUnhandledRejections && 230 + n.captureUnhandledRejections(r, l, !0); 231 + var a = e.autoInstrument; 232 + return ( 233 + !1 !== e.enabled && 234 + (void 0 === a || 235 + !0 === a || 236 + (function (r) { 237 + return !( 238 + 'object' != typeof r || 239 + (void 0 !== r.page && !r.page) 240 + ); 241 + })(a)) && 242 + r.addEventListener && 243 + (r.addEventListener('load', l.captureLoad.bind(l)), 244 + r.addEventListener( 245 + 'DOMContentLoaded', 246 + l.captureDomContentLoaded.bind(l), 247 + )), 248 + (r[o] = l), 249 + l 250 + ); 251 + })(); 252 + } 253 + }, 254 + Rollbar: c, 255 + }; 256 + }, 257 + function (r, e, o) { 258 + 'use strict'; 259 + function n(r, e, o, n) { 260 + r._rollbarWrappedError && 261 + (n[4] || (n[4] = r._rollbarWrappedError), 262 + n[5] || (n[5] = r._rollbarWrappedError._rollbarContext), 263 + (r._rollbarWrappedError = null)); 264 + var t = e.handleUncaughtException.apply(e, n); 265 + o && o.apply(r, n), 'anonymous' === t && (e.anonymousErrorsPending += 1); 266 + } 267 + r.exports = { 268 + captureUncaughtExceptions: function (r, e, o) { 269 + if (r) { 270 + var t; 271 + if ('function' == typeof e._rollbarOldOnError) 272 + t = e._rollbarOldOnError; 273 + else if (r.onerror) { 274 + for (t = r.onerror; t._rollbarOldOnError; ) 275 + t = t._rollbarOldOnError; 276 + e._rollbarOldOnError = t; 277 + } 278 + e.handleAnonymousErrors(); 279 + var a = function () { 280 + var o = Array.prototype.slice.call(arguments, 0); 281 + n(r, e, t, o); 282 + }; 283 + o && (a._rollbarOldOnError = t), (r.onerror = a); 284 + } 285 + }, 286 + captureUnhandledRejections: function (r, e, o) { 287 + if (r) { 288 + 'function' == typeof r._rollbarURH && 289 + r._rollbarURH.belongsToShim && 290 + r.removeEventListener('unhandledrejection', r._rollbarURH); 291 + var n = function (r) { 292 + var o, n, t; 293 + try { 294 + o = r.reason; 295 + } catch (r) { 296 + o = void 0; 297 + } 298 + try { 299 + n = r.promise; 300 + } catch (r) { 301 + n = '[unhandledrejection] error getting `promise` from event'; 302 + } 303 + try { 304 + (t = r.detail), !o && t && ((o = t.reason), (n = t.promise)); 305 + } catch (r) {} 306 + o || (o = '[unhandledrejection] error getting `reason` from event'), 307 + e && 308 + e.handleUnhandledRejection && 309 + e.handleUnhandledRejection(o, n); 310 + }; 311 + (n.belongsToShim = o), 312 + (r._rollbarURH = n), 313 + r.addEventListener('unhandledrejection', n); 314 + } 315 + }, 316 + }; 317 + }, 318 + function (r, e, o) { 319 + 'use strict'; 320 + function n(r, e, o) { 321 + if (e.hasOwnProperty && e.hasOwnProperty('addEventListener')) { 322 + for (var n = e.addEventListener; n._rollbarOldAdd && n.belongsToShim; ) 323 + n = n._rollbarOldAdd; 324 + var t = function (e, o, t) { 325 + n.call(this, e, r.wrap(o), t); 326 + }; 327 + (t._rollbarOldAdd = n), (t.belongsToShim = o), (e.addEventListener = t); 328 + for ( 329 + var a = e.removeEventListener; 330 + a._rollbarOldRemove && a.belongsToShim; 331 + 332 + ) 333 + a = a._rollbarOldRemove; 334 + var l = function (r, e, o) { 335 + a.call(this, r, (e && e._rollbar_wrapped) || e, o); 336 + }; 337 + (l._rollbarOldRemove = a), 338 + (l.belongsToShim = o), 339 + (e.removeEventListener = l); 340 + } 341 + } 342 + r.exports = function (r, e, o) { 343 + if (r) { 344 + var t, 345 + a, 346 + l = 347 + 'EventTarget,Window,Node,ApplicationCache,AudioTrackList,ChannelMergerNode,CryptoOperation,EventSource,FileReader,HTMLUnknownElement,IDBDatabase,IDBRequest,IDBTransaction,KeyOperation,MediaController,MessagePort,ModalWindow,Notification,SVGElementInstance,Screen,TextTrack,TextTrackCue,TextTrackList,WebSocket,WebSocketWorker,Worker,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split( 348 + ',', 349 + ); 350 + for (t = 0; t < l.length; ++t) 351 + r[(a = l[t])] && r[a].prototype && n(e, r[a].prototype, o); 352 + } 353 + }; 354 + }, 355 + function (r, e, o) { 356 + 'use strict'; 357 + function n(r, e) { 358 + (this.impl = r(e, this)), 359 + (this.options = e), 360 + (function (r) { 361 + for ( 362 + var e = function (r) { 363 + return function () { 364 + var e = Array.prototype.slice.call(arguments, 0); 365 + if (this.impl[r]) return this.impl[r].apply(this.impl, e); 366 + }; 367 + }, 368 + o = 369 + 'log,debug,info,warn,warning,error,critical,global,configure,handleUncaughtException,handleAnonymousErrors,handleUnhandledRejection,_createItem,wrap,loadFull,shimId,captureEvent,captureDomContentLoaded,captureLoad'.split( 370 + ',', 371 + ), 372 + n = 0; 373 + n < o.length; 374 + n++ 375 + ) 376 + r[o[n]] = e(o[n]); 377 + })(n.prototype); 378 + } 379 + (n.prototype._swapAndProcessMessages = function (r, e) { 380 + var o, n, t; 381 + for (this.impl = r(this.options); (o = e.shift()); ) 382 + (n = o.method), 383 + (t = o.args), 384 + this[n] && 385 + 'function' == typeof this[n] && 386 + ('captureDomContentLoaded' === n || 'captureLoad' === n 387 + ? this[n].apply(this, [t[0], o.ts]) 388 + : this[n].apply(this, t)); 389 + return this; 390 + }), 391 + (r.exports = n); 392 + }, 393 + function (r, e, o) { 394 + 'use strict'; 395 + r.exports = function (r) { 396 + return function (e) { 397 + if (!e && !window._rollbarInitialized) { 398 + for ( 399 + var o, 400 + n, 401 + t = (r = r || {}).globalAlias || 'Rollbar', 402 + a = window.rollbar, 403 + l = function (r) { 404 + return new a(r); 405 + }, 406 + i = 0; 407 + (o = window._rollbarShims[i++]); 408 + 409 + ) 410 + n || (n = o.handler), 411 + o.handler._swapAndProcessMessages(l, o.messages); 412 + (window[t] = n), (window._rollbarInitialized = !0); 413 + } 414 + }; 415 + }; 416 + }, 417 + ]); 418 + // End Rollbar Snippet
+15 -4
vite.config.js
··· 1 1 import preact from '@preact/preset-vite'; 2 2 import { execSync } from 'child_process'; 3 + import fs from 'fs'; 3 4 import { resolve } from 'path'; 4 5 import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'; 6 + import htmlPlugin from 'vite-plugin-html-config'; 5 7 import VitePluginHtmlEnv from 'vite-plugin-html-env'; 6 8 import { VitePWA } from 'vite-plugin-pwa'; 7 9 8 - const { VITE_CLIENT_NAME: CLIENT_NAME, NODE_ENV } = loadEnv( 9 - 'production', 10 - process.cwd(), 11 - ); 10 + const { 11 + VITE_CLIENT_NAME: CLIENT_NAME, 12 + NODE_ENV, 13 + VITE_APP_ERROR_LOGGING, 14 + } = loadEnv('production', process.cwd()); 12 15 13 16 const commitHash = execSync('git rev-parse --short HEAD').toString().trim(); 17 + 18 + const rollbarCode = fs.readFileSync( 19 + resolve(__dirname, './rollbar.js'), 20 + 'utf-8', 21 + ); 14 22 15 23 // https://vitejs.dev/config/ 16 24 export default defineConfig({ ··· 23 31 preact(), 24 32 splitVendorChunkPlugin(), 25 33 VitePluginHtmlEnv(), 34 + htmlPlugin({ 35 + headScripts: VITE_APP_ERROR_LOGGING ? [rollbarCode] : [], 36 + }), 26 37 VitePWA({ 27 38 manifest: { 28 39 name: CLIENT_NAME,