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

Add optional pageType parameter to ParselyMetadata class in Android SDK #103

Open
wants to merge 5 commits into
base: release/3.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions example/src/main/java/com/example/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void trackPlay(View view) {
"http://example.com/thumbs/video-1234",
"Awesome Video #1234",
Calendar.getInstance(),
"post",
90
);
// NOTE: For videos embedded in an article, "url" should be the URL for that article.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public class ParselyMetadata {
public ArrayList<String> authors, tags;
public String link, section, thumbUrl, title;
public String link, section, thumbUrl, title, pageType;
public Calendar pubDate;

/**
Expand All @@ -30,6 +30,7 @@ public class ParselyMetadata {
* @param thumbUrl URL at which the main image for this content is located.
* @param title The title of the content.
* @param pubDate The date this piece of content was published.
* @param pageType The type of page being tracked.
*/
public ParselyMetadata(
@Nullable ArrayList<String> authors,
Expand All @@ -38,7 +39,8 @@ public ParselyMetadata(
@Nullable ArrayList<String> tags,
@Nullable String thumbUrl,
@Nullable String title,
@Nullable Calendar pubDate
@Nullable Calendar pubDate,
@Nullable String pageType
Comment on lines +42 to +43
Copy link
Collaborator

Choose a reason for hiding this comment

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

hi @MartinAkram 👋 Instead of modifying the constructor, can we add a new one? This way we won't introduce a breaking change for the clients. Something like in this commit 8996f50

) {
this.authors = authors;
this.link = link;
Expand All @@ -47,6 +49,7 @@ public ParselyMetadata(
this.thumbUrl = thumbUrl;
this.title = title;
this.pubDate = pubDate;
this.pageType = pageType;
}

/**
Expand Down Expand Up @@ -77,6 +80,9 @@ public Map<String, Object> toMap() {
if (this.pubDate != null) {
output.put("pub_date_tmsp", this.pubDate.getTimeInMillis() / 1000);
}
if (this.pageType != null) {
output.put("page_type", this.pageType);
}
return output;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public ParselyVideoMetadata(
@Nullable String thumbUrl,
@Nullable String title,
@Nullable Calendar pubDate,
@Nullable String pageType,
@NonNull int durationSeconds
) {
super(authors, videoId, section, tags, thumbUrl, title, pubDate);
super(authors, videoId, section, tags, thumbUrl, title, pubDate, pageType);
if (videoId == null) {
throw new NullPointerException("videoId cannot be null");
}
Expand Down