-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Connector Facebook-Marketing: update insights streams with custom entries for fields, breakdowns and action_breakdowns #4864
Conversation
@vladimir-remar would this be supplanted by the solution in #2227 ? |
@sherifnada Yes, but, depending on the implementation, the Facebook-Marketing connector will need some additional changes as the request to the insights API has to explicitly include the limited number of fields. |
@sherifnada any thoughts or suggestions? |
@keu is possible to review this contribution? |
@marcosmarxm Hi again. |
@vladimir-remar Insights is already pretty custom streams. As I remember after my last refactor it should be easy to make it fully custom. The only reason why I didn't is that it breaks backward compatibility. You just need to move all hardcoded attributes to config and build instances of the {
"insights":
[
{
"name": "text",
"fields": [],
"breakdowns": [],
"action_breakdowns": [],
}
]
} |
@keu Ok, for each Insights stream we will have a different configuration and if some insights were not in the json object we would have to define default values for the streams that are not included in this object, right? |
I see two options to keep existing insights streams:
Plus come up with a good auto-naming strategy (breakdowns joined with |
@keu Hello, I did some changes in order to improve the new approach, can you take a look? |
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great job in general, just a few comments
@vladimir-remar awesome work! thanks so much for this contribution. Small change, could you solve the conflict in source.py? @keu can you final review this contribution? |
@marcosmarxm done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@vladimir-remar don't forget to run |
@keu done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladimir-remar thanks for the contribution! I certainly understand the value of having something like this that works well. Some points I'd like to make:
I'm wary of introducing a completely custom insights stream because the Facebook API is very volatile. Specifically: it is difficult to predict which inputs of fields/breakdowns/action_breakdowns are going to cause the insights sync to succeed or fail. For all of our current insights streams, we've done meticulous testing to make sure those requests succeed consistently. So the issue I'm worried about is a user might see this feature, try to use it, get a failure, and then assume the FB connector is unreliable and file support requests with Airbyte when really the issue is from the FB side. The error messages provided by the FB API tend to be pretty opaque too and unhelpful, e.g: Job Failed
without any extra information.
This is all to say that, I think all of this should be made very very clear in the connector's documentation (docs/integrations/sources/facebook-marketing.md
), that this is a "use with caution" or "experimental" feature. We should add a section about these custom insights streams in the docs describing all the above caveats.
Additionally, it would be great to have a way to tell the user ahead of time if their particular selection will work or not. For example, right now if they choose an incorrect field name, they will only know that problem at sync time not connector setup time.
WDYT?
insights_custom_streams = list() | ||
|
||
for insight in insights: | ||
args["name"] = insight.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this mutating the same config over and over, so in the end all the streams have the same config? can we copy the args instead? e.g:
arg_copy = copy.deepcopy(args)
arg_copy["fields"] = ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada the streams being created each time, so config never shared
@@ -126,3 +148,28 @@ def spec(self, *args, **kwargs) -> ConnectorSpecification: | |||
), | |||
), | |||
) | |||
|
|||
def _update_insights_streams(self, insights, args, streams) -> List[Type[Stream]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest the following approach for these custom streams:
- The "standard" streams offered by the connector are always available (if a user doesn't want them they can always just deselect them)
- If the user inputs any custom streams, they are named as
custom_<user-input-name>
and appended to the list of streams
This way it is very very obvious to the user what is happening. This is especially important as the connector's config is updated over time e.g: a user might call a stream ads_insights
today, then remove it next week, and now the data represented in that stream is mixed with the "standard" ads insight stream and the "custom" insight stream. Making the suggestion above to make such situations much less likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the change in the lastest commit
…tation and fix to resolve in spec schema
To @keu thank you for help me in the spec limitation, was very helpful.
|
return True | ||
|
||
|
||
def expand_local_ref(schema, resolver=None, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada thanks to @keu
With this, we can set properly the insights in the UI.
@sherifnada after the latest changes, the user will only be allowed to configure the fields provided by Facebook, but the combination of these will be left to the user's choice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladimir-remar thanks for adding the validations! just a couple of comments and I think we are good to go
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/source.py
Outdated
Show resolved
Hide resolved
@@ -26,6 +35,17 @@ | |||
) | |||
|
|||
|
|||
class InsightConfig(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladimir-remar did you validate that the json output by spec
works with the UI via the instructions here? Just checking because I don't remember if we support a list of objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada we do actually :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada thanks to @keu, I attached some images from UI
It will be filled like this
And it will look like this with two elements
and from destination side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @vladimir-remar !
@keu could you assign to someone on the team for publishing?
Hi @vladimir-remar, your changes was merged and published in PR #7158 |
This is awesome!! Thank you so much! |
What
In our integration with the Facebook-Marketing connector when we trying to synchronize the API data from insights all attempts were unsuccessful (see logs on Notes). After experiencing the same type of behavior in Stitch, the solution is to request less fields to Facebook API. For thar reason, it is proposed is to add custom dynamic schemas to reduce the number of fields that are sent in each request. This means, users will be able to choose the fields that are requested and obtained in the response. After seeing the positive results both in Stitch and in a custom Facebook-Marketing connector created by us, we propose the following alternative.
How
The solution is inspired by the connector of Google-Analytics-Singer that adds "custom_reports" that are configured in the config. With this idea we propose the following:
Notes
I'm adding some logs and some captures.
error.log
I acknowledge this first commit is missing the Documentation updates and the docker version bump.
Pre-merge Checklist
Expand the checklist which is relevant for this PR.
Connector checklist
airbyte_secret
in the connector's spec./gradlew :airbyte-integrations:connectors:<name>:integrationTest
./test connector=connectors/<name>
command as documented here is passing.README.md
docs/SUMMARY.md
if it's a new connectordocs/integrations/<source or destination>/<name>
.docs/integrations/...
. See changelog exampledocs/integrations/README.md
contains a reference to the new connector/publish
command described hereConnector Generator checklist
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changes