Skip to content

Commit 9868bdd

Browse files
Merge branch 'main' into add-reo-integration
2 parents 8e123ad + fc8b0e5 commit 9868bdd

19 files changed

+4970
-0
lines changed

.changeset/hot-ads-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-helpscout': major
3+
---
4+
5+
This change releases the first version of the HelpScout integration for GitBook

integrations/crisp/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@gitbook/eslint-config/integration"]
3+
}
377 KB
Loading

integrations/crisp/assets/icon.png

21.4 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: crisp
2+
title: Crisp
3+
icon: ./assets/icon.png
4+
previewImages:
5+
- ./assets/crisp-preview.png
6+
description: Add the Crisp chat widget to your published GitBook content.
7+
externalLinks:
8+
- label: Website
9+
url: https://crisp.chat/en/
10+
visibility: public
11+
script: ./src/index.ts
12+
# The following scope(s) are available only to GitBook Staff
13+
# See https://developer.gitbook.com/integrations/configurations#scopes
14+
scopes:
15+
- space:script:inject
16+
- site:script:inject
17+
organization: gitbook
18+
contentSecurityPolicy:
19+
script-src: |
20+
client.crisp.chat;
21+
style-src: |
22+
client.crisp.chat;
23+
https://client.crisp.chat
24+
summary: |
25+
# Overview
26+
27+
The Crisp integration for GitBook allows you to display the Crisp chat widget on your public documentation to connect and interact with your readers.
28+
29+
# How it works
30+
31+
Automatic chat widget on your documentation: Each of your connected GitBook spaces will fetch the Crisp chat widget script and inject it in your published content.
32+
33+
# Configure
34+
35+
You can configure the integration on single or multiple public spaces by navigating to the integrations in sub-navigation or org settings. You will then have to provide Crisp website ID to finish the configuration. This can be found in the URL from your Crisp dashboard.
36+
37+
categories:
38+
- analytics
39+
configurations:
40+
space:
41+
properties:
42+
tracking_id:
43+
type: string
44+
title: Crisp Site ID
45+
description: Available in the URL from your Crisp dashboard
46+
required:
47+
- tracking_id
48+
site:
49+
properties:
50+
tracking_id:
51+
type: string
52+
title: Crisp Site ID
53+
description: Available in the URL from your Crisp dashboard
54+
required:
55+
- tracking_id

integrations/crisp/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@gitbook/integration-crisp",
3+
"version": "0.0.1",
4+
"private": true,
5+
"dependencies": {
6+
"@gitbook/api": "*",
7+
"@gitbook/runtime": "*"
8+
},
9+
"devDependencies": {
10+
"@gitbook/cli": "*"
11+
},
12+
"scripts": {
13+
"lint": "eslint ./src/**/*.ts",
14+
"typecheck": "tsc --noEmit",
15+
"publish-integrations-staging": "gitbook publish .",
16+
"publish-integrations": "gitbook publish ."
17+
}
18+
}

integrations/crisp/src/index.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
createIntegration,
3+
FetchPublishScriptEventCallback,
4+
RuntimeContext,
5+
RuntimeEnvironment,
6+
} from '@gitbook/runtime';
7+
8+
import script from './script.raw.js';
9+
10+
type CrispRuntimeContext = RuntimeContext<
11+
RuntimeEnvironment<
12+
{},
13+
{
14+
tracking_id?: string;
15+
}
16+
>
17+
>;
18+
19+
export const handleFetchEvent: FetchPublishScriptEventCallback = async (
20+
event,
21+
{ environment }: CrispRuntimeContext
22+
) => {
23+
const trackingId =
24+
environment.siteInstallation?.configuration?.tracking_id ??
25+
environment.spaceInstallation.configuration.tracking_id;
26+
if (!trackingId) {
27+
throw new Error(
28+
`The Crisp Website ID is missing from the configuration (ID: ${
29+
'spaceId' in event ? event.spaceId : event.siteId
30+
}).`
31+
);
32+
}
33+
34+
return new Response(script.replace('<TO_REPLACE>', trackingId), {
35+
headers: {
36+
'Content-Type': 'application/javascript',
37+
'Cache-Control': 'max-age=604800',
38+
},
39+
});
40+
};
41+
42+
export default createIntegration<CrispRuntimeContext>({
43+
fetch_published_script: handleFetchEvent,
44+
});

integrations/crisp/src/script.raw.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(function (d, s) {
2+
const trackingID = '<TO_REPLACE>';
3+
window.$crisp = [];
4+
window.CRISP_WEBSITE_ID = trackingID;
5+
6+
d = document;
7+
s = d.createElement('script');
8+
s.src = 'https://client.crisp.chat/l.js';
9+
s.async = 1;
10+
d.getElementsByTagName('head')[0].appendChild(s);
11+
})(window, document);

integrations/crisp/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@gitbook/tsconfig/integration.json"
3+
}

integrations/helpscout/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["@gitbook/eslint-config/integration"]
3+
}
Loading
29.7 KB
Loading
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: helpscout
2+
title: HelpScout
3+
organization: gitbook
4+
visibility: public
5+
description: Add the HelpScout chat widget to your published GitBook content
6+
summary: |
7+
# Overview
8+
9+
The HelpScout integration for GitBook allows you to display the HelpScout chat widget on your public documentation to connect and interact with your readers.
10+
11+
# How it works
12+
13+
Automatic chat widget on your documentation: Each of your connected GitBook spaces will fetch the HelpScout chat widget script and add it to your published content.
14+
15+
# Configure
16+
17+
You can configure the integration on single or multiple public spaces by navigating to the integrations in sub-navigation or org settings. You will then have to provide HelpScout ID to finish the configuration.
18+
categories:
19+
- analytics
20+
script: src/index.tsx
21+
icon: ./assets/icon.png
22+
previewImages:
23+
- assets/helpscout-preview.png
24+
# The following scope(s) are available only to GitBook Staff
25+
# See https://developer.gitbook.com/integrations/configurations#scopes
26+
scopes:
27+
- space:script:inject
28+
- site:script:inject
29+
secrets: {}
30+
contentSecurityPolicy:
31+
script-src: https://beacon-v2.helpscout.net;
32+
configurations:
33+
space:
34+
properties:
35+
helpscout_id:
36+
type: string
37+
title: HelpScout ID
38+
description: Your HelpScout integration ID.
39+
required:
40+
- helpscout_id
41+
site:
42+
properties:
43+
helpscout_id:
44+
type: string
45+
title: HelpScout ID
46+
description: Your HelpScout integration ID.
47+
required:
48+
- helpscout_id

0 commit comments

Comments
 (0)