Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/pubmatic/openwrap/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ type Config struct {
GeoDB GeoDB
BidCache BidCache
ResponseOverride ResponseOverride
Template Template
}

type Template struct {
GoogleSDK TemplateData
AppLovingMax TemplateData
LevelPlay TemplateData
}

type TemplateData struct {
Enable bool
Data string
DeserializedData map[string]any
}

type ResponseOverride struct {
Expand Down
4 changes: 2 additions & 2 deletions modules/pubmatic/openwrap/entrypointhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func (m OpenWrap) handleEntrypointHook(

if endpoint == models.EndpointGoogleSDK {
rCtx.MetricsEngine = m.metricEngine
// Update fields from signal
payload.Body = googlesdk.ModifyRequestWithGoogleSDKParams(payload.Body, rCtx, m.features)
gsdk := googlesdk.NewGoogleSDK(m.metricEngine, m.cfg, m.features)
payload.Body = gsdk.ModifyRequestWithGoogleSDKParams(payload.Body)
result.ChangeSet.AddMutation(func(ep hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
ep.Body = payload.Body
return ep, nil
Expand Down
28 changes: 28 additions & 0 deletions modules/pubmatic/openwrap/openwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func initOpenWrap(rawCfg json.RawMessage, moduleDeps moduledeps.ModuleDeps) (Ope
featureLoader := feature.NewFeatureLoader(mysqlDriver, cfg.Database)
features := featureLoader.LoadFeatures()

// Deserisalize Template Data
err = deserializeTemplates(&cfg)
if err != nil {
return OpenWrap{}, fmt.Errorf("error deserializing templates: %v", err)
}

// Init VAST Unwrap
vastunwrap.InitUnWrapperConfig(cfg.VastUnwrapCfg)
uw := unwrap.NewUnwrap(fmt.Sprintf("http://%s:%d/unwrap", cfg.VastUnwrapCfg.APPConfig.Host, cfg.VastUnwrapCfg.APPConfig.Port),
Expand Down Expand Up @@ -187,3 +193,25 @@ func patchConfig(cfg *config.Config) error {
}
return nil
}

func deserializeTemplates(cfg *config.Config) error {
if cfg.Template.GoogleSDK.Enable && len(cfg.Template.GoogleSDK.Data) > 0 {
if err := json.Unmarshal([]byte(cfg.Template.GoogleSDK.Data), &cfg.Template.GoogleSDK.DeserializedData); err != nil {
return fmt.Errorf("error deserializing Google SDK template: %v", err)
}
}

if cfg.Template.AppLovingMax.Enable && len(cfg.Template.AppLovingMax.Data) > 0 {
if err := json.Unmarshal([]byte(cfg.Template.AppLovingMax.Data), &cfg.Template.AppLovingMax.DeserializedData); err != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should it be AppLovin ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It was added for future support

return fmt.Errorf("error deserializing App Loving Max template: %v", err)
}
}

if cfg.Template.LevelPlay.Enable && len(cfg.Template.LevelPlay.Data) > 0 {
if err := json.Unmarshal([]byte(cfg.Template.LevelPlay.Data), &cfg.Template.LevelPlay.DeserializedData); err != nil {
return fmt.Errorf("error deserializing Level Play template: %v", err)
}
}

return nil
}
Loading
Loading