@@ -74,7 +74,7 @@ type exposureSubject struct {
7474
7575// exposureContext represents service context metadata for the exposure payload
7676type exposureContext struct {
77- ServiceName string `json:"service_name "`
77+ ServiceName string `json:"service "`
7878 Version string `json:"version,omitempty"`
7979 Env string `json:"env,omitempty"`
8080}
@@ -85,17 +85,10 @@ type exposurePayload struct {
8585 Exposures []exposureEvent `json:"exposures"`
8686}
8787
88- type bufferKey struct {
89- flagKey string
90- allocationKey string
91- variantKey string
92- subjectID string
93- }
94-
9588// exposureWriter manages buffering and flushing of exposure events to the Datadog Agent
9689type exposureWriter struct {
9790 mu sync.Mutex
98- buffer map [ bufferKey ]exposureEvent // Deduplicate by composite key
91+ buffer [ ]exposureEvent // Buffer for exposure events
9992 flushInterval time.Duration
10093 httpClient * http.Client
10194 agentURL * url.URL
@@ -143,7 +136,7 @@ func newExposureWriter(config ProviderConfig) *exposureWriter {
143136 }
144137
145138 w := & exposureWriter {
146- buffer : make (map [ bufferKey ]exposureEvent ),
139+ buffer : make ([ ]exposureEvent , 0 ),
147140 flushInterval : flushInterval ,
148141 httpClient : httpClient ,
149142 agentURL : agentURL ,
@@ -172,7 +165,7 @@ func (w *exposureWriter) start() {
172165 }()
173166}
174167
175- // append adds an exposure event to the buffer with deduplication
168+ // append adds an exposure event to the buffer
176169func (w * exposureWriter ) append (event exposureEvent ) {
177170 w .mu .Lock ()
178171 defer w .mu .Unlock ()
@@ -181,17 +174,9 @@ func (w *exposureWriter) append(event exposureEvent) {
181174 return
182175 }
183176
184- // Create composite key for deduplication
185- // Deduplicate by flag, allocation, variant, and subject.id
186- key := bufferKey {
187- flagKey : event .Flag .Key ,
188- allocationKey : event .Allocation .Key ,
189- variantKey : event .Variant .Key ,
190- subjectID : event .Subject .ID ,
191- }
192-
193- // Store event (will overwrite if duplicate)
194- w .buffer [key ] = event
177+ // Append event to buffer
178+ // Each exposure event is tracked individually to maintain accurate analytics
179+ w .buffer = append (w .buffer , event )
195180}
196181
197182// flush sends all buffered exposure events to the agent
@@ -203,11 +188,8 @@ func (w *exposureWriter) flush() {
203188 }
204189
205190 // Move buffer to local variable and create new buffer
206- events := make ([]exposureEvent , 0 , len (w .buffer ))
207- for _ , event := range w .buffer {
208- events = append (events , event )
209- }
210- w .buffer = make (map [bufferKey ]exposureEvent )
191+ events := w .buffer
192+ w .buffer = make ([]exposureEvent , 0 )
211193 w .mu .Unlock ()
212194
213195 // Build payload
0 commit comments