Events not being logged in with AppEventsLogger - ios

I'm trying to use react-native-fbsdk for Facebook analytics. When I go to the events debugging page to check if it works, I can see a couple events like App Activation and App Installs and other stuff like Completed App Session. Of these, I'm manually logging App Activation whereas the rest is I think the sdk provides by default.
The problem is, it's not logging many other custom events that I'm trying to log.
How do I debug this? Thanks in advance.

When you send the custom events, are you setting the page_scoped_user_id correctly? Here is a raw JSON cutom event, per docs.
{
url : "https://graph.facebook.com/<app_id>/activities",
form: {
event: 'CUSTOM_APP_EVENTS',
custom_events: JSON.stringify([{
_eventName: "fb_mobile_purchase",
_valueToSum: 55.22,
_fb_currency: 'USD'
}]),
advertiser_tracking_enabled: 0,
application_tracking_enabled: 0,
extinfo: JSON.stringify(['mb1']),
page_id: <page_id>,
page_scoped_user_id: recipientId
}
}
The last value, recipientId, is misleading. If you want to log something the user sent, you would want to log the senderId property of that incoming message.

Related

For the Twilio Action - SendMessage, Where can i find the `conversationSid` ? This is to respond to an existing webchat

I have a basic twilio-flex 2.0 setup in my local. I have a plugin which basically renders a button. I am responding to a "customer" message which pops up in my list. I have a the button's "onClick" implemented to send a pretyped message , I am unable to find the conversationSid, that I need to plug into this below.
Actions.invokeAction('SendMessage',
{
body: "TBD",
conversationSid: "Where can i find this?"
})})
For the sake of testing, I was able to find the conversationSid in the browser console and plugged it in there and message is sent.
The documentation shows that the conversationSid is optional, but without it, nothing is sent.
Any help or direction would be much appreciated ?
Thanks to #csevero , i was able to figure out the way
conversationSid: this.manager.store.getState().flex.chat.messageList.activeChatChannel

Why does apostrophe keep making POST calls to check if user logged in?

