feat(provider/hotjar): add provider

This commit is contained in:
Kevin Franklin Kim 2024-11-07 16:51:50 +01:00
parent 427201c0c0
commit 5c56ceae20
No known key found for this signature in database
15 changed files with 293 additions and 279 deletions

View File

@ -51,6 +51,7 @@ Add a `sesamy.yaml` configuration
```yaml ```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/foomo/sesamy-cli/v0.4.1/sesamy.yaml # yaml-language-server: $schema=https://raw.githubusercontent.com/foomo/sesamy-cli/v0.4.1/sesamy.yaml
# yaml-language-server: $schema=sesamy.schema.json
version: '1.0' version: '1.0'
# Whether to redact the visitor ip # Whether to redact the visitor ip
@ -68,49 +69,33 @@ googleApi:
# --- Google Tag Manager settings # --- Google Tag Manager settings
googleTagManager: googleTagManager:
# The account id # The account id
accountId: 6099238525 accountId: '6099238525'
# Web container settings # Web container settings
webContainer: webContainer:
# The container tag id # The container tag id
tagId: GTM-57BHX34G tagId: GTM-57BHX34G
# The container id # The container id
containerId: 175355532 containerId: '175355532'
# The workspace id that should be used by the api # The workspace id that should be used by the api
workspaceId: 23 workspaceId: '23'
# Server container settings # Server container settings
serverContainer: serverContainer:
# The container tag id # The container tag id
tagId: GTM-5NWPR4QW tagId: GTM-5NWPR4QW
# The container id # The container id
containerId: 175348980 containerId: '175348980'
# The workspace id that should be used by the api # The workspace id that should be used by the api
workspaceId: 10 workspaceId: '10'
# --- Google Tag settings # --- Google Tag settings
googleTag: googleTag:
# A tag ID is an identifier that you put on your page to load a given Google tag # A tag ID is an identifier that you put on your page to load a given Google tag
tagId: G-PZ5ELRCR31 tagId: G-PZ5ELRCR31
# Whether a page_view should be sent on initial load
sendPageView: true
# Enable debug mode for all user devices # Enable debug mode for all user devices
debugMode: false debugMode: false
# Google Tag Manager web container settings # Whether a page_view should be sent on initial load
webContainer: sendPageView: true
# Contemplate package config for generated events # TypeScript settings
packages:
- path: github.com/foomo/sesamy-go/pkg/event
types:
- PageView
- SelectItem
# Google Tag Manager server container settings
serverContainer:
# Contemplate package config for generated events
packages:
- path: github.com/foomo/sesamy-go/pkg/event
types:
- PageView
- SelectItem
# Google Tag Manager web container settings
typeScript: typeScript:
# Target directory for generate files # Target directory for generate files
outputPath: path/to/target outputPath: path/to/target
@ -175,7 +160,6 @@ googleTag:
- ViewPromotion - ViewPromotion
- WorkingLead - WorkingLead
# --- Google Analytics settings # --- Google Analytics settings
googleAnalytics: googleAnalytics:
# Enable provider # Enable provider
@ -291,13 +275,13 @@ facebook:
apiAccessToken: '' apiAccessToken: ''
# Code used to verify that your server events are received correctly by Conversions API # Code used to verify that your server events are received correctly by Conversions API
testEventToken: '' testEventToken: ''
# Google Tag Manager server container settings
# Google Consent settings # Google Consent settings
googleConsent: googleConsent:
# Enable consent mode # Enable consent mode
enabled: true enabled: true
# Consent mode name # Consent mode name
mode: ad_storage mode: ad_storage
# Google Tag Manager server container settings
serverContainer: serverContainer:
# Contemplate package config for generated events # Contemplate package config for generated events
packages: packages:
@ -360,6 +344,13 @@ tracify:
- ViewItem - ViewItem
- Purchase - Purchase
# --- Hotjar
hotjar:
# Enable provider
enabled: true
# Hotjar site id
siteId: 123456
# --- Cookiebot CMP # --- Cookiebot CMP
cookiebot: cookiebot:
# Enable provider # Enable provider

View File

@ -6,6 +6,7 @@ import (
emarsysprovider "github.com/foomo/sesamy-cli/pkg/provider/emarsys" emarsysprovider "github.com/foomo/sesamy-cli/pkg/provider/emarsys"
googleanaylticsprovider "github.com/foomo/sesamy-cli/pkg/provider/googleanalytics" googleanaylticsprovider "github.com/foomo/sesamy-cli/pkg/provider/googleanalytics"
googletagprovider "github.com/foomo/sesamy-cli/pkg/provider/googletag" googletagprovider "github.com/foomo/sesamy-cli/pkg/provider/googletag"
hotjarprovider "github.com/foomo/sesamy-cli/pkg/provider/hotjar"
"github.com/foomo/sesamy-cli/pkg/tagmanager" "github.com/foomo/sesamy-cli/pkg/tagmanager"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -60,6 +61,12 @@ func NewWeb(root *cobra.Command) {
} }
} }
if cfg.Hotjar.Enabled && pkgcmd.Tag(hotjarprovider.Tag, tags) {
if err := hotjarprovider.Web(tm, cfg.Hotjar); err != nil {
return errors.Wrap(err, "failed to provision hotjar provider")
}
}
if cfg.Cookiebot.Enabled && pkgcmd.Tag(cookiebotprovider.Tag, tags) { if cfg.Cookiebot.Enabled && pkgcmd.Tag(cookiebotprovider.Tag, tags) {
if err := cookiebotprovider.Web(tm, cfg.Cookiebot); err != nil { if err := cookiebotprovider.Web(tm, cfg.Cookiebot); err != nil {
return errors.Wrap(err, "failed to provision cookiebot provider") return errors.Wrap(err, "failed to provision cookiebot provider")

View File

@ -5,6 +5,8 @@ import (
"errors" "errors"
"os" "os"
"path" "path"
"reflect"
"strings"
"testing" "testing"
testingx "github.com/foomo/go/testing" testingx "github.com/foomo/go/testing"
@ -22,6 +24,13 @@ func TestConfig(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
reflector := new(jsonschema.Reflector) reflector := new(jsonschema.Reflector)
reflector.RequiredFromJSONSchemaTags = true
reflector.Namer = func(t reflect.Type) string {
if t.Name() == "" {
return t.String()
}
return strings.ReplaceAll(t.PkgPath(), "/", ".") + "." + t.Name()
}
require.NoError(t, reflector.AddGoComments("github.com/foomo/sesamy-cli", "./")) require.NoError(t, reflector.AddGoComments("github.com/foomo/sesamy-cli", "./"))
schema := reflector.Reflect(&config.Config{}) schema := reflector.Reflect(&config.Config{})
actual, err := json.MarshalIndent(schema, "", " ") actual, err := json.MarshalIndent(schema, "", " ")

View File

@ -23,6 +23,8 @@ type Config struct {
Facebook Facebook `json:"facebook" yaml:"facebook"` Facebook Facebook `json:"facebook" yaml:"facebook"`
// Emarsys provider settings // Emarsys provider settings
Emarsys Emarsys `json:"emarsys" yaml:"emarsys"` Emarsys Emarsys `json:"emarsys" yaml:"emarsys"`
// Hotjar provider settings
Hotjar Hotjar `json:"hotjar" yaml:"hotjar"`
// Tracify provider settings // Tracify provider settings
Tracify Tracify `json:"tracify" yaml:"tracify"` Tracify Tracify `json:"tracify" yaml:"tracify"`
// Umami provider settings // Umami provider settings

View File

@ -5,9 +5,14 @@ import (
) )
type Emarsys struct { type Emarsys struct {
Enabled bool `json:"enabled" yaml:"enabled"` // Enable provider
MerchantID string `json:"merchantId" yaml:"merchantId"` Enabled bool `json:"enabled" yaml:"enabled"`
GoogleConsent GoogleConsent `json:"googleConsent" yaml:"googleConsent"` // Emarsys merchant id
WebContainer contemplate.Config `json:"webContainer" yaml:"webContainer"` MerchantID string `json:"merchantId" yaml:"merchantId"`
// Google Consent settings
GoogleConsent GoogleConsent `json:"googleConsent" yaml:"googleConsent"`
// Google Tag Manager web container settings
WebContainer contemplate.Config `json:"webContainer" yaml:"webContainer"`
// Google Tag Manager server container settings
ServerContainer contemplate.Config `json:"serverContainer" yaml:"serverContainer"` ServerContainer contemplate.Config `json:"serverContainer" yaml:"serverContainer"`
} }

View File

@ -1,8 +1,12 @@
package config package config
type GoogleTag struct { type GoogleTag struct {
TagID string `json:"tagId" yaml:"tagId"` // A tag ID is an identifier that you put on your page to load a given Google tag
DebugMode bool `json:"debugMode" yaml:"debugMode"` TagID string `json:"tagId" yaml:"tagId"`
SendPageView bool `json:"sendPageView" yaml:"sendPageView"` // Enable debug mode for all user devices
TypeScript TypeScript `json:"typeScript" yaml:"typeScript"` DebugMode bool `json:"debugMode" yaml:"debugMode"`
// Whether a page_view should be sent on initial load
SendPageView bool `json:"sendPageView" yaml:"sendPageView"`
// TypeScript settings
TypeScript TypeScript `json:"typeScript" yaml:"typeScript"`
} }

6
pkg/config/hotjar.go Normal file
View File

@ -0,0 +1,6 @@
package config
type Hotjar struct {
Enabled bool `json:"enabled" yaml:"enabled"`
SiteID string `json:"siteId" yaml:"siteId"`
}

View File

@ -5,9 +5,14 @@ import (
) )
type Tracify struct { type Tracify struct {
Enabled bool `json:"enabled" yaml:"enabled"` // Enable provider
Token string `json:"token" yaml:"token"` Enabled bool `json:"enabled" yaml:"enabled"`
CustomerSiteID string `json:"customerSiteId" yaml:"customerSiteId"` // Tracify token
GoogleConsent GoogleConsent `json:"googleConsent" yaml:"googleConsent"` Token string `json:"token" yaml:"token"`
// Tracify customer site id
CustomerSiteID string `json:"customerSiteId" yaml:"customerSiteId"`
// Google Consent settings
GoogleConsent GoogleConsent `json:"googleConsent" yaml:"googleConsent"`
// Google Tag Manager server container settings
ServerContainer contemplate.Config `json:"serverContainer" yaml:"serverContainer"` ServerContainer contemplate.Config `json:"serverContainer" yaml:"serverContainer"`
} }

View File

@ -0,0 +1,8 @@
package hotjar
const (
Tag = "hotjar"
Name = "Hotjar"
NameSiteID = "Hotjar Site ID"
NameHotjarTag = "Hotjar"
)

View File

@ -0,0 +1,31 @@
package hotjar
import (
"github.com/foomo/sesamy-cli/pkg/config"
client "github.com/foomo/sesamy-cli/pkg/provider/hotjar/web/tag"
"github.com/foomo/sesamy-cli/pkg/tagmanager"
commonvariable "github.com/foomo/sesamy-cli/pkg/tagmanager/common/variable"
)
func Web(tm *tagmanager.TagManager, cfg config.Hotjar) error {
{ // create folder
if folder, err := tm.UpsertFolder("Sesamy - " + Name); err != nil {
return err
} else {
tm.SetFolderName(folder.Name)
}
}
{ // setup hotjar
siteID, err := tm.UpsertVariable(commonvariable.NewConstant(NameSiteID, cfg.SiteID))
if err != nil {
return err
}
if _, err = tm.UpsertTag(client.NewHotjar(NameHotjarTag, siteID)); err != nil {
return err
}
}
return nil
}

View File

@ -0,0 +1,22 @@
package client
import (
"github.com/foomo/sesamy-cli/pkg/tagmanager/web/trigger"
"google.golang.org/api/tagmanager/v2"
)
func NewHotjar(name string, siteID *tagmanager.Variable) *tagmanager.Tag {
ret := &tagmanager.Tag{
FiringTriggerId: []string{trigger.IDAllPages},
Name: name,
Parameter: []*tagmanager.Parameter{
{
Key: "hotjar_site_id",
Type: "template",
Value: "{{" + siteID.Name + "}}",
},
},
Type: "hjtc",
}
return ret
}

View File

@ -1,6 +1,7 @@
package trigger package trigger
const ( const (
IDAllPages = "2147479553"
IDInitialization = "2147479573" IDInitialization = "2147479573"
IDConsentInitializtion = "2147479572" IDConsentInitializtion = "2147479572"
) )

View File

@ -1,9 +1,42 @@
{ {
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/foomo/sesamy-cli/pkg/config/config", "$id": "https://github.com/foomo/sesamy-cli/pkg/config/github.com.foomo.sesamy-cli.pkg.config.-config",
"$ref": "#/$defs/Config", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Config",
"$defs": { "$defs": {
"Config": { "[]*contemplate.PackageConfig": {
"items": {
"$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.PackageConfig"
},
"type": "array"
},
"[]string": {
"items": {
"type": "string"
},
"type": "array"
},
"github.com.foomo.gocontemplate.pkg.contemplate.Config": {
"properties": {
"packages": {
"$ref": "#/$defs/[]*contemplate.PackageConfig"
}
},
"additionalProperties": false,
"type": "object"
},
"github.com.foomo.gocontemplate.pkg.contemplate.PackageConfig": {
"properties": {
"path": {
"type": "string"
},
"types": {
"$ref": "#/$defs/[]string"
}
},
"additionalProperties": false,
"type": "object"
},
"github.com.foomo.sesamy-cli.pkg.config.Config": {
"properties": { "properties": {
"version": { "version": {
"type": "string", "type": "string",
@ -14,85 +47,73 @@
"description": "Globally redact visitor ip" "description": "Globally redact visitor ip"
}, },
"googleTag": { "googleTag": {
"$ref": "#/$defs/GoogleTag", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleTag",
"description": "Google Tag settings" "description": "Google Tag settings"
}, },
"googleApi": { "googleApi": {
"$ref": "#/$defs/GoogleAPI", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleAPI",
"description": "Google API settings" "description": "Google API settings"
}, },
"googleTagManager": { "googleTagManager": {
"$ref": "#/$defs/GoogleTagManager", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleTagManager",
"description": "Google Tag Manager settings" "description": "Google Tag Manager settings"
}, },
"googleAds": { "googleAds": {
"$ref": "#/$defs/GoogleAds", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleAds",
"description": "Google Ads provider settings" "description": "Google Ads provider settings"
}, },
"cookiebot": { "cookiebot": {
"$ref": "#/$defs/Cookiebot", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Cookiebot",
"description": "CookieBot provider settings" "description": "CookieBot provider settings"
}, },
"googleAnalytics": { "googleAnalytics": {
"$ref": "#/$defs/GoogleAnalytics", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleAnalytics",
"description": "Google Analytics provider settings" "description": "Google Analytics provider settings"
}, },
"conversionLinker": { "conversionLinker": {
"$ref": "#/$defs/ConversionLinker", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.ConversionLinker",
"description": "Conversion Linker provider settings" "description": "Conversion Linker provider settings"
}, },
"facebook": { "facebook": {
"$ref": "#/$defs/Facebook", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Facebook",
"description": "Facebook provider settings" "description": "Facebook provider settings"
}, },
"emarsys": { "emarsys": {
"$ref": "#/$defs/Emarsys", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Emarsys",
"description": "Emarsys provider settings" "description": "Emarsys provider settings"
}, },
"hotjar": {
"$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Hotjar",
"description": "Hotjar provider settings"
},
"tracify": { "tracify": {
"$ref": "#/$defs/Tracify", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Tracify",
"description": "Tracify provider settings" "description": "Tracify provider settings"
}, },
"umami": { "umami": {
"$ref": "#/$defs/Umami", "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.Umami",
"description": "Umami provider settings" "description": "Umami provider settings"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object",
"required": [ "required": [
"version", "version"
"redactVisitorIp",
"googleTag",
"googleApi",
"googleTagManager",
"googleAds",
"cookiebot",
"googleAnalytics",
"conversionLinker",
"facebook",
"emarsys",
"tracify",
"umami"
] ]
}, },
"ConversionLinker": { "github.com.foomo.sesamy-cli.pkg.config.ConversionLinker": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"googleConsent"
]
}, },
"Cookiebot": { "github.com.foomo.sesamy-cli.pkg.config.Cookiebot": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -114,45 +135,35 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"templateName",
"cookiebotId",
"cdnRegion",
"urlPassthrough",
"advertiserConsentModeEnabled"
]
}, },
"Emarsys": { "github.com.foomo.sesamy-cli.pkg.config.Emarsys": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean",
"description": "Enable provider"
}, },
"merchantId": { "merchantId": {
"type": "string" "type": "string",
"description": "Emarsys merchant id"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent",
"description": "Google Consent settings"
}, },
"webContainer": { "webContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config",
"description": "Google Tag Manager web container settings"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config",
"description": "Google Tag Manager server container settings"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"merchantId",
"googleConsent",
"webContainer",
"serverContainer"
]
}, },
"Facebook": { "github.com.foomo.sesamy-cli.pkg.config.Facebook": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -167,24 +178,16 @@
"type": "string" "type": "string"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"pixelId",
"apiAccessToken",
"testEventToken",
"googleConsent",
"serverContainer"
]
}, },
"GoogleAPI": { "github.com.foomo.sesamy-cli.pkg.config.GoogleAPI": {
"properties": { "properties": {
"credentials": { "credentials": {
"type": "string" "type": "string"
@ -197,42 +200,30 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"credentials",
"credentialsFile",
"requestQuota"
]
}, },
"GoogleAds": { "github.com.foomo.sesamy-cli.pkg.config.GoogleAds": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent"
}, },
"conversionId": { "conversionId": {
"type": "string" "type": "string"
}, },
"conversion": { "conversion": {
"$ref": "#/$defs/GoogleAdsConversion" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleAdsConversion"
}, },
"remarketing": { "remarketing": {
"$ref": "#/$defs/GoogleAdsRemarketing" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleAdsRemarketing"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"googleConsent",
"conversionId",
"conversion",
"remarketing"
]
}, },
"GoogleAdsConversion": { "github.com.foomo.sesamy-cli.pkg.config.GoogleAdsConversion": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -241,18 +232,13 @@
"type": "string" "type": "string"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"conversionLabel",
"serverContainer"
]
}, },
"GoogleAdsRemarketing": { "github.com.foomo.sesamy-cli.pkg.config.GoogleAdsRemarketing": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -262,41 +248,30 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"enableConversionLinker"
]
}, },
"GoogleAnalytics": { "github.com.foomo.sesamy-cli.pkg.config.GoogleAnalytics": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
}, },
"googleGTag": { "googleGTag": {
"$ref": "#/$defs/GoogleGTag" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleGTag"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent"
}, },
"webContainer": { "webContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"googleGTag",
"googleConsent",
"webContainer",
"serverContainer"
]
}, },
"GoogleConsent": { "github.com.foomo.sesamy-cli.pkg.config.GoogleConsent": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -306,13 +281,9 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"mode"
]
}, },
"GoogleGTag": { "github.com.foomo.sesamy-cli.pkg.config.GoogleGTag": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -325,58 +296,46 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"priority",
"ecommerceItems"
]
}, },
"GoogleTag": { "github.com.foomo.sesamy-cli.pkg.config.GoogleTag": {
"properties": { "properties": {
"tagId": { "tagId": {
"type": "string" "type": "string",
"description": "A tag ID is an identifier that you put on your page to load a given Google tag"
}, },
"debugMode": { "debugMode": {
"type": "boolean" "type": "boolean",
"description": "Enable debug mode for all user devices"
}, },
"sendPageView": { "sendPageView": {
"type": "boolean" "type": "boolean",
"description": "Whether a page_view should be sent on initial load"
}, },
"typeScript": { "typeScript": {
"$ref": "#/$defs/TypeScript" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.TypeScript",
"description": "TypeScript settings"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"tagId",
"debugMode",
"sendPageView",
"typeScript"
]
}, },
"GoogleTagManager": { "github.com.foomo.sesamy-cli.pkg.config.GoogleTagManager": {
"properties": { "properties": {
"accountId": { "accountId": {
"type": "string" "type": "string"
}, },
"webContainer": { "webContainer": {
"$ref": "#/$defs/GoogleTagManagerContainer" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleTagManagerContainer"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/GoogleTagManagerContainer" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleTagManagerContainer"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"accountId",
"webContainer",
"serverContainer"
]
}, },
"GoogleTagManagerContainer": { "github.com.foomo.sesamy-cli.pkg.config.GoogleTagManagerContainer": {
"properties": { "properties": {
"tagId": { "tagId": {
"type": "string" "type": "string"
@ -389,80 +348,59 @@
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"tagId",
"containerId",
"workspaceId"
]
}, },
"PackageConfig": { "github.com.foomo.sesamy-cli.pkg.config.Hotjar": {
"properties": {
"path": {
"type": "string"
},
"types": {
"items": {
"type": "string"
},
"type": "array"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"path",
"types"
]
},
"Tracify": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
}, },
"token": { "siteId": {
"type": "string" "type": "string"
},
"customerSiteId": {
"type": "string"
},
"googleConsent": {
"$ref": "#/$defs/GoogleConsent"
},
"serverContainer": {
"$ref": "#/$defs/Config"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"token",
"customerSiteId",
"googleConsent",
"serverContainer"
]
}, },
"TypeScript": { "github.com.foomo.sesamy-cli.pkg.config.Tracify": {
"properties": {
"enabled": {
"type": "boolean",
"description": "Enable provider"
},
"token": {
"type": "string",
"description": "Tracify token"
},
"customerSiteId": {
"type": "string",
"description": "Tracify customer site id"
},
"googleConsent": {
"$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent",
"description": "Google Consent settings"
},
"serverContainer": {
"$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config",
"description": "Google Tag Manager server container settings"
}
},
"additionalProperties": false,
"type": "object"
},
"github.com.foomo.sesamy-cli.pkg.config.TypeScript": {
"properties": { "properties": {
"packages": { "packages": {
"items": { "$ref": "#/$defs/[]*contemplate.PackageConfig"
"$ref": "#/$defs/PackageConfig"
},
"type": "array"
}, },
"outputPath": { "outputPath": {
"type": "string" "type": "string"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"packages",
"outputPath"
]
}, },
"Umami": { "github.com.foomo.sesamy-cli.pkg.config.Umami": {
"properties": { "properties": {
"enabled": { "enabled": {
"type": "boolean" "type": "boolean"
@ -477,22 +415,14 @@
"type": "string" "type": "string"
}, },
"googleConsent": { "googleConsent": {
"$ref": "#/$defs/GoogleConsent" "$ref": "#/$defs/github.com.foomo.sesamy-cli.pkg.config.GoogleConsent"
}, },
"serverContainer": { "serverContainer": {
"$ref": "#/$defs/Config" "$ref": "#/$defs/github.com.foomo.gocontemplate.pkg.contemplate.Config"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
"type": "object", "type": "object"
"required": [
"enabled",
"domain",
"websiteId",
"endpointUrl",
"googleConsent",
"serverContainer"
]
} }
} }
} }

View File

@ -16,49 +16,33 @@ googleApi:
# --- Google Tag Manager settings # --- Google Tag Manager settings
googleTagManager: googleTagManager:
# The account id # The account id
accountId: 6099238525 accountId: '6099238525'
# Web container settings # Web container settings
webContainer: webContainer:
# The container tag id # The container tag id
tagId: GTM-57BHX34G tagId: GTM-57BHX34G
# The container id # The container id
containerId: 175355532 containerId: '175355532'
# The workspace id that should be used by the api # The workspace id that should be used by the api
workspaceId: 23 workspaceId: '23'
# Server container settings # Server container settings
serverContainer: serverContainer:
# The container tag id # The container tag id
tagId: GTM-5NWPR4QW tagId: GTM-5NWPR4QW
# The container id # The container id
containerId: 175348980 containerId: '175348980'
# The workspace id that should be used by the api # The workspace id that should be used by the api
workspaceId: 10 workspaceId: '10'
# --- Google Tag settings # --- Google Tag settings
googleTag: googleTag:
# A tag ID is an identifier that you put on your page to load a given Google tag # A tag ID is an identifier that you put on your page to load a given Google tag
tagId: G-PZ5ELRCR31 tagId: G-PZ5ELRCR31
# Whether a page_view should be sent on initial load
sendPageView: true
# Enable debug mode for all user devices # Enable debug mode for all user devices
debugMode: false debugMode: false
# Google Tag Manager web container settings # Whether a page_view should be sent on initial load
webContainer: sendPageView: true
# Contemplate package config for generated events # TypeScript settings
packages:
- path: github.com/foomo/sesamy-go/pkg/event
types:
- PageView
- SelectItem
# Google Tag Manager server container settings
serverContainer:
# Contemplate package config for generated events
packages:
- path: github.com/foomo/sesamy-go/pkg/event
types:
- PageView
- SelectItem
# Google Tag Manager web container settings
typeScript: typeScript:
# Target directory for generate files # Target directory for generate files
outputPath: path/to/target outputPath: path/to/target
@ -307,6 +291,13 @@ tracify:
- ViewItem - ViewItem
- Purchase - Purchase
# --- Hotjar
hotjar:
# Enable provider
enabled: true
# Hotjar site id
siteId: '123456'
# --- Cookiebot CMP # --- Cookiebot CMP
cookiebot: cookiebot:
# Enable provider # Enable provider

View File

@ -12,6 +12,7 @@ import (
"github.com/foomo/sesamy-cli/pkg/config" "github.com/foomo/sesamy-cli/pkg/config"
"github.com/foomo/sesamy-cli/pkg/tagmanager" "github.com/foomo/sesamy-cli/pkg/tagmanager"
"github.com/foomo/sesamy-cli/pkg/tagmanager/common/trigger" "github.com/foomo/sesamy-cli/pkg/tagmanager/common/trigger"
"github.com/joho/godotenv"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"google.golang.org/api/option" "google.golang.org/api/option"
@ -20,6 +21,7 @@ import (
func TestNewClient_Web(t *testing.T) { func TestNewClient_Web(t *testing.T) {
testingx.Tags(t, tagx.Skip) testingx.Tags(t, tagx.Skip)
require.NoError(t, godotenv.Load("../../.env"))
c, err := tagmanager.New( c, err := tagmanager.New(
context.TODO(), context.TODO(),