Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/tender-shrimps-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gitbook/integration-fullstory": patch
---

Add Fullstory integration
18 changes: 16 additions & 2 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
"@gitbook/tsconfig": "workspace:*",
},
},
"integrations/fullstory": {
"name": "@gitbook/integration-fullstory",
"version": "0.1.0",
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*",
},
"devDependencies": {
"@gitbook/cli": "workspace:*",
"@gitbook/tsconfig": "workspace:*",
},
},
"integrations/github": {
"name": "@gitbook/integration-github",
"version": "0.6.3",
Expand Down Expand Up @@ -531,7 +543,7 @@
},
"integrations/slack": {
"name": "@gitbook/integration-slack",
"version": "2.4.0",
"version": "2.5.0",
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*",
Expand Down Expand Up @@ -652,7 +664,7 @@
},
"packages/api": {
"name": "@gitbook/api",
"version": "0.137.0",
"version": "0.138.0",
"dependencies": {
"event-iterator": "^2.0.0",
"eventsource-parser": "^3.0.0",
Expand Down Expand Up @@ -997,6 +1009,8 @@

"@gitbook/integration-formspree": ["@gitbook/integration-formspree@workspace:integrations/formspree"],

"@gitbook/integration-fullstory": ["@gitbook/integration-fullstory@workspace:integrations/fullstory"],

"@gitbook/integration-github": ["@gitbook/integration-github@workspace:integrations/github"],

"@gitbook/integration-github-copilot": ["@gitbook/integration-github-copilot@workspace:integrations/github-copilot"],
Expand Down
1 change: 1 addition & 0 deletions integrations/fullstory/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @gitbook/integration-fullstory
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/fullstory/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.
56 changes: 56 additions & 0 deletions integrations/fullstory/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: fullstory
title: Fullstory
icon: ./assets/icon.png
organization: gitbook
description: Capture user sessions in GitBook with Fullstory to understand reader behavior and improve UX.
previewImages:
- ./assets/fullstory-preview.png
externalLinks:
- label: Documentation
url: https://www.gitbook.com/integrations/fullstory
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:
- site:script:inject
- site:script:cookies
contentSecurityPolicy:
script-src: |
https://fullstory.com
https://edge.fullstory.com;
img-src: |
data:
blob:
fullstory.com
edge.fullstory.com;
font-src: |
data:;
connect-src: |
fullstory.com
edge.fullstory.com
about:;
summary: |
# Overview

Fullstory is a digital experience analytics platform that helps companies understand how users interact with their websites and apps. The Fullstory integration for GitBook allows you to gather analytics in Fullstory from visitors to your docs site.

# How it works

AI-powered insights from your documentation: Each of your connected GitBook sites will fetch the Fullstory tracking script and inject it into your public content.

# Configure

GitBook admins can enable the Fullstory integration by navigating to organization settings. The integration can be enabled on a per-site basis or for all sites in the organization.
categories:
- analytics
configurations:
site:
properties:
organization_id:
type: string
title: Organization ID
description: Look for this in your Fullstory account.
required:
- organization_id
target: site
19 changes: 19 additions & 0 deletions integrations/fullstory/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@gitbook/integration-fullstory",
"version": "0.1.0",
"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 ."
}
}
38 changes: 38 additions & 0 deletions integrations/fullstory/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
createIntegration,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

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

type FullStoryRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
organization_id?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: FullStoryRuntimeContext,
) => {
const organizationId = environment.siteInstallation?.configuration?.organization_id;
if (!organizationId) {
return;
}

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

export default createIntegration<FullStoryRuntimeContext>({
fetch_published_script: handleFetchEvent,
});
154 changes: 154 additions & 0 deletions integrations/fullstory/src/script.raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
window['_fs_host'] = 'fullstory.com';
window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
window['_fs_org'] = '<TO_REPLACE>';
window['_fs_namespace'] = 'FS';
!(function (m, n, e, t, l, o, g, y) {
var s,
f,
a = (function (h) {
return (
!(h in m) ||
(m.console &&
m.console.log &&
m.console.log(
'FullStory namespace conflict. Please set window["_fs_namespace"].',
),
!1)
);
})(e);
function p(b) {
var h,
d = [];
function j() {
h &&
(d.forEach(function (b) {
var d;
try {
d = b[h[0]] && b[h[0]](h[1]);
} catch (h) {
return void (b[3] && b[3](h));
}
d && d.then ? d.then(b[2], b[3]) : b[2] && b[2](d);
}),
(d.length = 0));
}
function r(b) {
return function (d) {
h || ((h = [b, d]), j());
};
}
return (
b(r(0), r(1)),
{
then: function (b, h) {
return p(function (r, i) {
d.push([b, h, r, i]), j();
});
},
}
);
}
a &&
((g = m[e] =
(function () {
var b = function (b, d, j, r) {
function i(i, c) {
h(b, d, j, i, c, r);
}
r = r || 2;
var c,
u = /Async$/;
return u.test(b)
? ((b = b.replace(u, '')),
'function' == typeof Promise ? new Promise(i) : p(i))
: h(b, d, j, c, c, r);
};
function h(h, d, j, r, i, c) {
return b._api
? b._api(h, d, j, r, i, c)
: (b.q && b.q.push([h, d, j, r, i, c]), null);
}
return (b.q = []), b;
})()),
(y = function (b) {
function h(h) {
'function' == typeof h[4] && h[4](new Error(b));
}
var d = g.q;
if (d) {
for (var j = 0; j < d.length; j++) h(d[j]);
(d.length = 0), (d.push = h);
}
}),
(function () {
((o = n.createElement(t)).async = !0),
(o.crossOrigin = 'anonymous'),
(o.src = 'https://' + l),
(o.onerror = function () {
y('Error loading ' + l);
});
var b = n.getElementsByTagName(t)[0];
b && b.parentNode ? b.parentNode.insertBefore(o, b) : n.head.appendChild(o);
})(),
(function () {
function b() {}
function h(b, h, d) {
g(b, h, d, 1);
}
function d(b, d, j) {
h('setProperties', { type: b, properties: d }, j);
}
function j(b, h) {
d('user', b, h);
}
function r(b, h, d) {
j(
{
uid: b,
},
d,
),
h && j(h, d);
}
(g.identify = r),
(g.setUserVars = j),
(g.identifyAccount = b),
(g.clearUserCookie = b),
(g.setVars = d),
(g.event = function (b, d, j) {
h(
'trackEvent',
{
name: b,
properties: d,
},
j,
);
}),
(g.anonymize = function () {
r(!1);
}),
(g.shutdown = function () {
h('shutdown');
}),
(g.restart = function () {
h('restart');
}),
(g.log = function (b, d) {
h('log', { level: b, msg: d });
}),
(g.consent = function (b) {
h('setIdentity', { consent: !arguments.length || b });
});
})(),
(s = 'fetch'),
(f = 'XMLHttpRequest'),
(g._w = {}),
(g._w[f] = m[f]),
(g._w[s] = m[s]),
m[s] &&
(m[s] = function () {
return g._w[s].apply(this, arguments);
}),
(g._v = '2.0.0'));
})(window, document, window._fs_namespace, 'script', window._fs_script);
3 changes: 3 additions & 0 deletions integrations/fullstory/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}