Skip to content

Commit c306d26

Browse files
Add SalesViewer integration (#894)
* Add salesviewer integration init * Add changeset * remove spaces and only use sites * remove wrong lock file * Correct branding for SalesViewer in manifest file * added site as target; fixed external link * added organization id --------- Co-authored-by: Addison <[email protected]>
1 parent 5c48da9 commit c306d26

File tree

10 files changed

+137
-0
lines changed

10 files changed

+137
-0
lines changed

.changeset/tall-suits-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-salesviewer': major
3+
---
4+
5+
Initial release of salesviewer integration

bun.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,18 @@
481481
"@gitbook/tsconfig": "workspace:*",
482482
},
483483
},
484+
"integrations/salesviewer": {
485+
"name": "@gitbook/integration-salesviewer",
486+
"version": "0.1.0",
487+
"dependencies": {
488+
"@gitbook/api": "*",
489+
"@gitbook/runtime": "*",
490+
},
491+
"devDependencies": {
492+
"@gitbook/cli": "workspace:*",
493+
"@gitbook/tsconfig": "workspace:*",
494+
},
495+
},
484496
"integrations/segment": {
485497
"name": "@gitbook/integration-segment",
486498
"version": "2.1.3",
@@ -1027,6 +1039,8 @@
10271039

10281040
"@gitbook/integration-runllm-widget": ["@gitbook/integration-runllm-widget@workspace:integrations/runllm-widget"],
10291041

1042+
"@gitbook/integration-salesviewer": ["@gitbook/integration-salesviewer@workspace:integrations/salesviewer"],
1043+
10301044
"@gitbook/integration-segment": ["@gitbook/integration-segment@workspace:integrations/segment"],
10311045

10321046
"@gitbook/integration-sentry": ["@gitbook/integration-sentry@workspace:integrations/sentry"],
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+
}
40.7 KB
Loading
258 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: salesviewer
2+
title: SalesViewer
3+
icon: ./assets/icon.png
4+
description: Track and identify GitBook page visitors with Salesviewer analytics.
5+
previewImages:
6+
- ./assets/salesviewer-preview.png
7+
externalLinks:
8+
- label: Documentation
9+
url: https://www.salesviewer.com/en/help/
10+
visibility: public
11+
organization: ebg2KXDsLAQnw4pxgpm6
12+
script: ./src/index.ts
13+
scopes:
14+
- site:script:inject
15+
contentSecurityPolicy:
16+
script-src: |
17+
https://slsnlytcs.com;
18+
connect-src: |
19+
slsnlytcs.com;
20+
summary: |
21+
# Overview
22+
23+
SalesViewer® is a powerful analytics and visitor identification platform that helps you understand who visits your pages and track their behavior.
24+
25+
# How it works
26+
27+
The GitBook SalesViewer® integration allows you to track traffic in your published sites from your SalesViewer® dashboard.
28+
29+
Each of your connected GitBook sites will fetch the SalesViewer® tracking script and inject it in your public content, enabling visitor tracking and identification.
30+
31+
# Configure
32+
Install the integration on the GitBook site of your choice.
33+
Locate the Account ID you want to use, which is available in SalesViewer® dashboard under "Profile > Project & Tracking code":
34+
categories:
35+
- analytics
36+
configurations:
37+
site:
38+
properties:
39+
tracking_id:
40+
type: string
41+
title: Tracking ID
42+
description: Your SalesViewer® Account ID
43+
required:
44+
- tracking_id
45+
target: site

integrations/salesviewer/package.json

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

integrations/salesviewer/src/index.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import {
2+
createIntegration,
3+
FetchPublishScriptEventCallback,
4+
RuntimeContext,
5+
RuntimeEnvironment,
6+
} from '@gitbook/runtime';
7+
8+
import script from './salesviewerScript.raw.js';
9+
10+
type SalesviewerRuntimeContext = RuntimeContext<
11+
RuntimeEnvironment<
12+
{},
13+
{
14+
tracking_id?: string;
15+
}
16+
>
17+
>;
18+
19+
export const handleFetchEvent: FetchPublishScriptEventCallback = async (
20+
event,
21+
{ environment }: SalesviewerRuntimeContext
22+
) => {
23+
const trackingId = environment.siteInstallation?.configuration?.tracking_id;
24+
25+
if (!trackingId) {
26+
return;
27+
}
28+
29+
return new Response(script.replace('<TO_REPLACE>', trackingId), {
30+
headers: {
31+
'Content-Type': 'application/javascript',
32+
'Cache-Control': 'max-age=604800',
33+
},
34+
});
35+
};
36+
37+
export default createIntegration<SalesviewerRuntimeContext>({
38+
fetch_published_script: handleFetchEvent,
39+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(function (w, d, s, l, i) {
2+
var g = w[l] ? '&s=' + w[l] : '',
3+
f = d.getElementsByTagName(s)[0],
4+
j = d.createElement(s);
5+
j.async = true;
6+
j.src = 'https://slsnlytcs.com/stm.js?id=' + i + g;
7+
j.referrerPolicy = 'no-referrer-when-downgrade';
8+
f.parentNode.insertBefore(j, f);
9+
})(window, document, 'script', 'name', '<TO_REPLACE>');
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+
}

0 commit comments

Comments
 (0)