analytics

package module
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: MPL-2.0 Imports: 14 Imported by: 2

Documentation

Overview

Package analytics provides a consistent and unique API for integrations related to customer data. It's heavily inspired by the well-known Segment API, giving access to the following methods:

  • Identify: Who is the customer?
  • Track: What are they doing?
  • Group: What account or organization are they part of?
  • Alias: What was their past identity?
  • Page: What web page are they on?
  • Screen: What application screen are they on?
  • Delete: Suppress (and optionally deletes) all data related to a user.

More info about the Segment API at: https://segment.com/docs/connections/spec/.

Note: The analytics specification is not implemented as originally described in the Segment documentation. We have updated it to better match the requirements and consistency of the Temporal Land ecosystem.

Index

Constants

View Source
const Specification string = "analytics"

Specification is the string representation of the analytics specification.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {

	// PreviousUserID is the existing user ID you've referred to the user by. It
	// might be an AnonymousID assigned to that user or a UserID you previously
	// identified them with using the "Identify" method.
	//
	// Required.
	//
	// More info at: https://segment.com/docs/connections/spec/alias/#previous-id
	PreviousUserID string `json:"previous_user_id"`

	// UserID is the user's new identity, or an existing identity that you wish to
	// merge with the PreviousUserID.
	//
	// Required.
	//
	// More info at: https://segment.com/docs/connections/spec/alias/#user-id
	NewUserID string `json:"new_user_id"`

	// Traits are additional pieces of information you know about a user. This is
	// useful in cases where you need to associate information from a previous
	// "Identify" call. You should fill this object the same way you would fill
	// Traits in an "Identify" call.
	Traits map[string]any `json:"traits,omitempty"`
}

Alias is used to merge two user identities, effectively connecting two sets of user data as one.

More info at: https://segment.com/docs/connections/spec/alias/

type Analytics

type Analytics interface {

	// RegisterWithAnalytics allows an end-user to register the analytics
	// specification within an integration.
	RegisterWithAnalytics(worker.Worker, Config) error
}

Analytics is the interface used by an overlying integration to leverage the analytics specification. The integration must satisfy the other AnalyticsWith interfaces to implement each method of the specification.

For a complete example, see how the Segment integration implements the different methods at: ./integrations/segment/analytics.go.

type AnalyticsWithAlias

type AnalyticsWithAlias interface {

	// ActivityAliasValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowAlias of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityAliasValidation of this package to not
	// start from scratch.
	ActivityAliasValidation(context.Context, InputAlias) (OutputAlias, error)

	// ActivityAliasRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityAliasRequest(context.Context, InputAlias) (OutputAlias, error)
}

AnalyticsWithAlias is the interface an integration must meet if it supports the "Alias" method.

For a complete example, see how the Segment integration implements the "Alias" method at: ./integrations/segment/analytics_alias.go.

type AnalyticsWithDelete

type AnalyticsWithDelete interface {

	// ActivityDeleteValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowDelete of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityDeleteValidation of this package to not
	// start from scratch.
	ActivityDeleteValidation(context.Context, InputDelete) (OutputDelete, error)

	// ActivityDeleteRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityDeleteRequest(context.Context, InputDelete) (OutputDelete, error)
}

AnalyticsWithDelete is the interface an integration must meet if it supports the "Delete" method.

For a complete example, see how the Segment integration implements the "Delete" method at: ./integrations/segment/analytics_delete.go.

type AnalyticsWithGroup

type AnalyticsWithGroup interface {

	// ActivityGroupValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowGroup of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityGroupValidation of this package to not
	// start from scratch.
	ActivityGroupValidation(context.Context, InputGroup) (OutputGroup, error)

	// ActivityGroupRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityGroupRequest(context.Context, InputGroup) (OutputGroup, error)
}

AnalyticsWithGroup is the interface an integration must meet if it supports the "Group" method.

For a complete example, see how the Segment integration implements the "Group" method at: ./integrations/segment/analytics_group.go.

type AnalyticsWithIdentify

