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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 19.10.0

### Breaking changes
- With **Network logs** off in the dashboard (also in a project that never set it), tickets no longer contain Resource Timing entries (request URLs). Turn the setting on or call `Gleap.startNetworkLogger()` before `Gleap.initialize()` to keep them. ([#251](https://github.com/GleapSDK/JavaScript-SDK/pull/251))
- Turning **Network logs** off also stops a running logger, restores `fetch` and `XMLHttpRequest`, and deletes its logs, unless the app called `Gleap.startNetworkLogger()`. ([#251](https://github.com/GleapSDK/JavaScript-SDK/pull/251))
- Resource Timing entries are left out until the project's settings are loaded. ([#251](https://github.com/GleapSDK/JavaScript-SDK/pull/251))
- `Gleap.destroy()` stops the network logger. Its logs are held back until the next `Gleap.initialize()` loads the settings. ([#251](https://github.com/GleapSDK/JavaScript-SDK/pull/251))

### Added
- `Gleap.stopNetworkLogger()` turns network logging off, whatever the dashboard says. Call it before `Gleap.initialize()` to send no network data at all. ([#251](https://github.com/GleapSDK/JavaScript-SDK/pull/251))

## 19.9.2

### Breaking changes
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ When the grant runs out and no fresh token arrives (no `setUserJwt` on this page

Older integrations that pass a user hash to `Gleap.identify(userId, data, userHash)` keep working while "Accept legacy user hash" is on for the project; see [Upgrade to identity tokens](https://docs.gleap.ai/en/articles/16752008-upgrade-to-identity-tokens) to move them to `Gleap.setUserJwt`. `Gleap.identify(userId, data)` without a hash creates an unsigned contact.

### Network logs (optional)

Network logs follow the **Network logs** setting in the dashboard. To keep all network data out of Gleap, whatever the dashboard says, stop the logger before you initialize the SDK:

```
Gleap.stopNetworkLogger();
Gleap.initialize("YOUR_PROJECT_ID");
```

After the call, no requests are logged, no Resource Timing entries are read and logs from `Gleap.attachNetworkLogs` are left out. `Gleap.startNetworkLogger()` turns logging on again, whatever the dashboard says; logs attached before that have to be attached again.

### Dark mode (optional)

The widget can match your app's dark/light mode. Enable "Adapt to dark / light mode" in the dashboard (Widget → Look & feel) and set the dark colors there: header colors, UI color and background. In dark mode the widget uses these dark colors, plus the dark logo, header image and composer glow set in the dashboard; without dark colors it keeps its normal colors. Override the scheme at runtime, e.g. from your own theme toggle (only takes effect while "Adapt to dark / light mode" is enabled in the dashboard; until you call it, the dashboard setting applies):
Expand Down
2 changes: 1 addition & 1 deletion build/browser/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/browser/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/cjs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/cjs/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/esm/index.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/esm/index.mjs.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ export namespace Gleap {
*/
function setAgentConversationUrl(agentConversationUrl: string): void;
function setMaxNetworkRequests(maxRequests: number): void;
/** Starts logging network requests, also when **Network logs** is off in the dashboard. */
function startNetworkLogger(): void;
/**
* Stops network logging until startNetworkLogger is called, whatever the dashboard says. Deletes
* what was logged and sends no network data, attached logs included (attach them again after a restart). Can be called before initialize.
*/
function stopNetworkLogger(): void;
function setNetworkLogsBlacklist(networkLogBlacklist: string[]): void;
function setNetworkLogPropsToIgnore(filters: string[]): void;
/**
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "JavaScript and TypeScript SDK for Gleap, an Intercom alternative with AI customer support, live chat, in-app bug reporting and customer feedback.",
"name": "gleap",
"version": "19.9.2",
"version": "19.10.0",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
2 changes: 2 additions & 0 deletions published/19.10.0/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions published/19.10.0/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions published/19.10.0/survey-embed.js

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

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js.map

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/Gleap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AgentNetworkManager from './AgentNetworkManager';

Check warning on line 1 in src/Gleap.js

View workflow job for this annotation

GitHub Actions / quality

quality file-lines

[file-lines] src/Gleap.js:1 file: 1132 -> 1136 code lines (limit 400) Fix: Move one responsibility into its own file next to this one. Never squeeze code onto fewer lines.
import ChecklistNetworkManager from './ChecklistNetworkManager';
import GleapAdminManager from './GleapAdminManager';
import GleapAgentChat from './GleapAgentChat';
Expand Down Expand Up @@ -400,6 +400,7 @@
GleapCaptureManager.getInstance().destroy();
} catch (exp) {}
GleapReplayRecorder.getInstance().stop();
GleapNetworkIntercepter.getInstance().destroy();
GleapStreamedEvent.getInstance().stop();
GleapFrameManager.getInstance().destroy();
GleapFeedbackButtonManager.getInstance().destroy();
Expand Down Expand Up @@ -605,10 +606,18 @@
}

/**
* Sets the maximum network request count.
* Starts logging network requests, also when the dashboard has network logs turned off.
*/
static startNetworkLogger() {
GleapNetworkIntercepter.getInstance().start();
GleapNetworkIntercepter.getInstance().startByApp();
}

/**
* Stops network logging until startNetworkLogger is called, whatever the dashboard says: deletes
* what was logged and sends no network data of any kind. Can be called before initialize.
*/
static stopNetworkLogger() {
GleapNetworkIntercepter.getInstance().stopByApp();
}

/**
Expand Down
13 changes: 11 additions & 2 deletions src/GleapCaptureApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { packEvents } from './GleapCaptureRecorder';
import { CAPTURE_PLATFORM, CAPTURE_SDK_TYPE, getSdkVersion } from './GleapCaptureSettings';
import { toJsonParts } from './GleapCaptureTasks';
import { linkNetworkLogs, withoutWithdrawnLogs } from './GleapNetworkLogPolicy';

// Server calls and the log bundle of capture requests (contract §4 and §9). Every call resolves
// (never rejects) with { status, data }; status 0 means no answer.
Expand Down Expand Up @@ -157,8 +158,12 @@ export const encodeLogsBundle = (bundle) =>
return encodeJson(withoutReplay).then((smaller) => (smaller.size <= MAX_LOGS_BODY_BYTES ? smaller : null));
});

// Logging may have been stopped since the bundle was built.
const withoutWithdrawnNetworkLogs = (bundle) =>
bundle.networkLogs ? { ...bundle, networkLogs: withoutWithdrawnLogs(bundle.networkLogs) } : bundle;

export const postCaptureLogs = (requestId, bundle) =>
encodeLogsBundle(bundle).then((encoded) =>
encodeLogsBundle(withoutWithdrawnNetworkLogs(bundle)).then((encoded) =>
encoded
? sendCaptureApiRequest('POST', capturePath(requestId, 'logs'), encoded.body, {
gzip: encoded.gzip,
Expand Down Expand Up @@ -295,7 +300,11 @@ export const buildLogsBundle = (options = {}) => {
collect('consoleLog', () => withinWindow(GleapConsoleLogManager.getInstance().getLogs(), filterFrom, windowEnd, options.pauses));
}
if (include.networkLogs) {
collect('networkLogs', () => withinWindow(GleapNetworkIntercepter.getInstance().getRequests(), filterFrom, windowEnd, options.pauses));
collect('networkLogs', () => {
const select = (logs) => withinWindow(logs, filterFrom, windowEnd, options.pauses);
const logs = GleapNetworkIntercepter.getInstance().getRequests();
return linkNetworkLogs({ from: logs, to: select(logs), select });
});
}
if (include.customData) {
collect('customData', () => GleapCustomDataManager.getInstance().getCustomData());
Expand Down
Loading
Loading