Skip to content

feat(brt): onboarding bing ads audience bulk upload poll function - #3429

Merged
ItsSudip merged 20 commits into
feat.bing-adsfrom
feat.bing-ads-poll
Jun 8, 2023
Merged

ItsSudip merged 20 commits into
feat.bing-adsfrom
feat.bing-ads-poll

Conversation

@shrouti1507

@shrouti1507 shrouti1507 commented May 31, 2023 •

Copy link
Copy Markdown
Contributor

Description

  • This pull request consists of the poll operation of bingAds audience bulk upload.

Notion Ticket

Notion Link

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Poll(importingJob *jobsdb.JobT, payload []byte, timeout time.Duration) ([]byte, int)
FetchFailedEvents(*backendconfig.DestinationT, *utils.DestinationWithSources, []*jobsdb.JobT, *jobsdb.JobT, common.AsyncStatusResponse, time.Duration) ([]byte, int)
Poll(pollStruct common.AsyncPoll) ([]byte, int)
FetchFailedEvents(*utils.DestinationWithSources, []*jobsdb.JobT, *jobsdb.JobT, common.AsyncStatusResponse) ([]byte, int)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function signature also needs to be simplified

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this

"github.com/rudderlabs/rudder-server/utils/misc"
)

const pollUrl = "https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is service url right? not specific to poll right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

failedJobIds := []int64{}
successJobIDs := []int64{}

filePath := createZipFile(asyncDestStruct.FileName, &failedJobIds, &successJobIDs, destConfig.AudienceId)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&failedJobIds, &successJobIDs required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are handling the following scenario. While transforming txt to CSV file if we need to exclude some data due to size mismatch we add those jobs as failed jobs so that they will be retried.

statusCode = 400
}

