cd C:\Kapsel_Projects\KapselGSDemo
cordova plugin add kapsel-plugin-usage --searchpath %KAPSEL_HOME%/plugins
or on a Mac
cd ~/Documents/Kapsel_Projects/KapselGSDemo
cordova plugin add kapsel-plugin-usage --searchpath $KAPSEL_HOME/plugins
var readTimerID = null;
var startUpTime = null;
...
function logonSuccessCallback(result) {
...
startUpTime = ((endTime2 - t0)/1000).toFixed(3);
...
function makeTimerSuccessCallback(result) {
console.log("EventLogging: makeTimerSuccess");
readTimerID = result;
}
function stopTimerSuccessCallback(result) {
console.log("EventLogging: stopTimerSuccess");
}
function showConsentCallback() {
var consent = sap.Usage.getUserConsent(getUserConsentCallback);
}
function getUserConsentCallback(consentGiven) {
console.log("EventLogging: Consent for usage collection is: " + consentGiven);
if (consentGiven) {
initUsagePlugin();
}
}
function initUsagePlugin() {
var host = applicationContext.registrationContext.serverHost;
var port = applicationContext.registrationContext.serverPort;
var path = '/clientusage';
s = "";
if (applicationContext.registrationContext.https) {
s = "s"
};
var uploadUrl = "http" + s + '://' + host + ":" + port + path;
var timeFor3GUpload = 0;
sap.Usage.init(uploadUrl, "myEncryptionKey", 1 /* how often to upload */, usageInitSuccessCallback, errorCallback);
}
function usageInitSuccessCallback(status) {
console.log("EventLogging: Successfully initialized the Usage plugin");
}
function usageReportsCallback(usageData) {
console.log("EventLogging: " + usageData);
alert(usageData);
}
function onUsageInitialized(initialized) {
if (initialized.detail.args) {
console.log("EventLogging: onUsageInitialized");
var info = new sap.Usage.InfoType();
info.setMeasurement(startUpTime);
info.setResult("App started in " + startUpTime + " seconds");
sap.Usage.log("startUpTime", info, "startUpTimer");
console.log("EventLogging: Added startup time to usage");
}
else {
alert("Usage initialization failed");
}
}
document.addEventListener("onUsageInitialized", onUsageInitialized, false);
function read() {
sap.Usage.makeTimer("readTimerKey", makeTimerSuccessCallback, errorCallback);
...
}
function readSuccessCallback(data, response) {
...
var info = new sap.Usage.InfoType();
info.setResult("Read " + data.results.length + " records");
sap.Usage.stopTimer(readTimerID, info, "readTimer", stopTimerSuccessCallback, errorCallback);
}
...
<button id="showConsent" onclick="sap.Usage.showConsentDialog(showConsentCallback)">Show Consent Dialog</button>
<button id="getUsage" onclick="sap.Usage.getReports(usageReportsCallback)">Show Usage Data</button>
cordova run android
or
cordova run ios
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
24 | |
10 | |
8 | |
8 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |