Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize deviceInfo in constructor of ParselyTracker #58

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class ParselyTracker {
private static int DEFAULT_FLUSH_INTERVAL_SECS = 60;
private static int DEFAULT_ENGAGEMENT_INTERVAL_MILLIS = 10500;
protected ArrayList<Map<String, Object>> eventQueue;
private String siteId, rootUrl, storageKey, uuidKey, adKey;
private String siteId, rootUrl, storageKey, uuidKey;
private boolean isDebug;
private SharedPreferences settings;
private int queueSizeLimit, storageSizeLimit;
Expand All @@ -79,8 +79,8 @@ protected ParselyTracker(String siteId, int flushInterval, Context c) {

this.siteId = siteId;
this.uuidKey = "parsely-uuid";
this.adKey = null;
// get the adkey straight away on instantiation
this.deviceInfo = collectDeviceInfo(null);
new GetAdKey(c).execute();
this.storageKey = "parsely-events.ser";
//this.rootUrl = "http://10.0.2.2:5001/"; // emulator localhost
Expand Down Expand Up @@ -638,12 +638,12 @@ private String getSiteUuid() {
*
* Collects info about the device and user to use in Parsely events.
*/
private Map<String, String> collectDeviceInfo() {
private Map<String, String> collectDeviceInfo(@Nullable final String adKey) {
Map<String, String> dInfo = new HashMap<>();

// TODO: screen dimensions (maybe?)
PLog("adkey is: %s, uuid is %s", this.adKey, this.getSiteUuid());
String uuid = (this.adKey != null) ? this.adKey : this.getSiteUuid();
PLog("adkey is: %s, uuid is %s", adKey, this.getSiteUuid());
final String uuid = (adKey != null) ? adKey : this.getSiteUuid();
dInfo.put("parsely_site_uuid", uuid);
dInfo.put("manufacturer", android.os.Build.MANUFACTURER);
dInfo.put("os", "android");
Expand Down Expand Up @@ -755,9 +755,7 @@ protected String doInBackground(Void... params) {

@Override
protected void onPostExecute(String advertId) {
adKey = advertId;
deviceInfo = collectDeviceInfo();
deviceInfo.put("parsely_site_uuid", adKey);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (❓): Just to confirm that, why was that deleted? My guess is because it is just being a duplicate of dInfo.put("parsely_site_uuid", uuid);, right?

FYI: Because this change was included as part of this 98c1dd6 refactor commit, which was mainly about removing the adKey field, it kind of made it harder for me to understand. Although you did add this on the description, I just want to be sure of it (🤷 + 😊): It makes codebase easier to understand and eliminates multiple sources for 'parsely_site_uuid'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this code was duplicating dInfo.put("parsely_site_uuid", uuid) from collectDeviceInfo.

deviceInfo = collectDeviceInfo(advertId);
}

}
Expand Down
Loading