Skip to content

Commit b23fa55

Browse files
Merge branch 'main' into front/fix-dark-light-mode
2 parents 573d251 + 0656358 commit b23fa55

File tree

112 files changed

+803
-4555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+803
-4555
lines changed

.changeset/deep-spoons-throw.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/grumpy-chicken-report.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
release:
1212
name: Release
1313
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
id-token: write
1418
steps:
1519
- name: Checkout
1620
uses: actions/checkout@v4
@@ -19,6 +23,15 @@ jobs:
1923
fetch-depth: 0
2024
# Using a PAT instead of the default token to ensure commits trigger CI
2125
token: ${{ secrets.GH_PERSONAL_TOKEN }}
26+
- name: Setup Node.js for npm trusted publishing
27+
uses: actions/setup-node@v4
28+
with:
29+
# npm trusted publishing requires npm 11.5.1+ (Node 22.14.0+)
30+
node-version: '24'
31+
registry-url: 'https://registry.npmjs.org'
32+
# Ensure npm 11.5.1 or later is installed
33+
- name: Update npm
34+
run: npm install -g npm@latest
2235
- name: Setup bun
2336
uses: oven-sh/setup-bun@v2
2437
with:
@@ -34,7 +47,7 @@ jobs:
3447
# Using a PAT instead of GITHUB_TOKEN because we need to run workflows when releases are created
3548
# https://github.com/orgs/community/discussions/26875#discussioncomment-3253761
3649
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
37-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
NPM_CONFIG_PROVENANCE: true
3851

3952
publish-integrations-staging:
4053
name: Publish Integrations to Staging

bun.lock

Lines changed: 49 additions & 213 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integrations/amplitude/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @gitbook/integration-amplitude
22

3+
## 2.1.0
4+
5+
### Minor Changes
6+
7+
- a09e3b5: Add more configuration options to amplitude integration
8+
39
## 2.0.0
410

511
### Major Changes

integrations/amplitude/gitbook-manifest.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ contentSecurityPolicy:
1818
https://cdn.amplitude.com;
1919
connect-src: |
2020
cdn.amplitude.com;
21+
api2.amplitude.com;
2122
summary: |
2223
# Overview
2324
@@ -42,6 +43,61 @@ configurations:
4243
type: string
4344
title: Amplitude API Key
4445
description: Your Amplitude API Key
46+
server_url:
47+
type: string
48+
title: Server URL
49+
description: URL where events are uploaded
50+
default: https://api2.amplitude.com/2/httpapi
51+
autocapture_attribution:
52+
type: boolean
53+
title: Attribution
54+
description: Enable marketing attribution tracking
55+
default: true
56+
autocapture_page_views:
57+
type: boolean
58+
title: Page Views
59+
description: Enable page view tracking
60+
default: true
61+
autocapture_sessions:
62+
type: boolean
63+
title: Sessions
64+
description: Enable session tracking
65+
default: true
66+
autocapture_form_interactions:
67+
type: boolean
68+
title: Form Interactions
69+
description: Enable form start and form submit tracking
70+
default: true
71+
autocapture_file_downloads:
72+
type: boolean
73+
title: File Downloads
74+
description: Enable file download tracking
75+
default: true
76+
autocapture_element_interactions:
77+
type: boolean
78+
title: Element Interactions
79+
description: Enable element click and form field interaction tracking
80+
default: false
81+
autocapture_frustration_interactions:
82+
type: boolean
83+
title: Frustration Interactions
84+
description: Enable rage clicks and dead clicks tracking (SDK 2.24.0+)
85+
default: false
86+
autocapture_page_url_enrichment:
87+
type: boolean
88+
title: Page URL Enrichment
89+
description: Add page URL-related properties to all events
90+
default: true
91+
autocapture_network_tracking:
92+
type: boolean
93+
title: Network Tracking
94+
description: Enable XHR and Fetch network request tracking
95+
default: false
96+
autocapture_web_vitals:
97+
type: boolean
98+
title: Web Vitals
99+
description: Enable Core Web Vitals tracking (SDK 2.27.0+)
100+
default: false
45101
required:
46102
- amplitude_api_key
47103
target: site