type AnalyticsWithIdentify interface {

	// ActivityIdentifyValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowIdentify of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityIdentifyValidation of this package to not
	// start from scratch.
	ActivityIdentifyValidation(context.Context, InputIdentify) (OutputIdentify, error)

	// ActivityIdentifyRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityIdentifyRequest(context.Context, InputIdentify) (OutputIdentify, error)
}

AnalyticsWithIdentify is the interface an integration must meet if it supports the "Identify" method.

For a complete example, see how the Segment integration implements the "Identify" method at: ./integrations/segment/analytics_identify.go.

type AnalyticsWithPage

type AnalyticsWithPage interface {

	// ActivityPageValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowPage of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityPageValidation of this package to not
	// start from scratch.
	ActivityPageValidation(context.Context, InputPage) (OutputPage, error)

	// ActivityPageRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityPageRequest(context.Context, InputPage) (OutputPage, error)
}

AnalyticsWithPage is the interface an integration must meet if it supports the "Page" method.

For a complete example, see how the Segment integration implements the "Page" method at: ./integrations/segment/analytics_page.go.

type AnalyticsWithScreen

type AnalyticsWithScreen interface {

	// ActivityScreenValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowScreen of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityScreenValidation of this package to not
	// start from scratch.
	ActivityScreenValidation(context.Context, InputScreen) (OutputScreen, error)

	// ActivityScreenRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityScreenRequest(context.Context, InputScreen) (OutputScreen, error)
}

AnalyticsWithScreen is the interface an integration must meet if it supports the "Screen" method.

For a complete example, see how the Segment integration implements the "Screen" method at: ./integrations/segment/analytics_screen.go.

type AnalyticsWithTrack

type AnalyticsWithTrack interface {

	// ActivityTrackValidation is the Temporal activity used to validate the input
	// sent by the client. It is used in the WorkflowTrack of this package but
	// should manually be triggered from a workflow.
	//
	// The integration can call ActivityTrackValidation of this package to not
	// start from scratch.
	ActivityTrackValidation(context.Context, InputTrack) (OutputTrack, error)

	// ActivityTrackRequest is the activity that will make the (HTTP) request
	// against the third-party service. It's up to the overlying integration to
	// implement its own logic.
	ActivityTrackRequest(context.Context, InputTrack) (OutputTrack, error)
}

AnalyticsWithTrack is the interface an integration must meet if it supports the "Track" method.

For a complete example, see how the Segment integration implements the "Track" method at: ./integrations/segment/analytics_track.go.

type Config

type Config struct {

	// Policies allows to set activity policies, such as timeouts and retries.
	Policies Policies `json:"policies"`
	// contains filtered or unexported fields
}

Config allows the end-user to configure the specification for an integration.

func (*Config) Validate

func (config *Config) Validate() error

Validate validates the config passed by the end-user when registering the specification for the overlying integration. It returns an error if anything critical occured.

type Delete

type Delete struct {

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// Required.
	UserID string `json:"user_id"`

	// Traits are pieces of information you know about a user that can be useful
	// to delete them if UserID is not relevant for the overlying integration.
	// For example, the MailChimp integration uses the "email" trait to archive
	// or delete a user.
	Traits map[string]any `json:"traits,omitempty"`
}

Delete specifies a user identity to delete that you can reference across the user's whole lifetime.

type Group

type Group struct {

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// Required if AnonymousID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/group/#identities
	UserID string `json:"user_id,omitempty"`

	// GroupID is the unique identifier which you recognize a group by in your
	// database.
	//
	// Required.
	//
	// More info at: https://segment.com/docs/connections/spec/group/#group-id
	GroupID string `json:"group_id"`

	// Traits are extra pieces of information you know about the group. Those are
	// a group's Traits, not a user's Traits found in "Identify" or "Alias"
	// methods.
	//
	// More info at: https://segment.com/docs/connections/spec/group/#traits
	Traits map[string]any `json:"traits,omitempty"`
}

Group associates an individual user with a group. It can be a company, organization, account, project, team or any other name related to this same concept.

More info at: https://segment.com/docs/connections/spec/group/

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles the analytics specification for an integration.

func New

func New(ctx context.Context, from integration.Integration, config Config, features ...With) (*Handler, error)

