-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-provider-visibility-to-node
# Conflicts: # core/bin/core_api.rs # core/src/data_sources/folder.rs # core/src/data_sources/node.rs # core/src/stores/postgres.rs # core/src/stores/store.rs
- Loading branch information
Showing
155 changed files
with
3,155 additions
and
4,080 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
100 changes: 100 additions & 0 deletions
100
connectors/migrations/20250110_investigate_zendesk_hc.ts
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,100 @@ | ||
import { makeScript } from "scripts/helpers"; | ||
|
||
import { isZendeskNotFoundError } from "@connectors/connectors/zendesk/lib/errors"; | ||
import { getZendeskSubdomainAndAccessToken } from "@connectors/connectors/zendesk/lib/zendesk_access_token"; | ||
import { | ||
fetchZendeskBrand, | ||
fetchZendeskCategoriesInBrand, | ||
fetchZendeskCurrentUser, | ||
getZendeskBrandSubdomain, | ||
} from "@connectors/connectors/zendesk/lib/zendesk_api"; | ||
import { ZENDESK_BATCH_SIZE } from "@connectors/connectors/zendesk/temporal/config"; | ||
import { ConnectorResource } from "@connectors/resources/connector_resource"; | ||
import { ZendeskBrandResource } from "@connectors/resources/zendesk_resources"; | ||
|
||
makeScript({}, async ({ execute }, logger) => { | ||
const connectors = await ConnectorResource.listByType("zendesk", {}); | ||
|
||
for (const connector of connectors) { | ||
const connectorId = connector.id; | ||
if (connector.isPaused()) { | ||
continue; | ||
} | ||
const { accessToken, subdomain } = await getZendeskSubdomainAndAccessToken( | ||
connector.connectionId | ||
); | ||
const user = await fetchZendeskCurrentUser({ accessToken, subdomain }); | ||
const brandsOnDb = await ZendeskBrandResource.fetchByConnector(connector); | ||
for (const brandOnDb of brandsOnDb) { | ||
const { brandId } = brandOnDb; | ||
if (!execute) { | ||
logger.info({ brandId }, "DRY: Fetching brand"); | ||
continue; | ||
} | ||
|
||
const fetchedBrand = await fetchZendeskBrand({ | ||
brandId, | ||
accessToken, | ||
subdomain, | ||
}); | ||
const brandSubdomain = await getZendeskBrandSubdomain({ | ||
brandId, | ||
connectorId, | ||
accessToken, | ||
subdomain, | ||
}); | ||
|
||
let couldFetchCategories; | ||
try { | ||
await fetchZendeskCategoriesInBrand(accessToken, { | ||
brandSubdomain, | ||
pageSize: ZENDESK_BATCH_SIZE, | ||
}); | ||
couldFetchCategories = true; | ||
} catch (e) { | ||
if (isZendeskNotFoundError(e)) { | ||
couldFetchCategories = false; | ||
// if (fetchedBrand?.has_help_center) { | ||
// const url = `https://${brandSubdomain}.zendesk.com/api/v2/help_center/articles.json`; | ||
// const res = await fetch(url, { | ||
// method: "GET", | ||
// headers: { | ||
// Authorization: `Bearer ${accessToken}`, | ||
// "Content-Type": "application/json", | ||
// }, | ||
// }); | ||
// const text = await res.text(); | ||
// logger.error( | ||
// { | ||
// res, | ||
// brandSubdomain, | ||
// status: res.status, | ||
// statusText: res.statusText, | ||
// headers: res.headers, | ||
// text, | ||
// body: res.body, | ||
// }, | ||
// "Failed to fetch categories" | ||
// ); | ||
// await res.json(); | ||
// } | ||
} else { | ||
throw e; | ||
} | ||
} | ||
logger.info( | ||
{ | ||
connectorId, | ||
brandId, | ||
couldFetchCategories, | ||
brandSubdomain, | ||
hasHelpCenter: fetchedBrand?.has_help_center, | ||
helpCenterState: fetchedBrand?.help_center_state, | ||
userRole: user.role, | ||
userActive: user.active, | ||
}, | ||
`FETCH` | ||
); | ||
} | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.