integrations/amplitude/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitbook/integration-amplitude",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"private": true,
55
"dependencies": {
66
"@gitbook/api": "*",

integrations/amplitude/src/amplitudeScript.raw.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function (w, d, s, apiKey) {
1+
(function (w, d, s, apiKey, initConfigJson) {
22
const GRANTED_COOKIE = '__gitbook_cookie_granted';
33

44
function getCookie(cname) {
@@ -30,10 +30,8 @@
3030
j.referrerPolicy = 'no-referrer-when-downgrade';
3131
j.onload = function () {
3232
window.amplitude.add(window.sessionReplay.plugin({ sampleRate: 1 }));
33-
window.amplitude.init(apiKey, {
34-
fetchRemoteConfig: true,
35-
autocapture: true,
36-
});
33+
const initConfig = JSON.parse(initConfigJson || '{}');
34+
window.amplitude.init(apiKey, initConfig);
3735
};
3836
f.parentNode.insertBefore(j, f);
39-
})(window, document, 'script', '<TO_REPLACE>');
37+
})(window, document, 'script', '<TO_REPLACE>', '<TO_REPLACE_INIT_CONFIG>');

integrations/amplitude/src/index.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,24 @@ import {
77

88
import script from './amplitudeScript.raw.js';
99

10+
const DEFAULT_SERVER_URL = 'https://api2.amplitude.com/2/httpapi';
11+
1012
type AmplitudeRuntimeContext = RuntimeContext<
1113
RuntimeEnvironment<
1214
{},
1315
{
1416
amplitude_api_key?: string;
17+
server_url?: string;
18+
autocapture_attribution?: boolean;
19+
autocapture_page_views?: boolean;
20+
autocapture_sessions?: boolean;
21+
autocapture_form_interactions?: boolean;
22+
autocapture_file_downloads?: boolean;
23+
autocapture_element_interactions?: boolean;
24+
autocapture_frustration_interactions?: boolean;
25+
autocapture_page_url_enrichment?: boolean;
26+
autocapture_network_tracking?: boolean;
27+
autocapture_web_vitals?: boolean;
1528
}
1629
>
1730
>;
@@ -20,13 +33,37 @@ export const handleFetchEvent: FetchPublishScriptEventCallback = async (
2033
_event,
2134
{ environment }: AmplitudeRuntimeContext,
2235
) => {
23-
const amplitudeApiKey = environment.siteInstallation?.configuration?.amplitude_api_key;
36+
const config = environment.siteInstallation?.configuration;
37+
const amplitudeApiKey = config?.amplitude_api_key;
2438

2539
if (!amplitudeApiKey) {
2640
return;
2741
}
2842

29-
return new Response((script as string).replace(/<TO_REPLACE>/g, amplitudeApiKey), {
43+
const serverUrl = config?.server_url ?? DEFAULT_SERVER_URL;
44+
const initConfig = {
45+
...(serverUrl !== DEFAULT_SERVER_URL ? { serverUrl } : {}),
46+
fetchRemoteConfig: true,
47+
autocapture: {
48+
attribution: config?.autocapture_attribution ?? true,
49+
pageViews: config?.autocapture_page_views ?? true,
50+
sessions: config?.autocapture_sessions ?? true,
51+
formInteractions: config?.autocapture_form_interactions ?? true,
52+
fileDownloads: config?.autocapture_file_downloads ?? true,
53+
elementInteractions: config?.autocapture_element_interactions ?? false,
54+
frustrationInteractions: config?.autocapture_frustration_interactions ?? false,
55+
pageUrlEnrichment: config?.autocapture_page_url_enrichment ?? true,
56+
networkTracking: config?.autocapture_network_tracking ?? false,
57+
webVitals: config?.autocapture_web_vitals ?? false,
58+
},
59+
};
60+
61+
const initConfigJson = JSON.stringify(initConfig).replace(/\\/g, '\\\\').replace(/'/g, "\\'");
62+
63+
let scriptContent = (script as string).replace(/<TO_REPLACE>/g, amplitudeApiKey);
64+
scriptContent = scriptContent.replace('<TO_REPLACE_INIT_CONFIG>', initConfigJson);
65+
66+
return new Response(scriptContent, {
3067
headers: {
3168
'Content-Type': 'application/javascript',
3269
'Cache-Control': 'max-age=604800',

integrations/arcade/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @gitbook/integration-arcade
22

3+
## 0.3.0
4+
5+
### Minor Changes
6+
7+
- 76e1a39: Add query param for language
8+
39
## 0.2.2
410

511
### Patch Changes

0 commit comments

Comments
 (0)