Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.3.2 update #248

Merged
merged 313 commits into from
Jun 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
313 commits
Select commit Hold shift + click to select a range
45ac71d
Feature/metrics (#36)
konraddysput Jun 30, 2023
fec485f
Add debug IDs support to sdk-core, node and browser packages (#33)
perf2711 Jul 3, 2023
9e9f4a6
Add ZIP upload of sourcemaps. (#37)
perf2711 Jul 11, 2023
5f01995
Adding React Backtrace Client, ErrorBoundary, and tests (#38)
adamcronin42 Jul 12, 2023
99c6e88
Add more robust error handling and common code for CLI. (#39)
perf2711 Jul 18, 2023
2f92702
Add CLI for manipulating source and sourcemap files. (#40)
perf2711 Jul 18, 2023
eff06ae
sdk: add 'backtrace.agent' attribute specifying submitting agent name…
perf2711 Jul 20, 2023
f9dffc3
Feature/react example app (#44)
adamcronin42 Jul 20, 2023
d27e520
Source debug ID insertion fixes. (#43)
perf2711 Jul 24, 2023
baf1890
cli: add glob patterns for finding files (#45)
perf2711 Jul 27, 2023
e1758f7
cli: add bin entry (#46)
perf2711 Jul 27, 2023
5ae3aaf
Include symbolication in the error object (#48)
konraddysput Jul 27, 2023
5454816
node uncaught error handler (#42)
konraddysput Jul 27, 2023
3179486
Before send event support (#49)
konraddysput Jul 31, 2023
7bd533d
Browser unhandler error handler (#51)
konraddysput Jul 31, 2023
71e56e2
Skip report callback (#50)
konraddysput Jul 31, 2023
3356bdf
Feature/component stack as backtracedata (#47)
adamcronin42 Aug 2, 2023
9a57e5d
Breadcrumbs support (#52)
konraddysput Aug 4, 2023
bc1b9cd
sourcemap tools: fix doesSourceMapHaveSources with undefined sources …
perf2711 Aug 4, 2023
17a9151
sourcemap tools: add common code for bundler plugins and CLI (#54)
perf2711 Aug 7, 2023
394cc50
cli: use common sourcemap tools code in CLI and add logging (#55)
perf2711 Aug 7, 2023
e27ee95
webpack plugin: update plugin to use common code (#56)
perf2711 Aug 7, 2023
e59c0d4
rollup: add rollup plugin (#57)
perf2711 Aug 7, 2023
871c27b
sourcemap tools: add stripping of sourceContent by default (#58)
perf2711 Aug 7, 2023
19d4f79
cli: add stripping sourcesContent by default (#59)
perf2711 Aug 7, 2023
c7d5f9c
sourcemap tools: fix invalid asset name for sourcemap upload
perf2711 Aug 7, 2023
57bd788
vite plugin based on rollup (#61)
perf2711 Aug 8, 2023
a70bd1b
Database support (#62)
konraddysput Aug 9, 2023
1ff97a7
Feature/error boundary name (#63)
adamcronin42 Aug 9, 2023
fda5b84
Browser breadcrumbs support (#64)
konraddysput Aug 9, 2023
f23f54b
cli: add chmod +x after build
perf2711 Aug 10, 2023
932282c
cli: quality of life improvements (#67)
perf2711 Aug 10, 2023
6b93fe1
Remove deduplication configuration
konraddysput Aug 10, 2023
e7ce9aa
node: add node diagnostics fatal error crash storage (#65)
perf2711 Aug 10, 2023
62a2b3a
node example: add OOM crash example (#66)
perf2711 Aug 10, 2023
e0c3194
cli: add subdomain and token options to upload (#68)
perf2711 Aug 10, 2023
91c92f0
Database send operations (#70)
konraddysput Aug 10, 2023
bb6c3df
Release setup (#71)
konraddysput Aug 10, 2023
25b21da
cli: add README.md (#69)
perf2711 Aug 11, 2023
684f840
Doc start (#60)
ianrice07 Aug 11, 2023
3526d89
Properly making @backtrace/browser a dependency (#72)
adamcronin42 Aug 14, 2023
d5b865d
Include OOM/native crash handler in the demo project
konraddysput Aug 16, 2023
e099b7c
Fix possible circular reference in the annotation object (#75)
konraddysput Aug 16, 2023
d32089f
Provide more detailed error-data information in the report object (#76)
konraddysput Aug 16, 2023
5d89a68
Backtrace report unhandled error/crash overrides (#77)
konraddysput Aug 16, 2023
c00caad
Allow to use only one client via user-friendly API (#78)
konraddysput Aug 16, 2023
b2d3975
Lazy load debug ids (#80)
konraddysput Aug 17, 2023
7425f54
Release files (#79)
konraddysput Aug 17, 2023
685c13c
Package export (#81)
konraddysput Aug 17, 2023
84010a7
Breadcrumb interceptor (#82)
konraddysput Aug 18, 2023
9a79a95
Feature/react redux middleware (#74)
adamcronin42 Aug 18, 2023
83d284c
Feature/browser readme (#84)
adamcronin42 Aug 23, 2023
56cac44
Feature/redux example (#83)
adamcronin42 Aug 23, 2023
ac31d5f
Adding react README.md (#86)
adamcronin42 Aug 23, 2023
fd1e5d6
Default true promise rejection
konraddysput Aug 23, 2023
ec1d4ac
Browser (#87)
konraddysput Aug 23, 2023
4218be3
Fallback to default log function if the util function is not availabl…
konraddysput Aug 24, 2023
a268cf0
Detect missing information about the agent and fallback to the defaul…
konraddysput Aug 24, 2023
bfbfd4c
Scope rename (#90)
konraddysput Aug 24, 2023
6e9659d
Invoke directly the console method to not generate an error in our code
konraddysput Aug 25, 2023
ea111f1
Source map tools README (#92)
konraddysput Aug 25, 2023
41fb8fc
SDK Core README (#91)
konraddysput Aug 25, 2023
2ab4feb
Backtrace node readme (#93)
konraddysput Aug 25, 2023
3c392f3
Add webpack readme
rick-bt Aug 25, 2023
184ab33
Add rollup, vite readmes. Fix instructions for url
rick-bt Aug 25, 2023
a6408e4
Merge pull request #97 from backtrace-labs/rick/sourcemap-readmes
rick-bt Aug 25, 2023
7b15d18
Updating target in base tsconfig to be es2015 (#98)
adamcronin42 Aug 25, 2023
9613891
Builder Api improvements (#95)
konraddysput Aug 28, 2023
d700a19
Client dispose (#94)
konraddysput Aug 28, 2023
2edd566
Client docs update (#100)
konraddysput Aug 28, 2023
25e69f4
Bin starting path (#99)
konraddysput Aug 28, 2023
6e4bb4c
Browser - simplify the Form data usage, export BacktraceBrowserReques…
konraddysput Aug 29, 2023
f71f478
Do not pass formdata content-type
konraddysput Aug 29, 2023
8b2c6f8
SDK-core: Version update 0.0.2
konraddysput Aug 29, 2023
b5141b5
Update SDK-Core package-lock.json
konraddysput Aug 29, 2023
20daf4d
Update SDK-Core package-lock.json
konraddysput Aug 29, 2023
2288041
NodeJS version update (#103)
konraddysput Aug 29, 2023
8617990
Browser update 0.0.2 (#104)
konraddysput Aug 29, 2023
448e721
React update 0.0.2 (#105)
konraddysput Aug 29, 2023
5bf198f
cli: do not filter out direct glob paths (#101)
perf2711 Aug 30, 2023
d477acb
cli: fix sourcemap upload issues (#102)
perf2711 Aug 30, 2023
294dbd9
sdk-core: fix skipping stack frame with message reports (#106)
perf2711 Aug 31, 2023
c3cf43a
add deferred user attributes (#110)
perf2711 Aug 31, 2023
2fd9cc4
Missing library name (#111)
konraddysput Aug 31, 2023
3113390
Detect unexpected message type and convert it to string (#112)
konraddysput Aug 31, 2023
d06ff19
SDK-core 0.0.3 release (#114)
konraddysput Aug 31, 2023
6502be4
browser: version 0.0.3, add dependency for sdk-core package (#108)
perf2711 Aug 31, 2023
d8bf3d9
react: version 0.0.3 (#109)
perf2711 Aug 31, 2023
d240d5d
Node: Version 0.0.3 (#115)
konraddysput Aug 31, 2023
aeb482e
Feature/error boundary fallback function (#116)
adamcronin42 Sep 1, 2023
5327496
cli: add `run` command executing everything in one go (#117)
perf2711 Sep 1, 2023
8780354
cli: add possibility of specifying source files for upload and add-so…
perf2711 Sep 4, 2023
f39a3cf
Source map tools 0.0.2 (#120)
konraddysput Sep 4, 2023
c5b6dbd
cli: fix missing sourcesContent after addSources
perf2711 Sep 4, 2023
9d76c47
Source map 0.0.3 release (#122)
konraddysput Sep 4, 2023
66b7ebb
sourcemap tools: fix sourcemap invalid sourcesContent and shebang off…
perf2711 Sep 7, 2023
b305ac3
cli: add asset error behavior (#124)
perf2711 Sep 7, 2023
8aebc93
Fixing typo (#126)
adamcronin42 Sep 7, 2023
e75924a
Combining the error and string overloads in BacktraceCoreClient.send(…
adamcronin42 Sep 11, 2023
d9811ef
Updating version in sourcemap-tol and updating monorepo package-lock.…
adamcronin42 Sep 11, 2023
df8c6ee
Updating tools/cli (#129)
adamcronin42 Sep 11, 2023
1008b80
cli: add integration tests for commands (#125)
perf2711 Sep 14, 2023
c9b5aa5
cli: optimization of `run` and simplification of code (#130)
perf2711 Sep 14, 2023
f76baf0
cli: remove duplicate debugIds before uploading (#131)
perf2711 Sep 14, 2023
8aae87e
cli: add finding sourcemap by {filename.js}.map (#132)
perf2711 Sep 14, 2023
4399567
CLI Release (#137)
konraddysput Sep 14, 2023
8fbb018
cli: fix unit tests (#138)
perf2711 Sep 15, 2023
323a678
Adding sourcemap support to react example (#133)
adamcronin42 Sep 15, 2023
85009bf
Single client instance (#134)
konraddysput Sep 15, 2023
97e5c48
Native Submission URLs (#136)
konraddysput Sep 15, 2023
1c09ebd
Allow Backtrace client to use core client attributes for any use case…
konraddysput Sep 15, 2023
e026a6c
Feature/attachment management (#140)
konraddysput Sep 15, 2023
3281527
Expose parsers from react client
konraddysput Sep 15, 2023
00f5ce2
Sdk-Core release 0.0.4 (#141)
konraddysput Sep 15, 2023
1aa7ec6
Browser release 0.0.4 (#142)
konraddysput Sep 15, 2023
ae497a9
Node release 0.0.4 (#143)
konraddysput Sep 15, 2023
550d630
React release 0.0.4 (#144)
konraddysput Sep 15, 2023
19bd248
Landing page readme
rick-bt Sep 15, 2023
9df6510
Update image to support light and dark modes.
rick-bt Sep 15, 2023
9ed0a93
Set max header image width.
rick-bt Sep 16, 2023
3b4a979
add events and modules to core client (#146)
perf2711 Sep 27, 2023
1bea758
node build and node example improvements (#148)
perf2711 Sep 27, 2023
5dae9c7
cli: various fixes (#149)
perf2711 Sep 27, 2023
92b1ddb
sdk-core, node: add file system abstractions (#147)
perf2711 Sep 29, 2023
eb27c2a
BT-700 Added feature descriptions and light/dark images.
rick-bt Sep 29, 2023
86990c7
Copy edit
rick-bt Sep 29, 2023
2ff8e6d
Update header image light/dark display
rick-bt Sep 29, 2023
7a3f502
node: breadcrumbs from previous session in database (#150)
perf2711 Oct 2, 2023
0002ade
node: attributes from previous session in native crashes (#152)
perf2711 Oct 2, 2023
75d7f2c
Error event callback if the error object is not available (#154)
konraddysput Oct 2, 2023
4134891
Do not use unsupported URL API in the react-native API (#153)
konraddysput Oct 2, 2023
f66863b
add NestJS library for handling NestJS errors (#151)
perf2711 Oct 2, 2023
66e5be7
Bigint serialization
konraddysput Oct 2, 2023
6ebbdc5
SDK-Core version bump to 0.0.5 (#156)
adamcronin42 Oct 2, 2023
f0efc81
Adding jsonEscaper to JSON.stringify() and not assuming action exists…
adamcronin42 Oct 2, 2023
760bf4b
Browser release 0.0.5 (#158)
adamcronin42 Oct 2, 2023
dcf43e3
React release 0.0.5 (#159)
adamcronin42 Oct 2, 2023
d5218ab
Adding real dependencies to example apps (#160)
adamcronin42 Oct 2, 2023
836f632
React native support (#119)
konraddysput Oct 3, 2023
2b060ae
Feature/react native demo (#155)
konraddysput Oct 3, 2023
3ab016c
Merge pull request #145 from backtrace-labs/update-core-readme
rick-bt Oct 3, 2023
7ef1510
BT-720 Initial draft
rick-bt Oct 4, 2023
c25a4e5
BT-720: Clean up some wording
rick-bt Oct 4, 2023
b7d9867
add methods to BacktraceBreadcrumbs interface and limit BacktraceMana…
perf2711 Oct 6, 2023
aacd8b1
Update packages/browser/README.md
rick-bt Oct 6, 2023
657d0fd
Update packages/browser/README.md
rick-bt Oct 6, 2023
bd1adec
Merge pull request #161 from backtrace-labs/BT-720-web-sdk-readme-rem…
rick-bt Oct 6, 2023
10a0dc1
Add breadcrumb attribute to the file (#165)
konraddysput Oct 9, 2023
6362984
sync versions script (#163)
perf2711 Oct 9, 2023
d6cd7a4
node: Remove overflowed records on the database startup and replace f…
konraddysput Oct 9, 2023
d2b5b22
sdk-core, browser, node, react, react-native: builder changes (#173)
perf2711 Oct 11, 2023
a295c16
sdk-core: version 0.0.6 (#168)
perf2711 Oct 16, 2023
f26a7ba
node: version 0.0.5 (#169)
perf2711 Oct 16, 2023
65846c7
nestjs: version 0.0.1 (#171)
perf2711 Oct 16, 2023
edc4085
sdk-core: remove const from Events for tsc <5 compatibility (#175)
perf2711 Oct 16, 2023
0e65316
cli: test and upload improvements (#179)
perf2711 Oct 16, 2023
b4c5c30
sdk-core: version 0.0.7 (#181)
perf2711 Oct 17, 2023
e609c8e
browser, node, react, react-native: update sdk-core dependency
perf2711 Oct 17, 2023
344c42a
node: version 0.0.6 (#183)
perf2711 Oct 18, 2023
401ce8c
nestjs: update node dependency to 0.0.6
perf2711 Oct 18, 2023
812b7e1
BT-734: React native readme
konraddysput Oct 18, 2023
57ee99b
react-native: android database support (#164)
konraddysput Oct 18, 2023
779aaef
react-native: Native database ios (#178)
konraddysput Oct 18, 2023
c429eac
clI: search sourcemaps in directory specified by sourceMappingURL (#174)
perf2711 Oct 19, 2023
cf20258
Bt 720 web sdk readme remove bt client methods (#180)
rick-bt Oct 19, 2023
5c12115
react, browser: add changelogs (#172)
perf2711 Oct 19, 2023
a44ddb0
electron: SDK for Electron (#176)
perf2711 Oct 19, 2023
71df3c0
electron example: add an example for using Electron SDK (#177)
perf2711 Oct 19, 2023
5f4e572
react-native: Add support for unhandled exception handler on Android …
konraddysput Oct 19, 2023
34524d6
Fixed dependencies
konraddysput Oct 19, 2023
44acbec
electron: add output dirs to .prettierignore (NFC)
perf2711 Oct 20, 2023
7f56c28
electron example: fix preload import
perf2711 Oct 20, 2023
479a68f
BT-733: Library rename backtrace-labs -> backtrace (#186)
konraddysput Oct 24, 2023
1ac3fcf
electron: add docs and README (#185)
perf2711 Oct 27, 2023
2897b33
Merge branch 'main' into dev
konraddysput Oct 30, 2023
0e597f1
electron: add additional attributes to main crashes (#188)
perf2711 Oct 30, 2023
f28ed16
scripts: add scripts for making releases (#182)
perf2711 Oct 31, 2023
22460c3
electron: add breadcrumbs (#189)
perf2711 Oct 31, 2023
7fa39c4
sdk-core, browser, node: add abort support to metrics and request han…
perf2711 Oct 31, 2023
12951bd
sdk-core: fix global is undeifned error
perf2711 Nov 3, 2023
cb2ce8c
node: fix missing FileSystem from node
perf2711 Nov 3, 2023
6296021
cli: fix include-sources flag in run
perf2711 Nov 3, 2023
ad6cb07
scripts: replace @backtrace-labs with @backtrace
perf2711 Nov 3, 2023
cc486c4
scripts: add simple --name switch to release scripts
perf2711 Nov 3, 2023
99310ea
scripts: fix package name without --name passed
perf2711 Nov 3, 2023
cd2945b
cli: version 0.2.1 (#192)
perf2711 Nov 3, 2023
79496d2
scripts: fix invalid positional arguments when arg=value is passed
perf2711 Nov 3, 2023
49ccd6b
node: version 0.1.1 (#193)
perf2711 Nov 6, 2023
49eaa7b
node: fix AlternatingFileWriter crash on high load (#195)
perf2711 Nov 9, 2023
75dcc97
nestjs: version 0.1.1 (#196)
perf2711 Nov 9, 2023
a9bc972
node: version 0.1.2 (#197)
perf2711 Nov 9, 2023
d4e2e62
node: export BacktraceNodeRequestHandler
perf2711 Nov 10, 2023
ba707fb
node: version 0.1.3 (#200)
perf2711 Nov 10, 2023
de63fe2
nestjs: add option to don't throw if BacktraceClient is undefined (#201)
perf2711 Nov 14, 2023
c34e414
electron: version 0.1.0 (#202)
perf2711 Nov 14, 2023
463a7e9
electron: version 0.1.0 hotfix - update @backtrace/node version
perf2711 Nov 14, 2023
58f0c5a
Main and dev rebase
konraddysput Nov 14, 2023
4238d0e
Hermes react stack trace (#194)
konraddysput Nov 15, 2023
8770eed
use Version 0.1.0
konraddysput Nov 16, 2023
e00601a
Source map global this (#203)
konraddysput Nov 17, 2023
a7d56bc
cli: partial processing (#198)
perf2711 Nov 17, 2023
5e01fa6
cli: support tuple paths (#199)
perf2711 Nov 20, 2023
a698bcd
node: fix native reports not sending after startup (#204)
perf2711 Nov 22, 2023
cd41693
browser: add middleware modes to redux middleware, move JSON action t…
perf2711 Nov 23, 2023
47dc6d8
Brand typo
konraddysput Nov 27, 2023
a68b173
react-native: ensure breadcrumb message is always a string type (#207)
konraddysput Nov 28, 2023
70a783f
react-native: managed breadcrumb support (#208)
konraddysput Nov 28, 2023
747504a
Dont create formdata without attachments (#206)
konraddysput Nov 28, 2023
63ee6f6
react-native: remove react dependency on react-native project (#209)
konraddysput Nov 28, 2023
e0b7b0f
sourcemap-tools: version 0.2.1 (#210)
perf2711 Nov 28, 2023
0d0ba2f
cli: version 0.3.0 (#211)
perf2711 Nov 28, 2023
52ee36e
sdk-core: version 0.2.0 (#212)
perf2711 Nov 28, 2023
bf200e6
node: version 0.2.0 (#213)
perf2711 Nov 28, 2023
110811d
browser: version 0.2.0 (#214)
perf2711 Nov 28, 2023
dbd7b5f
react: version 0.2.0 (#215)
perf2711 Nov 28, 2023
a232491
electron: version 0.2.0 (#216)
perf2711 Nov 28, 2023
dfc71b9
nestjs: version 0.2.0 (#217)
perf2711 Nov 28, 2023
ee9d0c4
React-Native support
konraddysput Nov 28, 2023
2b2a4ea
sourcemap-tools: improve sourcemap search from source file (#218)
perf2711 Dec 7, 2023
0a4cfd1
cli: add-sources error behavior (#220)
perf2711 Dec 12, 2023
094eb47
cli, sourcemap-tools: force snippet/comment generation (#219)
perf2711 Dec 12, 2023
c317450
sourcemap-tools: version 0.2.2 (#221)
perf2711 Dec 12, 2023
8b7eb7e
cli: version 0.3.1 (#222)
perf2711 Dec 12, 2023
d3a51a1
react-native Demo customizations
konraddysput Jan 3, 2024
72794ef
Use zlib instead of node:zlib
konraddysput Jan 3, 2024
b7f5efd
sourcemap-tools, cli: Version update
konraddysput Jan 3, 2024
2575a66
react-native: set transfer encoding to chunked (#223)
konraddysput Jan 4, 2024
fe32b84
Merge branch 'main' into dev
konraddysput Jan 4, 2024
a6c3bf5
Add support for async frames and generic params (#224)
konraddysput Jan 19, 2024
41e70f0
electron: update version to 28 (#226)
perf2711 Feb 7, 2024
f183971
electron: version 0.2.1 (#227)
perf2711 Feb 7, 2024
3e0f92a
cli: fix no error exit on upload fail
perf2711 Feb 23, 2024
bdb4f25
backtrace-node: Use https client only when the protocol is set to htt…
konraddysput Mar 14, 2024
4c04aee
sdk-core: Return send result (#233)
konraddysput Mar 15, 2024
bc3b3ce
Version 0.3.0 (#234)
konraddysput Mar 15, 2024
546b2d5
sdk-core: Destroy client on dispose (#235)
konraddysput Mar 19, 2024
16a8f6b
Sdk-core: Changelog update (#236)
konraddysput Mar 19, 2024
7dbe1ef
sdk-core: add useModule to builder, export dataStructures (#238)
perf2711 Apr 10, 2024
7f01062
session-replay: add session replay package (#239)
perf2711 Apr 10, 2024
17a54ad
chore: sync dependency versions
perf2711 Apr 11, 2024
b5f51fa
react-native: Attribute map - fixed attribute names for react-native …
konraddysput Apr 12, 2024
29b4df6
Auto source map upload on Android (#243)
konraddysput Apr 12, 2024
7f06777
react-native: Fixed application.version attribute
konraddysput Apr 26, 2024
4e562b3
react-native: Enable correctly OOM Watcher and do not report OOMs fro…
konraddysput Apr 26, 2024
89357c7
iOS source map support (#244)
konraddysput May 6, 2024
9336338
Exit on disabled database (#245)
konraddysput May 7, 2024
39e449a
Use abort controller from utility
konraddysput May 8, 2024
9046b0b
Use transfer encoding header (#246)
konraddysput May 8, 2024
e229c75
Release 0.3.2 (#247)
konraddysput May 9, 2024
c73101c
Merge branch 'main' into dev
konraddysput Jun 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Feature/metrics (#36)
* URL parsers

* Command line attribute provider

* Code review suggestions

* Metrics support

* Nullable token

* Accept null | undefined

* Correct import

* Determines typo

* Code review adjustements

* Code review adjustements, test based on the variable and not random date, delay helper reject

* Recursive to iterative + delay helper error on reject

* Added one more test case

* Rollback submission url in the test
  • Loading branch information
konraddysput authored Jun 30, 2023
commit 45ac71d47bc8fa5e8a924719418a088495a17dad
6 changes: 6 additions & 0 deletions examples/sdk/browser/index.html
Original file line number Diff line number Diff line change
@@ -31,6 +31,12 @@ <h1 class="card-header" style="text-align: left">Welcome to the Backtrace demo</
<div class="action-button center">
<a class="text" id="send-message" target="_blank">Send a message</a>
</div>
<div class="action-button center">
<a class="text" id="generate-metric" target="_blank">Generate metric</a>
</div>
<div class="action-button center">
<a class="text" id="send-metrics" target="_blank">Send metrics</a>
</div>
</div>
<div class="summary-information">
<p>If you have any questions or concerns, please contact us at</p>
22 changes: 22 additions & 0 deletions examples/sdk/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ function parseNotExistingDomElement(): string {

const sendErrorButton = document.getElementById('send-error') as HTMLElement;
const sendMessageButton = document.getElementById('send-message') as HTMLElement;
const generateMetricButton = document.getElementById('generate-metric') as HTMLElement;
const sendMetricsButton = document.getElementById('send-metrics') as HTMLElement;

async function sendHandledException() {
try {
@@ -40,5 +42,25 @@ async function sendMessage() {
]);
}

function generateMetric() {
console.log('generate-metric click');
if (!client.metrics) {
console.log('metrics are unavailable');
return;
}
client.metrics.addSummedEvent('click');
}

function sendMetrics() {
console.log('send-metrics click');
if (!client.metrics) {
console.log('metrics are unavailable');
return;
}
client.metrics.send();
}

sendErrorButton.onclick = sendHandledException;
sendMessageButton.onclick = sendMessage;
generateMetricButton.onclick = generateMetric;
sendMetricsButton.onclick = sendMetrics;
24 changes: 24 additions & 0 deletions examples/sdk/node/src/index.ts
Original file line number Diff line number Diff line change
@@ -38,11 +38,27 @@ async function sendMessage(message: string, attributes: Record<string, number>)
await client.send(message, attributes);
}

function addEvent(name: string, attributes: Record<string, number>) {
if (!client.metrics) {
console.log('metrics are unavailable');
return;
}
client.metrics.addSummedEvent(name, attributes);
}
function sendMetrics() {
if (!client.metrics) {
console.log('metrics are unavailable');
return;
}
client.metrics.send();
}
function showMenu() {
const menu =
`Please pick one of available options:\n` +
`1. Send an exception\n` +
`2. Send a message\n` +
`3. Add a new summed event\n` +
`4. Send all metrics\n` +
`0. Exit\n` +
`Type the option number:`;
reader.question(menu, async function executeUserOption(optionString: string) {
@@ -59,6 +75,14 @@ function showMenu() {
await sendMessage('test message', attributes);
break;
}
case 3: {
addEvent('Option clicked', attributes);
break;
}
case 4: {
sendMetrics();
break;
}
case 0: {
reader.close();
return exit(0);
68 changes: 68 additions & 0 deletions packages/browser/src/BacktraceBrowserSessionProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { BacktraceSessionProvider, IdGenerator } from '@backtrace/sdk-core';
import { TimeHelper } from '@backtrace/sdk-core/lib/common/TimeHelper';

export class BacktraceBrowserSessionProvider implements BacktraceSessionProvider {
/**
* Session persistence interval. If no event was send in the persistence interval
* the session is treaten as an old session.
*/
public static readonly PERSISTENCE_INTERVAL = TimeHelper.convertSecondsToMilliseconds(30 * 60);
private readonly SESSION_LAST_ACTIVE = 'backtrace-last-active';
private readonly SESSION_GUID = 'backtrace-guid';

get lastActive(): number {
return this._lastActive;
}

public readonly newSession: boolean = true;

public readonly sessionId: string = IdGenerator.uuid();

private _lastActive = 0;

constructor() {
if (!window.localStorage) {
return;
}

const lastActive = this.readLastActiveTimestamp();
if (!lastActive || TimeHelper.now() - lastActive > BacktraceBrowserSessionProvider.PERSISTENCE_INTERVAL) {
this.updateLastActiveTimestamp();
localStorage.setItem(this.SESSION_GUID, this.sessionId);
return;
}
this._lastActive = lastActive;
this.newSession = false;
this.sessionId = localStorage.getItem(this.SESSION_GUID) as string;
}

public afterMetricsSubmission(): void {
this.updateLastActiveTimestamp();
}

public shouldSend(): boolean {
// if the document is hidden, we shouldn't send metrics, because the open document
// is the one who is being used by the user. This condition makes sure two or more web
// browser tabs of the same app won't report the same metrics or false positive metrics.
return document.hidden === false;
}

private readLastActiveTimestamp(): number | undefined {
const lastActiveStringTimestamp = localStorage.getItem(this.SESSION_LAST_ACTIVE);
if (!lastActiveStringTimestamp) {
return undefined;
}

const lastActive = parseInt(lastActiveStringTimestamp, 10);
if (isNaN(lastActive)) {
return undefined;
}

return lastActive;
}

public updateLastActiveTimestamp() {
this._lastActive = TimeHelper.now();
localStorage.setItem(this.SESSION_LAST_ACTIVE, this._lastActive.toString(10));
}
}
3 changes: 2 additions & 1 deletion packages/browser/src/BacktraceClient.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import {
BacktraceStackTraceConverter,
} from '@backtrace/sdk-core';
import { AGENT } from './agentDefinition';
import { BacktraceBrowserSessionProvider } from './BacktraceBrowserSessionProvider';
import { BacktraceConfiguration } from './BacktraceConfiguration';
import { BacktraceClientBuilder } from './builder/BacktraceClientBuilder';

@@ -15,7 +16,7 @@ export class BacktraceClient extends BacktraceCoreClient {
attributeProviders: BacktraceAttributeProvider[],
stackTraceConverter: BacktraceStackTraceConverter,
) {
super(options, AGENT, handler, attributeProviders, stackTraceConverter);
super(options, AGENT, handler, attributeProviders, stackTraceConverter, new BacktraceBrowserSessionProvider());
}

public static builder(options: BacktraceConfiguration): BacktraceClientBuilder {
36 changes: 13 additions & 23 deletions packages/browser/tests/client/clientTests.spec.ts
Original file line number Diff line number Diff line change
@@ -7,26 +7,25 @@ describe('Client tests', () => {
postError: jest.fn().mockResolvedValue(Promise.resolve()),
};

const defaultClientOptions = {
name: 'test',
version: '1.0.0',
url: 'https://submit.backtrace.io/foo/bar/baz',
metrics: {
enable: false,
},
};

let client: BacktraceClient;
it('Should create a client', () => {
client = BacktraceClient.builder({
name: 'test',
version: '1.0.0',
url: 'https://submit.backtrace.io/foo/bar/baz',
}).build();
client = BacktraceClient.builder(defaultClientOptions).build();

expect(client).toBeDefined();
});

describe('Send tests', () => {
beforeEach(() => {
client = BacktraceClient.builder({
name: 'test',
version: '1.0.0',
url: 'https://submit.backtrace.io/foo/bar/baz',
})
.useRequestHandler(requestHandler)
.build();
client = BacktraceClient.builder(defaultClientOptions).useRequestHandler(requestHandler).build();
});
it(`Should not throw an error when sending a message`, async () => {
expect(async () => await client.send('test')).not.toThrow();
@@ -48,9 +47,7 @@ describe('Client tests', () => {
it(`Should generate an attachment list based on the client options`, async () => {
const testedAttachment = new BacktraceUint8ArrayAttachment('client-add-test', new Uint8Array(0));
client = BacktraceClient.builder({
name: 'test',
version: '1.0.0',
url: 'https://submit.backtrace.io/foo/bar/baz',
...defaultClientOptions,
attachments: [testedAttachment],
})
.useRequestHandler(requestHandler)
@@ -63,14 +60,7 @@ describe('Client tests', () => {

it(`Should allow to add more attachments`, async () => {
const testedAttachment = new BacktraceUint8ArrayAttachment('client-add-test', new Uint8Array(0));
client = BacktraceClient.builder({
name: 'test',
version: '1.0.0',
url: 'https://submit.backtrace.io/foo/bar/baz',
attachments: [],
})
.useRequestHandler(requestHandler)
.build();
client = BacktraceClient.builder(defaultClientOptions).useRequestHandler(requestHandler).build();

client.attachments.push(testedAttachment);
expect(client.attachments).toBeDefined();
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { TimeHelper } from '@backtrace/sdk-core/lib/common/TimeHelper';
import { BacktraceBrowserSessionProvider } from '../../src/BacktraceBrowserSessionProvider';
describe('Session provider tests', () => {
it('Should generate a new uuid on new session', () => {
const sessionProvider = new BacktraceBrowserSessionProvider();

expect(sessionProvider.sessionId).toBeDefined();
});

it('Should reuse the same sessionId', () => {
const sessionProvider1 = new BacktraceBrowserSessionProvider();
const sessionProvider2 = new BacktraceBrowserSessionProvider();
expect(sessionProvider1.sessionId).toEqual(sessionProvider2.sessionId);
});

it('Should generate a new sessionId if the lastActive timestamp is greater than persistence interval time', () => {
const fakeId = 'test';
const lastSessionActiveDate = new Date(Date.now() - BacktraceBrowserSessionProvider.PERSISTENCE_INTERVAL - 1);
localStorage.setItem('backtrace-last-active', lastSessionActiveDate.getTime().toString(10));
localStorage.setItem('backtrace-guid', fakeId);

const sessionProvider = new BacktraceBrowserSessionProvider();
expect(sessionProvider.sessionId).toBeDefined();
expect(sessionProvider.sessionId).not.toEqual(fakeId);
});

it('Should not generate a new sessionId if the lastActive timestamp is lower than persistence interval time', () => {
const fakeId = 'test';
const lastSessionActiveDate = new Date(Date.now() - BacktraceBrowserSessionProvider.PERSISTENCE_INTERVAL + 1);
localStorage.setItem('backtrace-last-active', lastSessionActiveDate.getTime().toString(10));
localStorage.setItem('backtrace-guid', fakeId);

const sessionProvider = new BacktraceBrowserSessionProvider();
expect(sessionProvider.sessionId).toBeDefined();
expect(sessionProvider.sessionId).toEqual(fakeId);
});

it('Should update timestamp', () => {
const timestamp = Date.now();
jest.spyOn(TimeHelper, 'now').mockImplementation(() => {
return timestamp;
});

localStorage.setItem('backtrace-last-active', new Date(2010, 1, 1, 1, 1, 1, 1).getTime().toString(10));
const sessionProvider = new BacktraceBrowserSessionProvider();

sessionProvider.afterMetricsSubmission();

expect(sessionProvider.lastActive).toEqual(timestamp);
});
});
30 changes: 11 additions & 19 deletions packages/node/tests/client/clientTests.spec.ts
Original file line number Diff line number Diff line change
@@ -8,22 +8,22 @@ describe('Client tests', () => {
postError: jest.fn().mockResolvedValue(Promise.resolve()),
};

const defaultClientOptions = {
url: 'https://submit.backtrace.io/foo/bar/baz',
metrics: {
enable: false,
},
};
let client: BacktraceClient;
it('Should create a client', () => {
client = BacktraceClient.builder({
url: 'https://submit.backtrace.io/foo/bar/baz',
}).build();
client = BacktraceClient.builder(defaultClientOptions).build();

expect(client).toBeDefined();
});

describe('Send tests', () => {
beforeEach(() => {
client = BacktraceClient.builder({
url: 'https://submit.backtrace.io/foo/bar/baz',
})
.useRequestHandler(requestHandler)
.build();
client = BacktraceClient.builder(defaultClientOptions).useRequestHandler(requestHandler).build();
});
it(`Should not throw an error when sending a message`, async () => {
expect(async () => await client.send('test')).not.toThrow();
@@ -46,10 +46,7 @@ describe('Client tests', () => {
const fileContent = fs.readFileSync(sampleFile, 'utf8');

it(`Should generate an attachment list based on the client options`, async () => {
client = BacktraceClient.builder({
url: 'https://submit.backtrace.io/foo/bar/baz',
attachments: [sampleFile],
})
client = BacktraceClient.builder({ ...defaultClientOptions, attachments: [sampleFile] })
.useRequestHandler(requestHandler)
.build();

@@ -66,7 +63,7 @@ describe('Client tests', () => {
it(`Should allow to setup bufer attachment`, async () => {
const testedBuffer = Buffer.from('test');
client = BacktraceClient.builder({
url: 'https://submit.backtrace.io/foo/bar/baz',
...defaultClientOptions,
attachments: [new BacktraceBufferAttachment('test', testedBuffer)],
})
.useRequestHandler(requestHandler)
@@ -79,12 +76,7 @@ describe('Client tests', () => {

it(`Should allow to add more attachments`, async () => {
const testedAttachment = new BacktraceFileAttachment(sampleFile);
client = BacktraceClient.builder({
url: 'https://submit.backtrace.io/foo/bar/baz',
attachments: [],
})
.useRequestHandler(requestHandler)
.build();
client = BacktraceClient.builder(defaultClientOptions).useRequestHandler(requestHandler).build();

client.attachments.push(testedAttachment);
expect(client.attachments).toBeDefined();
Loading