👋🏻 This package is currently under development. Please check back soon for more updates!
This package is an unofficial Go SDK for FullStory. It provides some useful tools for quickly integrating FullStory into your Go web application.
Getting started with FullStory is easy. Sign up for a free account at fullstory.com -- After, you'll be able to find your Org ID and API key in the Settings page.
This package provides a series of "snippets" that you'll want to include in your web pages to enable recording and playback of user sessions in FullStory. This package provides a simple interface for generating these snippets for use in Go html/templates.
In code, a Snippet
is simply some JavaScript text wrapped in a type that implements the Snippet
interface. One can use this interface to render the same snippet as both a JS expression or wrapped in <script>
tags.
type Snippet interface {
AsJS() template.JS
AsHTML() template.HTML
}
The recording script is key to FullStory's functionality and enables tracking of the activity in your web application. It is required to use FullStory and should be included in the <head>
of your HTML pages.
This package provides a helper function for generating a FullStory recording script that can be used in your Go templates:
package main
import (
"github.com/tylermmorton/go-fullstory/snippet"
"html/template"
"net/http"
)
var tmpl = template.Must(template.New("index.html").Parse(`
<html>
<head>
{{ .FullStorySnippet }}
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
`))
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl.Execute(w, map[string]interface{}{
"FullStorySnippet": snippet.MustRecordingSnippet("YOUR_ORG_ID").AsHTML(),
})
})
http.ListenAndServe(":8080", nil)
}
The identify snippet is used to associate a user with a FullStory session. This snippet should be included on every page of your web application where a user has been authenticated.
Additionally, you can use the identify snippet to set user variables that will be indexed and available in FullStory. This is useful for associating a user's name, email, or other information with a FullStory session.
func IdentifySnippet(userID, displayName, emailAddress string, userVars fullstory.Vars) (Snippet, error)
And a Must
variant that will panic if an error occurs:
func MustIdentifySnippet(userID, displayName, emailAddress string, userVars fullstory.Vars) Snippet
The pagevars snippet is used to set page variables that will be indexed and available in FullStory. This is useful for associating information about the page a user is on with a FullStory session.
func PageVarsSnippet(pageVars fullstory.Vars) (Snippet, error)
And a Must
variant that will panic if an error occurs:
func MustPageVarsSnippet(pageVars fullstory.Vars) Snippet
This package also provides an implementation of the FullStory Server API. One can create an API client like so:
package main
import (
"github.com/tylermmorton/go-fullstory"
"os"
)
func main() {
fs := fullstory.NewClient(&fullstory.Config{
OrgID: os.Getenv("FULLSTORY_ORG_ID"),
APIKey: os.Getenv("FULLSTORY_API_KEY"),
})
}