-
Notifications
You must be signed in to change notification settings - Fork 41
Analytics module #334
Analytics module #334
Conversation
docs/_docs/modules/analytics.md
Outdated
| title: "Module: Analytics" | ||
| --- | ||
|
|
||
| {% include under-construction.html %} |
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.
Should this be here? Is it still under construction?
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.
Good catch :)
| ## Setup | ||
|
|
||
| We used the gradle template so we have much of the job already done. | ||
| All we need to to is to add the analytics module to our [runmode]({{site.baseurl}}/docs/modules/core/runmodes/) in default.yaml |
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.
Shouldn't the dependency be added to build.gradle too?
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.
Fair point. The full setup description is in the docs/_docs/modules/analytics.md so I will just link this doc here
| ```yaml | ||
| google.analytics.datalayer: [name] | ||
| ``` | ||
| The default values are defined as follows: |
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.
Does it mean that if I don't configure it then these will be the values assigned to these properties?
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.
No, it wouldn't. I will fix that
| getActual(), | ||
| JSONCompareMode.LENIENT); | ||
| } catch (JSONException e) { | ||
| e.printStackTrace(); |
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.
A newline character would be nice, because currently the error log looks like this:
Data Layer is incorrect page.country
Expected: ford-g1b
got: ford-gb
; page.pageName
Expected: braxDnd:home
got: brand:home
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.
True
mkrzyzanowski
left a comment
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.
Please check https://github.com/Cognifide/bobcat/blob/master/CONTRIBUTING.md and apply correct formatting.
bb-analytics/pom.xml
Outdated
| <dependency> | ||
| <groupId>commons-io</groupId> | ||
| <artifactId>commons-io</artifactId> | ||
| <version>2.5</version> |
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.
There's newer version available, 2.6.
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.
ok
| private static final String CFG_PATH = "analytics/datalayers/"; | ||
|
|
||
| @Inject | ||
| private WebDriver webDriver; |
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.
Since there's no other use for WebDriver itself here, Instead of injecting it and casting it to JavascriptExecutor later on, you can inject the executor itself :).
| private static final String CFG_PATH = "analytics/datalayers/"; | ||
|
|
||
| @Inject | ||
| private WebDriver webDriver; |
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.
Since there's no other use for WebDriver itself here, Instead of injecting it and casting it to JavascriptExecutor later on, you can inject the executor itself :).
| getActual(), | ||
| JSONCompareMode.LENIENT); | ||
| } catch (JSONException e) { | ||
| e.printStackTrace(); |
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.
Use logger here
| */ | ||
| package com.cognifide.qa.bb.analytics; | ||
|
|
||
| public interface Analytics { |
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.
Missing JavaDoc here
|
|
||
| /** | ||
| * Compares data layer retrieved from the page with the expected one | ||
| * @param expectedData |
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.
Describe the param more explicitly
| } catch (IOException | URISyntaxException e) { | ||
| LOG.error("Could not read JSON file: " + fileName); | ||
| } | ||
| throw new IllegalStateException("JSON file could not be read"); |
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.
This can be thrown directly in the catch clause, without logging the error (pass the initial stacktrace: IllegalStateException("...". e))
| import com.cognifide.qa.bb.modules.CoreModule; | ||
| import com.google.inject.AbstractModule; | ||
|
|
||
| public class TestModule extends AbstractModule { |
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.
Let's call this AnalyticsTestModule - we have too many test modules flying around already :)
|
|
||
| @Test | ||
| public void shouldSetDataLayerForHomepageLoad() { | ||
| webDriver.get("https://solutionpartners.adobe.com/home.html"); |
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.
Depending on external sites seems a bit risky in terms of stability - could we somehow mimic this behaviour on a dummy page locally?
|
|
||
| @Test | ||
| public void shouldSetDataLayerForHomepageLoad() { | ||
| webDriver.get("https://www.cognifide.com/"); |
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.
Same as above
Add junit dependencies to analytics module POM
Add more tests for GoogleAnalytics class
- unit tests in bb-analytics module had incorrect endlines - domain changed on the dependent test page (cognifide.github.io -> tech.cognifide.com) - we need to address it in the future ;)
- yet another change in external resource caused tests to fail - need to remove it
Description
Analytics module, which supports the Adobe Analytics and the Google Analytics solutions
Motivation and Context
In order to easily create automated analytics tests
As a team member
I want to use the dedicated Bobcat solution
Types of changes
Checklist: