Skip to content

Commit

Permalink
[Fix] Improve error logs for license key validate and get auth (#1142)
Browse files Browse the repository at this point in the history
* improve license key error logs

* improve auth error logging

* add capture to access code input
  • Loading branch information
BrettCleary authored Nov 6, 2024
1 parent b400a31 commit af73a8e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
"hyperplay": {
"accesscodes": {
"error": {
"licenseUndefined": "Could not validate access code. Please check your internet access or firewall settings.",
"validation": "Access code is invalid"
},
"requirescode": "This game update requires an access code.",
Expand Down
9 changes: 8 additions & 1 deletion src/backend/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import getPartitionCookies from './utils/get_partition_cookies'
import { DEV_PORTAL_URL } from '../common/constants'
import { LogPrefix } from './logger/logger'
import { AuthSession } from '../common/types/auth'
import { captureException } from '@sentry/electron'

export async function getAuthSession() {
const cookieString = await getPartitionCookies({
Expand All @@ -17,8 +18,14 @@ export async function getAuthSession() {
})

if (!response.ok) {
const responseError = await response.text()
captureException(responseError, {
tags: {
event: 'getAuthSession Error'
}
})
throw new Error(
`${LogPrefix.Backend} Failed to get auth session: ${response.statusText}`
`${LogPrefix.Backend} Failed to get auth session. Status text: ${response.statusText}. Error message: ${responseError}`
)
}

Expand Down
13 changes: 13 additions & 0 deletions src/frontend/components/UI/AccessCodeInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TextInput, TextInputProps } from '@hyperplay/ui'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styles from './index.module.scss'
import { captureException } from '@sentry/electron'

export interface AccessCodeInputProps {
licenseConfigId?: number
Expand All @@ -25,6 +26,18 @@ export function AccessCodeInput({
useEffect(() => {
async function validateAccessCode() {
if (licenseConfigId === undefined) {
const errMsg =
'Could not validate access code input since license config id is undefined'
window.api.logError(errMsg)
setErrorText(
t(
'hyperplay.accesscodes.error.licenseUndefined',
'Could not validate access code. Please check your internet access or firewall settings.'
)
)
captureException(errMsg, {
tags: { event: 'validateAccessCode Error' }
})
return
}

Expand Down

0 comments on commit af73a8e

Please sign in to comment.