-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.1.2' into production
- Loading branch information
Showing
20 changed files
with
214 additions
and
13 deletions.
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
35 changes: 35 additions & 0 deletions
35
...main/java/org/royllo/explorer/core/util/parameters/RoylloExplorerAnalyticsParameters.java
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,35 @@ | ||
package org.royllo.explorer.core.util.parameters; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.validation.annotation.Validated; | ||
|
||
/** | ||
* Royllo explorer analytics parameters. | ||
*/ | ||
@Validated | ||
@Getter | ||
@Setter | ||
@ToString | ||
@ConfigurationProperties(prefix = "royllo.explorer.analytics") | ||
public class RoylloExplorerAnalyticsParameters { | ||
|
||
/** Piwik analytics. */ | ||
private Piwik piwik = new Piwik(); | ||
|
||
/** Piwik parameters. */ | ||
@Validated | ||
@Getter | ||
@Setter | ||
@ToString | ||
@ConfigurationProperties(prefix = "piwik") | ||
public static class Piwik { | ||
|
||
/** Piwik tracking id. */ | ||
private String trackingId; | ||
|
||
} | ||
|
||
} |
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
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
40 changes: 40 additions & 0 deletions
40
.../explorer-web/src/main/resources/templates/util/fragments/components/analytics_piwik.html
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,40 @@ | ||
<script type="text/javascript"> | ||
/*<![CDATA[*/ | ||
(function (window, document, dataLayerName, id) { | ||
window[dataLayerName] = window[dataLayerName] || [], window[dataLayerName].push({ | ||
start: (new Date).getTime(), | ||
event: "stg.start" | ||
}); | ||
var scripts = document.getElementsByTagName('script')[0], tags = document.createElement('script'); | ||
|
||
function stgCreateCookie(a, b, c) { | ||
var d = ""; | ||
if (c) { | ||
var e = new Date; | ||
e.setTime(e.getTime() + 24 * c * 60 * 60 * 1e3), d = "; expires=" + e.toUTCString(); | ||
f = "; SameSite=Strict" | ||
} | ||
document.cookie = a + "=" + b + d + f + "; path=/" | ||
} | ||
|
||
var isStgDebug = (window.location.href.match("stg_debug") || document.cookie.match("stg_debug")) && !window.location.href.match("stg_disable_debug"); | ||
stgCreateCookie("stg_debug", isStgDebug ? 1 : "", isStgDebug ? 14 : -1); | ||
var qP = []; | ||
dataLayerName !== "dataLayer" && qP.push("data_layer_name=" + dataLayerName), isStgDebug && qP.push("stg_debug"); | ||
var qPString = qP.length > 0 ? ("?" + qP.join("&")) : ""; | ||
tags.async = !0, tags.src = "https://royllo.containers.piwik.pro/" + id + ".js" + qPString, scripts.parentNode.insertBefore(tags, scripts); | ||
!function (a, n, i) { | ||
a[n] = a[n] || {}; | ||
for (var c = 0; c < i.length; c++) !function (i) { | ||
a[n][i] = a[n][i] || {}, a[n][i].api = a[n][i].api || function () { | ||
var a = [].slice.call(arguments, 0); | ||
"string" == typeof a[0] && window[dataLayerName].push({ | ||
event: n + "." + i + ":" + a[0], | ||
parameters: [].slice.call(arguments, 1) | ||
}) | ||
} | ||
}(i[c]) | ||
}(window, "ppms", ["tm", "cm"]); | ||
})(window, document, 'dataLayer', '[[${piwikAnalyticsTrackingId}]]'); | ||
/*]]>*/ | ||
</script> |
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
43 changes: 43 additions & 0 deletions
43
...r-web/src/test/java/org/royllo/explorer/web/test/controllers/util/AnalyticsPiwikTest.java
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,43 @@ | ||
package org.royllo.explorer.web.test.controllers.util; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.royllo.test.TapdData.ROYLLO_COIN_ASSET_ID; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@SpringBootTest | ||
@DirtiesContext | ||
@DisplayName("Analytics - Piwik tests") | ||
@AutoConfigureMockMvc | ||
@TestPropertySource(properties = {"royllo.explorer.analytics.piwik.trackingId=00000000-0000-0000-0000-000000000001"}) | ||
public class AnalyticsPiwikTest { | ||
|
||
@Autowired | ||
MockMvc mockMvc; | ||
|
||
@Test | ||
@DisplayName("Piwik configured") | ||
void piwikConfigured() throws Exception { | ||
|
||
// We test on each layout (home, asset). | ||
mockMvc.perform(get("/")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(containsString("(window, document, 'dataLayer', '00000000-0000-0000-0000-000000000001');"))); | ||
|
||
mockMvc.perform(get("/asset/" + ROYLLO_COIN_ASSET_ID)) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(containsString("(window, document, 'dataLayer', '00000000-0000-0000-0000-000000000001');"))); | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...orer-web/src/test/java/org/royllo/explorer/web/test/controllers/util/NoAnalyticsTest.java
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,44 @@ | ||
package org.royllo.explorer.web.test.controllers.util; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.royllo.test.TapdData.ROYLLO_COIN_ASSET_ID; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@SpringBootTest | ||
@DirtiesContext | ||
@DisplayName("Analytics - no analytics tests") | ||
@AutoConfigureMockMvc | ||
@TestPropertySource(properties = {"royllo.explorer.analytics.piwik.trackingId="}) | ||
public class NoAnalyticsTest { | ||
|
||
@Autowired | ||
MockMvc mockMvc; | ||
|
||
@Test | ||
@DisplayName("No analytics configured") | ||
void noAnalyticsConfigured() throws Exception { | ||
|
||
// We test on each layout (home, asset). | ||
mockMvc.perform(get("/")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(not(containsString("(window, document, 'dataLayer'")))); | ||
|
||
mockMvc.perform(get("/asset/" + ROYLLO_COIN_ASSET_ID)) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().string(not(containsString("(window, document, 'dataLayer'")))); | ||
|
||
} | ||
|
||
} |
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