Skip to content

Commit

Permalink
feat: add events
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinkim committed May 15, 2024
1 parent ce5bd23 commit 453e515
Show file tree
Hide file tree
Showing 37 changed files with 331 additions and 66 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

> **Se**rver **S**ide T**a**g **M**anagement **S**ystem
## References

- [Event naming rules](https://support.google.com/analytics/answer/13316687)

## How to Contribute

Make a pull request...
Expand Down
12 changes: 12 additions & 0 deletions event/click.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package event

import (
"github.com/foomo/sesamy-go"
"github.com/foomo/sesamy-go/event/params"
)

type Click sesamy.Event[params.Click]

func NewClick(p params.Click) Click {
return Click(sesamy.NewEvent(sesamy.EventNameClick, p))
}
12 changes: 12 additions & 0 deletions event/filedownload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package event

import (
"github.com/foomo/sesamy-go"
"github.com/foomo/sesamy-go/event/params"
)

type FileDownload sesamy.Event[params.FileDownload]

func NewFileDownload(p params.FileDownload) FileDownload {
return FileDownload(sesamy.NewEvent(sesamy.EventNameFileDownload, p))
}
12 changes: 12 additions & 0 deletions event/formstart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package event

import (
"github.com/foomo/sesamy-go"
"github.com/foomo/sesamy-go/event/params"
)

type FormStart sesamy.Event[params.FormStart]

func NewFormStart(p params.FormStart) FormStart {
return FormStart(sesamy.NewEvent(sesamy.EventNameFormStart, p))
}
12 changes: 12 additions & 0 deletions event/formsubmit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package event

import (
"github.com/foomo/sesamy-go"
"github.com/foomo/sesamy-go/event/params"
)

type FormSubmit sesamy.Event[params.FormSubmit]

func NewFormSubmit(p params.FormSubmit) FormSubmit {
return FormSubmit(sesamy.NewEvent(sesamy.EventNameFormSubmit, p))
}
14 changes: 9 additions & 5 deletions event/params/addpaymentinfo.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// AddPaymentInfo https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events
type AddPaymentInfo[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
PaymentType string `json:"payment_type,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
PaymentType string `json:"payment_type,omitempty"`
Items []Item `json:"items,omitempty"`
}
14 changes: 9 additions & 5 deletions event/params/addshippinginfo.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// AddShippingInfo https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#add_shipping_info
type AddShippingInfo[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
ShippingTier string `json:"shipping_tier,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
ShippingTier string `json:"shipping_tier,omitempty"`
Items []Item `json:"items,omitempty"`
}
10 changes: 7 additions & 3 deletions event/params/addtocart.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// AddToCart https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#add_to_cart
type AddToCart[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
}
10 changes: 7 additions & 3 deletions event/params/addtowishlist.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// AddToWishlist https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#add_to_wishlist
type AddToWishlist[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
}
15 changes: 10 additions & 5 deletions event/params/adimpression.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// AdImpression https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#ad_impression
type AdImpression struct {
AdPlatform string `json:"ad_platform,omitempty" mapstructure:"ad_platform"`
AdSource string `json:"ad_source,omitempty" mapstructure:"ad_source"`
AdFormat string `json:"ad_format,omitempty" mapstructure:"ad_format"`
AdUnitName string `json:"ad_unit_name,omitempty" mapstructure:"ad_unit_name"`
Currency string `json:"currency,omitempty" mapstructure:"currency"`
AdPlatform string `json:"ad_platform,omitempty"`
AdSource string `json:"ad_source,omitempty"`
AdFormat string `json:"ad_format,omitempty"`
AdUnitName string `json:"ad_unit_name,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
}
12 changes: 8 additions & 4 deletions event/params/begincheckout.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// BeginCheckout https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#begin_checkout
type BeginCheckout[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Coupon string `json:"coupon,omitempty"`
Items []Item `json:"items,omitempty"`
}
9 changes: 9 additions & 0 deletions event/params/click.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package params

type Click struct {
LinkClasses string `json:"link_classes,omitempty"`
LinkDomain string `json:"link_domain,omitempty"`
LinkID string `json:"link_id,omitempty"`
LinkURL string `json:"link_url,omitempty"`
Outbound bool `json:"outbound,omitempty"`
}
10 changes: 10 additions & 0 deletions event/params/filedownload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package params

type FileDownload struct {
FileExtension string `json:"file_extension,omitempty"`
FileName string `json:"file_name,omitempty"`
LinkClasses string `json:"link_classes,omitempty"`
LinkID string `json:"link_id,omitempty"`
LinkText string `json:"link_text,omitempty"`
LinkURL string `json:"link_url,omitempty"`
}
7 changes: 7 additions & 0 deletions event/params/formstart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package params

type FormStart struct {
FormID string `json:"form_id,omitempty"`
FormName string `json:"form_name,omitempty"`
FormDestination string `json:"form_destination,omitempty"`
}
8 changes: 8 additions & 0 deletions event/params/formsubmit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package params

type FormSubmit struct {
FormID string `json:"form_id,omitempty"`
FormName string `json:"form_name,omitempty"`
FormDestination string `json:"form_destination,omitempty"`
FormSubmitText string `json:"form_submit_text,omitempty"`
}
8 changes: 6 additions & 2 deletions event/params/generatelead.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// GenerateLead https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#generate_lead
type GenerateLead struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
}
18 changes: 11 additions & 7 deletions event/params/purchase.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// Purchase https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#purchase
type Purchase[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Coupon string `json:"coupon,omitempty"`
Shipping float64 `json:"shipping,omitempty"`
Tax float64 `json:"tax,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Coupon string `json:"coupon,omitempty"`
Shipping float64 `json:"shipping,omitempty"`
Tax float64 `json:"tax,omitempty"`
Items []Item `json:"items,omitempty"`
}
18 changes: 11 additions & 7 deletions event/params/refund.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// Refund https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#refund
type Refund[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Coupon string `json:"coupon,omitempty"`
Shipping float64 `json:"shipping,omitempty"`
Tax float64 `json:"tax,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
TransactionID string `json:"transaction_id,omitempty"`
Coupon string `json:"coupon,omitempty"`
Shipping float64 `json:"shipping,omitempty"`
Tax float64 `json:"tax,omitempty"`
Items []Item `json:"items,omitempty"`
}
10 changes: 7 additions & 3 deletions event/params/removefromcart.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// RemoveFromCart https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#remove_from_cart
type RemoveFromCart[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
}
5 changes: 5 additions & 0 deletions event/params/scroll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package params

type Scroll struct {
EngagementTimeMsec int64 `json:"engagement_time_msec,omitempty"`
}
3 changes: 3 additions & 0 deletions event/params/sessionstart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package params

type SessionStart struct{}
6 changes: 3 additions & 3 deletions event/params/unlockarchievement.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package params

// UnlockArchievement https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#unlock_achievement
type UnlockArchievement struct {
ArchievementName string `json:"archievement_name"`
// UnlockAchievement https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#unlock_achievement
type UnlockAchievement struct {
ArchievementID string `json:"achievement_id"`
}
5 changes: 5 additions & 0 deletions event/params/userengagement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package params

type UserEngagement struct {
EngagementTimeMsec int64 `json:"engagement_time_msec,omitempty"`
}
11 changes: 11 additions & 0 deletions event/params/videocomplete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package params

type VideoComplete struct {
VideoCurrentTime int64 `json:"video_current_time,omitempty"`
VideoDuration int64 `json:"video_duration,omitempty"`
VideoPercent int64 `json:"video_percent,omitempty"`
VideoProvider string `json:"video_provider,omitempty"`
VideoTitle string `json:"video_title,omitempty"`
VideoURL string `json:"video_url,omitempty"`
Visible bool `json:"visible,omitempty"`
}
11 changes: 11 additions & 0 deletions event/params/videoprogress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package params

type VideoProgress struct {
VideoCurrentTime int64 `json:"video_current_time,omitempty"`
VideoDuration int64 `json:"video_duration,omitempty"`
VideoPercent int64 `json:"video_percent,omitempty"`
VideoProvider string `json:"video_provider,omitempty"`
VideoTitle string `json:"video_title,omitempty"`
VideoURL string `json:"video_url,omitempty"`
Visible bool `json:"visible,omitempty"`
}
11 changes: 11 additions & 0 deletions event/params/videostart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package params

type VideoStart struct {
VideoCurrentTime int64 `json:"video_current_time,omitempty"`
VideoDuration int64 `json:"video_duration,omitempty"`
VideoPercent int64 `json:"video_percent,omitempty"`
VideoProvider string `json:"video_provider,omitempty"`
VideoTitle string `json:"video_title,omitempty"`
VideoURL string `json:"video_url,omitempty"`
Visible bool `json:"visible,omitempty"`
}
10 changes: 7 additions & 3 deletions event/params/viewcart.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// ViewCart https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#view_cart
type ViewCart[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
}
10 changes: 7 additions & 3 deletions event/params/viewitem.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package params

import (
"github.com/foomo/gostandards/iso4217"
)

// ViewItem https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/events#view_item
type ViewItem[Item any] struct {
Currency string `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
Currency iso4217.Currency `json:"currency,omitempty"`
Value float64 `json:"value,omitempty"`
Items []Item `json:"items,omitempty"`
}
12 changes: 12 additions & 0 deletions event/scroll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package event

import (
"github.com/foomo/sesamy-go"
"github.com/foomo/sesamy-go/event/params"
)

type Scroll sesamy.Event[params.Scroll]

func NewScroll(p params.Scroll) Scroll {
return Scroll(sesamy.NewEvent(sesamy.EventNameScroll, p))
}
Loading

0 comments on commit 453e515

Please sign in to comment.