New returns a new analytics Handler for the given integration. It applies the configuration passed by the end-user (forwarded by the integration). It also applies additional/optional features an integration might leverage.

It's not mandatory for an integration to implement every methods. Many only support "Identify" and "Track" for example. It's up to the overlying integration to inform the specification which methods are supported by using With. Example:

func New(myintegration, config, WithIdentify(), WithTrack(), WithPage())

func (*Handler) ActivityAliasValidation

func (h *Handler) ActivityAliasValidation(ctx context.Context, input InputAlias) (OutputAlias, error)

ActivityAliasValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityAliasValidation.

func (*Handler) ActivityDeleteValidation

func (h *Handler) ActivityDeleteValidation(ctx context.Context, input InputDelete) (OutputDelete, error)

ActivityDeleteValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityDeleteValidation.

func (*Handler) ActivityGroupValidation

func (h *Handler) ActivityGroupValidation(ctx context.Context, input InputGroup) (OutputGroup, error)

ActivityGroupValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityGroupValidation.

func (*Handler) ActivityIdentifyValidation

func (h *Handler) ActivityIdentifyValidation(ctx context.Context, input InputIdentify) (OutputIdentify, error)

ActivityIdentifyValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityIdentifyValidation.

func (*Handler) ActivityPageValidation

func (h *Handler) ActivityPageValidation(ctx context.Context, input InputPage) (OutputPage, error)

ActivityPageValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityPageValidation.

func (*Handler) ActivityScreenValidation

func (h *Handler) ActivityScreenValidation(ctx context.Context, input InputScreen) (OutputScreen, error)

ActivityScreenValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityScreenValidation.

func (*Handler) ActivityTrackValidation

func (h *Handler) ActivityTrackValidation(ctx context.Context, input InputTrack) (OutputTrack, error)

ActivityTrackValidation is the activity validating the input. It's up to the integration to call this function in its own ActivityTrackValidation.

func (*Handler) Close

func (h *Handler) Close() error

Close tries to properly close the specification. An error is returned in case the Handler has already been closed.

func (*Handler) ConfigMap

func (h *Handler) ConfigMap() map[string]any

ConfigMap transforms the configuration to a map, including a "from" key with the configuration of the overlying integration.

func (*Handler) Init

func (h *Handler) Init() error

Init initializes the specification. An error is returned in case the Handler has already been initialized.

func (*Handler) IsReady

func (h *Handler) IsReady() bool

IsReady indicates if the specification is ready to be consumed by the overlying integration. The specification must be initialized, must not be closed, and must have registered its workflows and activities in the Temporal worker.

func (*Handler) ListActivities

func (h *Handler) ListActivities() []string

ListActivities returns a sorted list of activities' name registered by the specification for the overlying integration.

func (*Handler) ListWorkflows

func (h *Handler) ListWorkflows() []string

ListWorkflows returns a sorted list of workflows' name registered by the specification for the overlying integration.

func (*Handler) Register

func (h *Handler) Register(w worker.Worker) error

Register registers the specification's workflows and activities in the given Temporal worker. An error is returned in case the registration has already been made.

func (*Handler) String

func (h *Handler) String() string

String returns the string representation of the overlying integration.

func (*Handler) WorkflowAlias

func (h *Handler) WorkflowAlias(ctx workflow.Context, input InputAlias) (OutputAlias, error)

WorkflowAlias is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityAliasValidation: Validates the input (local activity).

  2. ActivityAliasRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowAlias to benefit a ready-to-use workflow.

func (*Handler) WorkflowDelete

func (h *Handler) WorkflowDelete(ctx workflow.Context, input InputDelete) (OutputDelete, error)

WorkflowDelete is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityDeleteValidation: Validates the input (local activity).

  2. ActivityDeleteRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowDelete to benefit a ready-to-use workflow.

func (*Handler) WorkflowGroup

func (h *Handler) WorkflowGroup(ctx workflow.Context, input InputGroup) (OutputGroup, error)

WorkflowGroup is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityGroupValidation: Validates the input (local activity).

  2. ActivityGroupRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowGroup to benefit a ready-to-use workflow.

