Skip to content

Commit

Permalink
won't support that endpoint (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthoare013 authored May 25, 2023
1 parent 4fcacf4 commit 5561e41
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 64 deletions.
63 changes: 0 additions & 63 deletions identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package mixpanel

import (
"context"
"fmt"
"net/http"
"net/url"
)

const (
Expand Down Expand Up @@ -55,63 +52,3 @@ func (m *Mixpanel) Merge(ctx context.Context, distinctID1, distinctID2 string) e

return m.doPeopleRequest(ctx, payload, mergeEndpoint, formData, acceptPlainText(), applicationFormData(), m.useApiSecret())
}

type IdentityEvent struct {
*Event
}

func (m *Mixpanel) NewIdentityEvent(distinctID string, properties map[string]any, identifiedId, anonId string) *IdentityEvent {
event := m.NewEvent("$identify", distinctID, properties)
i := &IdentityEvent{
Event: event,
}
i.SetIdentifiedId(identifiedId)
i.SetAnonId(anonId)

return i
}

func (i *IdentityEvent) IdentifiedId() any {
return i.Properties["$identified_id"]
}

// A distinct_id to merge with the $anon_id.
func (i *IdentityEvent) SetIdentifiedId(id string) {
i.Properties["$identified_id"] = id
}

// A distinct_id to merge with the $identified_id. The $anon_id must be UUID v4 format and not already merged to an $identified_id.
func (i *IdentityEvent) SetAnonId(id string) {
i.Properties["$anon_id"] = id
}

func (i *IdentityEvent) AnonId(id string) {
i.Properties["$anon_id"] = id
}

type IdentityOptions struct {
Strict bool
}

func (m *Mixpanel) CreateIdentity(ctx context.Context, events []*IdentityEvent, identityOptions IdentityOptions) error {
// todo support import option
// todo add strict option

query := url.Values{}
query.Add("verbose", "1")

response, err := m.doRequestBody(
ctx,
http.MethodPost,
m.apiEndpoint+identityEndpoint,
events,
None,
addQueryParams(query), acceptPlainText(),
)
if err != nil {
return fmt.Errorf("failed to create identity:%w", err)
}
defer response.Body.Close()

return returnVerboseError(response)
}
1 change: 0 additions & 1 deletion mixpanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ var _ Export = (*Mixpanel)(nil)
type Identity interface {
Alias(ctx context.Context, distinctID, aliasID string) error
Merge(ctx context.Context, distinctID1, distinctID2 string) error
CreateIdentity(ctx context.Context, events []*IdentityEvent, options IdentityOptions) error
}

var _ Identity = (*Mixpanel)(nil)
Expand Down

0 comments on commit 5561e41

Please sign in to comment.