mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add Support Grist page and nudge
Summary: Adds a new Support Grist page (accessible only in grist-core), containing options to opt in to telemetry and sponsor Grist Labs on GitHub. A nudge is also shown in the doc menu, which can be collapsed or permanently dismissed. Test Plan: Browser and server tests. Reviewers: paulfitz, dsagal Reviewed By: paulfitz Subscribers: jarek, dsagal Differential Revision: https://phab.getgrist.com/D3926
This commit is contained in:
32
app/client/models/TelemetryModel.ts
Normal file
32
app/client/models/TelemetryModel.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {AppModel, getHomeUrl} from 'app/client/models/AppModel';
|
||||
import {TelemetryPrefs} from 'app/common/Install';
|
||||
import {InstallAPI, InstallAPIImpl, TelemetryPrefsWithSources} from 'app/common/InstallAPI';
|
||||
import {bundleChanges, Disposable, Observable} from 'grainjs';
|
||||
|
||||
export interface TelemetryModel {
|
||||
/** Telemetry preferences (e.g. the current telemetry level). */
|
||||
readonly prefs: Observable<TelemetryPrefsWithSources | null>;
|
||||
fetchTelemetryPrefs(): Promise<void>;
|
||||
updateTelemetryPrefs(prefs: Partial<TelemetryPrefs>): Promise<void>;
|
||||
}
|
||||
|
||||
export class TelemetryModelImpl extends Disposable implements TelemetryModel {
|
||||
public readonly prefs: Observable<TelemetryPrefsWithSources | null> = Observable.create(this, null);
|
||||
private readonly _installAPI: InstallAPI = new InstallAPIImpl(getHomeUrl());
|
||||
|
||||
constructor(_appModel: AppModel) {
|
||||
super();
|
||||
}
|
||||
|
||||
public async fetchTelemetryPrefs(): Promise<void> {
|
||||
const prefs = await this._installAPI.getInstallPrefs();
|
||||
bundleChanges(() => {
|
||||
this.prefs.set(prefs.telemetry);
|
||||
});
|
||||
}
|
||||
|
||||
public async updateTelemetryPrefs(prefs: Partial<TelemetryPrefs>): Promise<void> {
|
||||
await this._installAPI.updateInstallPrefs({telemetry: prefs});
|
||||
await this.fetchTelemetryPrefs();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user