func (Drift) Enabled() bool {
	return orgID() != ""
}
Enabled returns wether or not the Drift integration is enabled/configured
package drift
import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"net/http"
	"os"
	"github.com/Sirupsen/logrus"
	"github.com/jipiboily/forwardlytics/integrations"
)
type Drift struct {
	api service
}
type service interface {
	request(string, string, []byte) error
}
type driftAPIProduction struct {
	baseUrl string
}
type apiSubscriber struct {
	Attributes map[string]interface{} `json:"attributes"`
	CreatedAt  int64                  `json:"createdAt"`
	UserId     string                 `json:"userId"`
	OrgId      string                 `json:"orgId"`
}
type apiEvent struct {
	OrgId      string                 `json:"orgId"`
	UserId     string                 `json:"userId"`
	Event      string                 `json:"event"`
	CreatedAt  int64                  `json:"createdAt"`
	Attributes map[string]interface{} `json:"attributes"`
}
type apiPage struct {
	OrgId      string                 `json:"orgId"`
	UserId     string                 `json:"userId"`
	Event      string                 `json:"event"`
	Url        string                 `json:"url"`
	CreatedAt  int64                  `json:"createdAt"`
	Attributes map[string]interface{} `json:"attributes"`
}
func (d Drift) Identify(identification integrations.Identification) (err error) {
	s := apiSubscriber{}
	s.UserId = string(identification.UserID)
	s.CreatedAt = identification.Timestamp
	s.OrgId = orgID()
	s.Attributes = identification.UserTraits
	s.Attributes["forwardlyticsReceivedAt"] = identification.ReceivedAt
	s.Attributes["forwardlyticsTimestamp"] = identification.Timestamp
	payload, err := json.Marshal(s)
	err = d.api.request("POST", "identify", payload)
	if err != nil {
		logrus.WithError(err).WithField("identify", identification).WithField("payload", string(payload[:])).Error("Error sending identify to drift")
	}
	return
}
func (d Drift) Track(event integrations.Event) (err error) {
	e := apiEvent{}
	e.OrgId = orgID()
	e.UserId = event.UserID
	e.Attributes = event.Properties
	event.Properties["forwardlyticsReceivedAt"] = event.ReceivedAt
	e.Event = event.Name
	e.CreatedAt = event.Timestamp
	payload, err := json.Marshal(e)
	if err != nil {
		logrus.WithError(err).WithField("event", event).WithField("payload", string(payload[:])).Error("Error marshalling drift event to json")
	}
	err = d.api.request("POST", "track", payload)
	if err != nil {
		logrus.WithError(err).WithField("event", event).WithField("payload", string(payload[:])).Error("Error sending event to drift")
	}
	return
}
func (d Drift) Page(page integrations.Page) (err error) {
	p := apiPage{}
	p.OrgId = orgID()
	p.UserId = page.UserID
	p.Url = page.Url
	page.Properties["forwardlyticsReceivedAt"] = page.ReceivedAt
	page.Properties["name"] = page.Name
	p.Attributes = page.Properties
	p.Event = "page"
	p.CreatedAt = page.Timestamp
	payload, err := json.Marshal(p)
	if err != nil {
		logrus.WithError(err).WithField("page", page).WithField("payload", string(payload[:])).Error("Error marshalling drift page-event to json")
	}
	err = d.api.request("POST", "track", payload)
	if err != nil {
		logrus.WithError(err).WithField("page", page).WithField("payload", string(payload[:])).Error("Error sending page-event to drift")
	}
	return
}