Giter Site home page Giter Site logo

go-fullstory's Introduction

๐Ÿ‘‹๐Ÿป This package is currently under development. Please check back soon for more updates!

FullStory Go SDK

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

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.

Usage

Snippets

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
}

Recording Snippet

FullStory Documentation

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)
}

Identify Snippet

FullStory Documentation

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

PageVars Snippet

FullStory Documentation

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

HTTP API Client

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"),
	})
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.