mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
fix: allow optional test even token
This commit is contained in:
parent
acf13a73b1
commit
27dff33e47
@ -13,6 +13,7 @@ import (
|
||||
commonvariable "github.com/foomo/sesamy-cli/pkg/tagmanager/common/variable"
|
||||
"github.com/foomo/sesamy-cli/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
tagmanager2 "google.golang.org/api/tagmanager/v2"
|
||||
)
|
||||
|
||||
func Server(ctx context.Context, l *slog.Logger, tm *tagmanager.TagManager, cfg config.Facebook) error {
|
||||
@ -31,9 +32,13 @@ func Server(ctx context.Context, l *slog.Logger, tm *tagmanager.TagManager, cfg
|
||||
return err
|
||||
}
|
||||
|
||||
testEventToken, err := tm.UpsertVariable(ctx, folder, commonvariable.NewConstant(NameTestEventTokenConstant, cfg.TestEventToken))
|
||||
if err != nil {
|
||||
return err
|
||||
var testEventToken *tagmanager2.Variable
|
||||
if cfg.TestEventToken != "" {
|
||||
var err error
|
||||
testEventToken, err = tm.UpsertVariable(ctx, folder, commonvariable.NewConstant(NameTestEventTokenConstant, cfg.TestEventToken))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
template, err := tm.LookupTemplate(ctx, NameConversionsAPITagTemplate)
|
||||
|
||||
@ -13,42 +13,48 @@ func ConversionsAPITagName(v string) string {
|
||||
}
|
||||
|
||||
func NewConversionsAPITag(name string, pixelID, apiAccessToken, testEventCode *tagmanager.Variable, settings config.FacebookConversionAPITag, template *tagmanager.CustomTemplate, triggers ...*tagmanager.Trigger) *tagmanager.Tag {
|
||||
params := []*tagmanager.Parameter{
|
||||
{
|
||||
Key: "pixelId",
|
||||
Type: "template",
|
||||
Value: "{{" + pixelID.Name + "}}",
|
||||
},
|
||||
{
|
||||
Key: "apiAccessToken",
|
||||
Type: "template",
|
||||
Value: "{{" + apiAccessToken.Name + "}}",
|
||||
},
|
||||
{
|
||||
Key: "enableEventEnhancement",
|
||||
Type: "boolean",
|
||||
Value: strconv.FormatBool(settings.EnableEventEnhancement),
|
||||
},
|
||||
{
|
||||
Key: "extendCookies",
|
||||
Type: "boolean",
|
||||
Value: strconv.FormatBool(settings.ExtendCookies),
|
||||
},
|
||||
{
|
||||
Key: "actionSource",
|
||||
Type: "template",
|
||||
Value: "website",
|
||||
},
|
||||
}
|
||||
|
||||
if testEventCode != nil {
|
||||
params = append(params, &tagmanager.Parameter{
|
||||
Key: "testEventCode",
|
||||
Type: "template",
|
||||
Value: "{{" + testEventCode.Name + "}}",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return &tagmanager.Tag{
|
||||
FiringTriggerId: utils.TriggerIDs(triggers),
|
||||
Name: ConversionsAPITagName(name),
|
||||
TagFiringOption: "oncePerEvent",
|
||||
Parameter: []*tagmanager.Parameter{
|
||||
{
|
||||
Key: "pixelId",
|
||||
Type: "template",
|
||||
Value: "{{" + pixelID.Name + "}}",
|
||||
},
|
||||
{
|
||||
Key: "apiAccessToken",
|
||||
Type: "template",
|
||||
Value: "{{" + apiAccessToken.Name + "}}",
|
||||
},
|
||||
{
|
||||
Key: "testEventCode",
|
||||
Type: "template",
|
||||
Value: "{{" + testEventCode.Name + "}}",
|
||||
},
|
||||
{
|
||||
Key: "enableEventEnhancement",
|
||||
Type: "boolean",
|
||||
Value: strconv.FormatBool(settings.EnableEventEnhancement),
|
||||
},
|
||||
{
|
||||
Key: "extendCookies",
|
||||
Type: "boolean",
|
||||
Value: strconv.FormatBool(settings.ExtendCookies),
|
||||
},
|
||||
{
|
||||
Key: "actionSource",
|
||||
Type: "template",
|
||||
Value: "website",
|
||||
},
|
||||
},
|
||||
Type: utils.TemplateType(template),
|
||||
Parameter: params,
|
||||
Type: utils.TemplateType(template),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user