@flareapp/js 1.0.0 → 1.1.0-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/dist/index.d.mts +97 -102
- package/dist/index.d.ts +97 -102
- package/dist/index.js +184 -212
- package/dist/index.mjs +182 -210
- package/package.json +1 -1
- package/src/Flare.ts +208 -0
- package/src/api/Api.ts +27 -0
- package/src/api/index.ts +1 -0
- package/src/{browserClient/index.ts → browser/catchWindowErrors.ts} +2 -3
- package/src/browser/index.ts +1 -0
- package/src/context/collectContext.ts +18 -0
- package/src/context/cookie.ts +1 -1
- package/src/context/index.ts +1 -17
- package/src/env/index.ts +12 -0
- package/src/index.ts +8 -5
- package/src/solutions/getSolutions.ts +35 -0
- package/src/solutions/index.ts +1 -44
- package/src/stacktrace/createStackTrace.ts +59 -0
- package/src/stacktrace/fileReader.ts +7 -21
- package/src/stacktrace/index.ts +1 -71
- package/src/types.ts +66 -82
- package/src/util/assert.ts +9 -0
- package/src/util/assertKey.ts +11 -0
- package/src/util/assertSolutionProvider.ts +12 -0
- package/src/util/flatJsonStringify.ts +22 -0
- package/src/util/flattenOnce.ts +5 -0
- package/src/util/index.ts +6 -44
- package/src/util/now.ts +3 -0
- package/tsconfig.json +1 -1
- package/src/FlareClient.ts +0 -285
- package/src/build.ts +0 -16
- package/src/module.d.ts +0 -3
package/src/types.ts
CHANGED
|
@@ -1,92 +1,76 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export type Config = {
|
|
2
|
+
key: string;
|
|
3
|
+
version: string;
|
|
4
|
+
sourcemapVersion: string;
|
|
5
|
+
stage: string;
|
|
6
|
+
maxGlowsPerReport: number;
|
|
7
|
+
reportBrowserExtensionErrors: boolean;
|
|
8
|
+
reportingUrl: string;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
beforeEvaluate: (error: Error) => Error | false | null | Promise<Error | false | null>;
|
|
11
|
+
beforeSubmit: (report: Report) => Report | false | null | Promise<Report | false | null>;
|
|
12
|
+
};
|
|
5
13
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
export type Report = {
|
|
15
|
+
notifier: string;
|
|
16
|
+
exception_class: string;
|
|
17
|
+
seen_at: number;
|
|
18
|
+
message: string;
|
|
19
|
+
language: 'javascript';
|
|
20
|
+
glows: Glow[];
|
|
21
|
+
context: Context;
|
|
22
|
+
stacktrace: StackFrame[];
|
|
23
|
+
sourcemap_version_id: string;
|
|
24
|
+
solutions: Solution[];
|
|
25
|
+
stage?: string;
|
|
26
|
+
};
|
|
9
27
|
|
|
10
|
-
|
|
11
|
-
key: string;
|
|
12
|
-
reportingUrl: string;
|
|
13
|
-
maxGlowsPerReport: number;
|
|
14
|
-
maxReportsPerMinute: number;
|
|
15
|
-
stage?: string;
|
|
16
|
-
};
|
|
28
|
+
export interface SolutionProviderExtraParameters {}
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
message: string;
|
|
23
|
-
language: 'javascript';
|
|
24
|
-
glows: Array<Flare.Glow>;
|
|
25
|
-
context: Flare.Context;
|
|
26
|
-
stacktrace: Array<Flare.StackFrame>;
|
|
27
|
-
sourcemap_version_id: string;
|
|
28
|
-
solutions: Array<Flare.Solution>;
|
|
29
|
-
stage?: string;
|
|
30
|
-
};
|
|
30
|
+
export type SolutionProvider = {
|
|
31
|
+
canSolve: (error: Error, extraParameters?: SolutionProviderExtraParameters) => boolean | Promise<boolean>;
|
|
32
|
+
getSolutions: (error: Error, extraParameters?: SolutionProviderExtraParameters) => Solution[] | Promise<Solution[]>;
|
|
33
|
+
};
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
export type Solution = {
|
|
36
|
+
class: string;
|
|
37
|
+
title: string;
|
|
38
|
+
description: string;
|
|
39
|
+
links: { [label: string]: string };
|
|
40
|
+
action_description?: string;
|
|
41
|
+
is_runnable?: boolean;
|
|
42
|
+
};
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
error: Error,
|
|
41
|
-
extraParameters?: SolutionProviderExtraParameters,
|
|
42
|
-
) => Array<Flare.Solution> | Promise<Array<Flare.Solution>>;
|
|
44
|
+
export type Context = {
|
|
45
|
+
request?: {
|
|
46
|
+
url?: String;
|
|
47
|
+
useragent?: String;
|
|
48
|
+
referrer?: String; // TODO: Flare doesn't catch this yet
|
|
49
|
+
readyState?: String; // TODO: Flare doesn't catch this yet
|
|
43
50
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
class: string;
|
|
47
|
-
title: string;
|
|
48
|
-
description: string;
|
|
49
|
-
links: { [label: string]: string };
|
|
50
|
-
action_description?: string;
|
|
51
|
-
is_runnable?: boolean;
|
|
51
|
+
request_data?: {
|
|
52
|
+
queryString: { [key: string]: string };
|
|
52
53
|
};
|
|
54
|
+
cookies?: { [key: string]: string };
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
};
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
cookies?: { [key: string]: string };
|
|
65
|
-
[key: string]: any;
|
|
66
|
-
};
|
|
58
|
+
export type StackFrame = {
|
|
59
|
+
line_number: number;
|
|
60
|
+
column_number: number; // TODO: Flare doesn't catch this yet
|
|
61
|
+
method: string;
|
|
62
|
+
file: string;
|
|
63
|
+
code_snippet: { [key: number]: string };
|
|
64
|
+
trimmed_column_number: number | null;
|
|
65
|
+
class: string;
|
|
66
|
+
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export type Glow = {
|
|
79
|
-
time: number;
|
|
80
|
-
microtime: number;
|
|
81
|
-
name: String;
|
|
82
|
-
message_level: MessageLevel;
|
|
83
|
-
meta_data: Array<Object>;
|
|
84
|
-
};
|
|
68
|
+
export type Glow = {
|
|
69
|
+
time: number;
|
|
70
|
+
microtime: number;
|
|
71
|
+
name: String;
|
|
72
|
+
message_level: MessageLevel;
|
|
73
|
+
meta_data: object | object[];
|
|
74
|
+
};
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
| 'info'
|
|
88
|
-
| 'debug'
|
|
89
|
-
| 'warning'
|
|
90
|
-
| 'error'
|
|
91
|
-
| 'critical';
|
|
92
|
-
}
|
|
76
|
+
export type MessageLevel = 'info' | 'debug' | 'warning' | 'error' | 'critical';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assert } from './assert';
|
|
2
|
+
|
|
3
|
+
export function assertKey(key: unknown, debug: boolean): boolean {
|
|
4
|
+
return assert(
|
|
5
|
+
key,
|
|
6
|
+
'The client was not yet initialised with an API key. ' +
|
|
7
|
+
"Run client.light('<flare-project-key>') when you initialise your app. " +
|
|
8
|
+
"If you are running in dev mode and didn't run the light command on purpose, you can ignore this error.",
|
|
9
|
+
debug
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { assert } from './assert';
|
|
2
|
+
|
|
3
|
+
export function assertSolutionProvider(solutionProvider: object, debug: boolean): boolean {
|
|
4
|
+
return (
|
|
5
|
+
assert('canSolve' in solutionProvider, 'A solution provider without a [canSolve] property was added.', debug) &&
|
|
6
|
+
assert(
|
|
7
|
+
'getSolutions' in solutionProvider,
|
|
8
|
+
'A solution provider without a [getSolutions] property was added.',
|
|
9
|
+
debug
|
|
10
|
+
)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// https://stackoverflow.com/a/11616993/6374824
|
|
2
|
+
export function flatJsonStringify(json: Object): string {
|
|
3
|
+
let cache: any = [];
|
|
4
|
+
|
|
5
|
+
const flattenedStringifiedJson = JSON.stringify(json, function (_, value) {
|
|
6
|
+
if (typeof value === 'object' && value !== null) {
|
|
7
|
+
if (cache.indexOf(value) !== -1) {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(JSON.stringify(value));
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
cache.push(value);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
cache = null;
|
|
20
|
+
|
|
21
|
+
return flattenedStringifiedJson;
|
|
22
|
+
}
|
package/src/util/index.ts
CHANGED
|
@@ -1,44 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return !!value;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// https://stackoverflow.com/a/11616993/6374824
|
|
14
|
-
export function flatJsonStringify(json: Object): string {
|
|
15
|
-
let cache: any = [];
|
|
16
|
-
|
|
17
|
-
const flattenedStringifiedJson = JSON.stringify(json, function (_, value) {
|
|
18
|
-
if (typeof value === 'object' && value !== null) {
|
|
19
|
-
if (cache.indexOf(value) !== -1) {
|
|
20
|
-
try {
|
|
21
|
-
return JSON.parse(JSON.stringify(value));
|
|
22
|
-
} catch (error) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
cache.push(value);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
cache = null;
|
|
32
|
-
|
|
33
|
-
return flattenedStringifiedJson;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function now(): number {
|
|
37
|
-
return Math.round(Date.now() / 1000);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function flattenOnce(array: Array<Array<any>>) {
|
|
41
|
-
return array.reduce((flat, toFlatten) => {
|
|
42
|
-
return flat.concat(toFlatten);
|
|
43
|
-
}, []);
|
|
44
|
-
}
|
|
1
|
+
export * from './assert';
|
|
2
|
+
export * from './assertKey';
|
|
3
|
+
export * from './assertSolutionProvider';
|
|
4
|
+
export * from './flatJsonStringify';
|
|
5
|
+
export * from './flattenOnce';
|
|
6
|
+
export * from './now';
|
package/src/util/now.ts
ADDED
package/tsconfig.json
CHANGED
package/src/FlareClient.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { assert, now, flatJsonStringify } from './util';
|
|
2
|
-
import { collectContext } from './context';
|
|
3
|
-
import { createStackTrace } from './stacktrace';
|
|
4
|
-
import build from './build';
|
|
5
|
-
import getSolutions from './solutions';
|
|
6
|
-
import { Flare } from './types';
|
|
7
|
-
|
|
8
|
-
export default class FlareClient {
|
|
9
|
-
public version: string = build.clientVersion;
|
|
10
|
-
|
|
11
|
-
public config: Flare.Config = {
|
|
12
|
-
key: '',
|
|
13
|
-
reportingUrl: 'https://flareapp.io/api/reports',
|
|
14
|
-
maxGlowsPerReport: 30,
|
|
15
|
-
maxReportsPerMinute: 500,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
private glows: Array<Flare.Glow> = [];
|
|
19
|
-
|
|
20
|
-
private context: Flare.Context = { context: {} };
|
|
21
|
-
|
|
22
|
-
public beforeEvaluate: Flare.BeforeEvaluate = (error) => error;
|
|
23
|
-
|
|
24
|
-
public beforeSubmit: Flare.BeforeSubmit = (report) => report;
|
|
25
|
-
|
|
26
|
-
private reportedErrorsTimestamps: Array<number> = [];
|
|
27
|
-
|
|
28
|
-
private solutionProviders: Array<Flare.SolutionProvider> = [];
|
|
29
|
-
|
|
30
|
-
private sourcemapVersion: string = build.sourcemapVersion;
|
|
31
|
-
|
|
32
|
-
public debug: boolean = false;
|
|
33
|
-
|
|
34
|
-
public stage: string | undefined = undefined;
|
|
35
|
-
|
|
36
|
-
public light(key: string = build.flareJsKey, debug = false): FlareClient {
|
|
37
|
-
this.debug = debug;
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
!assert(
|
|
41
|
-
key && typeof key === 'string',
|
|
42
|
-
'An empty or incorrect Flare key was passed, errors will not be reported.',
|
|
43
|
-
this.debug,
|
|
44
|
-
) ||
|
|
45
|
-
!assert(
|
|
46
|
-
Promise,
|
|
47
|
-
'ES6 promises are not supported in this environment, errors will not be reported.',
|
|
48
|
-
this.debug,
|
|
49
|
-
)
|
|
50
|
-
) {
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.config.key = key;
|
|
55
|
-
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public glow(
|
|
60
|
-
name: string,
|
|
61
|
-
level: Flare.MessageLevel = 'info',
|
|
62
|
-
metaData: Array<object> = [],
|
|
63
|
-
): FlareClient {
|
|
64
|
-
const time = now();
|
|
65
|
-
|
|
66
|
-
this.glows.push({
|
|
67
|
-
name,
|
|
68
|
-
message_level: level,
|
|
69
|
-
meta_data: metaData,
|
|
70
|
-
time,
|
|
71
|
-
microtime: time,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (this.glows.length > this.config.maxGlowsPerReport) {
|
|
75
|
-
this.glows = this.glows.slice(
|
|
76
|
-
this.glows.length - this.config.maxGlowsPerReport,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public addContext(name: string, value: any): FlareClient {
|
|
84
|
-
this.context.context[name] = value;
|
|
85
|
-
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public addContextGroup(groupName: string, value: object): FlareClient {
|
|
90
|
-
this.context[groupName] = value;
|
|
91
|
-
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public registerSolutionProvider(
|
|
96
|
-
provider: Flare.SolutionProvider,
|
|
97
|
-
): FlareClient {
|
|
98
|
-
if (
|
|
99
|
-
!assert(
|
|
100
|
-
'canSolve' in provider,
|
|
101
|
-
'A solution provider without a [canSolve] property was added.',
|
|
102
|
-
this.debug,
|
|
103
|
-
) ||
|
|
104
|
-
!assert(
|
|
105
|
-
'getSolutions' in provider,
|
|
106
|
-
'A solution provider without a [getSolutions] property was added.',
|
|
107
|
-
this.debug,
|
|
108
|
-
)
|
|
109
|
-
) {
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
this.solutionProviders.push(provider);
|
|
114
|
-
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public reportMessage(
|
|
119
|
-
message: string,
|
|
120
|
-
context: Flare.Context = {},
|
|
121
|
-
exceptionClass: string = 'Log',
|
|
122
|
-
): void {
|
|
123
|
-
const seenAt = now();
|
|
124
|
-
|
|
125
|
-
createStackTrace(Error()).then((stacktrace) => {
|
|
126
|
-
// The first item in the stacktrace is from this file, and irrelevant
|
|
127
|
-
stacktrace.shift();
|
|
128
|
-
|
|
129
|
-
const report: Flare.ErrorReport = {
|
|
130
|
-
notifier: `Flare JavaScript client v${build.clientVersion}`,
|
|
131
|
-
exception_class: exceptionClass,
|
|
132
|
-
seen_at: seenAt,
|
|
133
|
-
message: message,
|
|
134
|
-
language: 'javascript',
|
|
135
|
-
glows: this.glows,
|
|
136
|
-
context: collectContext({ ...context, ...this.context }),
|
|
137
|
-
stacktrace,
|
|
138
|
-
sourcemap_version_id: this.sourcemapVersion,
|
|
139
|
-
solutions: [],
|
|
140
|
-
stage: this.stage,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
this.sendReport(report);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public report(
|
|
148
|
-
error: Error,
|
|
149
|
-
context: Flare.Context = {},
|
|
150
|
-
extraSolutionParameters: Flare.SolutionProviderExtraParameters = {},
|
|
151
|
-
): void {
|
|
152
|
-
Promise.resolve(this.beforeEvaluate(error)).then(
|
|
153
|
-
(reportReadyForEvaluation) => {
|
|
154
|
-
if (!reportReadyForEvaluation) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.createReport(error, context, extraSolutionParameters).then(
|
|
159
|
-
(report) => (report ? this.sendReport(report) : {}),
|
|
160
|
-
);
|
|
161
|
-
},
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
public createReport(
|
|
166
|
-
error: Error,
|
|
167
|
-
context: Flare.Context = {},
|
|
168
|
-
extraSolutionParameters: Flare.SolutionProviderExtraParameters = {},
|
|
169
|
-
): Promise<Flare.ErrorReport | false> {
|
|
170
|
-
if (!assert(error, 'No error provided.', this.debug)) {
|
|
171
|
-
return Promise.resolve(false);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const seenAt = now();
|
|
175
|
-
|
|
176
|
-
return Promise.all([
|
|
177
|
-
getSolutions(
|
|
178
|
-
this.solutionProviders,
|
|
179
|
-
error,
|
|
180
|
-
extraSolutionParameters,
|
|
181
|
-
),
|
|
182
|
-
createStackTrace(error),
|
|
183
|
-
]).then((result) => {
|
|
184
|
-
const [solutions, stacktrace] = result;
|
|
185
|
-
|
|
186
|
-
assert(
|
|
187
|
-
stacktrace.length,
|
|
188
|
-
"Couldn't generate stacktrace of this error: " + error,
|
|
189
|
-
this.debug,
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
notifier: `Flare JavaScript client v${build.clientVersion}`,
|
|
194
|
-
exception_class:
|
|
195
|
-
error.constructor && error.constructor.name
|
|
196
|
-
? error.constructor.name
|
|
197
|
-
: 'undefined',
|
|
198
|
-
seen_at: seenAt,
|
|
199
|
-
message: error.message,
|
|
200
|
-
language: 'javascript',
|
|
201
|
-
glows: this.glows,
|
|
202
|
-
context: collectContext({ ...context, ...this.context }),
|
|
203
|
-
stacktrace,
|
|
204
|
-
sourcemap_version_id: this.sourcemapVersion,
|
|
205
|
-
solutions,
|
|
206
|
-
stage: this.stage,
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
private sendReport(report: Flare.ErrorReport): void {
|
|
212
|
-
if (
|
|
213
|
-
!assert(
|
|
214
|
-
this.config.key,
|
|
215
|
-
'The client was not yet initialised with an API key. ' +
|
|
216
|
-
"Run client.light('<flare-project-key>') when you initialise your app. " +
|
|
217
|
-
"If you are running in dev mode and didn't run the light command on purpose, you can ignore this error.",
|
|
218
|
-
this.debug,
|
|
219
|
-
)
|
|
220
|
-
) {
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (this.maxReportsPerMinuteReached()) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
Promise.resolve(this.beforeSubmit(report)).then(
|
|
229
|
-
(reportReadyForSubmit) => {
|
|
230
|
-
if (!reportReadyForSubmit) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
fetch(this.config.reportingUrl, {
|
|
235
|
-
method: 'POST',
|
|
236
|
-
headers: {
|
|
237
|
-
'Content-Type': 'application/json',
|
|
238
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
239
|
-
'x-api-token': this.config.key,
|
|
240
|
-
},
|
|
241
|
-
body: flatJsonStringify({
|
|
242
|
-
...reportReadyForSubmit,
|
|
243
|
-
key: this.config.key,
|
|
244
|
-
}),
|
|
245
|
-
}).then(
|
|
246
|
-
(response) => {
|
|
247
|
-
if (response.status !== 204) {
|
|
248
|
-
console.error(
|
|
249
|
-
`Received response with status ${response.status} from Flare`,
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
(error) => console.error(error),
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
this.reportedErrorsTimestamps.push(Date.now());
|
|
257
|
-
},
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
private maxReportsPerMinuteReached(): boolean {
|
|
262
|
-
if (
|
|
263
|
-
this.reportedErrorsTimestamps.length >=
|
|
264
|
-
this.config.maxReportsPerMinute
|
|
265
|
-
) {
|
|
266
|
-
const nErrorsBack =
|
|
267
|
-
this.reportedErrorsTimestamps[
|
|
268
|
-
this.reportedErrorsTimestamps.length -
|
|
269
|
-
this.config.maxReportsPerMinute
|
|
270
|
-
];
|
|
271
|
-
|
|
272
|
-
if (nErrorsBack > Date.now() - 60 * 1000) {
|
|
273
|
-
return true;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
public test(): FlareClient {
|
|
281
|
-
this.report(new Error('The Flare client is set up correctly!'));
|
|
282
|
-
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
}
|
package/src/build.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare const FLARE_JS_KEY: string | undefined;
|
|
2
|
-
declare const FLARE_SOURCEMAP_VERSION: string | undefined;
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
// Injected during build
|
|
6
|
-
clientVersion:
|
|
7
|
-
typeof process.env.FLARE_JS_CLIENT_VERSION === 'undefined'
|
|
8
|
-
? '?'
|
|
9
|
-
: process.env.FLARE_JS_CLIENT_VERSION,
|
|
10
|
-
// Optionally injected by flare-vite-plugin-sourcemap-uploader
|
|
11
|
-
flareJsKey: typeof FLARE_JS_KEY === 'undefined' ? '' : FLARE_JS_KEY,
|
|
12
|
-
sourcemapVersion:
|
|
13
|
-
typeof FLARE_SOURCEMAP_VERSION === 'undefined'
|
|
14
|
-
? ''
|
|
15
|
-
: FLARE_SOURCEMAP_VERSION,
|
|
16
|
-
};
|
package/src/module.d.ts
DELETED