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

New Analytics Adapter: PubxAi #3863

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

New Analytics Adapter: PubxAi #3863

wants to merge 23 commits into from

Conversation

tej656
Copy link

@tej656 tej656 commented Aug 16, 2024

No description provided.

@bsardo bsardo changed the title PubxAi analytics adapter New Analytics Adapter: PubxAi Aug 16, 2024
@bsardo bsardo self-assigned this Sep 4, 2024
@bsardo
Copy link
Collaborator

bsardo commented Nov 4, 2024

Hi @tej656, when you have time, please merge with master and resolve conflicts.

Also, we recently released PBS 3.0, more specifically v3.1.0, which updates Prebid Server package import references throughout the project from v2 to v3.
For example:

import (
    "github.com/prebid/prebid-server/v3/adapters"
)

As a result, after merging with master, please ensure all Prebid Server package import references in the files you’ve changed are v3 such that the test suite passes so we can resume reviewing. Thanks!

przemkaczmarek
przemkaczmarek previously approved these changes Nov 5, 2024
@tej656
Copy link
Author

tej656 commented Nov 8, 2024

@bsardo i have updated the merge conflicts.

Copy link
Contributor

@SyntaxNode SyntaxNode left a comment

Choose a reason for hiding this comment

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

Taking an initial pass. This is a very large PR and there are a lot of complications we need to look out for regarding concurrent safety. Still need to take time to review concurrent constructs, but the use of sleep statements in tests is concerning.

@@ -43,6 +44,26 @@ func New(analytics *config.Analytics) analytics.Runner {
glog.Errorf("Could not initialize PubstackModule: %v", err)
}
}
glog.Info("pubxai.Enabled: ", analytics.Pubxai.Enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log line necessary? Do the other analytics adapters do this?

Copy link
Author

Choose a reason for hiding this comment

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

removed it

clock.New(),
)
if err == nil {
glog.Infof("PubxaiModule initialized")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: No need to use Infof for formatting for a static string.

return nil, fmt.Errorf("fail to parse the module args, arg=analytics.pubxai.configuration_refresh_delay: %v", err)
}

endpointUrl, err := url.Parse(endpoint + "/config?pubxId=" + pubxId)
Copy link
Contributor

Choose a reason for hiding this comment

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

You must sanitize the user provided pubxId string when including it as a query parameter.

@@ -0,0 +1,63 @@
// Code generated by MockGen. DO NOT EDIT.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the testify mock library? That's our standard in this project.

Copy link
Author

Choose a reason for hiding this comment

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

sure, updated all the mocks to use testify mock

close(stop)
// Ensure task stops correctly
time.Sleep(2 * time.Second)
assert.NotNil(t, configChan)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use sleep statements in tests. Instead, use channel messages or other definitive sync mechanisms. I'm not willing to add 4 seconds to this projects test runtime here.

Copy link
Author

Choose a reason for hiding this comment

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

updated the tests to remove sleeps

auctionBids, winningBids := processorService.ProcessLogData(ao)
assert.Nil(t, auctionBids)
assert.Nil(t, winningBids)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly reformat to Go table driven tests.

Copy link
Author

Choose a reason for hiding this comment

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

updated all the tests to Go table driven tests.

Timestamp int64 `json:"timestamp"`
}

type UtilsService interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do utils need to be a service?

Copy link
Author

Choose a reason for hiding this comment

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

this was for mainly for the Unit tests, but anyway, since not using gomock anymore, utils is not a service anymore

const (
DEVICE_DESKTOP = iota
DEVICE_MOBILE
DEVICE_TABLET
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Following Go naming standards, use MixedCaps here instead of SCREAMING_CAPS.

Copy link
Author

Choose a reason for hiding this comment

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

Updated

@przemkaczmarek przemkaczmarek self-assigned this Dec 19, 2024
Comment on lines 118 to 127
type FloorData struct {
FetchStatus string `json:"fetchStatus"`
FloorProvider string `json:"floorProvider"`
Location string `json:"location"`
ModelVersion string `json:"modelVersion"`
NoFloorSignaled bool `json:"noFloorSignaled"`
SkipRate int64 `json:"skipRate"`
Skipped bool `json:"skipped"`
SkippedReason string `json:"skippedReason"`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason to have duplicate struct ?
FloorDetail struct is having same fields

Copy link
Author

Choose a reason for hiding this comment

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

aah, my bad, this was not used, removed it

tej656 and others added 4 commits December 30, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants