MCPcopy Create free account
hub / github.com/GetStream/stream-go2 / TestAnalyticsTrackImpression

Function TestAnalyticsTrackImpression

analytics_test.go:45–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestAnalyticsTrackImpression(t *testing.T) {
46 ctx := context.Background()
47 client, requester := newClient(t)
48 analytics := client.Analytics()
49 imp := stream.ImpressionEventsData{}.
50 WithForeignIDs("a", "b", "c", "d").
51 WithUserData(stream.NewUserData().Int(123)).
52 WithFeedID("timeline:123").
53 WithFeatures(
54 stream.NewEventFeature("color", "red"),
55 stream.NewEventFeature("size", "xxl"),
56 ).
57 WithLocation("hawaii").
58 WithPosition(42)
59
60 _, err := analytics.TrackImpression(ctx, imp)
61 require.NoError(t, err)
62 expectedURL := "https://analytics.stream-io-api.com/analytics/v1.0/impression/?api_key=key"
63 expectedBody := `{"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}`
64 testRequest(t, requester.req, http.MethodPost, expectedURL, expectedBody)
65}
66
67func TestAnalyticsRedirectAndTrack(t *testing.T) {
68 client, _ := newClient(t)

Callers

nothing calls this directly

Calls 11

newClientFunction · 0.85
testRequestFunction · 0.85
AnalyticsMethod · 0.80
WithForeignIDsMethod · 0.80
IntMethod · 0.80
TrackImpressionMethod · 0.80
WithPositionMethod · 0.45
WithLocationMethod · 0.45
WithFeaturesMethod · 0.45
WithFeedIDMethod · 0.45
WithUserDataMethod · 0.45

Tested by

no test coverage detected