MobileFirst Analytics not working on other functions - ibm-mobilefirst

In ibm mobilefirst v7.0, I'm implementing the mfp analytics with angularjs.
"Log 1" is being showed in analytics console while "Log 2" is not.
Only the analytics that is called on my init function is being shown on the console, and on all the other functions, its not being shown on the console.
One weird encounter is the logs "MF analytics pushed to server successfully" is being called, so I could assume that its a success, but only "Log 1" is being shown and "Log 2" is not.
What could be the problem that "Log 2" is not being shown, or the logs on all other functions aside from init is not being shown on the console?
/** Initialization */
$scope.init = function() {
var log = {
"log" : "Log 1"
}
customMFAnalytics(log)
}
/** Called when the user press login */
$scope.login = function() {
var log = {
"log" : "Log 2"
}
customMFAnalytics(log)
}
$scope.init();
/** MFP Analytics */
function customMFAnalytics(event){
WL.Analytics.log(event);
WL.Analytics.send().then(function(state) {
console.log("MF analytics pushed to server successfully");
}).fail(function(errObj) {
console.log("Error while pushing MF analytics to server");
});;
}

Related

I am trying to login to the application but it says "A native alert dialog was invoked on page", I tried manually and could not see any dialog box

I am new to test cafe. I am trying to login to the application but it says " A native alert dialog was invoked on page, but no handler was set for it. Use the "setNativeDialogHandler" function to introduce a handler function for native dialogs.", I tried manually and could not see any dialog box.
page and function to login
import { Selector } from 'testcafe';
class Page {
constructor () {
this.loginInput = Selector("input[name*='username']");
this.passwordInput = Selector("input[name*='password']");
this.submitButton = Selector("div[role=button] div[class='gw-label']");
}
async login (t) {
await t
.maximizeWindow()
.typeText(this.loginInput, 'testRole')
.typeText(this.passwordInput, 'P#ssw0rd')
.setNativeDialogHandler(() => true)
.click(this.submitButton);
await t.wait(2000)
.expect(Selector("div[class = 'gw-TitleBar--title']").innerText).contains('Dashboard');
}
}
export default new Page();
Test:
website backend code:
enter code here

OneDrive FilePicker works with a personal account, but not with business account

I have an Angular web app that opens a OneDrive FilePicker and uses a Google Firebase cloud function to transfer the files the user picks to Google storage. It works fine if I use a personal OneDrive account, but if it is a business account I get a CORS error and the files are not transferred. My client-side code looks like this:
oneDriveOptions = {
clientId: '#####',
action: 'download',
multiSelect: true,
advanced: {
redirectUri: `${Utils.getBaseURL()}/one-drive-redirect`,
},
success: (files: any[]) => {
this.zone.run(() => {
this.oneDriveCallback(files);
});
},
cancel: () => {
this.zone.run(() => {
this.dbService.indeterminateProgress = false;
});
},
error: () => {
this.zone.run((error) => {
this.dbService.indeterminateProgress = false;
console.error('OneDrive file picker error:', error);
});
},
};
async oneDriveClicked() {
OneDrive.open(this.oneDriveOptions);
this.dialogRef.close();
}
async oneDriveCallback(files: any) {
try {
this.dbService.indeterminateProgress = true;
const cloudServiceFiles = this.convertOneDriveFiles(files.value);
await this.dbService.addFromCloudService(this.data.dbData, files.accessToken, cloudServiceFiles, this.data.insertIdx, 'oneDrive');
this.dbService.indeterminateProgress = false;
} catch (error) {
console.error(error.message);
this.dbService.indeterminateProgress = false;
}
}
And on the client side:
const getOneDriveFile = async (cloudServiceFile: CloudServiceFile) => {
const fileStream = oneDriveApi.items.download({
accessToken: cloudServiceAuthToken,
itemId: cloudServiceFile.id,
// drive:, default: 'me'. If it's set to be either 'user'/'drive'/'group'/'site', driveId has to be set to.
// driveId: The id of the drive that was shared to us. Must be set if params.drive is set.
});
return fileStream;
};
The output I get in the console:
Any suggestion why this code works fine for a personal account but gives CORS error from a business account?
This means you didn't register your app in Microsoft system so that they didn't let you to use the one drive .
follow this steps then check your app again
Setting up
To get started you need to register your application and receive an app ID from the Azure App registrations page.
To get started you need to register your application and receive an app ID from the Azure App registrations page.
Log in to the Azure App registrations page using your Microsoft account, or a work or school account.
Click Add an app and enter a name for your app.
After your application is created, configure it to support the JavaScript picker:
Click Generate New Password to create an Application secret. While this value is not necessary for the picker, it must have been created.
Click Add Platform and then select Web.
Enter one or more URLs where the picker will be hosted on your website. Each page that hosts the picker needs to have a redirect URL provided.
Click the Save button to save your changes.
Copy the Application Id for your application and use it in the JavaScript options object you provided to open or save a file.

