Skip to content

Commit

Permalink
🎉 Sendgrind add single send stats (#5910)
Browse files Browse the repository at this point in the history
* Sendgrind source: add single send stream
  • Loading branch information
avida authored Sep 9, 2021
1 parent 6041f3d commit 2ecc7a6
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-sendgrid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.6
LABEL io.airbyte.version=0.2.7
LABEL io.airbyte.name=airbyte/source-sendgrid
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ tests:
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "sample_files/no_spam_reports_configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.txt"
extra_fields: no
exact_order: no
extra_records: yes
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "sample_files/no_spam_reports_configured_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "single_sends",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "templates",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "single_sends",
"json_schema": {},
"supported_sync_modes": ["full_refresh"]
},
"sync_mode": "full_refresh",
"destination_sync_mode": "overwrite"
},
{
"stream": {
"name": "templates",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"ab_phase": {
"type": "string"
},
"ab_variation": {
"type": "string"
},
"aggregation": {
"type": "string"
},
"stats": {
"type": "object",
"properties": {
"bounce_drops": {
"type": "integer"
},
"bounces": {
"type": "integer"
},
"clicks": {
"type": "integer"
},
"unique_clicks": {
"type": "integer"
},
"delivered": {
"type": "integer"
},
"invalid_emails": {
"type": "integer"
},
"opens": {
"type": "integer"
},
"unique_opens": {
"type": "integer"
},
"requests": {
"type": "integer"
},
"spam_report_drops": {
"type": "integer"
},
"spam_reports": {
"type": "integer"
},
"unsubscribes": {
"type": "integer"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Lists,
Scopes,
Segments,
SingleSends,
SpamReports,
StatsAutomations,
SuppressionGroupMembers,
Expand Down Expand Up @@ -66,6 +67,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Contacts(authenticator=authenticator),
StatsAutomations(authenticator=authenticator),
Segments(authenticator=authenticator),
SingleSends(authenticator=authenticator),
Templates(authenticator=authenticator),
GlobalSuppressions(authenticator=authenticator, start_time=config["start_time"]),
SuppressionGroups(authenticator=authenticator),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ def path(self, **kwargs) -> str:
return "marketing/segments"


class SingleSends(SendgridStreamMetadataPagination):
"""
https://docs.sendgrid.com/api-reference/marketing-campaign-stats/get-all-single-sends-stats
"""

data_field = "results"

@staticmethod
def initial_path() -> str:
return "marketing/stats/singlesends"


class Templates(SendgridStreamMetadataPagination):
data_field = "result"

Expand All @@ -217,6 +229,8 @@ def path(self, **kwargs) -> str:


class SuppressionGroupMembers(SendgridStreamOffsetPagination):
primary_key = "group_id"

def path(self, **kwargs) -> str:
return "asm/suppressions"

Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/sendgrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ We recommend creating a key specifically for Airbyte access. This will allow you

| Version | Date | Pull Request | Subject |
| :------ | :-------- | :----- | :------ |
| 0.2.7 | 2021-09-08 | [5910](https://github.com/airbytehq/airbyte/pull/5910) | Add Single Sends Stats stream |
| 0.2.6 | 2021-07-19 | [4839](https://github.com/airbytehq/airbyte/pull/4839) | Gracefully handle malformed responses from the API |

0 comments on commit 2ecc7a6

Please sign in to comment.