AGPUSH-971 : Advanced Analytics, Server Side #540
Changes from all commits
c60a061
c72e443
e0f2a3b
1511333
241bead
a7bd2fa
19e4cec
a5d3a01
519a814
5051561
630a82a
5a49d49
993c37b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
import org.jboss.aerogear.unifiedpush.api.Installation; | ||
import org.jboss.aerogear.unifiedpush.api.Variant; | ||
import org.jboss.aerogear.unifiedpush.rest.AbstractBaseEndpoint; | ||
import org.jboss.aerogear.unifiedpush.rest.util.HttpRequestUtil; | ||
import org.jboss.aerogear.unifiedpush.service.metrics.PushMessageMetricsService; | ||
import org.jboss.aerogear.unifiedpush.utils.AeroGearLogger; | ||
import org.jboss.aerogear.unifiedpush.rest.util.HttpBasicHelper; | ||
import org.jboss.aerogear.unifiedpush.service.ClientInstallationService; | ||
|
@@ -51,6 +53,9 @@ public class InstallationRegistrationEndpoint extends AbstractBaseEndpoint { | |
@Inject | ||
private GenericVariantService genericVariantService; | ||
|
||
@Inject | ||
private PushMessageMetricsService metricsService; | ||
|
||
|
||
@OPTIONS | ||
@Path("{token: .*}") | ||
|
@@ -73,7 +78,7 @@ public Response crossOriginForInstallations(@Context HttpHeaders headers) { | |
* | ||
* <pre> | ||
* curl -u "variantID:secret" | ||
* -v -H "Accept: application/json" -H "Content-type: application/json" | ||
* -v -H "Accept: application/json" -H "Content-type: application/json" -H "aerogear-push-id: someid" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's have doc for that :-) what's it's for - when to inculde etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be added in our Registration doc https://aerogear.org/docs/unifiedpush/client-registration/ , seems that the good place ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah - but perhaps here too, especually we generate the REST docs from here |
||
* -X POST | ||
* -d '{ | ||
* "deviceToken" : "someTokenString", | ||
|
@@ -120,6 +125,12 @@ public Response registerInstallation( | |
// otherwise we register a new installation: | ||
logger.finest("Mobile Application on device was launched"); | ||
|
||
//let's do update the analytics | ||
|
||
String aerogearPushId = HttpRequestUtil.extractPushIdentifier(request); | ||
if(aerogearPushId!= null) { | ||
metricsService.updateAnalytics(aerogearPushId, variant.getVariantID()); | ||
} | ||
// async: | ||
clientInstallationService.addInstallation(variant, entity); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,16 @@ public static String extractAeroGearSenderInformation(final HttpServletRequest r | |
return request.getHeader("user-agent"); | ||
} | ||
|
||
/** | ||
* Extract the header that identifies the push message. | ||
* | ||
* @param request , the current @link{{HttpServletRequest}} | ||
* @return value of header | ||
*/ | ||
public static String extractPushIdentifier(HttpServletRequest request) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mind adding a test ? |
||
return request.getHeader("aerogear-push-id"); | ||
} | ||
|
||
/** | ||
* Simple validation, using java.net.InetAddress.getByName(). | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,10 @@ public class PushMessageInformation extends BaseModel { | |
private Date submitDate = new Date(); | ||
private long totalReceivers; | ||
|
||
private long appOpenCounter; | ||
private Date firstOpenDate; | ||
private Date lastOpenDate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to integrate this into the migration PR, that @qmx is currently working on for getting ready to be part of master There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have test for these new properties ? |
||
|
||
private Set<VariantMetricInformation> variantInformations = new HashSet<VariantMetricInformation>(); | ||
|
||
/** | ||
|
@@ -125,6 +129,52 @@ public void setTotalReceivers(long totalReceivers) { | |
this.totalReceivers = totalReceivers; | ||
} | ||
|
||
/** | ||
* The number of time this Push Application was opened after a Push Notification | ||
* | ||
* @return the number of time this Push Application was opened after a Push Notification | ||
*/ | ||
public long getAppOpenCounter() { | ||
return appOpenCounter; | ||
} | ||
|
||
public void setAppOpenCounter(long appOpenCounter) { | ||
this.appOpenCounter = appOpenCounter; | ||
} | ||
|
||
/** | ||
* Increment the AppOpenCounter | ||
*/ | ||
public void incrementAppOpenCounter() { | ||
this.setAppOpenCounter(this.getAppOpenCounter() +1); | ||
} | ||
|
||
/** | ||
* The date of the first time this Push Application was opened after a Push Notification | ||
* | ||
* @return the date of the first time this Push Application was opened after a Push Notification | ||
*/ | ||
public Date getFirstOpenDate() { | ||
return firstOpenDate; | ||
} | ||
|
||
public void setFirstOpenDate(Date firstOpenDate) { | ||
this.firstOpenDate = firstOpenDate; | ||
} | ||
|
||
/** | ||
* The date of the last time this Push Application was opened after a Push Notification | ||
* | ||
* @return the date of the last time this Push Application was opened after a Push Notification | ||
*/ | ||
public Date getLastOpenDate() { | ||
return lastOpenDate; | ||
} | ||
|
||
public void setLastOpenDate(Date lastOpenDate) { | ||
this.lastOpenDate = lastOpenDate; | ||
} | ||
|
||
public void addVariantInformations(VariantMetricInformation variantMetricInformation) { | ||
this.variantInformations.add(variantMetricInformation); | ||
variantMetricInformation.setPushMessageInformation(this); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ public class VariantMetricInformation extends BaseModel { | |
private long receivers; | ||
private Boolean deliveryStatus = Boolean.FALSE; | ||
private String reason; | ||
private long variantOpenCounter; | ||
|
||
@JsonIgnore | ||
private PushMessageInformation pushMessageInformation; | ||
|
@@ -97,4 +98,21 @@ public PushMessageInformation getPushMessageInformation() { | |
public void setPushMessageInformation(PushMessageInformation pushMessageInformation) { | ||
this.pushMessageInformation = pushMessageInformation; | ||
} | ||
|
||
/** | ||
* To track how many time this variant has been opened after a Push Notification | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return desc. missing |
||
* @return long , the times this variant has been opened after a Push Notification | ||
*/ | ||
public long getVariantOpenCounter() { | ||
return variantOpenCounter; | ||
} | ||
|
||
public void setVariantOpenCounter(long variantOpenCounter) { | ||
this.variantOpenCounter = variantOpenCounter; | ||
} | ||
|
||
public void incrementVariantOpenCounter() { | ||
this.setVariantOpenCounter(this.getVariantOpenCounter() + 1); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright Red Hat, Inc., and individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.aerogear.unifiedpush.dao; | ||
import org.jboss.aerogear.unifiedpush.api.VariantMetricInformation; | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's this class for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To retrieve a specific VariantMetricInformation instance, we had no dao for this entity before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. javadoc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of our DAO interfaces have Class level doc but yeah , I could add it for this one if needed. |
||
public interface VariantMetricInformationDao extends GenericBaseDao<VariantMetricInformation, String>{ | ||
|
||
/** | ||
* Finds a VariantMetricInformation instance by the related variantID | ||
* | ||
* @param variantID that is associated with the VariantMetricInformation instance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. second param missing |
||
* @param pushMessageinformationId of the @link{{org.jboss.aerogear.unifiedpush.api.PushMessageInformation}} that owns this instance | ||
* @return a VariantMetricInformation instance | ||
*/ | ||
VariantMetricInformation findVariantMetricInformationByVariantID(String variantID, String pushMessageinformationId); | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* JBoss, Home of Professional Open Source | ||
* Copyright Red Hat, Inc., and individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.jboss.aerogear.unifiedpush.jpa.dao.impl; | ||
|
||
import org.jboss.aerogear.unifiedpush.api.VariantMetricInformation; | ||
import org.jboss.aerogear.unifiedpush.dao.VariantMetricInformationDao; | ||
|
||
|
||
public class JPAVariantMetricInformationDao extends JPABaseDao<VariantMetricInformation, String> implements VariantMetricInformationDao { | ||
|
||
@Override | ||
public VariantMetricInformation findVariantMetricInformationByVariantID(String variantID, String pushmessageinformationId){ | ||
return getSingleResultForQuery(createQuery( | ||
"select vmi from VariantMetricInformation vmi where vmi.variantID = :variantId and vmi.pushMessageInformation.id = :pushmessageinformationId") | ||
.setParameter("variantId", variantID) | ||
.setParameter("pushmessageinformationId",pushmessageinformationId)); | ||
|
||
} | ||
|
||
@Override | ||
public Class<VariantMetricInformation> getType() { | ||
return VariantMetricInformation.class; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is no longer used in UI and needs to be removed in Beta1