mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-11 18:09:50 +08:00
add sage time gtag in main process
This commit is contained in:
@@ -740,7 +740,8 @@ async function toRecommendPage (hooks) {
|
||||
await storeStorage(page).catch(() => void 0)
|
||||
await sleepWithRandomDelay(2000)
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'afterJobSourceChosen'
|
||||
tag: 'afterJobSourceChosen',
|
||||
hooks
|
||||
})
|
||||
}
|
||||
await sleepWithRandomDelay(1500)
|
||||
@@ -936,7 +937,8 @@ async function toRecommendPage (hooks) {
|
||||
}
|
||||
requestNextPagePromiseWithResolver = null
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'afterJobListPageFetched'
|
||||
tag: 'afterJobListPageFetched',
|
||||
hooks
|
||||
})
|
||||
await sleep(5000)
|
||||
await updateJobListData()
|
||||
@@ -982,7 +984,8 @@ async function toRecommendPage (hooks) {
|
||||
await sleepWithRandomDelay(2000)
|
||||
}
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'afterJobDetailFetched'
|
||||
tag: 'afterJobDetailFetched',
|
||||
hooks
|
||||
})
|
||||
targetJobData = await page.evaluate('document.querySelector(".job-detail-box").__vue__.data')
|
||||
selectedJobData = await page.evaluate('document.querySelector(".page-jobs-main").__vue__.currentJob')
|
||||
@@ -1012,7 +1015,8 @@ async function toRecommendPage (hooks) {
|
||||
else if (jobNotActiveStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobNotSuitMarked'
|
||||
tag: 'beforeJobNotSuitMarked',
|
||||
hooks
|
||||
})
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.BOSS_INACTIVE)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
@@ -1053,7 +1057,8 @@ async function toRecommendPage (hooks) {
|
||||
else if (expectCityNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobNotSuitMarked'
|
||||
tag: 'beforeJobNotSuitMarked',
|
||||
hooks
|
||||
})
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.JOB_CITY_NOT_SUIT)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
@@ -1093,7 +1098,8 @@ async function toRecommendPage (hooks) {
|
||||
else if (expectWorkExpNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobNotSuitMarked'
|
||||
tag: 'beforeJobNotSuitMarked',
|
||||
hooks
|
||||
})
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.JOB_WORK_EXP_NOT_SUIT)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
@@ -1133,7 +1139,8 @@ async function toRecommendPage (hooks) {
|
||||
else if (jobNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobNotSuitMarked'
|
||||
tag: 'beforeJobNotSuitMarked',
|
||||
hooks
|
||||
})
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.JOB_NOT_SUIT)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
@@ -1176,7 +1183,8 @@ async function toRecommendPage (hooks) {
|
||||
else if (expectSalaryNotMatchStrategy === MarkAsNotSuitOp.MARK_AS_NOT_SUIT_ON_BOSS) {
|
||||
try {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobNotSuitMarked'
|
||||
tag: 'beforeJobNotSuitMarked',
|
||||
hooks
|
||||
})
|
||||
const { chosenReasonInUi } = await markJobAsNotSuitInRecommendPage(MarkAsNotSuitReason.JOB_SALARY_NOT_SUIT)
|
||||
await hooks.jobMarkedAsNotSuit.promise(
|
||||
@@ -1296,7 +1304,8 @@ async function toRecommendPage (hooks) {
|
||||
}
|
||||
})
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobChatStartup'
|
||||
tag: 'beforeJobChatStartup',
|
||||
hooks
|
||||
})
|
||||
await sleepWithRandomDelay(1000)
|
||||
const startChatButtonInnerHTML = await page.evaluate('document.querySelector(".job-detail-box .op-btn.op-btn-chat")?.innerHTML.trim()')
|
||||
@@ -1347,7 +1356,8 @@ async function toRecommendPage (hooks) {
|
||||
/剩\d+次沟通机会/.test(res.zpData.bizData?.chatRemindDialog?.content)
|
||||
) {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobChatStartupAfterTwiceConfirm'
|
||||
tag: 'beforeJobChatStartupAfterTwiceConfirm',
|
||||
hooks
|
||||
})
|
||||
const confirmButton = await page.waitForSelector('.chat-block-dialog .chat-block-footer .sure-btn')
|
||||
await confirmButton.click()
|
||||
@@ -1359,7 +1369,8 @@ async function toRecommendPage (hooks) {
|
||||
/猎头/.test(res.zpData.bizData?.chatRemindDialog?.content)
|
||||
) {
|
||||
await waitForSageTimeOrJustContinue({
|
||||
tag: 'beforeJobChatStartupAfterTwiceConfirm'
|
||||
tag: 'beforeJobChatStartupAfterTwiceConfirm',
|
||||
hooks
|
||||
})
|
||||
const confirmButton = await page.waitForSelector(`xpath///*[contains(@class, "chat-block-dialog")]//*[contains(@class, "chat-block-footer")]//*[contains(text(), "继续")]`)
|
||||
await confirmButton.click()
|
||||
|
||||
@@ -23,7 +23,8 @@ if (parseFloat(sageTimePauseMinute) === 0) {
|
||||
let totalEnabledTimes = 0
|
||||
let recordedOpCount = 0
|
||||
export const waitForSageTimeOrJustContinue = async ({
|
||||
tag
|
||||
tag,
|
||||
hooks,
|
||||
} = {}) => {
|
||||
if (!isSageTimeEnabled) {
|
||||
return
|
||||
@@ -32,8 +33,18 @@ export const waitForSageTimeOrJustContinue = async ({
|
||||
if (recordedOpCount > sageTimeOpTimes) {
|
||||
totalEnabledTimes++
|
||||
console.log(`[SageTime${tagText}] 请求已达限制,开启;当前记录次数 ${recordedOpCount};第 ${totalEnabledTimes} 次开启`)
|
||||
await hooks?.sageTimeEnter?.promise({
|
||||
tag,
|
||||
totalEnabledTimes,
|
||||
recordedOpCount,
|
||||
})
|
||||
await sleep(sageTimePauseMinute * 60 * 1000)
|
||||
console.log(`[SageTime${tagText}] 请求限制已解除,关闭;当前记录次数 ${recordedOpCount};第 ${totalEnabledTimes} 次关闭`)
|
||||
await hooks?.sageTimeExit?.promise({
|
||||
tag,
|
||||
totalEnabledTimes,
|
||||
recordedOpCount,
|
||||
})
|
||||
recordedOpCount = 0
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -57,7 +57,9 @@ const main = async () => {
|
||||
noPositionFoundForCurrentJob: new SyncHook(),
|
||||
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
||||
errorEncounter: new SyncHook(['errorInfo']),
|
||||
encounterEmptyRecommendJobList: new AsyncSeriesHook(['args'])
|
||||
encounterEmptyRecommendJobList: new AsyncSeriesHook(['args']),
|
||||
sageTimeEnter: new AsyncSeriesHook(['args']),
|
||||
sageTimeExit: new AsyncSeriesHook(['args'])
|
||||
}
|
||||
initPlugins(hooks)
|
||||
await hooks.daemonInitialized.callAsync()
|
||||
|
||||
@@ -94,7 +94,9 @@ const runAutoChat = async () => {
|
||||
noPositionFoundForCurrentJob: new SyncHook(),
|
||||
noPositionFoundAfterTraverseAllJob: new SyncHook(),
|
||||
errorEncounter: new SyncHook(['errorInfo']),
|
||||
encounterEmptyRecommendJobList: new AsyncSeriesHook(['args'])
|
||||
encounterEmptyRecommendJobList: new AsyncSeriesHook(['args']),
|
||||
sageTimeEnter: new AsyncSeriesHook(['args']),
|
||||
sageTimeExit: new AsyncSeriesHook(['args'])
|
||||
}
|
||||
initPlugins(hooks)
|
||||
|
||||
|
||||
@@ -31,5 +31,11 @@ export default class GtagPlugin {
|
||||
hooks.encounterEmptyRecommendJobList.tap('GtagPlugin', ({ pageQuery }) => {
|
||||
gtag('encounter_empty_rec_job_list', { pageQuery })
|
||||
})
|
||||
hooks.sageTimeEnter.tap('GtagPlugin', ({ tag, totalEnabledTimes, recordedOpCount }) => {
|
||||
gtag('sage_time_enter', { tag, totalEnabledTimes, recordedOpCount })
|
||||
})
|
||||
hooks.sageTimeExit.tap('GtagPlugin', ({ tag, totalEnabledTimes, recordedOpCount }) => {
|
||||
gtag('sage_time_exit', { tag, totalEnabledTimes, recordedOpCount })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user