Google plus API shutdown, How it will affect Google auth2 login for web sites?

I am confused with shutdown notification mails from Google one of the recent mail mentioned as
projects directly requesting the “plus.me” scope are affected. This scope may have been listed in some emails, even if not directly
requested by your project. We apologize for any confusion caused.
I am using following JS code for login, may I know will it affect anyway due to Google plus api shutdown?
<script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};HandleGoogleApiLibrary()" onreadystatechange="if (this.readyState === 'complete') this.onload()"></script>
<script type="text/javascript">
//google login starts
function HandleGoogleApiLibrary() {
// Load "client" & "auth2" libraries
gapi.load('client:auth2', {
callback: function() {
// Initialize client library
// clientId & scope is provided => automatically initializes auth2 library
gapi.client.init({
apiKey: 'API KEY HERE',
clientId: 'XXXXXXXXXXXXXXXXX.apps.googleusercontent.com',
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'
}).then(
// On success
function(success) {
// After library is successfully loaded then enable the login button
//CODE AFTER SUCCESS
},
// On error
function(error) {
alert('Error : Failed to Load Library');
}
);
},
onerror: function() {
// Failed to load libraries
}
});
}
// Click on login button
$("#login-button").on('click', function() {
// API call for Google login
gapi.auth2.getAuthInstance().signIn().then(
// On success
function(success) {
// API call to get user information
gapi.client.request({ path: 'https://www.googleapis.com/plus/v1/people/me' }).then(
// On success
function(success) {
console.log(success);
var user_info = JSON.parse(success.body);
//VALIDATION
},
// On error
function(error) {
alert('Error : Failed to login');
}
);
},
// On error
function(error) {
$("#login-button").removeAttr('disabled');
alert('Error : Login Failed');
}
);
});
There is good news and bad news.
The good news is that you're not using any of the plus scopes.
The bad news is that you're using the plus API, which is also being shut down, and which was mentioned in a previous email that should have been sent to you.
Specifically, this chunk of code:
gapi.client.request({ path: 'https://www.googleapis.com/plus/v1/people/me' }).then(
calls the "plus.people.me" API.
Fortunately, you should be able to switch to a different API, such as the "userinfo" API, by changing endpoints to
https://www.googleapis.com/oauth2/v2/userinfo
You may also wish to look into the more modern People API, which works very similarly, and is slightly more complicated, but can provide other profile fields.

How can I share text on a Windows 10 App?

I am building a Windows 10 Web App by Project Westminster. I want to create a button to invoke the native share capability, sharing some text I have. I have the below codes. Clicking on my button would call the share() function.
function share() {
Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
}
function shareTextHandler(e) {
var request = e.request;
request.data.properties.title = "Share Text Example";
request.data.properties.description = "Demonstrates how to share.";
request.data.setText("Hello World!");
}
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
// This app is newly launched. Register the app as share source.
var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
dataTransferManager.addEventListener("datarequested", shareTextHandler);
} else {
// TODO: This app was reactivated from suspension.
// Restore the app state here.
}
args.setPromise(WinJS.UI.processAll());
}
};
But now when I click on the button, it will share the screen captured on my app, not the text I intended to share. How can I correct the behaviour? Thanks!

FB.ui not working

After logging into our facebook application - after allowing access if I call -
FB.ui({ method: 'permissions.request', perms: 'email', access_token: accesstoken }, function(granted) {
if (granted.perms) {
//Do things here
}
});
This shows up a dialog box that keeps on loading and loading.This used to work
one month before.
Facebook has migrated to OAuth 2.0:
https://developers.facebook.com/docs/reference/javascript/FB.login/
Try:
FB.login( function( response ) {
if (response.authResponse) {
// user granted permissions
}
}, { scope: "email" } );
FB.ui still works.I do not have to use FB.login.I have added this line earlier FB.UIServer.setLoadedNode = function(a, b) { FB.UIServer._loadedNodes[a.id] = b; }; to close the un necessary iframe window coming up in IE after login.That was the root cause .Commented the same .It works as it was earlier.Only thing I had to close the pop up was using jquery and css.