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:
eventType: The event we are reporting happened ex. Generator Success
user: Hashed user ID unless privacy is activated then "NA"
Custom event parameters:
- IAAS (aws,ali,azure)
- Datacenter (stg10.int, cry10.int, ap21, prd40)
- Version
- Is SAP User
- The unique caller ID that extensions put in param
6 - 9. Extension's custom events provided via 'track' API