This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from illacloud/feat/update-utm
feat: add to ai utm, github add utm params
- Loading branch information
Showing
11 changed files
with
75 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const keys = ['utm_source', 'utm_medium', 'utm_campaign'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import { useRouter } from 'next/router' | ||
import { addParams } from '@/utils/addParams' | ||
import { keys } from '@/constants/utmKeys' | ||
export const useUtmParams = (url) => { | ||
const router = useRouter() | ||
const keys = ['utm_source', 'utm_medium', 'utm_campaign'] | ||
if (router?.query && Object.keys(router?.query).some(key => keys.includes(key))) { | ||
if ( | ||
router?.query && | ||
Object.keys(router?.query).some((key) => keys.includes(key)) | ||
) { | ||
const { utm_source, utm_medium, utm_campaign } = router.query | ||
return addParams(url, { utm_source, utm_medium, utm_campaign }) | ||
} else { | ||
return url | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
export const getGithubOauth = async () => { | ||
import { keys } from '@/constants/utmKeys' | ||
|
||
export const getGithubOauth = async (query) => { | ||
try { | ||
const redirectURI = new URL('https://cloud.illacloud.com/oauth') | ||
Object.keys(query).forEach((key) => { | ||
if (keys.includes(key)) { | ||
redirectURI.searchParams.append(key, query[key]) | ||
} | ||
}) | ||
const res = await fetch( | ||
'https://cloud-api.illacloud.com/supervisor/api/v1/oauth/github/uri/redirectTo/https%3A%2F%2Fcloud.illacloud.com%2Foauth/landing/signup' | ||
`https://cloud-api.illacloud.com/supervisor/api/v1/oauth/github/uri/redirectTo/${encodeURIComponent( | ||
redirectURI.toString(), | ||
)}/landing/signup`, | ||
) | ||
const resJSON = await res.json() | ||
return resJSON.uri | ||
} catch (e) { | ||
return '' | ||
} | ||
} | ||
} |