app-tutor-ai-consumer 1.26.0 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.26.1](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.26.0...v1.26.1) (2025-08-13)
2
+
3
+ ### Bug Fixes
4
+
5
+ - build staging ([60e5aa3](https://github.com/Hotmart-Org/app-tutor-ai-consumer/commit/60e5aa3bda6636f63bafb49a1d93c18b2b0dec5f))
6
+
1
7
  # [1.26.0](https://github.com/Hotmart-Org/app-tutor-ai-consumer/compare/v1.25.1...v1.26.0) (2025-08-12)
2
8
 
3
9
  ### Features
@@ -169,7 +169,7 @@ module.exports = async function (env) {
169
169
  template: path.resolve(paths.PUBLIC, 'index.html'),
170
170
  favicon: path.resolve(paths.PUBLIC, 'favicon.ico')
171
171
  })
172
- ].concat(await getEnvironmentPlugins(!productionMode)),
172
+ ].concat(await getEnvironmentPlugins(process.env.NODE_ENV)),
173
173
  watchOptions: {
174
174
  ignored: /node_modules/
175
175
  }
@@ -26,15 +26,18 @@ const envs = [
26
26
 
27
27
  const localEnvs = ['MEMBERSHIP_SLUG']
28
28
 
29
- const prodEnvs = ['APP_HOST_MF']
29
+ const stagingEnvs = [...envs, 'APP_HOST_MF']
30
+
31
+ const prodEnvs = ['SENTRY_DSN', 'SENTRY_ORG', 'SENTRY_PROJECT']
30
32
 
31
33
  const devEnvs = [...envs, ...localEnvs]
32
34
 
33
- const allEnvs = [...envs, ...prodEnvs]
35
+ const allEnvs = [...stagingEnvs, ...prodEnvs]
34
36
 
35
37
  module.exports = {
38
+ allEnvs,
39
+ devEnvs,
36
40
  envs,
37
41
  prodEnvs,
38
- devEnvs,
39
- allEnvs
42
+ stagingEnvs
40
43
  }
@@ -1,10 +1,17 @@
1
1
  const refreshPlugin = require('@rspack/plugin-react-refresh')
2
2
  const rspack = require('@rspack/core')
3
- const { devEnvs, allEnvs } = require('./envs')
3
+ const { allEnvs, devEnvs, stagingEnvs } = require('./envs')
4
4
  const CompressionPlugin = require('compression-webpack-plugin')
5
+ const { HotmartRumPlugin } = require('@hotmart-org-ca/hot-observability-js/rum/webpack')
6
+ const packageJSON = require('../../../package.json')
5
7
 
6
- async function getEnvironmentPlugins(isDevelopment) {
7
- if (isDevelopment) {
8
+ const release = `${packageJSON.name}@v${packageJSON.version}`
9
+
10
+ async function getEnvironmentPlugins(env) {
11
+ const developmentMode = env !== 'production' && env !== 'staging'
12
+ const stagingMode = env === 'staging'
13
+
14
+ if (developmentMode) {
8
15
  const res = await fetch(
9
16
  `${process.env.SECURITY_BASE_URL}/security/oauth/token?grant_type=password&username=${process.env.USER_VLC}&password=${process.env.VLC_PASSWORD}`,
10
17
  {
@@ -24,8 +31,7 @@ async function getEnvironmentPlugins(isDevelopment) {
24
31
  ]
25
32
  }
26
33
 
27
- return [
28
- new rspack.EnvironmentPlugin(allEnvs),
34
+ const prodCommonPlugins = [
29
35
  new rspack.CssExtractRspackPlugin({
30
36
  filename: 'app-tutor-ai-consumer.css',
31
37
  chunkFilename: '[id].[contenthash].css'
@@ -34,6 +40,28 @@ async function getEnvironmentPlugins(isDevelopment) {
34
40
  algorithm: 'gzip'
35
41
  })
36
42
  ]
43
+
44
+ if (stagingMode) return [new rspack.EnvironmentPlugin(stagingEnvs), ...prodCommonPlugins]
45
+
46
+ return [
47
+ new rspack.EnvironmentPlugin(allEnvs),
48
+ HotmartRumPlugin({
49
+ authToken: process.env.SENTRY_AUTH_TOKEN,
50
+ org: process.env.SENTRY_ORG,
51
+ project: process.env.SENTRY_PROJECT,
52
+ release: {
53
+ name: release,
54
+ deploy: {
55
+ env: process.env.NODE_ENV
56
+ }
57
+ },
58
+ moduleMetadata: () => ({
59
+ dsn: process.env.SENTRY_DSN,
60
+ release
61
+ })
62
+ }),
63
+ ...prodCommonPlugins
64
+ ]
37
65
  }
38
66
 
39
67
  module.exports = {
@@ -41,3 +41,8 @@ BUNDLE_PATH=https://app-club-microfrontends-prod.cp.hotmart.com
41
41
 
42
42
  # STATIC
43
43
  STATIC_URL=https://static.hotmart.com
44
+
45
+ # SENTRY
46
+ SENTRY_DSN=https://16c84dbea85a67f73a3696f6f05796bb@o49094.ingest.us.sentry.io/4509837136887808
47
+ SENTRY_ORG=hotmart
48
+ SENTRY_PROJECT=app-tutor-ai-consumer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "app-tutor-ai-consumer",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "dev": "rspack serve --env=development --config config/rspack/rspack.config.js",
@@ -104,6 +104,7 @@
104
104
  },
105
105
  "dependencies": {
106
106
  "@hot-observability-js/react": "~1.1.0",
107
+ "@hotmart-org-ca/hot-observability-js": "^1.1.0",
107
108
  "@hotmart/event-agent-js": "~1.1.2",
108
109
  "@hotmart/sparkie": "~5.1.0",
109
110
  "@lottiefiles/dotlottie-react": "~0.14.4",
@@ -0,0 +1 @@
1
+ declare module '@hotmart-org-ca/hot-observability-js/rum/react'
@@ -0,0 +1,7 @@
1
+ import { HotmartRum as HotmartObservability } from '@hot-observability-js/react'
2
+
3
+ import type { HotmartRumFunctions } from './types'
4
+
5
+ const HotmartRum: HotmartRumFunctions = HotmartObservability
6
+
7
+ export default HotmartRum
@@ -0,0 +1,2 @@
1
+ export { default as HotmartRum } from './hot-observability'
2
+ export * from './types'
@@ -0,0 +1,29 @@
1
+ export type Levels = 'fatal' | 'error' | 'warning' | 'log' | 'info' | 'debug'
2
+
3
+ export type ExtraParams = {
4
+ stack?: string
5
+ message?: string
6
+ }
7
+
8
+ export type ErrorParams = {
9
+ name: string
10
+ } & ExtraParams
11
+
12
+ export type User = {
13
+ id: number
14
+ email: string
15
+ }
16
+
17
+ export type ScopeParams = {
18
+ setUser: (user: User) => void
19
+ setTag: (key: string, value: string) => void
20
+ setLevel: (level: Levels) => void
21
+ setExtras: (params: ExtraParams) => void
22
+ }
23
+
24
+ export type HotmartRumFunctions = {
25
+ withScope: <T>(callback: (scope: ScopeParams) => T) => T
26
+ captureException: (error: string, hint: any) => void
27
+ captureMessage: (message: string) => string
28
+ ErrorBoundary: any
29
+ }
@@ -3,6 +3,8 @@ import { Component } from 'react'
3
3
  import { HotmartRum } from '@hot-observability-js/react'
4
4
  import type { ErrorInfo, PropsWithChildren, ReactNode } from 'react'
5
5
 
6
+ import { productionMode } from '../../utils'
7
+
6
8
  export type BoundaryState = {
7
9
  hasError: boolean
8
10
  }
@@ -18,7 +20,7 @@ export type BoundaryProps = PropsWithChildren<{
18
20
  }>
19
21
 
20
22
  const logError = (error: Error, errorInfo: ErrorInfo, user?: BoundaryProps['user']) => {
21
- if (process.env.TARGET_ENV !== 'production' && typeof vi === 'undefined') {
23
+ if (!productionMode && typeof vi === 'undefined') {
22
24
  return console.error(`Uncaught error: ${JSON.stringify({ error, errorInfo })}`)
23
25
  }
24
26
 
@@ -30,6 +32,7 @@ const logError = (error: Error, errorInfo: ErrorInfo, user?: BoundaryProps['user
30
32
  }
31
33
 
32
34
  const msg = errorInfo?.componentStack?.toString()
35
+
33
36
  if (msg) HotmartRum.captureMessage(msg)
34
37
 
35
38
  HotmartRum.captureException(error)
@@ -1,9 +1,21 @@
1
+ import { useEffect, useState } from 'react'
2
+
1
3
  import { useSubscribeMessageReceivedEvent } from '@/src/modules/messages/hooks'
2
4
  import { useSubscribeThreadClosedEvent } from '@/src/modules/thread/hooks'
3
5
  import { useListenToVisibilityEvents } from '../../hooks'
4
6
  import { useWidgetTabsAtom } from '../../store'
5
7
  import { WIDGET_TABS } from '../constants'
6
8
 
9
+ // TODO: REMOVE
10
+ const hotmartRumKey = 'app-tutor-ai-consumer::hotmart-rum::activate'
11
+ const useSentryDebugger = () => {
12
+ const [logError] = useState(() => Boolean(window?.localStorage?.getItem?.(hotmartRumKey)))
13
+
14
+ useEffect(() => {
15
+ if (logError) throw new Error(hotmartRumKey)
16
+ }, [logError])
17
+ }
18
+
7
19
  function WidgetContainer() {
8
20
  const [widgetTabs] = useWidgetTabsAtom()
9
21
 
@@ -11,6 +23,8 @@ function WidgetContainer() {
11
23
  useSubscribeThreadClosedEvent()
12
24
  useListenToVisibilityEvents()
13
25
 
26
+ useSentryDebugger()
27
+
14
28
  return (
15
29
  <div className='flex h-full flex-col items-center justify-stretch overflow-hidden'>
16
30
  {WIDGET_TABS[widgetTabs.currentTab]}