Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
0940084f
Unverified
Commit
0940084f
authored
Jan 24, 2024
by
zxhlyh
Committed by
GitHub
Jan 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: utm (#2180)
parent
95ad06c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
8 deletions
+41
-8
swr-initor.tsx
web/app/components/swr-initor.tsx
+9
-1
provider-context.tsx
web/context/provider-context.tsx
+19
-7
common.ts
web/models/common.ts
+8
-0
common.ts
web/service/common.ts
+5
-0
No files found.
web/app/components/swr-initor.tsx
View file @
0940084f
...
@@ -15,6 +15,14 @@ const SwrInitor = ({
...
@@ -15,6 +15,14 @@ const SwrInitor = ({
const
searchParams
=
useSearchParams
()
const
searchParams
=
useSearchParams
()
const
consoleToken
=
searchParams
.
get
(
'console_token'
)
const
consoleToken
=
searchParams
.
get
(
'console_token'
)
const
consoleTokenFromLocalStorage
=
localStorage
?.
getItem
(
'console_token'
)
const
consoleTokenFromLocalStorage
=
localStorage
?.
getItem
(
'console_token'
)
const
utm
=
{
utm_source
:
searchParams
.
get
(
'utm_source'
)
||
''
,
utm_medium
:
searchParams
.
get
(
'utm_medium'
)
||
''
,
utm_campaign
:
searchParams
.
get
(
'utm_campaign'
)
||
''
,
utm_content
:
searchParams
.
get
(
'utm_content'
)
||
''
,
utm_term
:
searchParams
.
get
(
'utm_term'
)
||
''
,
}
localStorage
?.
setItem
(
'utm'
,
JSON
.
stringify
(
utm
))
const
[
init
,
setInit
]
=
useState
(
false
)
const
[
init
,
setInit
]
=
useState
(
false
)
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -23,7 +31,7 @@ const SwrInitor = ({
...
@@ -23,7 +31,7 @@ const SwrInitor = ({
if
(
consoleToken
)
{
if
(
consoleToken
)
{
localStorage
?.
setItem
(
'console_token'
,
consoleToken
!
)
localStorage
?.
setItem
(
'console_token'
,
consoleToken
!
)
router
.
replace
(
'/apps'
,
{
forceOptimisticNavigation
:
false
})
router
.
replace
(
'/apps'
,
{
forceOptimisticNavigation
:
false
}
as
any
)
}
}
setInit
(
true
)
setInit
(
true
)
},
[])
},
[])
...
...
web/context/provider-context.tsx
View file @
0940084f
...
@@ -7,6 +7,7 @@ import {
...
@@ -7,6 +7,7 @@ import {
fetchModelList
,
fetchModelList
,
fetchModelProviders
,
fetchModelProviders
,
fetchSupportRetrievalMethods
,
fetchSupportRetrievalMethods
,
operationUtm
,
}
from
'@/service/common'
}
from
'@/service/common'
import
{
import
{
ModelFeatureEnum
,
ModelFeatureEnum
,
...
@@ -97,6 +98,23 @@ export const ProviderContextProvider = ({
...
@@ -97,6 +98,23 @@ export const ProviderContextProvider = ({
const
[
isFetchedPlan
,
setIsFetchedPlan
]
=
useState
(
false
)
const
[
isFetchedPlan
,
setIsFetchedPlan
]
=
useState
(
false
)
const
[
enableBilling
,
setEnableBilling
]
=
useState
(
true
)
const
[
enableBilling
,
setEnableBilling
]
=
useState
(
true
)
const
[
enableReplaceWebAppLogo
,
setEnableReplaceWebAppLogo
]
=
useState
(
false
)
const
[
enableReplaceWebAppLogo
,
setEnableReplaceWebAppLogo
]
=
useState
(
false
)
const
handleOperateUtm
=
()
=>
{
let
utm
try
{
utm
=
JSON
.
parse
(
localStorage
?.
getItem
(
'utm'
)
||
'{}'
)
}
catch
(
e
)
{
utm
=
{
utm_source
:
''
,
utm_medium
:
''
,
utm_campaign
:
''
,
utm_content
:
''
,
utm_term
:
''
,
}
}
operationUtm
({
url
:
'/operation/utm'
,
body
:
utm
})
}
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
(
async
()
=>
{
const
data
=
await
fetchCurrentPlanInfo
()
const
data
=
await
fetchCurrentPlanInfo
()
...
@@ -105,13 +123,7 @@ export const ProviderContextProvider = ({
...
@@ -105,13 +123,7 @@ export const ProviderContextProvider = ({
setEnableReplaceWebAppLogo
(
data
.
can_replace_logo
)
setEnableReplaceWebAppLogo
(
data
.
can_replace_logo
)
if
(
enabled
)
{
if
(
enabled
)
{
setPlan
(
parseCurrentPlan
(
data
))
setPlan
(
parseCurrentPlan
(
data
))
// setPlan(parseCurrentPlan({
handleOperateUtm
()
// ...data,
// annotation_quota_limit: {
// ...data.annotation_quota_limit,
// limit: 10,
// },
// }))
setIsFetchedPlan
(
true
)
setIsFetchedPlan
(
true
)
}
}
})()
})()
...
...
web/models/common.ts
View file @
0940084f
...
@@ -251,3 +251,11 @@ export type ModerationService = (
...
@@ -251,3 +251,11 @@ export type ModerationService = (
text
:
string
text
:
string
}
}
)
=>
Promise
<
ModerateResponse
>
)
=>
Promise
<
ModerateResponse
>
export
type
Utm
=
{
utm_source
?:
string
utm_medium
?:
string
utm_campaign
?:
string
utm_term
?:
string
utm_content
?:
string
}
web/service/common.ts
View file @
0940084f
...
@@ -20,6 +20,7 @@ import type {
...
@@ -20,6 +20,7 @@ import type {
ProviderAzureToken
,
ProviderAzureToken
,
SetupStatusResponse
,
SetupStatusResponse
,
UserProfileOriginResponse
,
UserProfileOriginResponse
,
Utm
,
}
from
'@/models/common'
}
from
'@/models/common'
import
type
{
import
type
{
UpdateOpenAIKeyResponse
,
UpdateOpenAIKeyResponse
,
...
@@ -262,3 +263,7 @@ type RetrievalMethodsRes = {
...
@@ -262,3 +263,7 @@ type RetrievalMethodsRes = {
export
const
fetchSupportRetrievalMethods
:
Fetcher
<
RetrievalMethodsRes
,
string
>
=
(
url
)
=>
{
export
const
fetchSupportRetrievalMethods
:
Fetcher
<
RetrievalMethodsRes
,
string
>
=
(
url
)
=>
{
return
get
<
RetrievalMethodsRes
>
(
url
)
return
get
<
RetrievalMethodsRes
>
(
url
)
}
}
export
const
operationUtm
:
Fetcher
<
CommonResponse
,
{
url
:
string
;
body
:
Utm
}
>
=
({
url
,
body
})
=>
{
return
post
(
url
,
{
body
})
as
Promise
<
CommonResponse
>
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment