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

Update guide from v1.0.2 to v2.0 of the SDK #161

Closed
PattaFeuFeu opened this issue May 8, 2017 · 7 comments
Closed

Update guide from v1.0.2 to v2.0 of the SDK #161

PattaFeuFeu opened this issue May 8, 2017 · 7 comments

Comments

@PattaFeuFeu
Copy link

Is there any resource that guides through the changes that occurred during the version upgrade from v1 to v2 of the SDK?
Changes like “TrackHelper can now be found under sdk.extra instead of sdk”, “Instead of ‘setOptOut’, please use XY now”, and so on?

@d4rken
Copy link
Member

d4rken commented May 8, 2017

Unfortunately not.

Could write one and we'll add it to the wiki?

@PattaFeuFeu
Copy link
Author

At the moment, I don’t have the time to write an article on that matter. But I could write down a few lines underneath this ticket with findings I obtained along the way while updating from 1.0.2 to 2.0.

@PattaFeuFeu
Copy link
Author

PattaFeuFeu commented May 8, 2017

Update guide 1.0 --> 2.0

Gradle

Update from

compile 'org.piwik.sdk:piwik-sdk:1.0.2'

to

compile 'org.piwik.sdk:piwik-sdk:2.0.0'

Classes that moved

TrackHelper

TrackHelper moved from org.piwik.sdk to org.piwik.sdk.extra --- the new fully qualified name therefore becomes org.piwik.sdk.extra.TrackHelper

Methods that changed

Creation of a new tracker

Previously, you could add a new tracker by calling Piwik.newTracker(String piwikUrl, int siteId).

Now, you need to create a new TrackerConfig which you then supply to the method, like so:

Piwik.newTracker(new TrackerConfig("https://piwik.example.com", "4223", "DEFAULT_TRACKER"));

A createDefault(String piwikUrl, int siteId) method is available so that no tracker name has to be supplied. This shortens the previous call to:

Piwik.newTracker(TrackerConfig.createDefault("https://piwik.example.com", "4223"));

See: #157

CustomVariables

CustomVariables have been deprecated.
See #148 (comment)

Dry run (e.g. sandbox builds, debug mode)

Instead of setting a flag on the Piwik instance by calling Piwik.getInstance(this).setDryRun(true)to enable dry run, you now supply your own list data structure to which the tracking calls are saved instead of being sent.

For example, use: piwikTracker.setDryRunTarget(debugBuild ? new ArrayList<Packet>() : null);

See: https://github.com/piwik/piwik-sdk-android/blob/master/piwik-sdk/src/main/java/org/piwik/sdk/Tracker.java#L542

Opt-out

The method for opting out moved from the Piwik class to the Tracker class.

Therefore, e.g. piwikTracker.getPiwik().setOptOut(true) becomes piwikTracker.setOptOut(true)

@PattaFeuFeu
Copy link
Author

PattaFeuFeu commented May 8, 2017

What happened to setDryRun(boolean)? I cannot seem to find it.

@d4rken
Copy link
Member

d4rken commented May 8, 2017

@PattaFeuFeu
Copy link
Author

I updated my “wiki” comment with all changes I found when updating my codebase. Feel free to add additional pieces of information and also to add my findings to the wiki.

@d4rken
Copy link
Member

d4rken commented May 8, 2017

@d4rken d4rken closed this as completed May 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants