Skip to content

Add Reo.Dev Integration #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
19 changes: 17 additions & 2 deletions package-lock.json

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

Loading