Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerbenw committed Nov 15, 2024
1 parent 8c4d59d commit 1b9a68e
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 4 deletions.
115 changes: 115 additions & 0 deletions packages/core/config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
export interface Schema {
apiKey: {
defaultValue: () => null
message: string
validate: (value: unknown) => boolean
}
appVersion: {
defaultValue: () => undefined
message: string
validate: (value: unknown) => boolean
}
appType: {
defaultValue: () => undefined
message: string
validate: (value: unknown) => boolean
}
autoDetectErrors: {
defaultValue: () => true
message: string
validate: (value: unknown) => boolean
}
enabledErrorTypes: {
defaultValue: () => { unhandledExceptions: boolean, unhandledRejections: boolean }
message: string
allowPartialObject: boolean
validate: (value: unknown) => boolean
}
onError: {
defaultValue: () => []
message: string
validate: (value: unknown) => boolean
}
onSession: {
defaultValue: () => []
message: string
validate: (value: unknown) => boolean
}
onBreadcrumb: {
defaultValue: () => []
message: string
validate: (value: unknown) => boolean
}
endpoints: {
defaultValue: (endpoints: { notify: string, sessions: string } | undefined) => { notify: string | null, sessions: string | null }
message: string
validate: (value: unknown) => boolean
}
autoTrackSessions: {
defaultValue: () => boolean
message: string
validate: (value: unknown) => boolean
}
enabledReleaseStages: {
defaultValue: () => null
message: string
validate: (value: unknown) => boolean
}
releaseStage: {
defaultValue: () => 'production'
message: string
validate: (value: unknown) => boolean
}
maxBreadcrumbs: {
defaultValue: () => 25
message: string
validate: (value: unknown) => boolean
}
enabledBreadcrumbTypes: {
defaultValue: () => ['navigation', 'request', 'process', 'log', 'user', 'state', 'error', 'manual']
message: string
validate: (value: unknown) => boolean
}
context: {
defaultValue: () => undefined
message: string
validate: (value: unknown) => boolean
}
user: {
defaultValue: () => {}
message: string
validate: (value: unknown) => boolean
}
metadata: {
defaultValue: () => {}
message: string
validate: (value: unknown) => boolean
}
logger: {
defaultValue: () => undefined
message: string
validate: (value: unknown) => boolean
}
redactedKeys: {
defaultValue: () => ['password']
message: string
validate: (value: unknown) => boolean
}
plugins: {
defaultValue: () => []
message: string
validate: (value: unknown) => boolean
}
featureFlags: {
defaultValue: () => []
message: string
validate: (value: unknown) => boolean
}
reportUnhandledPromiseRejectionsAsHandled: {
defaultValue: () => false
message: string
validate: (value: unknown) => boolean
}
}

export const schema: Schema
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import type ClientWithInternals from 'packages/core/client'
/*
* Leaves breadcrumbs when the user interacts with the DOM
*/
export default (win = window): Plugin<ClientWithInternals> => ({
export default (win = window): Plugin => ({
load: (client) => {
if (!('addEventListener' in win)) return
if (!client._isBreadcrumbTypeEnabled('user')) return
if (!(client as ClientWithInternals)._isBreadcrumbTypeEnabled('user')) return

win.addEventListener('click', (event) => {
let targetText, targetSelector
Expand All @@ -16,8 +16,8 @@ export default (win = window): Plugin<ClientWithInternals> => ({
targetSelector = getNodeSelector(event.target, win)
} catch (e) {
targetText = '[hidden]'
targetSelector = '[hidden]'
client._logger.error('Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z')
targetSelector = '[hidden]';
(client as ClientWithInternals)._logger.error('Cross domain error when tracking click event. See docs: https://tinyurl.com/yy3rn63z')
}
client.leaveBreadcrumb('UI click', { targetText, targetSelector }, 'user')
}, true)
Expand Down

0 comments on commit 1b9a68e

Please sign in to comment.