-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init. works * remove heap refs * update assets
- Loading branch information
1 parent
e7afee8
commit 0c7d088
Showing
8 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,43 @@ | ||
name: zoominfo | ||
title: ZoomInfo | ||
icon: ./assets/icon.png | ||
previewImages: | ||
- ./assets/preview.png | ||
description: Plug your GitBook site to your ZoomInfo instance. | ||
externalLinks: | ||
- label: Documentation | ||
url: https://www.gitbook.com/integrations/zoominfo | ||
visibility: private | ||
script: ./src/index.ts | ||
# The following scope(s) are available only to GitBook Staff | ||
# See https://developer.gitbook.com/integrations/configurations#scopes | ||
scopes: | ||
- site:script:inject | ||
organization: gitbook | ||
contentSecurityPolicy: | ||
script-src: https://js.zi-scripts.com 'unsafe-inline'; | ||
summary: | | ||
# Overview | ||
This integration allows to add the ZoomInfo Analytics tracker on your published GitBook site. | ||
# How it works | ||
The integration injects the ZoomInfo script on your page, using the script you provide during configuration, | ||
so that you can get analytics information from your GitBook site directly inside of ZoomInfo. | ||
# Configure | ||
Install the integration on the GitBook site of your choice. | ||
Locate the ZoomInfo script you want to use, which is available in WebSights management: | ||
* copy the script and paste it in the GitBook integration's configuration screen | ||
categories: | ||
- analytics | ||
configurations: | ||
site: | ||
properties: | ||
script: | ||
type: string | ||
title: Script | ||
description: Available in your ZoomInfo account | ||
required: | ||
- script | ||
target: site |
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,19 @@ | ||
{ | ||
"name": "@gitbook/integration-zoominfo", | ||
"version": "0.0.1", | ||
"private": true, | ||
"dependencies": { | ||
"@gitbook/api": "*", | ||
"@gitbook/runtime": "*" | ||
}, | ||
"devDependencies": { | ||
"@gitbook/cli": "workspace:*", | ||
"@gitbook/tsconfig": "workspace:*" | ||
}, | ||
"scripts": { | ||
"typecheck": "tsc --noEmit", | ||
"publish-integrations-staging": "gitbook publish .", | ||
"check": "gitbook check", | ||
"publish-integrations": "gitbook publish ." | ||
} | ||
} |
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,53 @@ | ||
import { | ||
createIntegration, | ||
FetchPublishScriptEventCallback, | ||
RuntimeContext, | ||
RuntimeEnvironment, | ||
} from '@gitbook/runtime'; | ||
|
||
import rawScript from './script.raw.js'; | ||
|
||
type ZoomInfoRuntimeContext = RuntimeContext< | ||
RuntimeEnvironment< | ||
{}, | ||
{ | ||
script?: string; | ||
} | ||
> | ||
>; | ||
|
||
export const handleFetchEvent: FetchPublishScriptEventCallback = async ( | ||
event, | ||
{ environment }: ZoomInfoRuntimeContext, | ||
) => { | ||
const script = environment.siteInstallation?.configuration?.script; | ||
if (!script) { | ||
throw new Error( | ||
`The ZoomInfo script is missing from the configuration (ID: ${ | ||
'spaceId' in event ? event.spaceId : event.siteId | ||
}).`, | ||
); | ||
} | ||
// matches occurances of alphanumeric strings inside single quotes | ||
// of length of exactly 20, which is what we need | ||
const regex = /'[a-f0-9]{20}'/; | ||
|
||
const match = script.match(regex); | ||
if (!match) { | ||
throw new Error(`Match for ZoomInfo's site id could not be found`); | ||
} | ||
|
||
// match[0] looks like "'abc...'" we need to remove the single quotes | ||
const siteId = match[0].replace(/\'/g, ''); | ||
|
||
return new Response((rawScript as string).replace('<TO_REPLACE>', siteId), { | ||
headers: { | ||
'Content-Type': 'application/javascript', | ||
'Cache-Control': 'max-age=604800', | ||
}, | ||
}); | ||
}; | ||
|
||
export default createIntegration<ZoomInfoRuntimeContext>({ | ||
fetch_published_script: handleFetchEvent, | ||
}); |
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,10 @@ | ||
const siteId = '<TO_REPLACE>'; | ||
|
||
(function (w, d, s) { | ||
w['ZIProjectKey'] = siteId; | ||
var n; | ||
n = d.createElement('script'); | ||
n.src = s; | ||
n.async = !0; | ||
d.head.appendChild(n); | ||
})(window, document, 'https://js.zi-scripts.com/zi-tag.js'); |
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,3 @@ | ||
{ | ||
"extends": "@gitbook/tsconfig/integration.json" | ||
} |