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

Scala Stream Collector: add URL redirect replacement macro #3491

Closed

Conversation

rbolkey
Copy link
Contributor

@rbolkey rbolkey commented Nov 1, 2017

Updates the Scala Stream Collector to look for a replacement macro in the redirect url in order to support cookie syncing with third parties.

Currently, the macro placeholder is hard coded to ${SP_UUID}. I image this feature could be enabled through the config and the placeholder parameterized, if this is desirable.

@alexanderdean

@snowplowcla
Copy link

Thanks for your pull request. Is this your first contribution to a Snowplow open source project? Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://github.com/snowplow/snowplow/wiki/CLA to learn more and sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@@ -231,7 +231,9 @@ class CollectorService(
queryParams: Map[String, String]
): (HttpResponse, List[Array[Byte]]) =
queryParams.get("u") match {
case Some(target) => (HttpResponse(StatusCodes.Found).withHeaders(`Location`(target)), Nil)
case Some(target) =>
val replacedTarget = if (event.isSetNetworkUserId) target.replaceAllLiterally("${SP_UUID}", event.networkUserId) else target
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make ${SP_UUID} configurable?

event.networkUserId = "1234"
val (res, Nil) = service.buildRedirectHttpResponse(event, "k", Map("u" -> "http://localhost/?uid=${SP_UUID}"))
res shouldEqual HttpResponse(302).withHeaders(`Location`("http://localhost/?uid=1234"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

could you move this test to https://github.com/snowplow/snowplow/pull/3491/files#diff-88f19e201a23cbae2294497905a6b8a1R201 , you can make a local copy of the event if there are issues with setting the networkUserId

@BenFradet BenFradet self-assigned this Nov 2, 2017
@rbolkey
Copy link
Contributor Author

rbolkey commented Nov 2, 2017

@BenFradet I made the suggested changes, and updated the documentation.

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

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

Looks great, scheduling 👍

@BenFradet BenFradet added this to the R9x [STR] Priority fixes milestone Nov 3, 2017
@christoph-buente
Copy link
Contributor

That fit's really nicely to my issue https://github.com/snowplow/snowplow/issues/2491

Thanks!

@alexanderdean
Copy link
Member

alexanderdean commented Dec 1, 2017

Hmm, reading @christoph-buente's issue, the default placeholder here really ought to be ${SP_NUID}.

@christoph-buente
Copy link
Contributor

@alexanderdean yes, whatever it might be, i care more about the possibility to do it at all. As @rbolkey pointed out, it is needed to implement some sort of cookie sync.

@rbolkey
Copy link
Contributor Author

rbolkey commented Dec 1, 2017

No issue changing the default. I wasn't distinguishing between the different types of identities that snowplow recognizes. The original value was simply what we've been using in production.

@rbolkey rbolkey force-pushed the onespot-cookie-replacement-macro branch from e9bc569 to 71937bb Compare December 1, 2017 21:34
@rbolkey
Copy link
Contributor Author

rbolkey commented Dec 1, 2017

I updated the default token value, and rebased off master.

@alexanderdean
Copy link
Member

Thanks @rbolkey !

@BenFradet BenFradet changed the title [Stream Collector] URL redirect replacement macro Scala Stream Collector: add URL redirect replacement macro Dec 14, 2017
@BenFradet BenFradet added cla:yes and removed cla:no labels Dec 15, 2017
@BenFradet BenFradet closed this in c04f42d Jan 5, 2018
lukeindykiewicz pushed a commit to snowplow/stream-collector that referenced this pull request Jun 4, 2020
lukeindykiewicz pushed a commit to snowplow/stream-collector that referenced this pull request Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants