mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
feat: add feedback module
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
SCThingsField,
|
||||
SCThingType,
|
||||
SCSaveableThing,
|
||||
SCFeedbackRequest,
|
||||
} from '@openstapps/core';
|
||||
import {chunk, fromPairs, toPairs} from 'lodash-es';
|
||||
import {environment} from '../../../environments/environment';
|
||||
@@ -292,6 +293,15 @@ export class DataProvider {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a feedback message (request)
|
||||
*
|
||||
* @param feedback Feedback message to be sent to the backend
|
||||
*/
|
||||
async sendFeedback(feedback: SCFeedbackRequest) {
|
||||
return this.client.feedback(feedback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the backend using the provided query and returns response
|
||||
*
|
||||
|
||||
68
src/app/modules/data/debug-data-collector.service.ts
Normal file
68
src/app/modules/data/debug-data-collector.service.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {SCFeedbackRequestMetaData} from '@openstapps/core';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {DataProvider} from './data.provider';
|
||||
import {NavigationEnd, Router} from '@angular/router';
|
||||
import {SettingsProvider} from '../settings/settings.provider';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DebugDataCollectorService {
|
||||
/**
|
||||
* Previously visited route
|
||||
*/
|
||||
previousRoute: string;
|
||||
|
||||
/**
|
||||
* Current route
|
||||
*/
|
||||
currentRoute: string;
|
||||
|
||||
constructor(
|
||||
private platform: Platform,
|
||||
private dataProvider: DataProvider,
|
||||
private router: Router,
|
||||
private settingsProvider: SettingsProvider,
|
||||
) {
|
||||
this.currentRoute = this.router.url;
|
||||
router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.previousRoute = this.currentRoute;
|
||||
this.currentRoute = event.url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides meta data for a feedback
|
||||
*/
|
||||
async getFeedbackMetaData(): Promise<SCFeedbackRequestMetaData> {
|
||||
return {
|
||||
debug: false,
|
||||
platform: this.platform.platforms().join(','),
|
||||
scope: {},
|
||||
state: {
|
||||
route: this.previousRoute,
|
||||
settings: await this.settingsProvider.getCache(),
|
||||
},
|
||||
userAgent: window.navigator.userAgent,
|
||||
version: this.dataProvider.appVersion,
|
||||
sendable: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user