Skip to content

Commit

Permalink
Merge pull request #33 from Moesif/add-weight-field-to-event
Browse files Browse the repository at this point in the history
Add: Weight field to event model
  • Loading branch information
dgilling committed Dec 19, 2019
2 parents 5cccc20 + 77e3425 commit f7fa442
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Add the Moesif dependency to your project's pom.xml file:
<dependency>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.6.8</version>
<version>1.6.9</version>
</dependency>
```

Expand All @@ -48,7 +48,7 @@ repositories {
}
dependencies {
compile 'com.moesif.servlet:moesif-servlet:1.6.8'
compile 'com.moesif.servlet:moesif-servlet:1.6.9'
}
```

Expand Down
4 changes: 2 additions & 2 deletions moesif-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.moesif.servlet</groupId>
<artifactId>moesif-servlet</artifactId>
<version>1.6.8</version>
<version>1.6.9</version>
<packaging>jar</packaging>
<name>moesif-servlet</name>
<description>Moesif SDK for Java Servlet to log and analyze API calls</description>
Expand Down Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.6.8</version>
<version>1.6.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ public void onFailure(HttpContext context, Throwable error) {

// Compare percentage to send event
if (samplingPercentage >= randomPercentage) {
maskedEvent.setWeight(moesifApi.getAPI().calculateWeight(samplingPercentage));
// Send Event
Map<String, String> eventApiResponse = moesifApi.getAPI().createEvent(maskedEvent);
// Get the etag from event api response
Expand Down
4 changes: 2 additions & 2 deletions moesif-springrequest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Add the Moesif dependency to your project's pom.xml file:
<dependency>
<groupId>com.moesif.springrequest</groupId>
<artifactId>moesif-springrequest</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
</dependency>
```

Expand All @@ -41,7 +41,7 @@ repositories {
}
dependencies {
compile 'com.moesif.springrequest:moesif-springrequest:1.0.8'
compile 'com.moesif.springrequest:moesif-springrequest:1.0.9'
}
```

Expand Down
4 changes: 2 additions & 2 deletions moesif-springrequest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.moesif.springrequest</groupId>
<artifactId>moesif-springrequest</artifactId>
<version>1.0.8</version>
<version>1.0.9</version>
<packaging>jar</packaging>
<name>moesif-springrequest</name>
<description>Moesif SDK for Java to log and analyze outgoing API calls</description>
Expand Down Expand Up @@ -56,7 +56,7 @@
<dependency>
<groupId>com.moesif.api</groupId>
<artifactId>moesifapi</artifactId>
<version>1.6.8</version>
<version>1.6.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp
config.identifyCompany(request, response),
config.getSessionToken(request, response),
config.getApiVersion(request, response),
config.getMetadata(request, response)
config.getMetadata(request, response),
"Outgoing"
);

eventModel.setDirection("Outgoing");

eventModel = config.maskContent(eventModel);

if (api.shouldSendSampledEvent(eventModel)) {
int sample_rate = api.getSampleRateToUse(eventModel);
eventModel.setWeight(api.calculateWeight(sample_rate));
try {
APICallBack<HttpResponse> callback = new APICallBack<HttpResponse>() {
public void onSuccess(HttpContext context, HttpResponse response) {
Expand Down

0 comments on commit f7fa442

Please sign in to comment.