Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling the Facebook App Events SDK for a specific build #930

Closed
gbyesiltas opened this issue Mar 19, 2024 · 3 comments
Closed

Disabling the Facebook App Events SDK for a specific build #930

gbyesiltas opened this issue Mar 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@gbyesiltas
Copy link
Contributor

gbyesiltas commented Mar 19, 2024

Summary

We have set-up the facebook app events plugin as per the docs. For now we want to only enable it in our staging app and not in the actual production app, and not in the app instances we build for End-to-end testing. However, simply not adding the facebook app events plugin doesn't seem to work (at least for Android).

From what I understand, the FB SDK is automatically initialized for Android. I have tried adding the meta-data that is supposed to turn that off to AndroidManifest but that didn't help either.

There is a closed issue about this here though the specific examples there are related to Expo which doesn't apply to us and honestly the issue was closed without a real conclusion :D

Is there a way to do this?

Screenshot 2024-03-19 at 17 58 11
Screenshot 2024-03-19 at 11 49 07
Screenshot_1710845354

@gbyesiltas gbyesiltas added the enhancement New feature or request label Mar 19, 2024
@oscb
Copy link
Contributor

oscb commented Mar 19, 2024

Looks like this validation is happening in the FBSDK itself so it's not something we can control from our plugin.
Do you want to fully remove it from the build or just not send any event to FB?

If it's the first one it might be an option in the native FB SDK to control this behavior: https://developers.facebook.com/docs/app-events/overview

If it's fine with just disabling Segment from sending events to FB this one is easier, you can keep the plugin there and add a plugin that filters FB if your app is in debug mode:

class FilterFBPlugin extends Plugin {
  type = Plugin.before
  
  execute(event: SegmentEvent) {
    if (!Config.FACEBOOK_APP_ID || !Config.FACEBOOK_CLIENT_TOKEN) {
       event.integrations['Facebook App Events'] = false;
    }
    return event;
  }
}

(If FB is automatically sending logs from your app outside of Segment this won't prevent those)

@gbyesiltas
Copy link
Contributor Author

gbyesiltas commented Mar 19, 2024

@oscb Hey thanks for the response :)

I have tried adding the meta properties from the FB documentation that I thought could be related to this to disable the auto-initialization, thinking that would fix the issue. But that didn't help unfortunately.

Otherwise, with the second approach, we will need to provide some APP_IDs and CLIENT_TOKENs even for our builds where we don't necessarily want logging and I was concerned about possible side-effects of that (maybe we provide just some mock ones? but again, I assume that may have other side-effects like errors trying to connect to the Facebook SDK).

I feel like at this point I've tried everything that I could think of to disable the initialisation from happening so I may just go with filtering out the events. Thank you for the suggestion!

@gbyesiltas
Copy link
Contributor Author

Didn't quite end-up disabling the SDK at all, but I was able to resolve my issue by passing some mock APP_IDs etc. and filtering out the events as suggested here so closing the issue to not crowd-up the issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants