Skip to content

Commit

Permalink
Add Reo.Dev Integration (#298)
Browse files Browse the repository at this point in the history
* Add Reo.Dev integration

* Add index.ts file

* Run npm install to update package-lock.json

* Rename folder to reo

* Delete old files

* Fix linter errors

* Update contentSecurityPolicy

* Update configuration based on coming site updates

* Update manifest for reo integration

* Update package lock

* Add new dependencies to pakcage lock

* fix conflicts in package-lock

---------

Co-authored-by: Addison <[email protected]>
Co-authored-by: taranvohra <[email protected]>
Co-authored-by: Addison <[email protected]>
  • Loading branch information
4 people authored Jul 8, 2024
1 parent fc8b0e5 commit c9f4cf9
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 1 deletion.
3 changes: 3 additions & 0 deletions integrations/reo/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@gitbook/eslint-config/integration"]
}
Binary file added integrations/reo/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added integrations/reo/assets/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions integrations/reo/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: reodotdev
title: Reo.dev
icon: ./assets/icon.png
previewImages:
- ./assets/preview.png
description: Plug your GitBook site to your Reo.dev installation.
externalLinks:
- label: Website
url: https://www.reo.dev/
visibility: public
script: ./src/index.ts
# The following scope(s) are available only to GitBook Staff
# See https://developer.gitbook.com/integrations/configurations#scopes
scopes:
- space:script:inject
- site:script:inject
organization: d8f63b60-89ae-11e7-8574-5927d48c4877
contentSecurityPolicy:
script-src: static.reo.dev www.ipapi.co;
summary: |
# Overview
Reo.Dev is the Business to Developer (B2D) ABM platform that helps you find revenue opportunity from developer activity.
This integration lets you add the Reo.Dev Javascript on your published GitBook site to seamlessly analyze developer intent through any interactions with your content on GitBook.
# How it works
The integration injects the Reo.dev script on your page, using the configured client ID,
so that you can get analytics information from your GitBook site directly inside of Reo.
# Configure
Install the integration on the GitBook space of your choice.
Locate the Reo.dev's client ID you want to use, which is available in Reo.dev's Integration -> Documentation section
categories:
- analytics
configurations:
space:
properties:
tracking_id:
type: string
title: Client ID
description: Available in Reo.dev's Integration -> Documentation section
required:
- tracking_id
site:
properties:
tracking_id:
type: string
title: Client ID
description: Available in Reo.dev's Integration -> Documentation section
required:
- tracking_id
18 changes: 18 additions & 0 deletions integrations/reo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@gitbook/integration-reo.dev",
"version": "0.0.1",
"private": true,
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*"
},
"devDependencies": {
"@gitbook/cli": "*"
},
"scripts": {
"lint": "eslint ./src/**/*.ts",
"typecheck": "tsc --noEmit",
"publish-integrations-staging": "gitbook publish .",
"publish-integrations": "gitbook publish ."
}
}
42 changes: 42 additions & 0 deletions integrations/reo/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
createIntegration,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

import script from './script.raw.js';

type ReoDotDevRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
tracking_id?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: ReoDotDevRuntimeContext
) => {
const trackingId =
environment.siteInstallation?.configuration?.tracking_id ??
environment.spaceInstallation.configuration.tracking_id;
if (!trackingId) {
throw new Error(
`The Reo.Dev tracking ID is missing from the configuration (ID: ${event.spaceId}).`
);
}

return new Response(script.replace('<TO_REPLACE>', trackingId), {
headers: {
'Content-Type': 'application/javascript',
'Cache-Control': 'max-age=604800',
},
});
};

export default createIntegration<ReoDotDevRuntimeContext>({
fetch_published_script: handleFetchEvent,
});
15 changes: 15 additions & 0 deletions integrations/reo/src/script.raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const trackingID = '<TO_REPLACE>';

(function (r, e, o) {
var t, c, n;
c = { clientID: trackingID };
t = function () {
Reo.init(c);
};
n = e.createElement("script");
n.src = o + c.clientID + '/reo.js';
n.async = !0;
n.onload = t;

e.head.appendChild(n);
})(window, document, "https://static.reo.dev/");
3 changes: 3 additions & 0 deletions integrations/reo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}
16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9f4cf9

Please sign in to comment.