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

## Unreleased
Fixed: `index.d.ts` declared `Gleap.setStyles` with one object, but the SDK takes positional arguments: `setStyles(primaryColor, headerColor, buttonColor, backgroundColor?, borderRadius?, buttonX?, buttonY?, buttonStyle?, headerColor2?, headerColor3?)`. A call in the declared object form threw an error on the page and injected no styles. TypeScript projects that call `setStyles` with an object now get a compile error pointing at that call, which never worked; pass the values as arguments instead. No runtime change.

## 19.9.0
Changed: the feedback form's **Record screen** uses the microphone only when **Developer options → Microphone** is on, and then it starts muted until the user turns it on. Until this version, form recordings asked for the microphone whenever the browser had one, regardless of that setting, and on a site that already had microphone permission the browser gave it without a prompt. The mic button is hidden when the setting is off. Projects that want sound in form recordings turn the setting on.
Added: product tours and tooltips can point at elements inside open shadow roots. A selector continues into a shadow root with `host >>> inner`, the element picker stores such selectors, and the highlight, the interaction lockout and click-to-continue work for those elements.
Expand Down
40 changes: 30 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,36 @@ export namespace Gleap {
function trackEvent(name: string, data?: any): void;
function setAppBuildNumber(buildNumber: string): void;
function setAppVersionCode(versionCode: string): void;
function setStyles(styles: {
primaryColor: string;
headerColor: string;
buttonColor: string;
backgroundColor: string;
borderRadius?: number;
buttonX?: number;
buttonY?: number;
buttonStyle?: string;
}): void;
/**
* Replaces the widget's stylesheet: colors, corner radius and the launcher's offsets.
* Takes positional arguments. The SDK applies the dashboard's look the same way
* whenever the project's config loads, which replaces an earlier call.
* Colors are six-digit hex colors such as "#485BFF".
* @param primaryColor UI color.
* @param headerColor Header color.
* @param buttonColor Launcher color.
* @param backgroundColor Widget background. Default "#ffffff".
* @param borderRadius Corner radius in px. Default 20.
* @param buttonX Distance of the launcher and widget from the page's side, in px. Default 20.
* @param buttonY Distance of the launcher from the page's bottom, in px. Default 20.
* @param buttonStyle The launcher's position ("BOTTOM_LEFT", "BOTTOM_RIGHT", "BUTTON_CLASSIC",
* "BUTTON_CLASSIC_LEFT", "BUTTON_CLASSIC_BOTTOM" or "BUTTON_NONE"), used to place
* notifications clear of it. Default "BOTTOM_LEFT".
* @param headerColor2 Second header gradient color. Defaults to `headerColor`.
* @param headerColor3 Third header gradient color. Defaults to `headerColor`.
*/
function setStyles(
primaryColor: string,
headerColor: string,
buttonColor: string,
backgroundColor?: string,
borderRadius?: number,
buttonX?: number,
buttonY?: number,
buttonStyle?: string,
headerColor2?: string,
headerColor3?: string
): void;
function disableConsoleLogOverwrite(): void;
function setLiveSite(isLiveSite: boolean): void;
function enableShortcuts(enabled: boolean): void;
Expand Down
9 changes: 9 additions & 0 deletions smoke/typings.fixture.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Calls a TypeScript project makes, compiled against index.d.ts by typings.spec.mjs.
// A call marked @ts-expect-error must not compile: the SDK would fail on it at runtime.
import Gleap from '../index';

Gleap.setStyles('#1A73E8', '#0B57D0', '#1A73E8');
Gleap.setStyles('#1A73E8', '#0B57D0', '#1A73E8', '#FFFFFF', 12, 24, 24, 'BOTTOM_RIGHT', '#4285F4', '#8AB4F8');

// @ts-expect-error setStyles takes positional arguments; an object throws on the page and injects no styles.
Gleap.setStyles({ primaryColor: '#1A73E8', headerColor: '#0B57D0', buttonColor: '#1A73E8', backgroundColor: '#FFFFFF' });
14 changes: 14 additions & 0 deletions smoke/typings.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// index.d.ts as a TypeScript project compiles against it, with the options of `npm run typecheck`.
import { fileURLToPath } from 'node:url';

import { expect, test } from '@playwright/test';
import ts from 'typescript';

const FIXTURE = fileURLToPath(new URL('typings.fixture.ts', import.meta.url));

// An unused @ts-expect-error is itself an error, so no errors means every marked call was rejected.
test('index.d.ts accepts the calls in typings.fixture.ts and rejects the ones marked @ts-expect-error', () => {
const program = ts.createProgram([FIXTURE], { strict: true, noEmit: true, types: ['node'] });
const errors = ts.getPreEmitDiagnostics(program).map((diagnostic) => ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '));
expect(errors).toEqual([]);
});
Loading