func (*Handler) WorkflowIdentify

func (h *Handler) WorkflowIdentify(ctx workflow.Context, input InputIdentify) (OutputIdentify, error)

WorkflowIdentify is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityIdentifyValidation: Validates the input (local activity).

  2. ActivityIdentifyRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowIdentify to benefit a ready-to-use workflow.

func (*Handler) WorkflowPage

func (h *Handler) WorkflowPage(ctx workflow.Context, input InputPage) (OutputPage, error)

WorkflowPage is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityPageValidation: Validates the input (local activity).

  2. ActivityPageRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowPage to benefit a ready-to-use workflow.

func (*Handler) WorkflowScreen

func (h *Handler) WorkflowScreen(ctx workflow.Context, input InputScreen) (OutputScreen, error)

WorkflowScreen is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityScreenValidation: Validates the input (local activity).

  2. ActivityScreenRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowScreen to benefit a ready-to-use workflow.

func (*Handler) WorkflowTrack

func (h *Handler) WorkflowTrack(ctx workflow.Context, input InputTrack) (OutputTrack, error)

WorkflowTrack is a high-level opiniated Temporal workflow. It executes the following activities:

  1. ActivityTrackValidation: Validates the input (local activity).

  2. ActivityTrackRequest: Executes the HTTP request against the third-party service.

It's up to the integration to call this workflow in its own WorkflowTrack to benefit a ready-to-use workflow.

type Identify

type Identify struct {

	// AnonymousID is a unique identifier used if you don't actually know who the
	// user is, but you still want to be able to tie them to traits, events, or page
	// views.
	//
	// More info at: https://segment.com/docs/connections/spec/identify/#anonymous-id
	AnonymousID string `json:"anonymous_id,omitempty"`

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// More info at: https://segment.com/docs/connections/spec/identify/#user-id
	UserID string `json:"user_id,omitempty"`

	// Traits are pieces of information you know about a user.
	//
	// More info at: https://segment.com/docs/connections/spec/identify/#traits
	Traits map[string]any `json:"traits,omitempty"`
}

Identify specifies a user identity that you can reference across the user's whole lifetime.

More info at: https://segment.com/docs/connections/spec/identify/

type InputAlias

type InputAlias struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Alias represents the user's data to alias them within the integration.
	Alias Alias `json:"alias"`
}

InputAlias is the input for the "Alias" workflow and activities.

func (*InputAlias) Validate

func (input *InputAlias) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityAliasValidation.

type InputDelete

type InputDelete struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Delete represents the user's data to delete within the integration.
	Delete Delete `json:"delete"`
}

InputDelete is the input for the "Delete" workflow and activities.

func (*InputDelete) Validate

func (input *InputDelete) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityDeleteValidation.

type InputGroup

type InputGroup struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Group represents the user's data to group them within the integration.
	Group Group `json:"group"`
}

InputGroup is the input for the "Group" workflow and activities.

func (*InputGroup) Validate

func (input *InputGroup) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityGroupValidation.

type InputIdentify

type InputIdentify struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Identify represents the user's data to identify them within the integration.
	Identify Identify `json:"identify"`
}

InputIdentify is the input for the "Identify" workflow and activities.

func (*InputIdentify) Validate

func (input *InputIdentify) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityIdentifyValidation.

type InputPage

type InputPage struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Page represents a record whenever a user sees a page of your website, along
	// with any optional properties about the page.
	Page Page `json:"page"`
}

InputPage is the input for the "Page" workflow and activities.

func (*InputPage) Validate

func (input *InputPage) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityPageValidation.

type InputScreen

type InputScreen struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Screen represents a record whenever a user sees a mobile screen of your
	// application, along with any optional properties about the screen. This is
	// the mobile equivalent of Page.
	Screen Screen `json:"screen"`
}

InputScreen is the input for the "Screen" workflow and activities.

func (*InputScreen) Validate

func (input *InputScreen) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityScreenValidation.

type InputTrack

