-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[IGNORE WIP] Use FP to decrease bundle size #4381
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
Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
7bce4cc
IGNORE
yordis f553fef
asd
yordis d7a49d7
feat: move functions out of the class
yordis 2fbffc4
chore: move cloneScope to file context instead of being a static func…
yordis ac90228
chore: move more functions from the object out
yordis 4ac12dd
chore: move more hub functions out of the prototype
yordis 3feec27
chore: move fns outside class
yordis cef8a95
chore: fix compiler issues
yordis e2da41a
chore: move all methods from Hub class
yordis 8558cad
chore: rename field
yordis 482696f
chore: move declaration to body
yordis c25359c
chore: move functions out
yordis 98ebe31
fix: compiler issues
yordis 06042d0
fix: compilation issues
yordis f88b7fd
chore: remove Hub interface funcs
yordis 9fc028c
Update packages/integrations/src/angular.ts
yordis 712ebb8
chore: make scope functional
yordis 798210a
chore: reorder code
yordis db6dde6
chore: fix compiler
yordis c417d9a
Merge branch 'testing-fp-things' of github.com:yordis/sentry-javascri…
yordis 6c59dad
chore: fixing test cases
yordis 0bb6089
chore: fixing tests
yordis 648ca06
chore: make scope to pass tests
yordis 7b72534
chore: increase test coverage
yordis 434acc1
chore: fix tests
yordis 581e9e7
chore: fix test cases
yordis 07abdbe
chore: fix issues
yordis eff9fd4
chore: fix test
yordis 51976cb
fix node client
yordis 7c7bee2
chore: change session flusher api and hub functions
yordis 121a455
fix: node client
yordis 8bb8391
fix: minimal package
yordis ee258de
fix: core
yordis 64e9d6b
fix: browser
yordis a9204ed
fix: react
yordis 31c6711
fix: nextjs
yordis d1370e7
fix: tracing
yordis 8929a9f
fix: compilers
yordis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { getCurrentHub, initAndBind, Integrations as CoreIntegrations } from '@sentry/core'; | ||
import { Hub } from '@sentry/types'; | ||
import { | ||
getScopeUser, | ||
captureHubSession, | ||
getHubClient, | ||
getHubLastEventId, | ||
getHubScope, | ||
Hub, | ||
startHubSession, | ||
} from '@sentry/hub'; | ||
import { addInstrumentationHandler, getGlobalObject, isDebugBuild, logger, resolvedSyncPromise } from '@sentry/utils'; | ||
|
||
import { BrowserOptions } from './backend'; | ||
|
@@ -107,18 +115,18 @@ export function init(options: BrowserOptions = {}): void { | |
*/ | ||
export function showReportDialog(options: ReportDialogOptions = {}): void { | ||
const hub = getCurrentHub(); | ||
const scope = hub.getScope(); | ||
const scope = getHubScope(hub); | ||
if (scope) { | ||
options.user = { | ||
...scope.getUser(), | ||
...getScopeUser(scope), | ||
...options.user, | ||
}; | ||
} | ||
|
||
if (!options.eventId) { | ||
options.eventId = hub.lastEventId(); | ||
options.eventId = getHubLastEventId(hub); | ||
} | ||
const client = hub.getClient<BrowserClient>(); | ||
const client = getHubClient<BrowserClient>(hub); | ||
if (client) { | ||
client.showReportDialog(options); | ||
} | ||
|
@@ -130,7 +138,7 @@ export function showReportDialog(options: ReportDialogOptions = {}): void { | |
* @returns The last event id of a captured event. | ||
*/ | ||
export function lastEventId(): string | undefined { | ||
return getCurrentHub().lastEventId(); | ||
return getHubLastEventId(getCurrentHub()); | ||
} | ||
|
||
/** | ||
|
@@ -158,7 +166,7 @@ export function onLoad(callback: () => void): void { | |
* doesn't (or if there's no client defined). | ||
*/ | ||
export function flush(timeout?: number): PromiseLike<boolean> { | ||
const client = getCurrentHub().getClient<BrowserClient>(); | ||
const client = getHubClient<BrowserClient>(getCurrentHub()); | ||
if (client) { | ||
return client.flush(timeout); | ||
} | ||
|
@@ -177,7 +185,7 @@ export function flush(timeout?: number): PromiseLike<boolean> { | |
* doesn't (or if there's no client defined). | ||
*/ | ||
export function close(timeout?: number): PromiseLike<boolean> { | ||
const client = getCurrentHub().getClient<BrowserClient>(); | ||
const client = getHubClient<BrowserClient>(getCurrentHub()); | ||
if (client) { | ||
return client.close(timeout); | ||
} | ||
|
@@ -200,8 +208,8 @@ export function wrap(fn: (...args: any) => any): any { | |
} | ||
|
||
function startSessionOnHub(hub: Hub): void { | ||
hub.startSession({ ignoreDuration: true }); | ||
hub.captureSession(); | ||
startHubSession(hub, { ignoreDuration: true }); | ||
captureHubSession(hub); | ||
} | ||
|
||
/** | ||
|
@@ -226,9 +234,10 @@ function startSessionTracking(): void { | |
// https://github.com/getsentry/sentry-javascript/issues/3207 and | ||
// https://github.com/getsentry/sentry-javascript/issues/3234 and | ||
// https://github.com/getsentry/sentry-javascript/issues/3278. | ||
if (!hub.captureSession) { | ||
return; | ||
} | ||
// TODO: Follow up on this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get it but I dont ... probably need to circle back on this one |
||
// if (!hub.captureSession) { | ||
// return; | ||
// } | ||
|
||
// The session duration for browser sessions does not track a meaningful | ||
// concept that can be used as a metric. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
is no longer this ... therefore,_key
and_limit
should bepublic
... thinking later how to continue to do more FP tuff in another part of the code base