@apolitical/error-reporting 0.1.0 → 0.2.1-rc.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.1] - 2021-05-13
9
+ ### Fixed
10
+ - Set context function error handling
11
+
12
+ ## [0.2.0] - 2022-05-10
13
+ ### Changed
14
+ - The `environment` is now defined externally
15
+
8
16
  ## [0.1.0] - 2022-01-31
9
17
  ### Fixed
10
18
  - Node.js version
package/build/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("stackdriver-errors-js")):"function"==typeof define&&define.amd?define(["stackdriver-errors-js"],r):"object"==typeof exports?exports.ApoliticalErrorReporting=r(require("stackdriver-errors-js")):e.ApoliticalErrorReporting=r(e["stackdriver-errors-js"])}(this,(function(e){return function(){"use strict";var r={542:function(r){r.exports=e}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(r,{a:r}),r},o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return function(){o.r(n),o.d(n,{reportError:function(){return u},setContext:function(){return s}});var e=o(542),r=o.n(e);const{APOLITICAL:{WEBSITES:t},GCP:{ENVIRONMENTS:i,PROJECT_ID:c}}={APOLITICAL:{WEBSITES:{BETA:"https://beta.apolitical.co",BETA_2:"https://beta-2.apolitical.co",LIVE:"https://apolitical.co",RC:"https://rc.apolitical.co"}},GCP:{ENVIRONMENTS:{BETA:"beta",BETA_2:"beta-2",RC:"rc",LIVE:"live"},PROJECT_ID:"hazel-tea-194609"}};let a={key:null,environment:null,projectId:c};const s=({apiKey:e,environment:r,origin:o=null,projectId:n,serviceName:s})=>{a.key=e,a.environment=r||(e=>{let r=null,o=null;switch(o="undefined"!=typeof window?window.origin||window.location.origin:e,o){case t.BETA:r=i.BETA;break;case t.BETA_2:r=i.BETA_2;break;case t.LIVE:r=i.LIVE;break;case t.RC:r=i.RC;break;default:r=i.BETA}return r})(o),a.projectId=n||c,s&&(a.service=`${s}:${a.environment}`)},u=async(e,t)=>{try{const o=new(r());o.start(a),t&&o.setUser(t),await o.report(e)}catch(e){console.warn(`Cannot report error: ${e.message}`)}}}(),n}()}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("stackdriver-errors-js")):"function"==typeof define&&define.amd?define(["stackdriver-errors-js"],r):"object"==typeof exports?exports.ApoliticalErrorReporting=r(require("stackdriver-errors-js")):e.ApoliticalErrorReporting=r(e["stackdriver-errors-js"])}(this,(function(e){return function(){"use strict";var r={542:function(r){r.exports=e}},t={};function n(e){var o=t[e];if(void 0!==o)return o.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,n),i.exports}n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,{a:r}),r},n.d=function(e,r){for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return function(){n.r(o),n.d(o,{reportError:function(){return s},setContext:function(){return c}});var e=n(542),r=n.n(e);const{GCP:{PROJECT_ID:t}}={GCP:{PROJECT_ID:"hazel-tea-194609"}};let i={key:null,environment:null,projectId:t};const c=({apiKey:e,environment:r,projectId:n,serviceName:o})=>{if(!e)throw new Error("Cannot set context: REACT_APP_GCP_ERRORS_API_KEY not defined");if(i.key=e,!r)throw new Error("Cannot set context: Environment not defined");i.environment=r,i.projectId=n||t,o&&(i.service=`${o}:${i.environment}`)},s=async(e,t)=>{try{const n=new(r());n.start(i),"string"==typeof t&&n.setUser(t),await n.report(e)}catch(e){console.warn(`Cannot report error: ${e.message}`)}}}(),o}()}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apolitical/error-reporting",
3
- "version": "0.1.0",
3
+ "version": "0.2.1-rc.1",
4
4
  "description": "Browser library to report errors to GCP",
5
5
  "author": "Apolitical Group Limited <engineering@apolitical.co>",
6
6
  "license": "MIT",
@@ -16,7 +16,8 @@
16
16
  "lint": "eslint --ext .js ./lib",
17
17
  "format": "prettier --write 'lib/**/*.+(js|json)'",
18
18
  "lint-format": "lint-staged",
19
- "prepare": "husky install"
19
+ "prepare": "husky install",
20
+ "prepack": "yarn build"
20
21
  },
21
22
  "keywords": [
22
23
  "JavaScript",
@@ -30,16 +31,17 @@
30
31
  "stackdriver-errors-js": "0.12.0"
31
32
  },
32
33
  "devDependencies": {
33
- "@apolitical/eslint-config": "1.0.2",
34
- "@babel/core": "7.16.12",
35
- "@babel/eslint-parser": "7.16.5",
36
- "@babel/plugin-transform-runtime": "7.16.10",
37
- "@babel/preset-env": "7.16.11",
38
- "husky": "7.0.4",
39
- "jest": "27.4.7",
40
- "jest-junit": "13.0.0",
41
- "lint-staged": "12.3.2",
42
- "webpack": "5.67.0",
34
+ "@apolitical/eslint-config": "2.0.1",
35
+ "@babel/core": "7.17.10",
36
+ "@babel/eslint-parser": "7.17.0",
37
+ "@babel/plugin-transform-runtime": "7.17.10",
38
+ "@babel/preset-env": "7.17.10",
39
+ "eslint-config-prettier": "8.5.0",
40
+ "husky": "8.0.1",
41
+ "jest": "28.1.0",
42
+ "jest-junit": "13.2.0",
43
+ "lint-staged": "12.4.1",
44
+ "webpack": "5.72.1",
43
45
  "webpack-cli": "4.9.2"
44
46
  },
45
47
  "eslintConfig": {