@ohbug/react 1.0.13 → 2.0.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/README.md +4 -6
- package/dist/index.d.ts +23 -3
- package/dist/index.js +67 -0
- package/dist/index.mjs +38 -0
- package/package.json +28 -23
- package/src/OhbugErrorBoundary.ts +55 -0
- package/src/index.ts +1 -0
- package/dist/OhbugErrorBoundary.d.ts +0 -44
- package/dist/OhbugErrorBoundary.d.ts.map +0 -1
- package/dist/extension.d.ts +0 -2
- package/dist/extension.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/ohbug-react.cjs.js +0 -272
- package/dist/ohbug-react.esm.js +0 -270
- package/dist/ohbug-react.esm.min.js +0 -30
- package/dist/ohbug-react.umd.js +0 -278
- package/dist/ohbug-react.umd.min.js +0 -30
package/README.md
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@ohbug/react)
|
|
4
4
|
[](https://bundlephobia.com/result?p=@ohbug/react)
|
|
5
|
-
[](https://github.com/prettier/prettier)
|
|
6
5
|
|
|
7
6
|
English | [简体中文](./README-zh_CN.md)
|
|
8
7
|
|
|
9
8
|
## Installation
|
|
10
9
|
|
|
11
10
|
```
|
|
12
|
-
|
|
11
|
+
pnpm instal @ohbug/browser @ohbug/react
|
|
13
12
|
```
|
|
14
13
|
|
|
15
14
|
## Usage
|
|
@@ -17,15 +16,14 @@ yarn add @ohbug/browser @ohbug/react
|
|
|
17
16
|
```jsx
|
|
18
17
|
import React from 'react'
|
|
19
18
|
import Ohbug from '@ohbug/browser'
|
|
20
|
-
import
|
|
19
|
+
import { OhbugErrorBoundary } from '@ohbug/react'
|
|
21
20
|
|
|
22
|
-
const client = Ohbug.
|
|
23
|
-
const OhbugErrorBoundary = client.use(OhbugReact, React)
|
|
21
|
+
const client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })
|
|
24
22
|
|
|
25
23
|
function App() {
|
|
26
24
|
return (
|
|
27
25
|
<div className="App">
|
|
28
|
-
<OhbugErrorBoundary>
|
|
26
|
+
<OhbugErrorBoundary client={client}>
|
|
29
27
|
<HelloWorld />
|
|
30
28
|
</OhbugErrorBoundary>
|
|
31
29
|
</div>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
interface ReactErrorDetail extends OhbugBaseDetail {
|
|
5
|
+
name: string;
|
|
6
|
+
stack?: string;
|
|
7
|
+
errorInfo: any;
|
|
8
|
+
}
|
|
9
|
+
interface ErrorBoundaryProp {
|
|
10
|
+
client: OhbugClient;
|
|
11
|
+
FallbackComponent?: React.ReactElement;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
interface ErrorBoundaryState {
|
|
15
|
+
error: any;
|
|
16
|
+
}
|
|
17
|
+
declare class OhbugErrorBoundary extends React.Component<ErrorBoundaryProp, ErrorBoundaryState> {
|
|
18
|
+
constructor(props: ErrorBoundaryProp);
|
|
19
|
+
componentDidCatch(error: Error, info: any): void;
|
|
20
|
+
render(): string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment | null | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { OhbugErrorBoundary, ReactErrorDetail };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/index.ts
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
OhbugErrorBoundary: () => OhbugErrorBoundary
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/OhbugErrorBoundary.ts
|
|
30
|
+
var import_react = __toESM(require("react"));
|
|
31
|
+
var import_core = require("@ohbug/core");
|
|
32
|
+
var OhbugErrorBoundary = class extends import_react.default.Component {
|
|
33
|
+
constructor(props) {
|
|
34
|
+
super(props);
|
|
35
|
+
this.state = { error: null };
|
|
36
|
+
}
|
|
37
|
+
componentDidCatch(error, info) {
|
|
38
|
+
const { client } = this.props;
|
|
39
|
+
const detail = {
|
|
40
|
+
name: error.name,
|
|
41
|
+
message: error.message,
|
|
42
|
+
stack: error.stack,
|
|
43
|
+
errorInfo: info
|
|
44
|
+
};
|
|
45
|
+
const event = client.createEvent({
|
|
46
|
+
category: "error",
|
|
47
|
+
type: import_core.EventTypes.REACT,
|
|
48
|
+
detail
|
|
49
|
+
});
|
|
50
|
+
client.notify(event);
|
|
51
|
+
this.setState({ error });
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
const { error } = this.state;
|
|
55
|
+
const { FallbackComponent, children } = this.props;
|
|
56
|
+
if (error) {
|
|
57
|
+
if (FallbackComponent)
|
|
58
|
+
return FallbackComponent;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return children;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
OhbugErrorBoundary
|
|
67
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/OhbugErrorBoundary.ts
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { EventTypes } from "@ohbug/core";
|
|
4
|
+
var OhbugErrorBoundary = class extends React.Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = { error: null };
|
|
8
|
+
}
|
|
9
|
+
componentDidCatch(error, info) {
|
|
10
|
+
const { client } = this.props;
|
|
11
|
+
const detail = {
|
|
12
|
+
name: error.name,
|
|
13
|
+
message: error.message,
|
|
14
|
+
stack: error.stack,
|
|
15
|
+
errorInfo: info
|
|
16
|
+
};
|
|
17
|
+
const event = client.createEvent({
|
|
18
|
+
category: "error",
|
|
19
|
+
type: EventTypes.REACT,
|
|
20
|
+
detail
|
|
21
|
+
});
|
|
22
|
+
client.notify(event);
|
|
23
|
+
this.setState({ error });
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const { error } = this.state;
|
|
27
|
+
const { FallbackComponent, children } = this.props;
|
|
28
|
+
if (error) {
|
|
29
|
+
if (FallbackComponent)
|
|
30
|
+
return FallbackComponent;
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return children;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
OhbugErrorBoundary
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohbug/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Ohbug SDK for React",
|
|
5
|
+
"license": "Apache-2.0",
|
|
5
6
|
"author": "chenyueban <jasonchan0527@gmail.com>",
|
|
6
7
|
"homepage": "https://github.com/ohbug-org/ohbug",
|
|
7
8
|
"bugs": {
|
|
@@ -11,34 +12,38 @@
|
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "https://github.com/ohbug-org/ohbug"
|
|
13
14
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"module": "dist/ohbug-react.esm.js",
|
|
17
|
-
"unpkg": "dist/ohbug-react.umd.js",
|
|
18
|
-
"jsdelivr": "dist/ohbug-react.umd.js",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"module": "dist/index.mjs",
|
|
19
17
|
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"require": "./dist/index.js",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
"files": [
|
|
21
|
-
"dist"
|
|
26
|
+
"dist",
|
|
27
|
+
"src"
|
|
22
28
|
],
|
|
23
|
-
"
|
|
24
|
-
"@ohbug/core": "^1.1.5"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/react": "^17.0.4"
|
|
28
|
-
},
|
|
29
|
+
"sideEffects": false,
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"react": "^16.8.6"
|
|
31
32
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"order": 4
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@ohbug/core": "2.0.0",
|
|
35
|
+
"@ohbug/types": "2.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@ohbug/browser": "2.0.0",
|
|
39
|
+
"@types/react": "^18.0.9"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
|
-
}
|
|
44
|
-
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"dev": "tsup --watch"
|
|
47
|
+
},
|
|
48
|
+
"readme": "# `@ohbug/react`\n\n[](https://www.npmjs.com/package/@ohbug/react)\n[](https://bundlephobia.com/result?p=@ohbug/react)\n\nEnglish | [简体中文](./README-zh_CN.md)\n\n## Installation\n\n```\npnpm instal @ohbug/browser @ohbug/react\n```\n\n## Usage\n\n```jsx\nimport React from 'react'\nimport Ohbug from '@ohbug/browser'\nimport { OhbugErrorBoundary } from '@ohbug/react'\n\nconst client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })\n\nfunction App() {\n return (\n <div className=\"App\">\n <OhbugErrorBoundary client={client}>\n <HelloWorld />\n </OhbugErrorBoundary>\n </div>\n )\n}\n```\n"
|
|
49
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { EventTypes } from '@ohbug/core'
|
|
4
|
+
|
|
5
|
+
export interface ReactErrorDetail extends OhbugBaseDetail {
|
|
6
|
+
name: string
|
|
7
|
+
stack?: string
|
|
8
|
+
errorInfo: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ErrorBoundaryProp {
|
|
12
|
+
client: OhbugClient
|
|
13
|
+
FallbackComponent?: React.ReactElement
|
|
14
|
+
children?: React.ReactNode
|
|
15
|
+
}
|
|
16
|
+
interface ErrorBoundaryState {
|
|
17
|
+
error: any
|
|
18
|
+
}
|
|
19
|
+
export class OhbugErrorBoundary extends React.Component<
|
|
20
|
+
ErrorBoundaryProp,
|
|
21
|
+
ErrorBoundaryState
|
|
22
|
+
> {
|
|
23
|
+
constructor(props: ErrorBoundaryProp) {
|
|
24
|
+
super(props)
|
|
25
|
+
this.state = { error: null }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
componentDidCatch(error: Error, info: any) {
|
|
29
|
+
const { client } = this.props
|
|
30
|
+
const detail: ReactErrorDetail = {
|
|
31
|
+
name: error.name,
|
|
32
|
+
message: error.message,
|
|
33
|
+
stack: error.stack,
|
|
34
|
+
errorInfo: info,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const event = client.createEvent<ReactErrorDetail>({
|
|
38
|
+
category: 'error',
|
|
39
|
+
type: EventTypes.REACT,
|
|
40
|
+
detail,
|
|
41
|
+
})
|
|
42
|
+
client.notify(event)
|
|
43
|
+
this.setState({ error })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
const { error } = this.state
|
|
48
|
+
const { FallbackComponent, children } = this.props
|
|
49
|
+
if (error) {
|
|
50
|
+
if (FallbackComponent) return FallbackComponent
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
return children
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './OhbugErrorBoundary'
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export interface ReactErrorDetail extends OhbugBaseDetail {
|
|
4
|
-
name: string;
|
|
5
|
-
stack?: string;
|
|
6
|
-
errorInfo: any;
|
|
7
|
-
}
|
|
8
|
-
interface ErrorBoundaryProp {
|
|
9
|
-
FallbackComponent: React.ReactElement;
|
|
10
|
-
}
|
|
11
|
-
interface ErrorBoundaryState {
|
|
12
|
-
error: any;
|
|
13
|
-
info: any;
|
|
14
|
-
}
|
|
15
|
-
export declare function createOhbugErrorBoundary(client: OhbugClient, react: typeof React): {
|
|
16
|
-
new (props: ErrorBoundaryProp): {
|
|
17
|
-
componentDidCatch(error: Error, info: any): void;
|
|
18
|
-
render(): React.ReactNode;
|
|
19
|
-
context: any;
|
|
20
|
-
setState<K extends keyof ErrorBoundaryState>(state: ErrorBoundaryState | ((prevState: Readonly<ErrorBoundaryState>, props: Readonly<ErrorBoundaryProp>) => ErrorBoundaryState | Pick<ErrorBoundaryState, K> | null) | Pick<ErrorBoundaryState, K> | null, callback?: (() => void) | undefined): void;
|
|
21
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
22
|
-
readonly props: Readonly<ErrorBoundaryProp> & Readonly<{
|
|
23
|
-
children?: React.ReactNode;
|
|
24
|
-
}>;
|
|
25
|
-
state: Readonly<ErrorBoundaryState>;
|
|
26
|
-
refs: {
|
|
27
|
-
[key: string]: React.ReactInstance;
|
|
28
|
-
};
|
|
29
|
-
componentDidMount?(): void;
|
|
30
|
-
shouldComponentUpdate?(nextProps: Readonly<ErrorBoundaryProp>, nextState: Readonly<ErrorBoundaryState>, nextContext: any): boolean;
|
|
31
|
-
componentWillUnmount?(): void;
|
|
32
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<ErrorBoundaryProp>, prevState: Readonly<ErrorBoundaryState>): any;
|
|
33
|
-
componentDidUpdate?(prevProps: Readonly<ErrorBoundaryProp>, prevState: Readonly<ErrorBoundaryState>, snapshot?: any): void;
|
|
34
|
-
componentWillMount?(): void;
|
|
35
|
-
UNSAFE_componentWillMount?(): void;
|
|
36
|
-
componentWillReceiveProps?(nextProps: Readonly<ErrorBoundaryProp>, nextContext: any): void;
|
|
37
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<ErrorBoundaryProp>, nextContext: any): void;
|
|
38
|
-
componentWillUpdate?(nextProps: Readonly<ErrorBoundaryProp>, nextState: Readonly<ErrorBoundaryState>, nextContext: any): void;
|
|
39
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<ErrorBoundaryProp>, nextState: Readonly<ErrorBoundaryState>, nextContext: any): void;
|
|
40
|
-
};
|
|
41
|
-
contextType?: React.Context<any> | undefined;
|
|
42
|
-
};
|
|
43
|
-
export {};
|
|
44
|
-
//# sourceMappingURL=OhbugErrorBoundary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OhbugErrorBoundary.d.ts","sourceRoot":"","sources":["../src/OhbugErrorBoundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,GAAG,CAAA;CACf;AAED,UAAU,iBAAiB;IACzB,iBAAiB,EAAE,KAAK,CAAC,YAAY,CAAA;CACtC;AACD,UAAU,kBAAkB;IAC1B,KAAK,EAAE,GAAG,CAAA;IACV,IAAI,EAAE,GAAG,CAAA;CACV;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,OAAO,KAAK;gBAME,iBAAiB;iCAQX,KAAK,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;EA+B5C"}
|
package/dist/extension.d.ts
DELETED
package/dist/extension.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,4CAQpB,CAAA"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/ohbug-react.cjs.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/*! *****************************************************************************
|
|
4
|
-
Copyright (c) Microsoft Corporation.
|
|
5
|
-
|
|
6
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
-
purpose with or without fee is hereby granted.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
***************************************************************************** */
|
|
17
|
-
|
|
18
|
-
var __assign = function() {
|
|
19
|
-
__assign = Object.assign || function __assign(t) {
|
|
20
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
-
s = arguments[i];
|
|
22
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
function isString(value) {
|
|
30
|
-
return typeof value === 'string';
|
|
31
|
-
}
|
|
32
|
-
function isObject(value) {
|
|
33
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createExtension(extension) {
|
|
37
|
-
return extension;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
var Action = /** @class */ (function () {
|
|
41
|
-
function Action(message, data, type, timestamp) {
|
|
42
|
-
this.type = type;
|
|
43
|
-
this.timestamp = timestamp || new Date().toISOString();
|
|
44
|
-
this.message = message;
|
|
45
|
-
this.data = data;
|
|
46
|
-
}
|
|
47
|
-
return Action;
|
|
48
|
-
}());
|
|
49
|
-
function getErrorMessage(message, data) {
|
|
50
|
-
return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function addMetaData(map, section, data) {
|
|
54
|
-
if (!section)
|
|
55
|
-
return;
|
|
56
|
-
map[section] = data;
|
|
57
|
-
}
|
|
58
|
-
function getMetaData(map, section) {
|
|
59
|
-
if (map[section]) {
|
|
60
|
-
return map[section];
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
function deleteMetaData(map, section) {
|
|
65
|
-
if (map[section]) {
|
|
66
|
-
return delete map[section];
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** @class */ ((function () {
|
|
72
|
-
function Event(values, client) {
|
|
73
|
-
var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
|
|
74
|
-
this.apiKey = apiKey;
|
|
75
|
-
this.appVersion = appVersion;
|
|
76
|
-
this.appType = appType;
|
|
77
|
-
this.releaseStage = releaseStage;
|
|
78
|
-
this.timestamp = timestamp;
|
|
79
|
-
this.category = category;
|
|
80
|
-
this.type = type;
|
|
81
|
-
this.sdk = sdk;
|
|
82
|
-
this.detail = detail;
|
|
83
|
-
this.device = device;
|
|
84
|
-
this.user = user;
|
|
85
|
-
this.actions = actions;
|
|
86
|
-
this.metaData = metaData;
|
|
87
|
-
this._client = client;
|
|
88
|
-
}
|
|
89
|
-
Object.defineProperty(Event.prototype, "_isOhbugEvent", {
|
|
90
|
-
get: function () {
|
|
91
|
-
return true;
|
|
92
|
-
},
|
|
93
|
-
enumerable: false,
|
|
94
|
-
configurable: true
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* Add an action.
|
|
98
|
-
* Once the threshold is reached, the oldest breadcrumbs will be deleted.
|
|
99
|
-
* 新增一个动作。
|
|
100
|
-
* 一旦达到阈值,最老的 Action 将被删除。
|
|
101
|
-
*
|
|
102
|
-
* @param message
|
|
103
|
-
* @param data
|
|
104
|
-
* @param type
|
|
105
|
-
* @param timestamp
|
|
106
|
-
*/
|
|
107
|
-
Event.prototype.addAction = function (message, data, type, timestamp) {
|
|
108
|
-
var _a, _b;
|
|
109
|
-
var actions = this.actions;
|
|
110
|
-
var targetMessage = isString(message) ? message : '';
|
|
111
|
-
var targetData = data || {};
|
|
112
|
-
var targetType = isString(type) ? type : '';
|
|
113
|
-
var action = new Action(targetMessage, targetData, targetType, timestamp);
|
|
114
|
-
if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
|
|
115
|
-
actions.shift();
|
|
116
|
-
}
|
|
117
|
-
actions.push(action);
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Get current user information
|
|
121
|
-
* 获取当前的用户信息
|
|
122
|
-
*/
|
|
123
|
-
Event.prototype.getUser = function () {
|
|
124
|
-
return this.user;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Set current user information
|
|
128
|
-
* 设置当前的用户信息
|
|
129
|
-
*/
|
|
130
|
-
Event.prototype.setUser = function (user) {
|
|
131
|
-
var _a;
|
|
132
|
-
if (isObject(user) && Object.keys(user).length <= 6) {
|
|
133
|
-
this.user = __assign(__assign({}, this.user), user);
|
|
134
|
-
return this.getUser();
|
|
135
|
-
}
|
|
136
|
-
(_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
|
|
137
|
-
return undefined;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Add metaData
|
|
141
|
-
* 新增 metaData
|
|
142
|
-
*
|
|
143
|
-
* @param section
|
|
144
|
-
* @param data
|
|
145
|
-
*/
|
|
146
|
-
Event.prototype.addMetaData = function (section, data) {
|
|
147
|
-
return addMetaData(this.metaData, section, data);
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Get metaData
|
|
151
|
-
* 获取 metaData
|
|
152
|
-
*
|
|
153
|
-
* @param section
|
|
154
|
-
*/
|
|
155
|
-
Event.prototype.getMetaData = function (section) {
|
|
156
|
-
return getMetaData(this.metaData, section);
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Delete metaData
|
|
160
|
-
* 删除 metaData
|
|
161
|
-
*
|
|
162
|
-
* @param section
|
|
163
|
-
*/
|
|
164
|
-
Event.prototype.deleteMetaData = function (section) {
|
|
165
|
-
return deleteMetaData(this.metaData, section);
|
|
166
|
-
};
|
|
167
|
-
Event.prototype.toJSON = function () {
|
|
168
|
-
var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
|
|
169
|
-
return {
|
|
170
|
-
apiKey: apiKey,
|
|
171
|
-
appVersion: appVersion,
|
|
172
|
-
appType: appType,
|
|
173
|
-
timestamp: timestamp,
|
|
174
|
-
category: category,
|
|
175
|
-
type: type,
|
|
176
|
-
sdk: sdk,
|
|
177
|
-
device: device,
|
|
178
|
-
detail: detail,
|
|
179
|
-
user: user,
|
|
180
|
-
actions: actions,
|
|
181
|
-
metaData: metaData,
|
|
182
|
-
releaseStage: releaseStage,
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
return Event;
|
|
186
|
-
})());
|
|
187
|
-
|
|
188
|
-
/*! *****************************************************************************
|
|
189
|
-
Copyright (c) Microsoft Corporation.
|
|
190
|
-
|
|
191
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
192
|
-
purpose with or without fee is hereby granted.
|
|
193
|
-
|
|
194
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
195
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
196
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
197
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
198
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
199
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
200
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
201
|
-
***************************************************************************** */
|
|
202
|
-
/* global Reflect, Promise */
|
|
203
|
-
|
|
204
|
-
var extendStatics = function(d, b) {
|
|
205
|
-
extendStatics = Object.setPrototypeOf ||
|
|
206
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
207
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
208
|
-
return extendStatics(d, b);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
function __extends(d, b) {
|
|
212
|
-
if (typeof b !== "function" && b !== null)
|
|
213
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
214
|
-
extendStatics(d, b);
|
|
215
|
-
function __() { this.constructor = d; }
|
|
216
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function createOhbugErrorBoundary(client, react) {
|
|
220
|
-
return /** @class */ (function (_super) {
|
|
221
|
-
__extends(OhbugErrorBoundary, _super);
|
|
222
|
-
function OhbugErrorBoundary(props) {
|
|
223
|
-
var _this = _super.call(this, props) || this;
|
|
224
|
-
_this.state = {
|
|
225
|
-
error: null,
|
|
226
|
-
info: null,
|
|
227
|
-
};
|
|
228
|
-
return _this;
|
|
229
|
-
}
|
|
230
|
-
OhbugErrorBoundary.prototype.componentDidCatch = function (error, info) {
|
|
231
|
-
var detail = {
|
|
232
|
-
name: error.name,
|
|
233
|
-
message: error.message,
|
|
234
|
-
stack: error.stack,
|
|
235
|
-
errorInfo: info,
|
|
236
|
-
};
|
|
237
|
-
var event = client.createEvent({
|
|
238
|
-
category: 'error',
|
|
239
|
-
type: 'react',
|
|
240
|
-
detail: detail,
|
|
241
|
-
});
|
|
242
|
-
client.notify(event);
|
|
243
|
-
this.setState({
|
|
244
|
-
error: error,
|
|
245
|
-
info: info,
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
|
-
OhbugErrorBoundary.prototype.render = function () {
|
|
249
|
-
var error = this.state.error;
|
|
250
|
-
if (error) {
|
|
251
|
-
var FallbackComponent = this.props.FallbackComponent;
|
|
252
|
-
if (FallbackComponent)
|
|
253
|
-
return FallbackComponent;
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
return this.props.children;
|
|
257
|
-
};
|
|
258
|
-
return OhbugErrorBoundary;
|
|
259
|
-
}(react.Component));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
var extension = createExtension({
|
|
263
|
-
name: 'OhbugReact',
|
|
264
|
-
init: function (client, react) {
|
|
265
|
-
if (!react) {
|
|
266
|
-
throw new Error('Ohbug @ohbug/react reference to `React` was undefined');
|
|
267
|
-
}
|
|
268
|
-
return createOhbugErrorBoundary(client, react);
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
module.exports = extension;
|
package/dist/ohbug-react.esm.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
var __assign = function() {
|
|
17
|
-
__assign = Object.assign || function __assign(t) {
|
|
18
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
-
s = arguments[i];
|
|
20
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function isString(value) {
|
|
28
|
-
return typeof value === 'string';
|
|
29
|
-
}
|
|
30
|
-
function isObject(value) {
|
|
31
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function createExtension(extension) {
|
|
35
|
-
return extension;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var Action = /** @class */ (function () {
|
|
39
|
-
function Action(message, data, type, timestamp) {
|
|
40
|
-
this.type = type;
|
|
41
|
-
this.timestamp = timestamp || new Date().toISOString();
|
|
42
|
-
this.message = message;
|
|
43
|
-
this.data = data;
|
|
44
|
-
}
|
|
45
|
-
return Action;
|
|
46
|
-
}());
|
|
47
|
-
function getErrorMessage(message, data) {
|
|
48
|
-
return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function addMetaData(map, section, data) {
|
|
52
|
-
if (!section)
|
|
53
|
-
return;
|
|
54
|
-
map[section] = data;
|
|
55
|
-
}
|
|
56
|
-
function getMetaData(map, section) {
|
|
57
|
-
if (map[section]) {
|
|
58
|
-
return map[section];
|
|
59
|
-
}
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
function deleteMetaData(map, section) {
|
|
63
|
-
if (map[section]) {
|
|
64
|
-
return delete map[section];
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** @class */ ((function () {
|
|
70
|
-
function Event(values, client) {
|
|
71
|
-
var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
|
|
72
|
-
this.apiKey = apiKey;
|
|
73
|
-
this.appVersion = appVersion;
|
|
74
|
-
this.appType = appType;
|
|
75
|
-
this.releaseStage = releaseStage;
|
|
76
|
-
this.timestamp = timestamp;
|
|
77
|
-
this.category = category;
|
|
78
|
-
this.type = type;
|
|
79
|
-
this.sdk = sdk;
|
|
80
|
-
this.detail = detail;
|
|
81
|
-
this.device = device;
|
|
82
|
-
this.user = user;
|
|
83
|
-
this.actions = actions;
|
|
84
|
-
this.metaData = metaData;
|
|
85
|
-
this._client = client;
|
|
86
|
-
}
|
|
87
|
-
Object.defineProperty(Event.prototype, "_isOhbugEvent", {
|
|
88
|
-
get: function () {
|
|
89
|
-
return true;
|
|
90
|
-
},
|
|
91
|
-
enumerable: false,
|
|
92
|
-
configurable: true
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Add an action.
|
|
96
|
-
* Once the threshold is reached, the oldest breadcrumbs will be deleted.
|
|
97
|
-
* 新增一个动作。
|
|
98
|
-
* 一旦达到阈值,最老的 Action 将被删除。
|
|
99
|
-
*
|
|
100
|
-
* @param message
|
|
101
|
-
* @param data
|
|
102
|
-
* @param type
|
|
103
|
-
* @param timestamp
|
|
104
|
-
*/
|
|
105
|
-
Event.prototype.addAction = function (message, data, type, timestamp) {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
var actions = this.actions;
|
|
108
|
-
var targetMessage = isString(message) ? message : '';
|
|
109
|
-
var targetData = data || {};
|
|
110
|
-
var targetType = isString(type) ? type : '';
|
|
111
|
-
var action = new Action(targetMessage, targetData, targetType, timestamp);
|
|
112
|
-
if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
|
|
113
|
-
actions.shift();
|
|
114
|
-
}
|
|
115
|
-
actions.push(action);
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Get current user information
|
|
119
|
-
* 获取当前的用户信息
|
|
120
|
-
*/
|
|
121
|
-
Event.prototype.getUser = function () {
|
|
122
|
-
return this.user;
|
|
123
|
-
};
|
|
124
|
-
/**
|
|
125
|
-
* Set current user information
|
|
126
|
-
* 设置当前的用户信息
|
|
127
|
-
*/
|
|
128
|
-
Event.prototype.setUser = function (user) {
|
|
129
|
-
var _a;
|
|
130
|
-
if (isObject(user) && Object.keys(user).length <= 6) {
|
|
131
|
-
this.user = __assign(__assign({}, this.user), user);
|
|
132
|
-
return this.getUser();
|
|
133
|
-
}
|
|
134
|
-
(_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
|
|
135
|
-
return undefined;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Add metaData
|
|
139
|
-
* 新增 metaData
|
|
140
|
-
*
|
|
141
|
-
* @param section
|
|
142
|
-
* @param data
|
|
143
|
-
*/
|
|
144
|
-
Event.prototype.addMetaData = function (section, data) {
|
|
145
|
-
return addMetaData(this.metaData, section, data);
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Get metaData
|
|
149
|
-
* 获取 metaData
|
|
150
|
-
*
|
|
151
|
-
* @param section
|
|
152
|
-
*/
|
|
153
|
-
Event.prototype.getMetaData = function (section) {
|
|
154
|
-
return getMetaData(this.metaData, section);
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Delete metaData
|
|
158
|
-
* 删除 metaData
|
|
159
|
-
*
|
|
160
|
-
* @param section
|
|
161
|
-
*/
|
|
162
|
-
Event.prototype.deleteMetaData = function (section) {
|
|
163
|
-
return deleteMetaData(this.metaData, section);
|
|
164
|
-
};
|
|
165
|
-
Event.prototype.toJSON = function () {
|
|
166
|
-
var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
|
|
167
|
-
return {
|
|
168
|
-
apiKey: apiKey,
|
|
169
|
-
appVersion: appVersion,
|
|
170
|
-
appType: appType,
|
|
171
|
-
timestamp: timestamp,
|
|
172
|
-
category: category,
|
|
173
|
-
type: type,
|
|
174
|
-
sdk: sdk,
|
|
175
|
-
device: device,
|
|
176
|
-
detail: detail,
|
|
177
|
-
user: user,
|
|
178
|
-
actions: actions,
|
|
179
|
-
metaData: metaData,
|
|
180
|
-
releaseStage: releaseStage,
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
return Event;
|
|
184
|
-
})());
|
|
185
|
-
|
|
186
|
-
/*! *****************************************************************************
|
|
187
|
-
Copyright (c) Microsoft Corporation.
|
|
188
|
-
|
|
189
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
190
|
-
purpose with or without fee is hereby granted.
|
|
191
|
-
|
|
192
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
193
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
194
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
195
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
196
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
197
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
198
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
199
|
-
***************************************************************************** */
|
|
200
|
-
/* global Reflect, Promise */
|
|
201
|
-
|
|
202
|
-
var extendStatics = function(d, b) {
|
|
203
|
-
extendStatics = Object.setPrototypeOf ||
|
|
204
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
205
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
206
|
-
return extendStatics(d, b);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
function __extends(d, b) {
|
|
210
|
-
if (typeof b !== "function" && b !== null)
|
|
211
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
212
|
-
extendStatics(d, b);
|
|
213
|
-
function __() { this.constructor = d; }
|
|
214
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function createOhbugErrorBoundary(client, react) {
|
|
218
|
-
return /** @class */ (function (_super) {
|
|
219
|
-
__extends(OhbugErrorBoundary, _super);
|
|
220
|
-
function OhbugErrorBoundary(props) {
|
|
221
|
-
var _this = _super.call(this, props) || this;
|
|
222
|
-
_this.state = {
|
|
223
|
-
error: null,
|
|
224
|
-
info: null,
|
|
225
|
-
};
|
|
226
|
-
return _this;
|
|
227
|
-
}
|
|
228
|
-
OhbugErrorBoundary.prototype.componentDidCatch = function (error, info) {
|
|
229
|
-
var detail = {
|
|
230
|
-
name: error.name,
|
|
231
|
-
message: error.message,
|
|
232
|
-
stack: error.stack,
|
|
233
|
-
errorInfo: info,
|
|
234
|
-
};
|
|
235
|
-
var event = client.createEvent({
|
|
236
|
-
category: 'error',
|
|
237
|
-
type: 'react',
|
|
238
|
-
detail: detail,
|
|
239
|
-
});
|
|
240
|
-
client.notify(event);
|
|
241
|
-
this.setState({
|
|
242
|
-
error: error,
|
|
243
|
-
info: info,
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
OhbugErrorBoundary.prototype.render = function () {
|
|
247
|
-
var error = this.state.error;
|
|
248
|
-
if (error) {
|
|
249
|
-
var FallbackComponent = this.props.FallbackComponent;
|
|
250
|
-
if (FallbackComponent)
|
|
251
|
-
return FallbackComponent;
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
return this.props.children;
|
|
255
|
-
};
|
|
256
|
-
return OhbugErrorBoundary;
|
|
257
|
-
}(react.Component));
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
var extension = createExtension({
|
|
261
|
-
name: 'OhbugReact',
|
|
262
|
-
init: function (client, react) {
|
|
263
|
-
if (!react) {
|
|
264
|
-
throw new Error('Ohbug @ohbug/react reference to `React` was undefined');
|
|
265
|
-
}
|
|
266
|
-
return createOhbugErrorBoundary(client, react);
|
|
267
|
-
},
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
export default extension;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */
|
|
15
|
-
var t=function(){return(t=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var r=function(t,e,r,n){this.type=r,this.timestamp=n||(new Date).toISOString(),this.message=t,this.data=e};!function(){function n(t,e){var r=t.apiKey,n=t.appVersion,o=t.appType,a=t.releaseStage,i=t.timestamp,s=t.category,p=t.type,c=t.sdk,u=t.detail,l=t.device,f=t.user,h=t.actions,y=t.metaData;this.apiKey=r,this.appVersion=n,this.appType=o,this.releaseStage=a,this.timestamp=i,this.category=s,this.type=p,this.sdk=c,this.detail=u,this.device=l,this.user=f,this.actions=h,this.metaData=y,this._client=e}Object.defineProperty(n.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),n.prototype.addAction=function(t,n,o,a){var i,s,p=this.actions,c=e(t)?t:"",u=n||{},l=e(o)?o:"",f=new r(c,u,l,a);p.length>=(null!==(s=null===(i=this._client)||void 0===i?void 0:i._config.maxActions)&&void 0!==s?s:30)&&p.shift(),p.push(f)},n.prototype.getUser=function(){return this.user},n.prototype.setUser=function(e){var r,n,o;if(n=e,"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(r=this._client)||void 0===r||r._logger.warn((o=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(o))))},n.prototype.addMetaData=function(t,e){return function(t,e,r){e&&(t[e]=r)}(this.metaData,t,e)},n.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},n.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},n.prototype.toJSON=function(){var t=this;return{apiKey:t.apiKey,appVersion:t.appVersion,appType:t.appType,timestamp:t.timestamp,category:t.category,type:t.type,sdk:t.sdk,device:t.device,detail:t.detail,user:t.user,actions:t.actions,metaData:t.metaData,releaseStage:t.releaseStage}}}();
|
|
16
|
-
/*! *****************************************************************************
|
|
17
|
-
Copyright (c) Microsoft Corporation.
|
|
18
|
-
|
|
19
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
-
purpose with or without fee is hereby granted.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
-
***************************************************************************** */
|
|
30
|
-
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function o(t,e){return function(e){function r(t){var r=e.call(this,t)||this;return r.state={error:null,info:null},r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(r,e),r.prototype.componentDidCatch=function(e,r){var n={name:e.name,message:e.message,stack:e.stack,errorInfo:r},o=t.createEvent({category:"error",type:"react",detail:n});t.notify(o),this.setState({error:e,info:r})},r.prototype.render=function(){if(this.state.error){var t=this.props.FallbackComponent;return t||null}return this.props.children},r}(e.Component)}var a={name:"OhbugReact",init:function(t,e){if(!e)throw new Error("Ohbug @ohbug/react reference to `React` was undefined");return o(t,e)}};export default a;
|
package/dist/ohbug-react.umd.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.OhbugReact = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
|
|
22
|
-
var __assign = function() {
|
|
23
|
-
__assign = Object.assign || function __assign(t) {
|
|
24
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
25
|
-
s = arguments[i];
|
|
26
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
return __assign.apply(this, arguments);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
function isString(value) {
|
|
34
|
-
return typeof value === 'string';
|
|
35
|
-
}
|
|
36
|
-
function isObject(value) {
|
|
37
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createExtension(extension) {
|
|
41
|
-
return extension;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var Action = /** @class */ (function () {
|
|
45
|
-
function Action(message, data, type, timestamp) {
|
|
46
|
-
this.type = type;
|
|
47
|
-
this.timestamp = timestamp || new Date().toISOString();
|
|
48
|
-
this.message = message;
|
|
49
|
-
this.data = data;
|
|
50
|
-
}
|
|
51
|
-
return Action;
|
|
52
|
-
}());
|
|
53
|
-
function getErrorMessage(message, data) {
|
|
54
|
-
return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function addMetaData(map, section, data) {
|
|
58
|
-
if (!section)
|
|
59
|
-
return;
|
|
60
|
-
map[section] = data;
|
|
61
|
-
}
|
|
62
|
-
function getMetaData(map, section) {
|
|
63
|
-
if (map[section]) {
|
|
64
|
-
return map[section];
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
function deleteMetaData(map, section) {
|
|
69
|
-
if (map[section]) {
|
|
70
|
-
return delete map[section];
|
|
71
|
-
}
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** @class */ ((function () {
|
|
76
|
-
function Event(values, client) {
|
|
77
|
-
var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
|
|
78
|
-
this.apiKey = apiKey;
|
|
79
|
-
this.appVersion = appVersion;
|
|
80
|
-
this.appType = appType;
|
|
81
|
-
this.releaseStage = releaseStage;
|
|
82
|
-
this.timestamp = timestamp;
|
|
83
|
-
this.category = category;
|
|
84
|
-
this.type = type;
|
|
85
|
-
this.sdk = sdk;
|
|
86
|
-
this.detail = detail;
|
|
87
|
-
this.device = device;
|
|
88
|
-
this.user = user;
|
|
89
|
-
this.actions = actions;
|
|
90
|
-
this.metaData = metaData;
|
|
91
|
-
this._client = client;
|
|
92
|
-
}
|
|
93
|
-
Object.defineProperty(Event.prototype, "_isOhbugEvent", {
|
|
94
|
-
get: function () {
|
|
95
|
-
return true;
|
|
96
|
-
},
|
|
97
|
-
enumerable: false,
|
|
98
|
-
configurable: true
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* Add an action.
|
|
102
|
-
* Once the threshold is reached, the oldest breadcrumbs will be deleted.
|
|
103
|
-
* 新增一个动作。
|
|
104
|
-
* 一旦达到阈值,最老的 Action 将被删除。
|
|
105
|
-
*
|
|
106
|
-
* @param message
|
|
107
|
-
* @param data
|
|
108
|
-
* @param type
|
|
109
|
-
* @param timestamp
|
|
110
|
-
*/
|
|
111
|
-
Event.prototype.addAction = function (message, data, type, timestamp) {
|
|
112
|
-
var _a, _b;
|
|
113
|
-
var actions = this.actions;
|
|
114
|
-
var targetMessage = isString(message) ? message : '';
|
|
115
|
-
var targetData = data || {};
|
|
116
|
-
var targetType = isString(type) ? type : '';
|
|
117
|
-
var action = new Action(targetMessage, targetData, targetType, timestamp);
|
|
118
|
-
if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
|
|
119
|
-
actions.shift();
|
|
120
|
-
}
|
|
121
|
-
actions.push(action);
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Get current user information
|
|
125
|
-
* 获取当前的用户信息
|
|
126
|
-
*/
|
|
127
|
-
Event.prototype.getUser = function () {
|
|
128
|
-
return this.user;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Set current user information
|
|
132
|
-
* 设置当前的用户信息
|
|
133
|
-
*/
|
|
134
|
-
Event.prototype.setUser = function (user) {
|
|
135
|
-
var _a;
|
|
136
|
-
if (isObject(user) && Object.keys(user).length <= 6) {
|
|
137
|
-
this.user = __assign(__assign({}, this.user), user);
|
|
138
|
-
return this.getUser();
|
|
139
|
-
}
|
|
140
|
-
(_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
|
|
141
|
-
return undefined;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Add metaData
|
|
145
|
-
* 新增 metaData
|
|
146
|
-
*
|
|
147
|
-
* @param section
|
|
148
|
-
* @param data
|
|
149
|
-
*/
|
|
150
|
-
Event.prototype.addMetaData = function (section, data) {
|
|
151
|
-
return addMetaData(this.metaData, section, data);
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Get metaData
|
|
155
|
-
* 获取 metaData
|
|
156
|
-
*
|
|
157
|
-
* @param section
|
|
158
|
-
*/
|
|
159
|
-
Event.prototype.getMetaData = function (section) {
|
|
160
|
-
return getMetaData(this.metaData, section);
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Delete metaData
|
|
164
|
-
* 删除 metaData
|
|
165
|
-
*
|
|
166
|
-
* @param section
|
|
167
|
-
*/
|
|
168
|
-
Event.prototype.deleteMetaData = function (section) {
|
|
169
|
-
return deleteMetaData(this.metaData, section);
|
|
170
|
-
};
|
|
171
|
-
Event.prototype.toJSON = function () {
|
|
172
|
-
var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
|
|
173
|
-
return {
|
|
174
|
-
apiKey: apiKey,
|
|
175
|
-
appVersion: appVersion,
|
|
176
|
-
appType: appType,
|
|
177
|
-
timestamp: timestamp,
|
|
178
|
-
category: category,
|
|
179
|
-
type: type,
|
|
180
|
-
sdk: sdk,
|
|
181
|
-
device: device,
|
|
182
|
-
detail: detail,
|
|
183
|
-
user: user,
|
|
184
|
-
actions: actions,
|
|
185
|
-
metaData: metaData,
|
|
186
|
-
releaseStage: releaseStage,
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
return Event;
|
|
190
|
-
})());
|
|
191
|
-
|
|
192
|
-
/*! *****************************************************************************
|
|
193
|
-
Copyright (c) Microsoft Corporation.
|
|
194
|
-
|
|
195
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
196
|
-
purpose with or without fee is hereby granted.
|
|
197
|
-
|
|
198
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
199
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
200
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
201
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
202
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
203
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
204
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
205
|
-
***************************************************************************** */
|
|
206
|
-
/* global Reflect, Promise */
|
|
207
|
-
|
|
208
|
-
var extendStatics = function(d, b) {
|
|
209
|
-
extendStatics = Object.setPrototypeOf ||
|
|
210
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
211
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
212
|
-
return extendStatics(d, b);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
function __extends(d, b) {
|
|
216
|
-
if (typeof b !== "function" && b !== null)
|
|
217
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
218
|
-
extendStatics(d, b);
|
|
219
|
-
function __() { this.constructor = d; }
|
|
220
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function createOhbugErrorBoundary(client, react) {
|
|
224
|
-
return /** @class */ (function (_super) {
|
|
225
|
-
__extends(OhbugErrorBoundary, _super);
|
|
226
|
-
function OhbugErrorBoundary(props) {
|
|
227
|
-
var _this = _super.call(this, props) || this;
|
|
228
|
-
_this.state = {
|
|
229
|
-
error: null,
|
|
230
|
-
info: null,
|
|
231
|
-
};
|
|
232
|
-
return _this;
|
|
233
|
-
}
|
|
234
|
-
OhbugErrorBoundary.prototype.componentDidCatch = function (error, info) {
|
|
235
|
-
var detail = {
|
|
236
|
-
name: error.name,
|
|
237
|
-
message: error.message,
|
|
238
|
-
stack: error.stack,
|
|
239
|
-
errorInfo: info,
|
|
240
|
-
};
|
|
241
|
-
var event = client.createEvent({
|
|
242
|
-
category: 'error',
|
|
243
|
-
type: 'react',
|
|
244
|
-
detail: detail,
|
|
245
|
-
});
|
|
246
|
-
client.notify(event);
|
|
247
|
-
this.setState({
|
|
248
|
-
error: error,
|
|
249
|
-
info: info,
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
OhbugErrorBoundary.prototype.render = function () {
|
|
253
|
-
var error = this.state.error;
|
|
254
|
-
if (error) {
|
|
255
|
-
var FallbackComponent = this.props.FallbackComponent;
|
|
256
|
-
if (FallbackComponent)
|
|
257
|
-
return FallbackComponent;
|
|
258
|
-
return null;
|
|
259
|
-
}
|
|
260
|
-
return this.props.children;
|
|
261
|
-
};
|
|
262
|
-
return OhbugErrorBoundary;
|
|
263
|
-
}(react.Component));
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
var extension = createExtension({
|
|
267
|
-
name: 'OhbugReact',
|
|
268
|
-
init: function (client, react) {
|
|
269
|
-
if (!react) {
|
|
270
|
-
throw new Error('Ohbug @ohbug/react reference to `React` was undefined');
|
|
271
|
-
}
|
|
272
|
-
return createOhbugErrorBoundary(client, react);
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
return extension;
|
|
277
|
-
|
|
278
|
-
})));
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).OhbugReact=e()}(this,(function(){"use strict";
|
|
2
|
-
/*! *****************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var t=function(){return(t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var n=function(t,e,n,r){this.type=n,this.timestamp=r||(new Date).toISOString(),this.message=t,this.data=e};!function(){function r(t,e){var n=t.apiKey,r=t.appVersion,o=t.appType,i=t.releaseStage,a=t.timestamp,s=t.category,p=t.type,c=t.sdk,u=t.detail,f=t.device,l=t.user,h=t.actions,y=t.metaData;this.apiKey=n,this.appVersion=r,this.appType=o,this.releaseStage=i,this.timestamp=a,this.category=s,this.type=p,this.sdk=c,this.detail=u,this.device=f,this.user=l,this.actions=h,this.metaData=y,this._client=e}Object.defineProperty(r.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.addAction=function(t,r,o,i){var a,s,p=this.actions,c=e(t)?t:"",u=r||{},f=e(o)?o:"",l=new n(c,u,f,i);p.length>=(null!==(s=null===(a=this._client)||void 0===a?void 0:a._config.maxActions)&&void 0!==s?s:30)&&p.shift(),p.push(l)},r.prototype.getUser=function(){return this.user},r.prototype.setUser=function(e){var n,r,o;if(r=e,"[object Object]"===Object.prototype.toString.call(r)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(n=this._client)||void 0===n||n._logger.warn((o=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(o))))},r.prototype.addMetaData=function(t,e){return function(t,e,n){e&&(t[e]=n)}(this.metaData,t,e)},r.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},r.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},r.prototype.toJSON=function(){var t=this;return{apiKey:t.apiKey,appVersion:t.appVersion,appType:t.appType,timestamp:t.timestamp,category:t.category,type:t.type,sdk:t.sdk,device:t.device,detail:t.detail,user:t.user,actions:t.actions,metaData:t.metaData,releaseStage:t.releaseStage}}}();
|
|
16
|
-
/*! *****************************************************************************
|
|
17
|
-
Copyright (c) Microsoft Corporation.
|
|
18
|
-
|
|
19
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
-
purpose with or without fee is hereby granted.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
-
***************************************************************************** */
|
|
30
|
-
var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function o(t,e){return function(e){function n(t){var n=e.call(this,t)||this;return n.state={error:null,info:null},n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(n,e),n.prototype.componentDidCatch=function(e,n){var r={name:e.name,message:e.message,stack:e.stack,errorInfo:n},o=t.createEvent({category:"error",type:"react",detail:r});t.notify(o),this.setState({error:e,info:n})},n.prototype.render=function(){if(this.state.error){var t=this.props.FallbackComponent;return t||null}return this.props.children},n}(e.Component)}return{name:"OhbugReact",init:function(t,e){if(!e)throw new Error("Ohbug @ohbug/react reference to `React` was undefined");return o(t,e)}}}));
|