(t *testing.T)
| 65 | } |
| 66 | |
| 67 | func TestAnalyticsRedirectAndTrack(t *testing.T) { |
| 68 | client, _ := newClient(t) |
| 69 | analytics := client.Analytics() |
| 70 | event1 := stream.EngagementEvent{}. |
| 71 | WithLabel("click"). |
| 72 | WithForeignID("abcdef"). |
| 73 | WithUserData(stream.NewUserData().Int(12345).Alias("John Doe")). |
| 74 | WithFeedID("timeline:123"). |
| 75 | WithLocation("hawaii"). |
| 76 | WithPosition(42). |
| 77 | WithBoost(10) |
| 78 | event2 := stream.EngagementEvent{}. |
| 79 | WithLabel("share"). |
| 80 | WithForeignID("aabbccdd"). |
| 81 | WithUserData(stream.NewUserData().String("bob")). |
| 82 | WithFeedID("timeline:123"). |
| 83 | WithFeatures( |
| 84 | stream.NewEventFeature("color", "red"), |
| 85 | stream.NewEventFeature("size", "xxl"), |
| 86 | ) |
| 87 | imp := stream.ImpressionEventsData{}. |
| 88 | WithForeignIDs("a", "b", "c", "d"). |
| 89 | WithUserData(stream.NewUserData().Int(123)). |
| 90 | WithFeedID("timeline:123"). |
| 91 | WithFeatures( |
| 92 | stream.NewEventFeature("color", "red"), |
| 93 | stream.NewEventFeature("size", "xxl"), |
| 94 | ). |
| 95 | WithLocation("hawaii"). |
| 96 | WithPosition(42) |
| 97 | |
| 98 | link, err := analytics.RedirectAndTrack("foo.bar.baz", event1, event2, imp) |
| 99 | require.NoError(t, err) |
| 100 | query, err := url.ParseQuery(`api_key=key&authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3Rpb24iOiIqIiwicmVzb3VyY2UiOiJyZWRpcmVjdF9hbmRfdHJhY2siLCJ1c2VyX2lkIjoiKiJ9.A1vy9pFwLw5s6qn0chkhRcoy974A16a0lE-x5Vtxb-o&events=[{"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"},{"content_list":["a","b","c","d"],"features":[{"group":"color","value":"red"},{"group":"size","value":"xxl"}],"feed_id":"timeline:123","location":"hawaii","position":42,"user_data":123}]&stream-auth-type=jwt&url=foo.bar.baz`) |
| 101 | require.NoError(t, err) |
| 102 | expected := "https://analytics.stream-io-api.com/analytics/v1.0/redirect/?" + query.Encode() |
| 103 | assert.Equal(t, expected, link) |
| 104 | } |
nothing calls this directly
no test coverage detected