There are a bunch of POST calls from the website to the server and I don't know how to turn them off.
2019-10-24T21:24:49.606Z - info: admin already logged in. Passing through...
2019-10-24T21:25:09.767Z - info: /modules/apostrophe-notifications/poll-notifications
2019-10-24T21:25:09.768Z - info: admin already logged in. Passing through...
2019-10-24T21:25:29.911Z - info: /modules/apostrophe-notifications/poll-notifications
2019-10-24T21:25:29.912Z - info: admin already logged in. Passing through...
2019-10-24T21:25:50.023Z - info: /modules/apostrophe-notifications/poll-notifications
2019-10-24T21:25:50.024Z - info: admin already logged in. Passing through...
That just keeps going on and on...
In my app.js file, I've set the longPollingTimeout options to 0, but it doesn't stop it, and when I set it to 20000 ms it sends it every 20 seconds.
var apos = Mongo.getMongoPw().then(function(mongoPw){
return require('apostrophe')({
...
modules: {
...
'apostrophe-notifications': {
longPollingTimeout: 20000
},
...
}
});
It seems very pointless and spammy in my logs which we send to splunk.
How can I turn this off if it's unnecessary?
The API you're referring to is polling for notifications, which can be sent at any time by server-side or browser-side code. For instance, if you try this in the browser console:
apos.notify('Oh no!', { type: 'error' });
You'll get a notification, which persists until dismissed (it's stored server-side).
Where this gets more useful is when they are sent on the server side. For instance, your server-side javascript may also say:
if (req.user) {
// server side you must include req
apos.notify(req, 'Oh no!', { type: 'error' });
}
Now a notification will reach the currently logged-in user, sooner or later, and you don't have to think about how to deliver it; it just gets taken care of for you by poll-notifications. This is very useful in long running tasks. Without this feature enabled Apostrophe would be unable to deliver many necessary messages to the user.
However, you're wondering why you get this annoying message in your logs:
admin already logged in. Passing through...
I have checked both the apostrophe core module and the apostrophe workflow module. Neither contains any such message. I have also used github search to check the entire apostrophecms organization for this message, which does not appear. Same for a github-wide search. I left out the word "admin" and, in the apostrophecms org, also tried a search for "passing through" alone without turning up any code.
So what this indicates is that your custom code, or another npm module you have added to your project, contains custom middleware that is logging this message on every request that comes in. I would recommend quieting that middleware down as it's not necessary to report this on every notification poll.

"Internal" Error When Submitting Form With Firebase onCall Function on IOS Safari

I am trying to submit a form but I get an "internal" error after submit on IOS Safari. Happened on two separate devices. I'm using Firebase functions onCall function. Client code:
var contactForm =
window.firebase.functions().httpsCallable('contactForm');
let result = await contactForm({ accountUID, foldersFilter,
firstName, lastName, email, cellNumber, dobDay, dobMonth })
And server code:
exports.contactForm = functions.https.onCall(( data, context ) => {
return contactForm.contactForm( data, context )
});
This function is called via form. The form works great on chrome, safari desktop, but for some reason it gets an internal errror sometimes when testing on IOS device. At first I thought it only happened when I was using autofill, but I've tested more and I get the same error when not using autofill too.
The confusing thing is my function code is actually never being called (I don't see any firebase function logs). Here is my console in safari:
The network connection was lost.
Fetch API cannot load https://us-central1-projectId.cloudfunctions.net/contactForm due to access control checks
Failed to load resource: The network connection was lost.
internal
Why won't this form submit on ios safari?
I fixed the issue. Turns out it has something to do with Google Cloud Functions being IPv4, and Safari requiring IPv6. I suspect this will become a bigger issue moving forward. I'm having to move all onCall Firebase functions to https triggers. In order to make https triggers work, you have to use a custom domain in Firebase hosting and rewrite to your function endpoint.
{
"hosting": {
...
"rewrites": [
{
"source": "/api/contactForm",
"function": "contactForm"
}
}
and so now instead of calling https://us-central1-projectId.cloudfunctions.net/contactForm to trigger my api. I call https://customdomain.com/api/contactForm

Are there additional requirements to get the sender info on a Facebook messenger optin event?

I'm listening to the optin event fired by Facebook Messenger. The docs say I should receive an object with { 'sender': { 'id': 'USER_ID' } } in it. However, the data I get is missing this information. I do receive the optin event, and I get the rest of the data, but I'm missing the sender.
The response I get looks like this:
"messaging"=>[{
"recipient"=>{"id"=>"MY_PAGE_ID"},
"timestamp"=>1503480281655,
"optin"=>{"ref"=>"PASS_THROUGH_PARAM", "user_ref"=>"5019"}
}]
I'm using the facebook-messenger gem to handle the webhook events. However I decided to intercept the request directly to check the data I was getting, which is what I used to generate the above response. The object the gem gives me looks like this:
#<Facebook::Messenger::Incoming::Optin:0x007fe2829a4928
#messaging={ "recipient"=>{"id"=>"MY_PAGE_ID"},
"timestamp"=>1503480091027,
"optin"=>{"ref"=>"PASS_THROUGH_PARAM", "user_ref"=>"58326"}
}>
Here's where I listen to the optin event.
Finally the click handler to fire the optin event is exactly per Facebook's documentation:
FB.AppEvents.logEvent('MessengerCheckboxUserConfirmation', null, {
'app_id':'<%= Figaro.env.facebook_app_id %>',
'page_id':'<%= Figaro.env.facebook_page_id %>',
'ref':'PASS_THROUGH_PARAM',
'user_ref':'<%= #uniq_user_ref %>'
});
Here's the rest of that file in case it's valuable.
Is there anything else I need to set up or pass through to tell Facebook I want this information?
Is it possible you're using the Checkbox plugin instead of the Send to Messenger plugin? On the Checkbox documentation, they mention the following (emphasis mine):
Callback
After the opt-in event, we will post a webhook event to your server if
the checkbox state was checked. This callback has the same format as
the opt-in callback, but instead of a sender field, it has an optin
object with a user_ref field.

How to force Google OAuth popup in Firebase when user already authenticated previously?

Whenever a user has previously authenticated with Google, it automatically defaults to logging them in with THAT account on subsequent attempts. I want to eliminate this and force the popup/redirect so that a user with multiple google accounts can choose which one to use. How?
Background:
The automatic logging in feature is proving problematic for me as I have a whitelisted set of e-mails for users allowed to use my app. If a Google user chooses the wrong account when first logging in, they can't go back and choose the one associated to their whitelisted e-mail.
Just as #nvnagr said, you can do this with the following code:
var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
'prompt': 'select_account'
});
But I think you need to update the firebase version to 3.6.0 something.
Google supports a parameter in authentication url to deal with this issue.
If you add prompt=select_account in your request to Google authentication, it'll force the user to do an account selection. See the details and other values of prompt.
https://developers.google.com/identity/protocols/OpenIDConnect#authenticationuriparameters
I'm not sure if there is an easy way to add this parameter through firebase api.
When you're calling the oAuth function, you can pass a third options parameter to make the authentication last for the session only. This should solve your problem. Docs
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithOAuthPopup("google", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
}, {
remember: 'sessionOnly'
});

Resources