SAP Web Analytics npm package for Visual Code Extensions
Wrapper for SWA meant to be used in Visual code and SAP Application Studio.
Usage
Installation
TBD
ENV
Everything in the environment should be set up, if using in AppStudio please make sure swa-chart is installed as a ws-ext
API
There are only two functions to call for usage
Import
import { SWATracker } from '@sap/swa-for-sapbas-vsx';
Constructor
Has 3 params that are detailed in the constructor call:
var myErrorListener = (err) => { myErrorHandling(err); }
swa = new SWATracker("My Vscode Ext Publisher","My Package name", myErrorListener)
Track
After creating a new swa class as detailed above usage is pretty simple
swa.track("myEvent", ["custom event 1", "custom event 2", "This array is optional"]);
Example
import * as vscode from 'vscode';
import {SWATracker} from "@sap/swa-for-sapbas-vsx";
export function activate(context: vscode.ExtensionContext) {
const swa = new SWATracker("SAP", "vscode-close-editor", (err : string|number) => {console.log(err);});
let cmd_closeActiveEditor = vscode.commands.registerCommand('extension.closeActiveEditor', () => {
vscode.commands.executeCommand("workbench.action.closeActiveEditor");
swa.track("Close Active Editor");
});
...
...
- If running in Appstudio and SWA chart is not enabled code will throw error into console log that it is unable to track.
- Please take note that if environment is not configured correctly with privacy settings code will not send any tracking.
SWA Reports and Parameter Mapping
The following fields can be used for creating SWA reports:
SWA Field | Origin |
---|
eventType | The "myEvent" parameter sent via track API |
user | Hashed user ID unless privacy is activated, then "na" |
Custom event parameter 1 | Event additional data 1, "custom event 1" sent via track API |
Custom event parameter 2 | Event additional data 2, "custom event 2" sent via track API |
Custom event parameter 3 | Event additional data 3, "custom event 3" sent via track API |
Custom event parameter 4 | Event additional data 4, "custom event 4" sent via track API |
Custom event parameter 5 | Event additional data 5, "custom event 5" sent via track API |
Custom event parameter 6 | IAAS (aws,ali,azure), set by the lib automatically |
Custom event parameter 7 | Datacenter (stg10.int, cry10.int, ap21, prd40), set by the lib automatically |
Custom event parameter 8 | Version (currently not supported), set by the lib automatically |
Custom event parameter 9 | Is SAP User where allowed, empty overwise, set by the lib automatically |
Custom event parameter 10 | The unique caller ID "vsxPublisher.vsxPackageName", set by lib automatically |