Skip to content

The first submission of the project, integrating salesmartly components #691

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions integrations/salesmartly/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @gitbook/integration-salesmartly

## 0.0.1

### Patch Changes

- The first submission of the project, integrating salesmartly components
Binary file added integrations/salesmartly/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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions integrations/salesmartly/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: salesmartly
title: Salesmartly
icon: ./assets/icon.png
organization: XKKpOzQCRtNWW2u1zORS
description: Add the Salesmartly chat widget to your published GitBook content
previewImages:
- ./assets/salesmartly-preview.png
externalLinks:
- label: Documentation
url: https://www.gitbook.com/integrations/salesmartly
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://assets.salesmartly.com
https://client.salesmartly.com
https://api.salesmartly.com
https://srz.salesmartly.com;
style-src: |
'unsafe-inline'
assets.salesmartly.com;
img-src: |
data:
blob:
assets-cdn.salesmartly.com
assets.salesmartly.com
connect-src: |
wss://msg-ws.salesmartly.com
assets.salesmartly.com
form-action: |
msg.salesmartly.com
assets.salesmartly.com
media-src: |
assets-cdn.salesmartly.com
assets.salesmartly.com;
font-src: |
assets.salesmartly.com
summary: |
# Overview

The Salesmartly integration for GitBook allows you to display the Salesmartly chat widget on your public documentation to connect and interact with your readers.

# How it works

Automatic chat widget on your documentation: Each of your connected GitBook spaces will fetch the Salesmartly chat widget script and inject it in your published content.

# Configure

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 Application ID to finish the configuration.
categories:
- analytics
configurations:
site:
properties:
app_id:
type: string
title: Application ID
description: You can find it in your Salesmartly account.
required:
- app_id
target: site
19 changes: 19 additions & 0 deletions integrations/salesmartly/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@gitbook/integration-Salesmartly",
"version": "0.5.2",
"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 ."
}
}
39 changes: 39 additions & 0 deletions integrations/salesmartly/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
createIntegration,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

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

type IntercomRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
app_id?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: IntercomRuntimeContext,
) => {
const appId = environment.siteInstallation?.configuration?.app_id;

if (!appId) {
return;
}

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

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

var w = window;

var d = document;

var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://assets.salesmartly.com/js/' + APP_ID + '.js';
var x = d.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})();
3 changes: 3 additions & 0 deletions integrations/salesmartly/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}