type InputTrack struct {

	// Policies passed in the input can override the ones set when creating the
	// specification. It will only apply if allowed in the integration's Config
	// via AllowPoliciesOverride.
	Policies *Policies `json:"policies"`

	// Context represents the event's context, shared across every specifications
	// and integrations of this ecosystem.
	Context *event.Context `json:"context,omitempty"`

	// Track records any actions your users perform, along with any properties that
	// describe the action.
	Track Track `json:"track"`
}

InputTrack is the input for the "Track" workflow and activities.

func (*InputTrack) Validate

func (input *InputTrack) Validate(config *Config) error

Validate can be used to validate the workflow/activity's input. It's the validation function used in the local activity ActivityTrackValidation.

type OutputAlias

type OutputAlias struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Alias represents the computed user's data used to alias the user within the
	// integration. Some fields may have been updated/formatted to meet the
	// integration's requirements.
	Alias Alias `json:"alias"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityAliasRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputAlias is the output for the "Alias" workflow and activities.

type OutputDelete

type OutputDelete struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Delete represents the computed user's data used to delete the user
	// within the integration. Some fields may have been updated/formatted to
	// meet the integration's requirements.
	Delete Delete `json:"delete"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityDeleteRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputDelete is the output for the "Delete" workflow and activities.

type OutputGroup

type OutputGroup struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Group represents the computed user's data used to group the user within the
	// integration. Some fields may have been updated/formatted to meet the
	// integration's requirements.
	Group Group `json:"group"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityGroupRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputGroup is the output for the "Group" workflow and activities.

type OutputIdentify

type OutputIdentify struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Identify represents the computed user's data used to identify the user
	// within the integration. Some fields may have been updated/formatted to
	// meet the integration's requirements.
	Identify Identify `json:"identify"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityIdentifyRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputIdentify is the output for the "Identify" workflow and activities.

type OutputPage

type OutputPage struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Page represents the computed data used to record the page visited by the
	// user. Some fields may have been updated/formatted to meet the
	// integration's requirements.
	Page Page `json:"page"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityPageRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputPage is the output for the "Page" workflow and activities.

type OutputScreen

type OutputScreen struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Screen represents the computed data used to record the mobile screen visited
	// by the user. Some fields may have been updated/formatted to meet the
	// integration's requirements.
	Screen Screen `json:"screen"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityScreenRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputScreen is the output for the "Screen" workflow and activities.

type OutputTrack

type OutputTrack struct {

	// Status is the status of the workflow or activity. It's one of "success",
	// "failure".
	Status lifecycle.Status `json:"status"`

	// Track represents the computed user's data used to track the user within the
	// integration. Some fields may have been updated/formatted to meet the
	// integration's requirements.
	Track Track `json:"track"`

	// Response is the HTTP response returned by the third-party service with no
	// modification. We omit the key when empty because only the activity making
	// the HTTP request (ActivityTrackRequest) will write the value.
	Response rest.HTTPResponse `json:"response,omitempty"`
}

OutputTrack is the output for the "Track" workflow and activities.

type Page

type Page struct {

	// AnonymousID is a unique identifier used if you don't actually know who the
	// user is, but you still want to be able to tie them to traits, events, or page
	// views.
	//
	// Required if UserID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/page/#identities
	AnonymousID string `json:"anonymous_id,omitempty"`

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// Required if AnonymousID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/page/#identities
	UserID string `json:"user_id,omitempty"`

	// Name is the name of the page viewed by the user.
	//
	// Required.
	Name string `json:"name"`

	// Properties are extra pieces of information that describe the page. They can
	// be anything you want.
	//
	// More info at: https://segment.com/docs/connections/spec/page/#properties
	Properties map[string]any `json:"properties,omitempty"`
}

Page represents a record whenever a user sees a page of your website, along with any optional properties about the page.

More info at: https://segment.com/docs/connections/spec/page/

type Policies

type Policies struct {

	// Request is the policy to apply by the activity used to make the HTTP request
	// against the third-party service.
	//
	// Note: Since this is a short-live policy, activity's heartbeat is not used.
	// Therefore, Request.HeartbeatTimeout is not applied. We advise to set a
	// short-live Request.SingleAttemptTimeout, such as 3 seconds.
	Request lifecycle.ActivityPolicy `json:"request"`
	// contains filtered or unexported fields
}

Policies represents the Temporal activity policies to apply within the workflows exposed by this package and the overlying integration.

type Screen

type Screen struct {

	// AnonymousID is a unique identifier used if you don't actually know who the
	// user is, but you still want to be able to tie them to traits, events, or page
	// views.
	//
	// Required if UserID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/screen/#identities
	AnonymousID string `json:"anonymous_id,omitempty"`

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// Required if AnonymousID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/screen/#identities
	UserID string `json:"user_id,omitempty"`

	// Name is the name of the mobile screen viewed by the user.
	//
	// Required.
	Name string `json:"name"`

	// Properties are extra pieces of information that describe the mobile screen.
	// They can be anything you want.
	//
	// More info at: https://segment.com/docs/connections/spec/screen/#properties
	Properties map[string]any `json:"properties,omitempty"`
}

Screen represents a record whenever a user sees a mobile screen of your application, along with any optional properties about the screen. This is the mobile equivalent of Page.

More info at: https://segment.com/docs/connections/spec/page/

type Track

type Track struct {

	// AnonymousID is a unique identifier used if you don't actually know who the
	// user is, but you still want to be able to tie them to traits, events, or page
	// views.
	//
	// Required if UserID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/track/#identities
	AnonymousID string `json:"anonymous_id,omitempty"`

	// UserID is the unique identifier of a known user, consistent across a user's
	// lifetime.
	//
	// Required if AnonymousID is not set.
	//
	// More info at: https://segment.com/docs/connections/spec/track/#identities
	UserID string `json:"user_id,omitempty"`

	// Event is the name of the action that a user has performed.
	//
	// Required.
	Event string `json:"event"`

	// Properties are extra pieces of information you know about the event.
	//
	// More info at: https://segment.com/docs/connections/spec/track/#properties
	Properties map[string]any `json:"properties,omitempty"`

	// Traits are additional pieces of information you know about a user. This is
	// useful in cases where you need to associate information from a previous
	// "Identify" call. You should fill this object the same way you would fill
	// Traits in an "Identify" call.
	Traits map[string]any `json:"traits,omitempty"`
}

Track records any actions your users perform, along with any properties that describe the action.

More info at: https://segment.com/docs/connections/spec/track/

type With

type With func(*Handler) error

With allows an integration to add features or customize the behavior of the specification. It's in addition to Config. Since Config is designed for — and accessible by — end-users, With is specifically designed for integrations.

For example, an integration might call WithIdentif and WithTrack if it handles the "Identify" and "Track" methods:

func New(myintegration, config, WithIdentify(identify), WithTrack(track))

func WithAlias

func WithAlias(alias AnalyticsWithAlias) With

WithAlias must be passed to New if the overlying integration handles the "Alias" method:

func New(myintegration, config, WithAlias(alias))

func WithDelete

func WithDelete(delete AnalyticsWithDelete) With

WithDelete must be passed to New if the overlying integration handles the "Delete" method:

func New(myintegration, config, WithDelete(delete))

func WithGroup

func WithGroup(group AnalyticsWithGroup) With

WithGroup must be passed to New if the overlying integration handles the "Group" method:

func New(myintegration, config, WithGroup(group))

func WithIdentify

func WithIdentify(identify AnalyticsWithIdentify) With

WithIdentify must be passed to New if the overlying integration handles the "Identify" method:

func New(myintegration, config, WithIdentify(identify))

func WithPage

func WithPage(page AnalyticsWithPage) With

WithPage must be passed to New if the overlying integration handles the "Page" method:

func New(myintegration, config, WithPage(page))

func WithScreen

func WithScreen(screen AnalyticsWithScreen) With

WithScreen must be passed to New if the overlying integration handles the "Screen" method:

func New(myintegration, config, WithScreen(screen))

func WithTrack

func WithTrack(track AnalyticsWithTrack) With

WithTrack must be passed to New if the overlying integration handles the "Track" method:

func New(myintegration, config, WithTrack(track))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL