feat(client): send session_info with every service request
Adds a single-row `session_info` input table to every service call made through SasService.request, describing where the request came from: - url - the URL of the Data Controller page itself (the iframe), not the document embedding it, so an embedded report and any parameters its author added to the embed URL can be told apart - referrer - the embedding document - timezone / tz_offset / locale - the browser's, so services and hooks can match date logic and labels to what the user sees - version - the client build, for support and version-aware hooks - va_result_name / va_row_count / va_available_row_count - VA data-driven content metadata, blank and zero when not embedded in VA When VA is present its parameters and columns are sent too, as `va_parameters` and `va_columns` tables, so a hook script can branch on the report's own parameters. The table is always sent - when the app is standalone the VA fields are simply empty. Hook scripts read it directly from WORK; no service needs to change.
This commit is contained in:
1 parent
f1734a2de0
commit
50282f2ddb
1 file changed
+42
@@ -20,6 +20,8 @@ import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapper
|
||||
import { SasViyaService } from './sas-viya.service'
|
||||
import { ViyaApiFolder } from '../viya-api-explorer/models/viya-api-folder.model'
|
||||
import { ViyaApiFolderMembers } from '../viya-api-explorer/models/viya-api-folder-content.model'
|
||||
import { VaMessagingService } from './va-messaging.service'
|
||||
import { VERSION } from '../../environments/version'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -45,6 +47,7 @@ export class SasService {
|
||||
private sasViyaService: SasViyaService,
|
||||
private loggerService: LoggerService,
|
||||
private startupCheckService: StartupCheckService,
|
||||
private vaMessagingService: VaMessagingService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
@@ -118,6 +121,45 @@ export class SasService {
|
||||
|
||||
if (!wrapperOptions) wrapperOptions = {}
|
||||
|
||||
// Tell the backend where the request came from. This is the URL of this
|
||||
// page - the Data Controller iframe - not the document that embeds it, so
|
||||
// an embedded report can be distinguished (and any parameters the report
|
||||
// author added to the embed URL are visible). Sent as an input table so
|
||||
// that any service, and any hook script, can read it.
|
||||
if (data && typeof data === 'object' && !data.session_info) {
|
||||
const va = this.vaMessagingService.latestMessage()
|
||||
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
data.session_info = [
|
||||
{
|
||||
url: window.location.href,
|
||||
referrer: document.referrer,
|
||||
timezone: tz || '',
|
||||
tz_offset: new Date().getTimezoneOffset(),
|
||||
locale: navigator.language || '',
|
||||
version: VERSION.semverString,
|
||||
va_result_name: va?.resultName ?? '',
|
||||
va_row_count: va?.rowCount ?? 0,
|
||||
va_available_row_count: va?.availableRowCount ?? 0
|
||||
}
|
||||
]
|
||||
if (va?.parameters?.length) {
|
||||
data.va_parameters = va.parameters.map((p) => ({
|
||||
name: p.name,
|
||||
label: p.label ?? '',
|
||||
data_type: p.dataType ?? '',
|
||||
value: p.value === null || p.value === undefined ? '' : String(p.value)
|
||||
}))
|
||||
}
|
||||
if (va?.columns?.length) {
|
||||
data.va_columns = va.columns.map((c) => ({
|
||||
name: c.name,
|
||||
label: c.label ?? '',
|
||||
type: c.type,
|
||||
usage: c.usage ?? ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
// If debug is on it will print what is going inside the adapter
|
||||
this.loggerService.logRequestData(url, data)
|
||||
|
||||
|
||||
Reference in new issue
Block a user