-
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.
feat: add click, page_view and scroll events
- Loading branch information
1 parent
ce0e8e6
commit 2f4880f
Showing
5 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package event | ||
|
||
import ( | ||
mp "github.com/foomo/sesamy-go/measurementprotocol" | ||
mpv2 "github.com/foomo/sesamy-go/measurementprotocol/v2" | ||
) | ||
|
||
type Click struct { | ||
LinkID string `json:"linkId,omitempty"` | ||
LinkURL string `json:"link_url,omitempty"` | ||
LinkDomain string `json:"link_domain,omitempty"` | ||
LinkClasses string `json:"link_classes,omitempty"` | ||
Outbound bool `json:"outbound,omitempty"` | ||
} | ||
|
||
func (e *Click) MarshalMPv2() (*mpv2.Event, error) { | ||
eventParameter := map[string]string{} | ||
mp.AddStringMap(eventParameter, mpv2.EventParameterLinkID.String(), mp.SetString(e.LinkID)) | ||
mp.AddStringMap(eventParameter, mpv2.EventParameterLinkUrl.String(), mp.SetString(e.LinkURL)) | ||
mp.AddStringMap(eventParameter, mpv2.EventParameterLinkDomain.String(), mp.SetString(e.LinkDomain)) | ||
mp.AddStringMap(eventParameter, mpv2.EventParameterLinkClasses.String(), mp.SetString(e.LinkClasses)) | ||
mp.AddStringMap(eventParameter, mpv2.EventParameterOutbound.String(), mp.SetBool(e.Outbound)) | ||
return &mpv2.Event{ | ||
EventName: mp.Set(mpv2.EventNameClick), | ||
EventParameter: mp.SetStringMap(eventParameter), | ||
}, 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,14 @@ | ||
package event | ||
|
||
import ( | ||
mp "github.com/foomo/sesamy-go/measurementprotocol" | ||
mpv2 "github.com/foomo/sesamy-go/measurementprotocol/v2" | ||
) | ||
|
||
type PageView struct{} | ||
|
||
func (e *PageView) MarshalMPv2() (*mpv2.Event, error) { | ||
return &mpv2.Event{ | ||
EventName: mp.Set(mpv2.EventNamePageView), | ||
}, 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,19 @@ | ||
package event | ||
|
||
import ( | ||
mp "github.com/foomo/sesamy-go/measurementprotocol" | ||
mpv2 "github.com/foomo/sesamy-go/measurementprotocol/v2" | ||
) | ||
|
||
type Scroll struct { | ||
PercentScrolled float64 `json:"percent_scrolled"` | ||
} | ||
|
||
func (e *Scroll) MarshalMPv2() (*mpv2.Event, error) { | ||
eventParameterNumber := map[string]string{} | ||
mp.AddStringMap(eventParameterNumber, mpv2.EventParameterNumberPercentScrolled.String(), mp.SetFloat64(e.PercentScrolled)) | ||
return &mpv2.Event{ | ||
EventName: mp.Set(mpv2.EventNameScroll), | ||
EventParameterNumber: mp.SetStringMap(eventParameterNumber), | ||
}, 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
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