@caperjs/plugin-rollbar 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/lib/RollbarPlugin.d.ts +17 -0
- package/lib/RollbarPlugin.d.ts.map +1 -0
- package/lib/caper-plugin-rollbar.mjs +30 -0
- package/lib/caper-plugin-rollbar.mjs.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/version.d.ts +3 -0
- package/lib/version.d.ts.map +1 -0
- package/package.json +42 -0
- package/src/RollbarPlugin.ts +66 -0
- package/src/index.ts +5 -0
- package/src/version.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Relish Interactive
|
|
4
|
+
Copyright (c) 2026 Anthony Sapp
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IApplication, IPlugin, Plugin } from '@caperjs/core';
|
|
2
|
+
import { default as Rollbar } from 'rollbar';
|
|
3
|
+
export interface RollbarPluginOptions extends Rollbar.Configuration {
|
|
4
|
+
isDev?: boolean;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface IRollbarPlugin extends IPlugin<RollbarPluginOptions> {
|
|
8
|
+
readonly rollbar: Rollbar;
|
|
9
|
+
}
|
|
10
|
+
export declare class RollbarPlugin extends Plugin<RollbarPluginOptions> implements IRollbarPlugin {
|
|
11
|
+
protected _options: RollbarPluginOptions;
|
|
12
|
+
private _rollbar;
|
|
13
|
+
get rollbar(): Rollbar;
|
|
14
|
+
private hello;
|
|
15
|
+
initialize(options: Partial<RollbarPluginOptions>, _app: IApplication): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=RollbarPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RollbarPlugin.d.ts","sourceRoot":"","sources":["../src/RollbarPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAAM,WAAW,oBAAqB,SAAQ,OAAO,CAAC,aAAa;IACjE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,OAAO,CAAC,oBAAoB,CAAC;IACnE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAUD,qBAAa,aAAc,SAAQ,MAAM,CAAC,oBAAoB,CAAE,YAAW,cAAc;IACvF,SAAS,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACzC,OAAO,CAAC,QAAQ,CAAU;IAE1B,IAAI,OAAO,YAEV;IAED,OAAO,CAAC,KAAK;IAcP,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,IAAI,EAAE,YAAY;CAsB5E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Logger as e, Plugin as t, isDev as n } from "@caperjs/core";
|
|
2
|
+
import r from "rollbar";
|
|
3
|
+
//#region src/version.ts
|
|
4
|
+
var i = "0.1.0", a = "2.26.4", o = {
|
|
5
|
+
isDev: !1,
|
|
6
|
+
enabled: !0,
|
|
7
|
+
captureUncaught: !0,
|
|
8
|
+
captureUnhandledRejections: !0,
|
|
9
|
+
debug: n
|
|
10
|
+
}, s = class extends t {
|
|
11
|
+
get rollbar() {
|
|
12
|
+
return this._rollbar;
|
|
13
|
+
}
|
|
14
|
+
hello() {
|
|
15
|
+
let t = `%c Caper Rollbar Plugin v${i} | %cRollbar v${a}`;
|
|
16
|
+
console.log(t, "background: rgba(31, 41, 55, 1);color: #74b64c", "background: rgba(31, 41, 55, 1);color: #e91e63", "background: rgba(31, 41, 55, 1);color: #74b64c"), this._options.debug && e.log(this._options);
|
|
17
|
+
}
|
|
18
|
+
async initialize(t, n) {
|
|
19
|
+
if (this._options = {
|
|
20
|
+
accessToken: n.env.VITE_ROLLBAR_ACCESS_TOKEN || n.env.ROLLBAR_ACCESS_TOKEN,
|
|
21
|
+
...o,
|
|
22
|
+
...t
|
|
23
|
+
}, !this._options.accessToken) throw Error("Rollbar accessToken is required");
|
|
24
|
+
this._rollbar = new r(this._options), this.hello(), this._options.isDev ? (e.warn("Rollbar is disabled in development mode"), this._rollbar.configure({ enabled: !1 })) : e.log("Rollbar is enabled");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { s as default };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=caper-plugin-rollbar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caper-plugin-rollbar.mjs","names":[],"sources":["../src/version.ts","../src/RollbarPlugin.ts","../src/index.ts"],"sourcesContent":["export const version = '0.1.0';\nexport const rollbarVersion = '2.26.4';","import { IApplication, IPlugin, isDev, Logger, Plugin } from '@caperjs/core';\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 Caper 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","import { RollbarPlugin } from './RollbarPlugin';\n\nexport type { IRollbarPlugin, RollbarPluginOptions } from './RollbarPlugin';\n\nexport default RollbarPlugin;\n"],"mappings":";;;AAAA,IAAa,IAAU,SACV,IAAiB,UCYxB,IAAiB;CACrB,OAAO;CACP,SAAS;CACT,iBAAiB;CACjB,4BAA4B;CAC5B,OAAO;CACR,ECfD,IDiBA,cAAmC,EAAuD;CAIxF,IAAI,UAAU;AACZ,SAAO,KAAK;;CAGd,QAAgB;EACd,IAAM,IAAQ,4BAA4B,EAAQ,gBAAgB;AAQlE,EAPA,QAAQ,IACN,GACA,kDACA,kDACA,iDACD,EAEG,KAAK,SAAS,SAChB,EAAO,IAAI,KAAK,SAAS;;CAI7B,MAAM,WAAW,GAAwC,GAAoB;AAQ3E,MAPA,KAAK,WAAW;GACd,aAAa,EAAK,IAAI,6BAA6B,EAAK,IAAI;GAC5D,GAAG;GACH,GAAG;GACJ,EAGG,CAAC,KAAK,SAAS,YACjB,OAAU,MAAM,kCAAkC;AAMpD,EAHA,KAAK,WAAW,IAAI,EAAQ,KAAK,SAAS,EAC1C,KAAK,OAAO,EAER,KAAK,SAAS,SAChB,EAAO,KAAK,0CAA0C,EACtD,KAAK,SAAS,UAAU,EAAE,SAAS,IAAO,CAAC,IAE3C,EAAO,IAAI,qBAAqB"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,eAAe,aAAa,CAAC"}
|
package/lib/version.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,cAAc,WAAW,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@caperjs/plugin-rollbar",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rollbar",
|
|
5
|
+
"files": [
|
|
6
|
+
"lib",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"main": "lib/caper-plugin-rollbar.mjs",
|
|
10
|
+
"types": "lib/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"default": "./lib/caper-plugin-rollbar.mjs",
|
|
14
|
+
"types": "./lib/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"keywords": [
|
|
19
|
+
"rollbar",
|
|
20
|
+
"rollbar.js",
|
|
21
|
+
"@caperjs/core",
|
|
22
|
+
"caper"
|
|
23
|
+
],
|
|
24
|
+
"author": "",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"vite": "^8.0.7",
|
|
28
|
+
"vite-plugin-dts": "^4.5.3",
|
|
29
|
+
"@caperjs/core": "0.1.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@caperjs/core": "0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"rollbar": "^2.26.4"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "pnpm run generate-version && vite build",
|
|
39
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
40
|
+
"generate-version": "node generateVersion.mjs"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IApplication, IPlugin, isDev, Logger, Plugin } from '@caperjs/core';
|
|
2
|
+
import Rollbar from 'rollbar';
|
|
3
|
+
import { rollbarVersion, version } from './version';
|
|
4
|
+
|
|
5
|
+
export interface RollbarPluginOptions extends Rollbar.Configuration {
|
|
6
|
+
isDev?: boolean;
|
|
7
|
+
debug?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IRollbarPlugin extends IPlugin<RollbarPluginOptions> {
|
|
11
|
+
readonly rollbar: Rollbar;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const defaultOptions = {
|
|
15
|
+
isDev: false,
|
|
16
|
+
enabled: true,
|
|
17
|
+
captureUncaught: true,
|
|
18
|
+
captureUnhandledRejections: true,
|
|
19
|
+
debug: isDev,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export class RollbarPlugin extends Plugin<RollbarPluginOptions> implements IRollbarPlugin {
|
|
23
|
+
protected _options: RollbarPluginOptions;
|
|
24
|
+
private _rollbar: Rollbar;
|
|
25
|
+
|
|
26
|
+
get rollbar() {
|
|
27
|
+
return this._rollbar;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private hello() {
|
|
31
|
+
const hello = `%c Caper Rollbar Plugin v${version} | %cRollbar v${rollbarVersion}`;
|
|
32
|
+
console.log(
|
|
33
|
+
hello,
|
|
34
|
+
'background: rgba(31, 41, 55, 1);color: #74b64c',
|
|
35
|
+
'background: rgba(31, 41, 55, 1);color: #e91e63',
|
|
36
|
+
'background: rgba(31, 41, 55, 1);color: #74b64c',
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (this._options.debug) {
|
|
40
|
+
Logger.log(this._options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async initialize(options: Partial<RollbarPluginOptions>, _app: IApplication) {
|
|
45
|
+
this._options = {
|
|
46
|
+
accessToken: _app.env.VITE_ROLLBAR_ACCESS_TOKEN || _app.env.ROLLBAR_ACCESS_TOKEN,
|
|
47
|
+
...defaultOptions,
|
|
48
|
+
...options,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// check if accessToken is set
|
|
52
|
+
if (!this._options.accessToken) {
|
|
53
|
+
throw new Error('Rollbar accessToken is required');
|
|
54
|
+
}
|
|
55
|
+
// TODO: should we even instantiate Rollbar here if isDev is true?
|
|
56
|
+
this._rollbar = new Rollbar(this._options);
|
|
57
|
+
this.hello();
|
|
58
|
+
|
|
59
|
+
if (this._options.isDev) {
|
|
60
|
+
Logger.warn('Rollbar is disabled in development mode');
|
|
61
|
+
this._rollbar.configure({ enabled: false });
|
|
62
|
+
} else {
|
|
63
|
+
Logger.log('Rollbar is enabled');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/index.ts
ADDED
package/src/version.ts
ADDED