Skip to content

Commit cd678a9

Browse files
committed
Squashed commit of the following:
commit 411e7f5 Merge: 68ef1d8 c366034 Author: Konrad Dysput <[email protected]> Date: Mon May 29 15:50:49 2023 +0200 Merge branch 'feature/monorepo-setup' into dev commit c366034 Author: Konrad Dysput <[email protected]> Date: Mon May 29 13:12:04 2023 +0200 Test setup (#2) commit 68ef1d8 Author: Konrad Dysput <[email protected]> Date: Mon May 29 13:11:27 2023 +0200 Monorepo setup (#1) * Monorepo setup * Package rename * Code review adjustements * Sdk core rename * Use unknown instead of any * Rename method * Added missing commands * Configuration changes * database as an option of a client * Merge client settings * Basic Backtrace configuration settings union * Optional token * Remove legacy - use direct submission url instead * Interface rename * Optional rate limit * Deduplication settings * Retry interval in ms instead of sec * Report getters * Use fields as attachments/attributes in the report object commit 13eb7aa Author: Konrad Dysput <[email protected]> Date: Mon May 29 13:08:29 2023 +0200 Use fields as attachments/attributes in the report object commit 3825fba Author: Konrad Dysput <[email protected]> Date: Mon May 29 13:01:35 2023 +0200 Report getters commit 0c7e62d Author: Konrad Dysput <[email protected]> Date: Mon May 29 13:01:16 2023 +0200 Retry interval in ms instead of sec commit 8b34c72 Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:57:49 2023 +0200 Deduplication settings commit 4328c3c Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:52:38 2023 +0200 Optional rate limit commit 889277c Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:47:55 2023 +0200 Interface rename commit 6abd107 Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:47:24 2023 +0200 Remove legacy - use direct submission url instead commit d84df8a Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:45:12 2023 +0200 Optional token commit 3eca08e Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:38:03 2023 +0200 Basic Backtrace configuration settings union commit 7506c02 Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:27:40 2023 +0200 Merge client settings commit 9309487 Author: Konrad Dysput <[email protected]> Date: Mon May 29 12:26:02 2023 +0200 database as an option of a client commit ce82a24 Author: Konrad Dysput <[email protected]> Date: Mon May 29 11:55:29 2023 +0200 Configuration changes commit 6674401 Author: Konrad Dysput <[email protected]> Date: Mon May 29 10:58:57 2023 +0200 Added missing commands commit 433f23b Author: Konrad Dysput <[email protected]> Date: Mon May 29 10:45:50 2023 +0200 Rename method
1 parent 10f3e76 commit cd678a9

10 files changed

+2041
-2397
lines changed

package-lock.json

+1,963-2,358
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/browser/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8+
"build": "tsc",
9+
"clean": "tsc -b --clean && rimraf \"lib\"",
10+
"format": "prettier --write '**/*.ts'",
11+
"lint": "eslint . --ext .ts",
12+
"watch": "tsc -w",
813
"test": "NODE_ENV=test jest"
914
},
1015
"repository": {

packages/node/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8+
"build": "tsc",
9+
"clean": "tsc -b --clean && rimraf \"lib\"",
10+
"format": "prettier --write '**/*.ts'",
11+
"lint": "eslint . --ext .ts",
12+
"watch": "tsc -w",
813
"test": "NODE_ENV=test jest"
914
},
1015
"engines": {

packages/sdk-core/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8+
"build": "tsc",
9+
"clean": "tsc -b --clean && rimraf \"lib\"",
10+
"format": "prettier --write '**/*.ts'",
11+
"lint": "eslint . --ext .ts",
12+
"watch": "tsc -w",
813
"test": "NODE_ENV=test jest"
914
},
1015
"repository": {

packages/sdk-core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './model/configuration/BacktraceConfiguration';
33
export * from './model/configuration/BacktraceDatabaseConfiguration';
44
export * from './model/report/BacktraceAttachment';
55
export * from './model/report/BacktraceReport';
6+
export * from './model/report/ErrorType';
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
import { BacktraceAttachment } from '../report/BacktraceAttachment';
22
import { BacktraceDatabaseConfiguration } from './BacktraceDatabaseConfiguration';
33

4-
// Submission information
5-
export type BacktraceBasicSubmissionInformation = {
6-
/**
7-
* The server address (submission URL) is required to submit exceptions from your project to your Backtrace instance.
8-
*
9-
* The Server Address must be in the following format: https://submit.backtrace.io/{subdomain}/{submission-token}/json.
10-
*/
11-
url: string;
12-
timeout?: number;
13-
ignoreSslCertificate?: boolean;
14-
};
15-
export type BacktraceLegacySubmitInformation = BacktraceBasicSubmissionInformation & { token: string };
16-
export type BacktraceSubmissionInformation = BacktraceBasicSubmissionInformation | BacktraceLegacySubmitInformation;
17-
18-
export type BacktraceMetricsSupport = {
4+
export interface BacktraceMetricsSupport {
195
metricsSubmissionUrl?: string;
206
enable: boolean;
217
ignoreSslCertificate?: boolean;
@@ -24,14 +10,33 @@ export type BacktraceMetricsSupport = {
2410
* By default, session events are sent on application startup/finish, and every 30 minutes while the game is running.
2511
*/
2612
autoSendInterval?: number;
27-
};
13+
}
14+
15+
export interface BacktraceConfiguration {
16+
/**
17+
* The server address (submission URL) is required to submit exceptions from your project to your Backtrace instance.
18+
*
19+
* The Server Address must be in the following format: https://submit.backtrace.io/{subdomain}/{submission-token}/json
20+
*
21+
* For users who need to use a direct URL to the Backtrace instance, the server address must be in the following format:
22+
* https://universe-name.sp.backtrace.io:6098/
23+
*
24+
* The direct submission URL requires an optional token to be available.
25+
*/
26+
url: string;
27+
28+
/**
29+
* Submission token - the token is required only if the user uses direct submission URL to Backtrace.
30+
*/
31+
token?: string;
32+
timeout?: number;
33+
ignoreSslCertificate?: boolean;
2834

29-
export type BasicBacktraceClientSettings = BacktraceBasicSubmissionInformation & {
3035
/**
3136
* Limits the number of reports the client will send per minute. If set to '0', there is no limit.
3237
* If set to a value greater than '0' and the value is reached, the client will not send any reports until the next minute.
3338
*/
34-
rateLimit: number;
39+
rateLimit?: number;
3540
/**
3641
* Attributes are additional metadata that can be attached to error and crash reports. You can use attributes to filter,
3742
* aggregate, analyze, and debug errors in the Backtrace console.
@@ -46,6 +51,8 @@ export type BasicBacktraceClientSettings = BacktraceBasicSubmissionInformation &
4651
* Metrics such as crash free users and crash free sessions
4752
*/
4853
metrics?: BacktraceMetricsSupport;
49-
};
50-
51-
export type BacktraceConfiguration = BasicBacktraceClientSettings & BacktraceDatabaseConfiguration;
54+
/**
55+
* Offline database settings
56+
*/
57+
database?: BacktraceDatabaseConfiguration;
58+
}

packages/sdk-core/src/model/configuration/BacktraceDatabaseConfiguration.ts

+28-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
export enum DeduplicationStrategy {
2+
/**
3+
* Duplicated reports are not aggregated
4+
*/
25
None = 0,
6+
/**
7+
* Aggregates based on the current stack trace
8+
*/
39
Callstack = 1 << 0,
10+
/**
11+
* Aggregates by stack trace and exception type
12+
*/
413
Classifier = 1 << 1,
14+
/**
15+
* Aggregates by stack trace and exception message
16+
*/
517
Message = 1 << 2,
18+
/**
19+
* Aggregates by faulting callstack, exception type, and exception message
20+
*/
621
All = ~(~0 << 4),
722
}
8-
export type EnabledBacktraceConfiguration = {
23+
export interface EnabledBacktraceDatabaseConfiguration {
924
/**
1025
* Determine if the Database is enabled
1126
*/
@@ -16,17 +31,13 @@ export type EnabledBacktraceConfiguration = {
1631
path: string;
1732
/**
1833
* Determine if the directory should be auto created by the SDK.
19-
* By default = true.
34+
* By default true.
2035
*/
2136
createDatabaseDirectory?: boolean;
2237

2338
/**
24-
* Aggregates duplicated reports. The available options are:
25-
* None: Duplicated reports are not aggregated.
26-
* Callstack: Aggregates based on the current stack trace.
27-
* Classifier: Aggregates by stack trace and exception type.
28-
* Message: Aggregates by stack trace and exception message.
29-
* All: Aggregates by faulting callstack, exception type, and exception message.
39+
* Duplicated reports aggregration settings. If defined, the same reports can be combined
40+
* together.
3041
*/
3142
deduplicationStrategy?: DeduplicationStrategy;
3243

@@ -50,22 +61,25 @@ export type EnabledBacktraceConfiguration = {
5061
*/
5162
maximumDatabaseSizeInMb?: number;
5263
/**
53-
* The amount of time (in seconds) to wait between retries if the database is unable to send a report.
54-
* The default value is 60
64+
* The amount of time (in ms) to wait between retries if the database is unable to send a report.
65+
* The default value is 60 000
5566
*/
5667
retryInterval?: number;
5768
/**
5869
* The maximum number of retries to attempt if the database is unable to send a report.
5970
* The default value is 3
6071
*/
6172
maximumRetries?: number;
62-
};
73+
}
6374

64-
export type DisabledBacktraceConfiguration = {
75+
export interface DisabledBacktraceDatabaseConfiguration
76+
extends Omit<Partial<EnabledBacktraceDatabaseConfiguration>, 'enabled'> {
6577
/**
6678
* Determine if the Database is enabled
6779
*/
6880
enabled?: false;
69-
} & Partial<EnabledBacktraceConfiguration>;
81+
}
7082

71-
export type BacktraceDatabaseConfiguration = EnabledBacktraceConfiguration | DisabledBacktraceConfiguration;
83+
export type BacktraceDatabaseConfiguration =
84+
| EnabledBacktraceDatabaseConfiguration
85+
| DisabledBacktraceDatabaseConfiguration;
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
export type BacktraceInMemoryAttachment = {
1+
export interface BacktraceInMemoryAttachment {
22
/**
33
* Attachment name
44
*/
55
name: string;
66
/**
77
* Attachment data
88
*/
9-
data: string;
10-
};
9+
data: Uint8Array;
10+
}
1111

1212
export type BacktraceFileAttachment = string;
1313
export type BacktraceAttachment = BacktraceInMemoryAttachment | BacktraceFileAttachment;

packages/sdk-core/src/model/report/BacktraceReport.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BacktraceAttachment } from './BacktraceAttachment';
2+
import { ErrorType } from './ErrorType';
23

34
export class BacktraceReport {
45
/**
@@ -29,7 +30,7 @@ export class BacktraceReport {
2930
public readonly attributes: Record<string, unknown> = {},
3031
public readonly attachments: BacktraceAttachment[] = [],
3132
) {
32-
let errorType: string = 'Exception';
33+
let errorType: ErrorType = 'Exception';
3334
if (data instanceof Error) {
3435
this.annotations['error'] = data;
3536
this.classifiers = [data.name];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type ErrorType = 'Exception' | 'Unhandled Exception' | 'Message' | 'Crash' | 'OOMException';

0 commit comments

Comments
 (0)