-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
653c9b3
commit 22ed844
Showing
7 changed files
with
0 additions
and
151 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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,55 +1,7 @@ | ||
import type { | ||
PlaidLinkError, | ||
PlaidLinkOnEventMetadata, | ||
PlaidLinkOnExitMetadata, | ||
} from 'react-plaid-link' | ||
|
||
export async function copyToClipboard(text: string) { | ||
if ('clipboard' in navigator) { | ||
return navigator.clipboard.writeText(text) | ||
} else { | ||
return document.execCommand('copy', true, text) | ||
} | ||
} | ||
|
||
export function getLocalStorageSession<TData>(key: string, initialValue: TData) { | ||
return { | ||
getLocalStorageItem: () => { | ||
if (typeof window === 'undefined') return initialValue | ||
|
||
const item = window.localStorage.getItem(key) | ||
|
||
return item ? (JSON.parse(item) as TData) : initialValue | ||
}, | ||
setLocalStorageItem: (data: TData | ((data: TData) => TData)) => { | ||
if (typeof window === 'undefined') return | ||
|
||
const previousValue = window.localStorage.getItem(key) | ||
|
||
const isFunc = data instanceof Function | ||
|
||
window.localStorage.setItem( | ||
key, | ||
JSON.stringify( | ||
isFunc ? data(previousValue ? JSON.parse(previousValue) : initialValue) : data | ||
) | ||
) | ||
}, | ||
} | ||
} | ||
|
||
export function prepareSentryContext( | ||
plaidMetadata: PlaidLinkOnExitMetadata | PlaidLinkOnEventMetadata, | ||
plaidError?: PlaidLinkError | null | ||
): { [key: string]: any } | undefined { | ||
if (!plaidError && !plaidMetadata) return undefined | ||
|
||
// The keys here will be the headers in Sentry context sections (hence the formatted spacing) | ||
const errorContext = plaidError ? { 'Plaid Error': plaidError } : undefined | ||
const metadataContext = plaidMetadata ? { 'Plaid Metadata': plaidMetadata } : undefined | ||
|
||
return { | ||
...errorContext, | ||
...metadataContext, | ||
} | ||
} |
This file contains 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 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