respBytes, err := stdjson.Marshal(resp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why marshalling? it should return common struct not the bytes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because marketo_bulk_upload is using

func HTTPCallWithRetryWithTimeout(url string, payload []byte, timeout time.Duration) ([]byte, int) {
, which returns bytes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yet to do this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

AccountId: destConfig.CustomerAccountId,
CustomerId: destConfig.CustomerId,
HTTPClient: http.DefaultClient,
AccessTokenGenerator: func() (string, string, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define this function somewhere else as we need to write tests for this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pollUrl := gjson.GetBytes(parameters, "pollURL").String()
bodyBytes, statusCode := misc.HTTPCallWithRetryWithTimeout(transformUrl+pollUrl, payload, timeout)
pollUrl := "/pollStatus"
bodyBytes, statusCode := misc.HTTPCallWithRetryWithTimeout(transformUrl+pollUrl, payload, b.timeout)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should unmarshall here and return struct instead of bytes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

payload := common.GenerateFailedPayload(destStruct.Destination.Config, importingList, importId, destType, csvHeaders)
failedBodyBytes, statusCode := misc.HTTPCallWithRetryWithTimeout(transformUrl+failedJobUrl, payload, common.HTTPTimeout)
payload := common.GenerateFailedPayload(destStruct.Destination.Config, importingList, importId, b.destName, csvHeaders)
//payload eg: "{\"config\":{\"clientId\":\"01a70f1f-ff37-46fc-bdff-42e92a3f2bb3\",\"clientSecret\":\"rziQBHtZ34Vl1CE3x3OiA3n8Wr45lwar\",\"columnFieldsMapping\":[{\"from\":\"anonymousId\",\"to\":\"anonymousId\"},{\"from\":\"address\",\"to\":\"address\"},{\"from\":\"email\",\"to\":\"email\"}],\"deDuplicationField\":\"\",\"munchkinId\":\"585-AXP-425\",\"oneTrustCookieCategories\":[],\"uploadInterval\":\"10\"},\"input\":[{\"message\":{\"address\":23,\"anonymousId\":\"Test Kinesis\",\"email\":\"[email protected]\"},\"metadata\":{\"job_id\":5}}],\"destType\":\"marketo_bulk_upload\",\"importId\":\"3095\""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put is indented format for better readability, same in all other places and make sure it doesn't have any sensitive information

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep these? I added this for ease of understanding

@shrouti1507 shrouti1507 changed the title Feat.bing ads poll feat(batch router): onboarding bing ads audience bulk upload poll function Jun 2, 2023
@shrouti1507 shrouti1507 changed the title feat(batch router): onboarding bing ads audience bulk upload poll function feat(batch-router): onboarding bing ads audience bulk upload poll function Jun 2, 2023
@shrouti1507 shrouti1507 changed the title feat(batch-router): onboarding bing ads audience bulk upload poll function feat(brt): onboarding bing ads audience bulk upload poll function Jun 7, 2023
@ItsSudip
ItsSudip marked this pull request as ready for review June 8, 2023 06:17
@ItsSudip
ItsSudip merged commit 3bcbd34 into feat.bing-ads Jun 8, 2023
shrouti1507 added a commit that referenced this pull request Aug 9, 2023
* feat.bing ads first commit

* feat : interface flow for bingAds primary flow

* feat: adding marketo via interface

* fix: deleting type.go

* fix: cleaning up the code

* fix: adding with decided interface

* fix: addressing primary review comments

* fix: addressing code reviews

* fix: poll function update

* initial commit with bingAds

* implement fatchFailedEvents function placeholder

* feat(brt): onboarding bing ads audience bulk upload poll function (#3429)

* fix: adding temporary commits

* feat: initial commit for poll function

* fix: removing commented out code

* fix: small update in poll function

* feat: fetch failed results for bingAds

* fix: small edit in function definition

* fix: shortening function parameters fot fetchFailedEvents

* update message structure of bingads_audience (#3444)

* fix: adding success key logic and addressing review comments

* fix: making poll url an optional field

* fix: fixing in the status code data type

* fix: fixing rudder-auth service connection and editing test cases(#3455)

* update message structure of bingads_audience

* add implementation of tokenSource interface

* update existing testcases

* fix: fixing marketo bulk upload struct

* fix: small comments added

* fix: removing the poll status file after the response is written

* fix: adding function comments

* fix: remove the zip file after data upload

---------

Co-authored-by: Sudip Paul <[email protected]>

* Apply suggestions from code review

Co-authored-by: Leonidas Vrachnis <[email protected]>

* Update router/batchrouter/asyncdestinationmanager/bing-ads/bingads.go

Co-authored-by: Leonidas Vrachnis <[email protected]>

* Update router/batchrouter/asyncdestinationmanager/bing-ads/bingads.go

Co-authored-by: Leonidas Vrachnis <[email protected]>

* Update router/batchrouter/asyncdestinationmanager/bing-ads/bingads.go

Co-authored-by: Leonidas Vrachnis <[email protected]>

* Update router/batchrouter/asyncdestinationmanager/bing-ads/bingads.go

Co-authored-by: Leonidas Vrachnis <[email protected]>

* fix: review comment addressed

* remove magic number and use constant

* Apply suggestions from code review

Co-authored-by: Leonidas Vrachnis <[email protected]>

* chore: refactors, and test cases added from chore.bingads

* fix: adding temporary commits

* feat: initial commit for poll function

* fix: removing commented out code

* fix: small update in poll function

* feat: fetch failed results for bingAds

* fix: small edit in function definition

* fix: shortening function parameters fot fetchFailedEvents

* update message structure of bingads_audience

* update message structure of bingads_audience (#3444)

* fix: adding success key logic and addressing review comments

* fix: making poll url an optional field

* fix: fixing in the status code data type

* add implementation of tokenSource interface

* update existing testcases

* fix: fixing rudder-auth service connection and editing test cases(#3455)

* update message structure of bingads_audience

* add implementation of tokenSource interface

* update existing testcases

* fix: fixing marketo bulk upload struct

* fix: small comments added

* fix: removing the poll status file after the response is written

* fix: adding function comments

* fix: remove the zip file after data upload

* add initial testcases

* feat(brt): adding unit test cases for bingads audience bulk upload (#3462)

* update message structure of bingads_audience

* add implementation of tokenSource interface

* update existing testcases

* add initial testcases

* add testcases

* refactor code and add testcases

* feat: adding primary unit test case for poll function (#3471)

* feat: adding primary unit test case for poll function

* feat: fetch failed events and poll functions test cases added

* fix: cleaning up the code

---------

Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: shrouti1507 <[email protected]>

* refer bingads sdk from other repo

* fix: retrieveImportantKey is deleted for bingads bulk upload and used better names for variables and structures(#3483)

* fix: retrieveImportantKey is deleted

* fix: changing variable names to more readble ones

* fix: changing variable names to more readble ones

* fix: adding interface for util function and mocking test cases

* fix go.mod

* fix: bingads unit test file location change and minor refactors

* update failedreason for bingads

* fix: removing unnecessary files

* fix: removed mock for util functions and parsed the code (#3512)

* feat: initial try for bingads test case update

* feat: test case update for poll and getUploadStatus

* feat: test case update for upload

* feat: test cas for new manager

* feat: removing unnecessary files

* fix: removing absolute paths

* fix: adding logger inits

* fix: adding test cases for upload  size control

* fix: uncomment the required code for uploadInterval

* fix: making temp files in test cases through env var

* fix: upadating the batch router test case by sending destination object as full

* fix: fixing go.mod file, removing panic and adding test case

* chore: bing ads tests

* fix: adding stats for bingads upload and upload status

* fix: omit panics for marketo

* fix: stats type

* chore: altering upload freq for QA

* fix: fix potential bug and add clientID logic

* fix: lint error fix

* fix: lint error fix

* fix: tidying up go.mod

* fix: tidying up go.mod

* feat: bingads audience adding support for multiple action polling and response parsing (#3565)

* feat: add support of remove and update in upload function of bingAds

* feat: adding support for multiple action polling and response parsing

* fix: pulling upload function updates as well as some bug fixes

* address comments

* update test cases

* refactor: refactoring bingads poll

* fix: fixing test cases error

* fix: adding comments

---------

Co-authored-by: ItsSudip <[email protected]>

* refactor: run go mod tidy

* refactor: bingads uploader into multiple files

* feat: bingads destination config refresh (#3577)

* feat: add support of destination config refresh

* refactor: bingads implementation (#3573)

* refactor: bingads implementation

* fix: primary edits

* fix: removed ResultFileUrl field from structures

* fix: addressing code commnets

* fix: editing cumulative poll response

* fix: comment address part 1

* fix: comment address part 2

* refactor: fix issues

* fix: util changes

* fix: util changes

* refactor: createActionFile

* refactor clientID and Metadata

* refactor clientID and Metadata

* refactor names

* fix: bug solve

* fix action type

* fix: merged struct fields

* fix test cases

* fix: test cases part 1

* change TestBingAdsGetUploadStats

* fix: test cases part 2

* fix: remove unnecessary file

* fix: small fix

* address comments

* fix errors found while testing

* fix: remove commented code

---------

Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: ItsSudip <[email protected]>

* fix: addressing some lint issues

* fix: action file processing for event count zero

* fix: status count via loop

* fix: adding debug log

* fix: linting issues

* Fix: TestRouterManager

* fix: addressing comments regarding bingads

* fix: addressing comments regarding marketo

* add log on error

* add statuscode in log

* fix: Adding stat for non initializing destination

* fix initializtion of logger

* refactor: AsyncDestinationStruct

* fix: small fix in refresh dest

* refactor: initAsyncDestinationStruct

* refactor: initAsyncDestinationStruct

* refactor: handle_lifecycle setup

* fix: edit for testing

* Apply suggestions from code review

Co-authored-by: Rohith BCS <[email protected]>

* refactor: batch router handle async and review comments address (#3623)

* refactor: batch router handle async

* fix: pr comments

* fix: pr comments

* fix: pr comments

* fix: errors and address comments

* fix: remove unncessary lines

* fix: making upload time out 2 mins for testing scenarios

* fix: editing the stat type

* fix: editing invalid manager error message

---------

Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: shrouti1507 <[email protected]>

* fix: putting upload timeout to 30 mins

* Update router/batchrouter/handle_async.go

Co-authored-by: Rohith BCS <[email protected]>

* Update router/batchrouter/handle_async.go

Co-authored-by: Rohith BCS <[email protected]>

* Update router/batchrouter/handle_async.go

Co-authored-by: Rohith BCS <[email protected]>

* Update router/batchrouter/handle_async.go

Co-authored-by: Rohith BCS <[email protected]>

* fix: review comments addressed

* chore: comments addressed

* chore: comments addressed

* chore: comments addressed

* Apply suggestions from code review part 1

Co-authored-by: Leonidas Vrachnis <[email protected]>

* fix: bingAds related new review comments

* fix: apply suggestions for marketo bulk upload from code review

Co-authored-by: Rohith BCS <[email protected]>

* Apply suggestions for marketo from code review part 2

Co-authored-by: Rohith BCS <[email protected]>

* fix: editing some import problem

* fix: lint error

* fix: pollAsyncStatus to handle error cases

* rename test files dir

* fix: move function to type.go

* Apply suggestions from code review

Co-authored-by: Rohith BCS <[email protected]>

* Apply name suggestions from code review

Co-authored-by: Rohith BCS <[email protected]>

* Apply suggestions from code review part 3

Co-authored-by: Rohith BCS <[email protected]>

* Apply name suggestions from code review part 3

Co-authored-by: Rohith BCS <[email protected]>
Co-authored-by: Leonidas Vrachnis <[email protected]>

* fix: code error edits

* fix: review comment for marshal unmarshal addressed

* fix: actionFile template making review

* fix: code error solve

* remove empty string check

* fix: bingAds SDK version change

* refactor: handle async

* chore: fix lint issues

* fix: marketo bulk upload poll function (#3684)

* Update router/batchrouter/asyncdestinationmanager/bing-ads/bulk_uploader.go

Co-authored-by: Dilip Kola <[email protected]>

* fix: review comments addressed

* fix: remove unnecessary code

* fix: batch router attemptnos (#3696)

* fix: initial commit

* chore: clean up

* chore: clean up

* chore: clean up

* chore: clean up

---------

Co-authored-by: shrouti1507 <[email protected]>
Co-authored-by: Chandra shekar Varkala <[email protected]>

* update buffer size of scanner

* update buffer size of scanner to 50mb

* fix: batch router attemptnos, reports, rsources stats (#3698)

* chore: lint fixes

* chore: live events

* chore: max file size

---------

Co-authored-by: Chandra shekar Varkala <[email protected]>
Co-authored-by: ItsSudip <[email protected]>
Co-authored-by: Sudip Paul <[email protected]>
Co-authored-by: Leonidas Vrachnis <[email protected]>
Co-authored-by: Dilip Kola <[email protected]>
Co-authored-by: Dilip Kola <[email protected]>
Co-authored-by: Rohith BCS <[email protected]>
Co-authored-by: chandumlg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants