-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from foomo/hotjar
feat(provider/hotjar): add provider
- Loading branch information
Showing
15 changed files
with
282 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package config | ||
|
||
type GoogleTag struct { | ||
TagID string `json:"tagId" yaml:"tagId"` | ||
DebugMode bool `json:"debugMode" yaml:"debugMode"` | ||
SendPageView bool `json:"sendPageView" yaml:"sendPageView"` | ||
TypeScript TypeScript `json:"typeScript" yaml:"typeScript"` | ||
// A tag ID is an identifier that you put on your page to load a given Google tag | ||
TagID string `json:"tagId" yaml:"tagId"` | ||
// Enable debug mode for all user devices | ||
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"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package config | ||
|
||
type Hotjar struct { | ||
Enabled bool `json:"enabled" yaml:"enabled"` | ||
SiteID string `json:"siteId" yaml:"siteId"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package hotjar | ||
|
||
const ( | ||
Tag = "hotjar" | ||
Name = "Hotjar" | ||
NameSiteID = "Hotjar Site ID" | ||
NameHotjarTag = "Hotjar" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package trigger | ||
|
||
const ( | ||
IDAllPages = "2147479553" | ||
IDInitialization = "2147479573" | ||
IDConsentInitializtion = "2147479572" | ||
) |
Oops, something went wrong.