mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor: eject platform env, extract oauth
This commit is contained in:
parent
53796dec97
commit
83690816cf
3 changed files with 8 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import * as Sentry from '@sentry/browser'
|
||||
import { Middleware } from 'driver/connect.js'
|
||||
import { IN_PRODUCTION_MODE, PLATFORM } from 'env'
|
||||
import { IN_PRODUCTION_MODE } from 'env'
|
||||
import { version } from '../package.json'
|
||||
|
||||
const PUBLIC_KEY = 'd22ec5c9cc874539a51c78388c12e3b0'
|
||||
|
|
@ -10,11 +10,9 @@ const sentryOptions: Sentry.BrowserOptions = {
|
|||
dsn: `https://${PUBLIC_KEY}@sentry.io/${PROJECT_ID}`,
|
||||
release: `v${version}`,
|
||||
environment: IN_PRODUCTION_MODE ? 'production' : 'development',
|
||||
}
|
||||
if (PLATFORM !== 'chrome') {
|
||||
// Not safe to activate all integrations in non-Chrome environments where Gitako may not run in top context
|
||||
// https://docs.sentry.io/platforms/javascript/#sdk-integrations
|
||||
sentryOptions.integrations = ints => ints.filter(({ name }) => name !== 'TryCatch')
|
||||
integrations: ints => ints.filter(({ name }) => name !== 'TryCatch'),
|
||||
}
|
||||
Sentry.init(sentryOptions)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import Icon from 'components/Icon'
|
||||
import { oauth } from 'env'
|
||||
import * as React from 'react'
|
||||
import configHelper, { Config, configKeys } from 'utils/configHelper'
|
||||
import { friendlyFormatShortcut, JSONRequest, parseURLSearch } from 'utils/general'
|
||||
|
|
@ -14,11 +15,6 @@ const wikiLinks = {
|
|||
createAccessToken: `${WIKI_HOME_LINK}/How-to-create-access-token-for-Gitako%3F`,
|
||||
}
|
||||
|
||||
const oauth = {
|
||||
clientId: process.env.GITHUB_OAUTH_CLIENT_ID,
|
||||
clientSecret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
|
||||
}
|
||||
|
||||
const ACCESS_TOKEN_REGEXP = /^[0-9a-f]{40}$/
|
||||
|
||||
type Props = {
|
||||
|
|
|
|||
|
|
@ -4,3 +4,8 @@ type KnownPlatform = 'chrome' | 'firefox'
|
|||
type Platform = KnownPlatform | Exclude<string, keyof KnownPlatform>
|
||||
|
||||
export const PLATFORM: Platform = process.env.PLATFORM || 'unknown'
|
||||
|
||||
export const oauth = {
|
||||
clientId: process.env.GITHUB_OAUTH_CLIENT_ID,
|
||||
clientSecret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue