1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-10 18:10:49 +09:00

GO-2050 Fix crash

This commit is contained in:
Mikhail Iudin 2023-12-02 01:14:55 +01:00
parent 129b2e70e5
commit 2d92f5c01f
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
2 changed files with 10 additions and 4 deletions

View file

@ -61,8 +61,13 @@ func (c *Client) SendEvents(amplEvents []Event, info AppInfoProvider) error {
req.Set("api_key", arena.NewString(c.key))
events := arena.NewArray()
for i, ev := range amplEvents {
ampEvent := *ev.MarshalFastJson(arena)
amIndex := 0
for _, ev := range amplEvents {
tryEvent := ev.MarshalFastJson(arena)
if tryEvent == nil {
continue
}
ampEvent := *tryEvent
ampEvent.Set("app_version", appVersion)
ampEvent.Set("device_id", deviceId)
ampEvent.Set("platform", platform)
@ -70,7 +75,8 @@ func (c *Client) SendEvents(amplEvents []Event, info AppInfoProvider) error {
ampEvent.Set("user_id", userId)
ampEvent.Set("time", arena.NewNumberInt(int(ev.GetTimestamp())))
events.SetArrayItem(i, &ampEvent)
events.SetArrayItem(amIndex, &ampEvent)
amIndex++
}
req.Set("events", events)

View file

@ -28,7 +28,7 @@ const (
)
const amplEndpoint = "https://amplitude.anytype.io/2/httpapi"
const inhouseEndpoint = "https://metrics.anytype.io/2/httpapi"
const inhouseEndpoint = "https://telemetry.anytype.io/2/httpapi"
type SamplableEvent interface {
amplitude.Event