Skip to content
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

3.7.0 #521

Merged
merged 7 commits into from
Nov 15, 2024
Merged

3.7.0 #521

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
VERSION=3.6.2
VERSION=3.7.0
CHANGELOG_VERSION=3.0.1
SENTRY_RELEASE=3.6.2
GOOGLE_MEASUREMENT_ID="G-SN6JNMXND2"
PROXY_URL=https://monkfish-app-4bylm.ondigitalocean.app
PROXY_OPENAI_URL=https://monkfish-app-4bylm.ondigitalocean.app/api/openai
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.6",
"@tailwindcss/typography": "0.5.13",
"@tailwindcss/typography": "0.5.15",
"@types/chrome": "^0.0.268",
"@types/jest": "^29.5.13",
"@types/lodash": "^4.17.4",
"@types/lodash": "^4.17.13",
"@types/node": "^20.12.12",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.18.0",
"autoprefixer": "10.4.19",
"autoprefixer": "10.4.20",
"babel-jest": "^29.7.0",
"babel-loader": "9.1.3",
"copy-webpack-plugin": "^12.0.2",
Expand All @@ -35,7 +35,7 @@
"eslint": "^8.57.0",
"eslint-config-yenz": "^5.3.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-perfectionist": "^2.10.0",
"jest": "^29.7.0",
"jest-chrome": "^0.8.0",
Expand All @@ -50,8 +50,6 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@sentry/browser": "8.15.0",
"@sentry/webpack-plugin": "2.17.0",
"dayjs": "^1.11.13",
"dotenv-webpack": "8.1.0",
"lodash": "^4.17.21",
Expand Down
2 changes: 0 additions & 2 deletions src/js/ai/call-openai.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { sendEvent } from '@sx/analytics/event'
import { AiPromptType } from '@sx/analyze/types/ai-prompt-type'
import { OpenAIError } from '@sx/utils/errors'
import scope from '@sx/utils/sentry'

import { fetchCompletion } from './fetch-completion'
import getCompletionFromProxy from './get-completion-from-proxy'
Expand All @@ -14,7 +13,6 @@ async function callOpenAi(description: string, type: AiPromptType, tabId: number
const useProxy = !token
sendEvent('ai', { token_provided: !useProxy, type }).catch((e) => {
console.error('Error sending event:', e)
scope.captureException(e)
})

if (useProxy) {
Expand Down
3 changes: 0 additions & 3 deletions src/js/analyze/ai-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { sendEvent } from '@sx/analytics/event'
import { AiPromptType } from '@sx/analyze/types/ai-prompt-type'
import { AiProcessMessage, AiProcessMessageType } from '@sx/analyze/types/AiProcessMessage'
import '@sx/analyze/listeners'
import scope from '@sx/utils/sentry'
import sleep from '@sx/utils/sleep'
import { Story } from '@sx/utils/story'

Expand Down Expand Up @@ -61,7 +60,6 @@ export class AiFunctions {
}
catch (e) {
console.error(e)
scope.captureException(e)
}
}
}
Expand Down Expand Up @@ -111,7 +109,6 @@ export class AiFunctions {
}
sendEvent('ai_request_failed').catch((e) => {
console.error(e)
scope.captureException(e)
})
}

Expand Down
44 changes: 21 additions & 23 deletions src/js/keyboard-shortcuts/keyboard-shortcuts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import scope from '@sx/utils/sentry'

import camelToSnake from '../utils/camel-to-snake'

