-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support siteId
per tracking request
#116
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3fd2009
chore: move internal classes to `internal` package
wzieba 329735f
feat: introduce `SiteIdSource` and allow SDK users to provide custom …
wzieba 3c1e4d0
tests: provide unit tests for building events with custom `sideId` pe…
wzieba e4d96e7
tests: add functional test for "custom site id in engagement session"
wzieba 7f2782e
feat: log json payload in dry run
wzieba 2273370
feat: add edit text for testing custom site id in `example/MainActivity`
wzieba 306635d
revert: adding `internal` package
wzieba f4bb8a2
build: update parsely.api dump
wzieba 68eec00
docs: add Javadoc parameter comments for `buildEvent`
wzieba 9af20d9
docs: extend comment for `siteIdSource` parameter
wzieba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package com.parsely.parselyandroid | ||
|
||
import com.parsely.parselyandroid.Logging.log | ||
import java.util.Calendar | ||
import java.util.TimeZone | ||
|
||
internal class EventsBuilder( | ||
private val deviceInfoRepository: DeviceInfoRepository, | ||
private val siteId: String, | ||
private val initializationSiteId: String, | ||
private val clock: Clock, | ||
) { | ||
/** | ||
|
@@ -16,6 +14,8 @@ internal class EventsBuilder( | |
* @param action Action to use (e.g. pageview, heartbeat, videostart, vheartbeat) | ||
* @param metadata Metadata to attach to the event. | ||
* @param extraData A Map of additional information to send with the event. | ||
* @param uuid A unique identifier for the event. | ||
* @param siteIdSource The source of the site ID to use for the event. | ||
* @return A Map object representing the event to be sent to Parse.ly. | ||
*/ | ||
fun buildEvent( | ||
|
@@ -24,15 +24,19 @@ internal class EventsBuilder( | |
action: String, | ||
metadata: ParselyMetadata?, | ||
extraData: Map<String, Any>?, | ||
uuid: String | ||
uuid: String, | ||
siteIdSource: SiteIdSource, | ||
Comment on lines
+27
to
+28
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. Parameter docs for these two are missing. |
||
): Map<String, Any> { | ||
log("buildEvent called for %s/%s", action, url) | ||
|
||
// Main event info | ||
val event: MutableMap<String, Any> = HashMap() | ||
event["url"] = url | ||
event["urlref"] = urlRef | ||
event["idsite"] = siteId | ||
event["idsite"] = when (siteIdSource) { | ||
is SiteIdSource.Default -> initializationSiteId | ||
is SiteIdSource.Custom -> siteIdSource.siteId | ||
} | ||
event["action"] = action | ||
|
||
// Make a copy of extraData and add some things. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
parsely/src/main/java/com/parsely/parselyandroid/SiteIdSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.parsely.parselyandroid | ||
|
||
/** | ||
* Configuration for the site ID to be used for an event. | ||
*/ | ||
public sealed class SiteIdSource { | ||
/** | ||
* Instruct SDK to use site ID provided during [ParselyTracker.init]. | ||
*/ | ||
public data object Default : SiteIdSource() | ||
|
||
/** | ||
* Instruct SDK to override the site ID for the event. | ||
* | ||
* @param siteId The Parsely public site ID (e.g. "example.com") to use for the event. | ||
*/ | ||
public data class Custom(val siteId: String) : SiteIdSource() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I wonder if
ParselyTracker.init()
shouldn't also receive aSiteIdSource
🤔Are there reasons not to?
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.
Because we need some site id to be defined. If
ParselyTracker.init()
receivedSiteIdSource
, then API consumer could passSiteIdSource.Default
, which would have to be supported and it's not a valid state.Alternatively, we could make
ParselyTracker.init()
receiveSiteIdSource.Custom
, but I think it only shadows implementation and causes confusion as it can raise a question: "custom" to what? InParselyTracker.trackPageview
it's "custom" to the value provided in initialization, so it makes sense there.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.
Got it! Makes sense 👍