mirror of
https://github.com/foomo/sesamy-cli.git
synced 2025-10-16 12:35:36 +00:00
feat: add debug_mode transformation
This commit is contained in:
parent
c67e4d4898
commit
036c32ee0c
@ -17,6 +17,7 @@ import (
|
||||
servervariable "github.com/foomo/sesamy-cli/pkg/tagmanager/server/variable"
|
||||
"github.com/foomo/sesamy-cli/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
api "google.golang.org/api/tagmanager/v2"
|
||||
)
|
||||
|
||||
func Server(tm *tagmanager.TagManager, cfg config.GoogleAnalytics, redactVisitorIP, enableGeoResolution bool) error {
|
||||
@ -69,7 +70,15 @@ func Server(tm *tagmanager.TagManager, cfg config.GoogleAnalytics, redactVisitor
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = tm.UpsertTransformation(servertransformation.NewMPv2UserData(NameMPv2UserDataTransformation, userDataVariable, client))
|
||||
debugModeVariable, err := tm.UpsertVariable(servervariable.NewMPv2Data("debug_mode", userDataTemplate))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = tm.UpsertTransformation(servertransformation.NewMPv2UserData(NameMPv2UserDataTransformation, map[string]*api.Variable{
|
||||
"user_data": userDataVariable,
|
||||
"debug_mode": debugModeVariable,
|
||||
}, client))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -4,7 +4,27 @@ import (
|
||||
"google.golang.org/api/tagmanager/v2"
|
||||
)
|
||||
|
||||
func NewMPv2UserData(name string, variable *tagmanager.Variable, client *tagmanager.Client) *tagmanager.Transformation {
|
||||
func NewMPv2UserData(name string, variables map[string]*tagmanager.Variable, client *tagmanager.Client) *tagmanager.Transformation {
|
||||
var list []*tagmanager.Parameter
|
||||
for k, v := range variables {
|
||||
list = append(list, &tagmanager.Parameter{
|
||||
IsWeakReference: false,
|
||||
Map: []*tagmanager.Parameter{
|
||||
{
|
||||
Key: "paramName",
|
||||
Type: "template",
|
||||
Value: k,
|
||||
},
|
||||
{
|
||||
Key: "paramValue",
|
||||
Type: "template",
|
||||
Value: "{{" + v.Name + "}}",
|
||||
},
|
||||
},
|
||||
Type: "map",
|
||||
})
|
||||
}
|
||||
|
||||
return &tagmanager.Transformation{
|
||||
Name: name,
|
||||
Parameter: []*tagmanager.Parameter{
|
||||
@ -23,25 +43,8 @@ func NewMPv2UserData(name string, variable *tagmanager.Variable, client *tagmana
|
||||
Type: "template",
|
||||
},
|
||||
{
|
||||
Key: "augmentEventTable",
|
||||
List: []*tagmanager.Parameter{
|
||||
{
|
||||
IsWeakReference: false,
|
||||
Map: []*tagmanager.Parameter{
|
||||
{
|
||||
Key: "paramName",
|
||||
Type: "template",
|
||||
Value: "user_data",
|
||||
},
|
||||
{
|
||||
Key: "paramValue",
|
||||
Type: "template",
|
||||
Value: "{{" + variable.Name + "}}",
|
||||
},
|
||||
},
|
||||
Type: "map",
|
||||
},
|
||||
},
|
||||
Key: "augmentEventTable",
|
||||
List: list,
|
||||
Type: "list",
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user