(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestAnalyticsTrackEngagement(t *testing.T) { |
| 16 | ctx := context.Background() |
| 17 | client, requester := newClient(t) |
| 18 | analytics := client.Analytics() |
| 19 | event1 := stream.EngagementEvent{}. |
| 20 | WithLabel("click"). |
| 21 | WithForeignID("abcdef"). |
| 22 | WithUserData(stream.NewUserData().Int(12345).Alias("John Doe")). |
| 23 | WithFeedID("timeline:123"). |
| 24 | WithLocation("hawaii"). |
| 25 | WithPosition(42). |
| 26 | WithBoost(10) |
| 27 | |
| 28 | event2 := stream.EngagementEvent{}. |
| 29 | WithLabel("share"). |
| 30 | WithForeignID("aabbccdd"). |
| 31 | WithUserData(stream.NewUserData().String("bob")). |
| 32 | WithFeedID("timeline:123"). |
| 33 | WithFeatures( |
| 34 | stream.NewEventFeature("color", "red"), |
| 35 | stream.NewEventFeature("size", "xxl"), |
| 36 | ) |
| 37 | |
| 38 | _, err := analytics.TrackEngagement(ctx, event1, event2) |
| 39 | require.NoError(t, err) |
| 40 | expectedURL := "https://analytics.stream-io-api.com/analytics/v1.0/engagement/?api_key=key" |
| 41 | expectedBody := `{"content_list":[{"boost":10,"content":"abcdef","feed_id":"timeline:123","label":"click","location":"hawaii","position":42,"user_data":{"alias":"John Doe","id":12345}},{"content":"aabbccdd","features":[{"group":"color","value":"red"},{"group":"size","value":"xxl"}],"feed_id":"timeline:123","label":"share","user_data":"bob"}]}` |
| 42 | testRequest(t, requester.req, http.MethodPost, expectedURL, expectedBody) |
| 43 | } |
| 44 | |
| 45 | func TestAnalyticsTrackImpression(t *testing.T) { |
| 46 | ctx := context.Background() |
nothing calls this directly
no test coverage detected