/tap-impact

Primary LanguagePythonGNU Affero General Public License v3.0AGPL-3.0

tap-impact

This is a Singer tap that produces JSON-formatted data following the Singer spec.

This tap:

Streams

actions

  • Endpoint: https://api.impact.com/{api_catalog}/{account_sid}/Actions
  • Primary key fields: id
  • Foreign key fields: ad_id, caller_id, campaign_id, customer_id, media_partner_id, shared_id, order_id
  • Replication strategy: INCREMENTAL (Query filtered)
    • Filter: CampaignId (parent)
    • Filter: StartDate (event_date)
    • Bookmark: event_date
  • Transformations: camelCase to snake_case, oid to order_id
  • Parent: campaigns

action_inquiries

  • Endpoint: https://api.impact.com/{api_catalog}/{account_sid}/ActionInquiries
  • Primary key fields: id
  • Foreign key fields: action_id, campaign_id, media_partner_id, order_id
  • Replication strategy: INCREMENTAL (Query filtered)
    • Filter: CampaignId (parent)
    • Filter: StartDate (creation_date)
    • Bookmark: creation_date
  • Transformations: camelCase to snake_case, oid to order_id
  • Parent: campaigns

action_updates

  • Endpoint: https://api.impact.com/{api_catalog}/{account_sid}/ActionUpdates
  • Primary key fields: id
  • Foreign key fields: action_id, ad_id, caller_id, campaign_id, customer_id, media_partner_id, shared_id
  • Replication strategy: INCREMENTAL (Query filtered)
    • Filter: CampaignId (parent)
    • Filter: StartDate (update_date)
    • Bookmark: update_date
  • Transformations: camelCase to snake_case
  • Parent: campaigns

ads

api_submissions

campaigns

catalogs

catalog_items

clicks

contacts

conversion_paths

deals

exception_lists

exception_list_items

ftp_file_submissions

invoices w/ line_items

  • Endpoint: https://api.impact.com/{api_catalog}/{account_sid}/Invoices
  • Primary key fields: id
  • Foreign key fields: campaign_id, media_id
  • Replication strategy: INCREMENTAL (Query filtered)
    • Filter: StartDate (created_date)
    • Bookmark: created_date (date-time)
  • Transformations: camelCase to snake_case

media_partners

media_partner_groups

notes

phone_numbers

promo_codes

reports

report_metadata

tracking_value_requests

unique_urls

Quick Start

  1. Install

    Clone this repository, and then install using setup.py. We recommend using a virtualenv:

    > virtualenv -p python3 venv
    > source venv/bin/activate
    > python setup.py install
    OR
    > cd .../tap-impact
    > pip install .
  2. Dependent libraries The following dependent libraries were installed.

    > pip install singer-python
    > pip install singer-tools
    > pip install target-stitch
    > pip install target-json
    
  3. Create your tap's config.json file. The api_catalog is one of the following: Advertisers, Agencies, Partners. The account_sid and auth_token may be found in your user settings when API access is enabled. Contact Impact Support to get your model_id (for Conversion Paths endpoint).

    {
        "account_sid": "YOUR_API_ACCOUNT_SID",
        "auth_token": "YOUR_API_AUTH_TOKEN",
        "api_catalog": "YOUR_API_CATALOG",
        "model_id": "YOUR_MODEL_ID",
        "start_date": "2019-01-01T00:00:00Z",
        "user_agent": "tap-impact <api_user_email@your_company.com>"
    }

    Optionally, also create a state.json file. currently_syncing is an optional attribute used for identifying the last object to be synced in case the job is interrupted mid-stream. The next run would begin where the last job left off.

    {
        "currently_syncing": "ftp_file_submissions",
        "bookmarks": {
            "actions": "2019-09-21T01:05:17.000000Z",
            "action_inquiries": "2019-09-14T14:34:03.000000Z",
            "action_updates": "2019-09-21T02:27:16.000000Z",
            "clicks": "2019-09-21T00:54:26.000000Z",
            "api_submissions": "2019-09-21T00:47:35.000000Z",
            "ftp_submissions": "2019-09-20T00:42:39.000000Z",
            "invoices": "2019-09-03T10:02:01.000000Z"
        }
    }
  4. Run the Tap in Discovery Mode This creates a catalog.json for selecting objects/fields to integrate:

    tap-impact --config config.json --discover > catalog.json

    See the Singer docs on discovery mode here.

  5. Run the Tap in Sync Mode (with catalog) and write out to state file

    For Sync mode:

    > tap-impact --config tap_config.json --catalog catalog.json > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    To load to json files to verify outputs:

    > tap-impact --config tap_config.json --catalog catalog.json | target-json > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    To pseudo-load to Stitch Import API with dry run:

    > tap-impact --config tap_config.json --catalog catalog.json | target-stitch --config target_config.json --dry-run > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
  6. Test the Tap

    While developing the impact tap, the following utilities were run in accordance with Singer.io best practices: Pylint to improve code quality:

    > pylint tap_impact -d missing-docstring -d logging-format-interpolation -d too-many-locals -d too-many-arguments

    Pylint test resulted in the following score:

    Your code has been rated at 9.79/10

    To check the tap and verify working:

    > tap-impact --config tap_config.json --catalog catalog.json | singer-check-tap > state.json
    > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json

    Check tap resulted in the following:

    Checking stdin for valid Singer-formatted data
    The output is valid.
    It contained 80959 messages for 24 streams.
    
        135 schema messages
    80766 record messages
        58 state messages
    
    Details by stream:
    +-------------------------+---------+---------+
    | stream                  | records | schemas |
    +-------------------------+---------+---------+
    | tracking_value_requests | 0       | 1       |
    | ftp_file_submissions    | 0       | 1       |
    | api_submissions         | 345     | 1       |
    | unique_urls             | 0       | 1       |
    | invoices                | 34      | 1       |
    | ads                     | 54      | 1       |
    | phone_numbers           | 603     | 1       |
    | deals                   | 1       | 1       |
    | campaigns               | 1       | 1       |
    | notes                   | 0       | 1       |
    | media_partner_groups    | 10      | 1       |
    | action_updates          | 1389    | 1       |
    | actions                 | 1075    | 1       |
    | action_inquiries        | 1       | 1       |
    | clicks                  | 76213   | 1       |
    | contacts                | 383     | 1       |
    | exception_lists         | 0       | 1       |
    | promo_codes             | 20      | 1       |
    | media_partners          | 230     | 1       |
    | catalogs                | 1       | 1       |
    | catalog_items           | 181     | 1       |
    | reports                 | 112     | 1       |
    | report_metadata         | 112     | 1       |
    | company_information     | 1       | 1       |
    +-------------------------+---------+---------+
    

Copyright © 2019 Stitch