import changeEstimate from './change-estimate'
Expand All @@ -21,29 +19,29 @@ export type shortcut = ({
export class KeyboardShortcuts {
predefinedShortcuts: shortcut[] = [
// MacOS
{key: 's', shiftKey: true, metaKey: true, func: changeState},
{key: 'i', shiftKey: true, metaKey: true, func: changeIteration},
{key: 'e', shiftKey: true, metaKey: true, func: changeEstimate},
{key: 'g', shiftKey: true, metaKey: true, func: copyGitBranch},
{key: '.', shiftKey: true, metaKey: true, func: copyBranchAndMoveToInDevelopment},
{ key: 's', shiftKey: true, metaKey: true, func: changeState },
{ key: 'i', shiftKey: true, metaKey: true, func: changeIteration },
{ key: 'e', shiftKey: true, metaKey: true, func: changeEstimate },
{ key: 'g', shiftKey: true, metaKey: true, func: copyGitBranch },
{ key: '.', shiftKey: true, metaKey: true, func: copyBranchAndMoveToInDevelopment },
// Windows
{key: 's', shiftKey: true, ctrlKey: true, func: changeState},
{key: 'i', shiftKey: true, ctrlKey: true, func: changeIteration},
{key: 'e', shiftKey: true, ctrlKey: true, func: changeEstimate},
{key: 'g', shiftKey: true, ctrlKey: true, func: copyGitBranch},
{key: '.', shiftKey: true, ctrlKey: true, func: copyBranchAndMoveToInDevelopment}
{ key: 's', shiftKey: true, ctrlKey: true, func: changeState },
{ key: 'i', shiftKey: true, ctrlKey: true, func: changeIteration },
{ key: 'e', shiftKey: true, ctrlKey: true, func: changeEstimate },
{ key: 'g', shiftKey: true, ctrlKey: true, func: copyGitBranch },
{ key: '.', shiftKey: true, ctrlKey: true, func: copyBranchAndMoveToInDevelopment }
]

shortcuts: Map<string, () => Promise<void>>

constructor() {
this.shortcuts = new Map()
this.predefinedShortcuts.forEach(shortcut => {
this.predefinedShortcuts.forEach((shortcut) => {
this.registerShortcut(shortcut)
})
}

activate() {
activate(): void {
document.addEventListener('keydown', this.handleKeyDown.bind(this))
}

Expand All @@ -60,11 +58,11 @@ export class KeyboardShortcuts {
* @returns {string} The serialized string representation of the shortcut.
* @example {key: 'a', shiftKey: True, func: () => {} } => 'a-0-1-0-0'
*/
serializeShortcut({key, metaKey, shiftKey, altKey, ctrlKey}: {
altKey?: boolean,
ctrlKey?: boolean,
key: string,
metaKey?: boolean,
serializeShortcut({ key, metaKey, shiftKey, altKey, ctrlKey }: {
altKey?: boolean
ctrlKey?: boolean
key: string
metaKey?: boolean
shiftKey: boolean
}): string {
return `${key.toLowerCase()}-${metaKey ? '1' : '0'}-${shiftKey ? '1' : '0'}-${altKey ? '1' : '0'}-${ctrlKey ? '1' : '0'}`
Expand All @@ -88,7 +86,8 @@ export class KeyboardShortcuts {
this.shortcuts.set(serializedKey, shortcut.func.bind(this))
}

handleKeyDown(event: KeyboardEvent) {
// eslint-disable-next-line @typescript-eslint/require-await
async handleKeyDown(event: KeyboardEvent): Promise<void> {
const serializedEventKey = this.serializeShortcut({
altKey: event.altKey,
ctrlKey: event.ctrlKey,
Expand All @@ -101,10 +100,9 @@ export class KeyboardShortcuts {
event.preventDefault()
const func: (() => Promise<void>) | undefined = this.shortcuts.get(serializedEventKey)
if (func) {
chrome.runtime.sendMessage({action: 'sendEvent', data: {eventName: 'keyboard-shortcut', params: {shortcutAction: camelToSnake(func.name)}}})
func().catch(e => {
chrome.runtime.sendMessage({ action: 'sendEvent', data: { eventName: 'keyboard-shortcut', params: { shortcutAction: camelToSnake(func.name) } } })
func().catch((e) => {
console.error('Error running shortcut:', e)
scope.captureException(e)
})
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/js/popup/popup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { sendEvent } from '@sx/analytics/event'
import { IpcRequestSaveUserToken } from '@sx/types/ipc-request'
import { getSyncedSetting } from '@sx/utils/get-synced-setting'
import scope from '@sx/utils/sentry'
import sleep from '@sx/utils/sleep'

import { NotesPopup } from './notes-popup'
Expand Down Expand Up @@ -46,11 +45,9 @@ export class Popup {

sendEvent('popup_view').catch((e) => {
console.error(e)
scope.captureException(e)
})
this.popupLoaded().catch((e) => {
console.error(e)
scope.captureException(e)
})
}

Expand Down Expand Up @@ -167,7 +164,6 @@ export class Popup {

this.handleNewVersionBadge().catch((e) => {
console.error(e)
scope.captureException(e)
})
const versionSpan = document.getElementById('versionInfo')
if (versionSpan === null) {
Expand All @@ -178,7 +174,6 @@ export class Popup {
new NotesPopup()
sendEvent('popup_loaded', { page_title: 'Popup', page_location: '/popup.html' }).catch((e) => {
console.error(e)
scope.captureException(e)
})
}
}
2 changes: 0 additions & 2 deletions src/js/service-worker/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
handleOpenAICall
} from '@sx/service-worker/handlers'
import IpcRequest from '@sx/types/ipc-request'
import scope from '@sx/utils/sentry'
import '@sx/auth/oauth/service-worker/listener'
import '@sx/ai/labels/listener'

Expand Down Expand Up @@ -36,7 +35,6 @@ function registerAnalyticsListeners(): void {
if (request.action === 'sendEvent') {
sendEvent(request.data.eventName, request.data.params).catch((e) => {
console.error('Error sending event:', e)
scope.captureException(e)
})
}
})
Expand Down
2 changes: 0 additions & 2 deletions src/js/service-worker/omnibox/listeners.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sendEvent } from '@sx/analytics/event'
import scope from '@sx/utils/sentry'

import { redirectFromOmnibox, setOmniboxSuggestion } from './omnibox'

Expand All @@ -13,6 +12,5 @@ chrome.omnibox.onInputEntered.addListener((text: string, disposition: 'currentTa
redirectFromOmnibox(text, disposition)
sendEvent('omnibox_entered').catch((error) => {
console.error(error)
scope.captureException(error)
})
})
35 changes: 19 additions & 16 deletions src/js/service-worker/on-install-and-update.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
import scope from '@sx/utils/sentry'

import InstalledDetails = chrome.runtime.InstalledDetails


class InstallAndUpdate {
static onInstall() {
// eslint-disable-next-line @typescript-eslint/require-await
static async onInstall(): Promise<void> {
chrome.windows.create({
url: '../html/installed.html',
type: 'popup',
width: 310,
height: 500
})
chrome.storage.sync.set({'enableTodoistOptions': false}).catch(e => {
chrome.storage.sync.set({ enableTodoistOptions: false }).catch((e) => {
console.error('Error setting enableTodoistOptions:', e)
scope.captureException(e)
})
}

static async onUpdate() {
await chrome.action.setBadgeText({text: ' '})
await chrome.action.setBadgeBackgroundColor({color: '#a30000'})
static async onUpdate(): Promise<void> {
await chrome.action.setBadgeText({ text: ' ' })
await chrome.action.setBadgeBackgroundColor({ color: '#a30000' })
}
}


function onInstallAndUpdate(details: InstalledDetails) {
if (details.reason === 'install') {
function isValidVersion(version: string): boolean {
return /^\d+\.\d+\.\d+$/.test(version)
}

function onInstallAndUpdate(details: InstalledDetails): void {
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
InstallAndUpdate.onInstall()
}
else if (details.reason === 'update') {
// Only display the update page if the changelog has been updated for the current version
if (process.env.CHANGELOG_VERSION === process.env.VERSION) {
InstallAndUpdate.onUpdate().catch(e => {
else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
const changelogVersion = process.env.CHANGELOG_VERSION
const currentVersion = process.env.VERSION

if (isValidVersion(changelogVersion!) && changelogVersion === currentVersion) {
InstallAndUpdate.onUpdate().catch((e) => {
console.error('Error updating:', e)
scope.captureException(e)
})
}
}
}

export {InstallAndUpdate, onInstallAndUpdate}
export { InstallAndUpdate, onInstallAndUpdate }
17 changes: 9 additions & 8 deletions src/js/service-worker/slug-manager.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import scope from '@sx/utils/sentry'

import TabChangeInfo = chrome.tabs.TabChangeInfo


export class SlugManager {
// eslint-disable-next-line @typescript-eslint/require-await
static async getCompanySlugFromTab(tabId: number, changeInfo: TabChangeInfo): Promise<string | null> {
const url = changeInfo.url
if (!url) {
Expand All @@ -12,12 +11,15 @@ export class SlugManager {
return url.split('/')[3]
}

static async setCompanySlug(companySlug: string): Promise<void>{
await chrome.storage.sync.set({companySlug: companySlug})
static async setCompanySlug(companySlug: string): Promise<void> {
if (!companySlug || typeof companySlug !== 'string' || companySlug.trim().length === 0) {
throw new Error('Invalid company slug')
}
await chrome.storage.sync.set({ companySlug: companySlug })
}

static async getCompanySlug(): Promise<string | null>{
const result: {[key: string]: string} = await chrome.storage.sync.get('companySlug')
static async getCompanySlug(): Promise<string | null> {
const result: { [key: string]: string | undefined } = await chrome.storage.sync.get('companySlug')
const value = result.companySlug
if (value !== undefined) {
return value
Expand All @@ -30,9 +32,8 @@ export class SlugManager {
static async refreshCompanySlug(tabId: number, changeInfo: TabChangeInfo): Promise<void> {
const companySlug = await this.getCompanySlugFromTab(tabId, changeInfo)
if (companySlug) {
this.setCompanySlug(companySlug).catch(e => {
this.setCompanySlug(companySlug).catch((e) => {
console.error('Error setting company slug:', e)
scope.captureException(e)
})
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/js/utils/log-error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import scope from '@sx/utils/sentry'


export function logError(error: Error): void {
console.error(error)
scope.captureException(error)
}
39 changes: 0 additions & 39 deletions src/js/utils/sentry.ts

This file was deleted.

Loading
Loading