add logic for utm saving to deal stats
This commit is contained in:
parent
e7d90d5076
commit
c2cf928f8a
2
go.mod
2
go.mod
@ -13,7 +13,7 @@ require (
|
||||
github.com/twmb/franz-go v1.16.1
|
||||
go.uber.org/zap v1.27.0
|
||||
google.golang.org/protobuf v1.33.0
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240517190320-6bd772ee236c
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240519122235-c74e1f395480
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af
|
||||
)
|
||||
|
||||
|
2
go.sum
2
go.sum
@ -132,5 +132,7 @@ penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3
|
||||
penahub.gitlab.yandexcloud.net/backend/penahub_common v0.0.0-20240223054633-6cb3d5ce45b6/go.mod h1:lTmpjry+8evVkXWbEC+WMOELcFkRD1lFMc7J09mOndM=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240517190320-6bd772ee236c h1:XTkOH9osBDN08Q0n/Hkqp59h0FQ+N+68tW8Sxt8YWlU=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240517190320-6bd772ee236c/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240519122235-c74e1f395480 h1:lAHN8c6Vi4Fg+3zlSe1sdiyYYZuJDhisCS+iEsj6Huw=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/common.git v0.0.0-20240519122235-c74e1f395480/go.mod h1:oRyhT55ctjqp/7ZxIzkR7OsQ7T/NLibsfrbb7Ytns64=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af h1:jQ7HaXSutDX5iepU7VRImxhikK7lV/lBKkiloOZ4Emo=
|
||||
penahub.gitlab.yandexcloud.net/backend/quiz/core.git v0.0.0-20240219174804-d78fd38511af/go.mod h1:5S5YwjSXWmnEKjBjG6MtyGtFmljjukDRS8CwHk/CF/I=
|
||||
|
@ -124,3 +124,24 @@ func AddContactFields(contactFields []models.FieldsValues, fieldValue string, fi
|
||||
}
|
||||
return contactFields
|
||||
}
|
||||
|
||||
func ConstructUTMFields(utmMap model.UTMSavingMap, currentFields []model.Field) []models.FieldsValues {
|
||||
var fields []models.FieldsValues
|
||||
for _, field := range currentFields {
|
||||
if data, ok := utmMap[field.Name]; ok {
|
||||
val := []interface{}{
|
||||
models.Values{
|
||||
Value: data,
|
||||
},
|
||||
}
|
||||
f := models.FieldsValues{
|
||||
FieldID: int(field.Amoid),
|
||||
Values: val,
|
||||
}
|
||||
fields = append(fields, f)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
@ -95,6 +95,13 @@ func (wc *PostDeals) startFetching(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
currentFields, err := wc.amoRepo.AmoRepo.GetUserFieldsByID(ctx, result.AmoAccountID)
|
||||
if err != nil {
|
||||
wc.logger.Error("error getting current user fields from db", zap.Error(err))
|
||||
}
|
||||
|
||||
utmFields := tools.ConstructUTMFields(result.UTMs, currentFields)
|
||||
|
||||
_, err = wc.amoClient.CreatingCustomer(customerToCreate, result.AccessToken)
|
||||
if err != nil {
|
||||
wc.logger.Error("error sending requests for create customer", zap.Error(err))
|
||||
@ -109,6 +116,7 @@ func (wc *PostDeals) startFetching(ctx context.Context) {
|
||||
|
||||
deal.Embed.Contact = contactData
|
||||
deal.Embed.Company = companyData
|
||||
deal.CustomFieldsValues = utmFields
|
||||
|
||||
if len(mapDealReq[result.AccessToken]) >= 49 {
|
||||
wc.logger.Info("reached maximum number of deals for access token", zap.String("access_token", result.AccessToken))
|
||||
|
Loading…
Reference in New Issue
Block a user