UNPKG

@dill-pixel/plugin-rollbar

Version:

Rollbar

1 lines 3 kB
{"version":3,"file":"dill-pixel-plugin-rollbar.mjs","sources":["../src/version.ts","../src/RollbarPlugin.ts"],"sourcesContent":["export const version = '6.2.3';\nexport const rollbarVersion = '2.26.4';","import { IApplication, IPlugin, isDev, Logger, Plugin } from 'dill-pixel';\nimport Rollbar from 'rollbar';\nimport { rollbarVersion, version } from './version';\n\nexport interface RollbarPluginOptions extends Rollbar.Configuration {\n isDev?: boolean;\n debug?: boolean;\n}\n\nexport interface IRollbarPlugin extends IPlugin<RollbarPluginOptions> {\n readonly rollbar: Rollbar;\n}\n\nconst defaultOptions = {\n isDev: false,\n enabled: true,\n captureUncaught: true,\n captureUnhandledRejections: true,\n debug: isDev,\n};\n\nexport class RollbarPlugin extends Plugin<RollbarPluginOptions> implements IRollbarPlugin {\n protected _options: RollbarPluginOptions;\n private _rollbar: Rollbar;\n\n get rollbar() {\n return this._rollbar;\n }\n\n private hello() {\n const hello = `%c Dill Pixel Rollbar Plugin v${version} | %cRollbar v${rollbarVersion}`;\n console.log(\n hello,\n 'background: rgba(31, 41, 55, 1);color: #74b64c',\n 'background: rgba(31, 41, 55, 1);color: #e91e63',\n 'background: rgba(31, 41, 55, 1);color: #74b64c',\n );\n\n if (this._options.debug) {\n Logger.log(this._options);\n }\n }\n\n async initialize(options: Partial<RollbarPluginOptions>, _app: IApplication) {\n this._options = {\n accessToken: _app.env.VITE_ROLLBAR_ACCESS_TOKEN || _app.env.ROLLBAR_ACCESS_TOKEN,\n ...defaultOptions,\n ...options,\n };\n\n // check if accessToken is set\n if (!this._options.accessToken) {\n throw new Error('Rollbar accessToken is required');\n }\n // TODO: should we even instantiate Rollbar here if isDev is true?\n this._rollbar = new Rollbar(this._options);\n this.hello();\n\n if (this._options.isDev) {\n Logger.warn('Rollbar is disabled in development mode');\n this._rollbar.configure({ enabled: false });\n } else {\n Logger.log('Rollbar is enabled');\n }\n }\n}\n"],"names":["version","rollbarVersion","defaultOptions","isDev","RollbarPlugin","Plugin","hello","Logger","options","_app","Rollbar"],"mappings":";;AAAO,MAAMA,IAAU,SACVC,IAAiB,UCYxBC,IAAiB;AAAA,EACrB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,OAAOC;AACT;AAEO,MAAMC,UAAsBC,EAAuD;AAAA,EAIxF,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EAAA;AAAA,EAGN,QAAQ;AACd,UAAMC,IAAQ,iCAAiCN,CAAO,iBAAiBC,CAAc;AACrF,YAAQ;AAAA,MACNK;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAGE,KAAK,SAAS,SAChBC,EAAO,IAAI,KAAK,QAAQ;AAAA,EAC1B;AAAA,EAGF,MAAM,WAAWC,GAAwCC,GAAoB;AAQ3E,QAPA,KAAK,WAAW;AAAA,MACd,aAAaA,EAAK,IAAI,6BAA6BA,EAAK,IAAI;AAAA,MAC5D,GAAGP;AAAA,MACH,GAAGM;AAAA,IAAA,GAID,CAAC,KAAK,SAAS;AACjB,YAAM,IAAI,MAAM,iCAAiC;AAGnD,SAAK,WAAW,IAAIE,EAAQ,KAAK,QAAQ,GACzC,KAAK,MAAA,GAED,KAAK,SAAS,SAChBH,EAAO,KAAK,yCAAyC,GACrD,KAAK,SAAS,UAAU,EAAE,SAAS,IAAO,KAE1CA,EAAO,IAAI,oBAAoB;AAAA,EACjC;AAEJ;"}