Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Windsor committed Dec 9, 2011
1 parent d86889b commit 5f4a4fa
Show file tree
Hide file tree
Showing 43 changed files with 4,827 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Analytics/AnalyticsExample/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/net.rim.ejde.BlackBerryVMInstallType/BlackBerry JRE 7.0.0"/>
<classpathentry exported="true" kind="lib" path="C:/Users/twindsor/Downloads/AnalyticsService_v1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
29 changes: 29 additions & 0 deletions Analytics/AnalyticsExample/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AnalyticsExample</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>net.rim.ejde.internal.builder.BlackBerryPreprocessBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.rim.ejde.internal.builder.BlackBerryResourcesBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>net.rim.ejde.BlackBerryPreProcessNature</nature>
<nature>net.rim.ejde.BlackBerryProjectCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
21 changes: 21 additions & 0 deletions Analytics/AnalyticsExample/BlackBerry_App_Descriptor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- This file has been generated by the BlackBerry Plugin for Eclipse v3.7.100. -->

<Properties ModelVersion="1.1.2">
<General Title="" Version="1.0.0" Vendor="BlackBerry Developer" Description=""/>
<Application Type="BlackBerry Application" MainMIDletName="" MainArgs="" HomeScreenPosition="0" StartupTier="7" IsSystemModule="false" IsAutostartup="false"/>
<Resources hasTitleResource="false" TitleResourceBundleName="" TitleResourceBundleRelativePath="" TitleResourceBundleClassName="" TitleResourceBundleKey="" DescriptionId="">
<Icons/>
</Resources>
<KeywordResources KeywordResourceBundleName="" KeywordResourceBundleRelativePath="" KeywordResourceBundleClassName="" KeywordResourceBundleKey=""/>
<Compile OutputCompilerMessages="false" ConvertImages="true" CreateWarningForNoExportedRoutine="true" CompressResources="false" AliasList="">
<PreprocessorDefines/>
</Compile>
<Packaging PreBuildStep="" PostBuildStep="" CleanStep="" OutputFileName="AnalyticsExample" OutputFolder="deliverables" GenerateALXFile="true">
<AlxFiles/>
</Packaging>
<HiddenProperties>
<ClassProtection/>
<PackageProtection/>
</HiddenProperties>
<AlternateEntryPoints/>
</Properties>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<loader version="1.0">
<application id="AnalyticsExample">
<name >

</name>
<description >

</description>
<version >
1.0.0
</version>
<vendor >
BlackBerry Developer
</vendor>
<copyright >
Copyright (c) 2011 BlackBerry Developer
</copyright>
<fileset Java="1.54" _blackberryVersion="[7.0.0)">
<directory >
7.0.0
</directory>
<files >
AnalyticsExample.cod

</files>

</fileset>

</application>

</loader>
82 changes: 82 additions & 0 deletions Analytics/AnalyticsExample/src/mypackage/MyApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package mypackage;

import net.rim.device.api.system.ApplicationDescriptor;
import net.rim.device.api.system.CodeModuleManager;

import com.webtrends.mobile.analytics.rim.WebtrendsConfig;
import com.webtrends.mobile.analytics.rim.WebtrendsConfigurator;
import com.webtrends.mobile.analytics.rim.WebtrendsDataCollector;
import com.webtrends.mobile.rim.WebtrendsUiApplication;

/**
* This class extends the UiApplication class, providing a graphical user
* interface.
*/
public class MyApp extends WebtrendsUiApplication {
/**
* Entry point for application
*
* @param args
* Command line arguments (not used)
*/
public static void main(String[] args) {
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}

/**
* Creates a new MyApp object
*/
public MyApp() {
WebtrendsConfigurator.LoadConfigFile(new AnalyticsConfig());
WebtrendsDataCollector wtDC = WebtrendsDataCollector.getInstance();
wtDC.Initialize();
// Push a screen onto the UI stack for rendering.
pushScreen(new MyScreen());
}

private class AnalyticsConfig extends WebtrendsConfig {

public String wt_dc_app_name() {
return ApplicationDescriptor.currentApplicationDescriptor().getName();
}

public String wt_dc_app_version() {
return ApplicationDescriptor.currentApplicationDescriptor().getVersion();
}

public String wt_dc_dcsid() {
return "dcssp2rzw5bv0hk35mx7god5y_7f8z"; // Analytics Demo
}

public String wt_dc_timezone() {
return "-5";
}

public String wt_dc_app_category() {
return "Utilities";
}

public String wt_dc_app_publisher() {
return CodeModuleManager.getModuleVendor(ApplicationDescriptor.currentApplicationDescriptor().getModuleHandle());
}
}
}
166 changes: 166 additions & 0 deletions Analytics/AnalyticsExample/src/mypackage/MyScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* Copyright (c) 2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package mypackage;

import com.webtrends.mobile.analytics.IllegalWebtrendsParameterValueException;
import com.webtrends.mobile.analytics.rim.WebtrendsDataCollector;

import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.container.MainScreen;

/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen {
/**
* Creates a new MyScreen object
*/
public MyScreen() {
// Set the displayed title of the screen
setTitle("Analytics Example");

addMenuItem(new SendAnalyticsEvent("AdClickEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onAdClickEvent("/mainscreen", "Main Screen", "menu", null, "Demo Ad");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("AdImpressionEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onAdImpressionEvent("/mainscreen", "Main Screen", "menu", null,
new String[] { "Demo Ad 1", "Demo Ad 2" });
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("ButtonClick", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onButtonClick("/mainscreen", "Main Screen", "menu", null);
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("ScreenView", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onScreenView("/mainscreen", "Main Screen", "menu", null, "Demo Content");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("ConversionEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onConversionEvent("/mainscreen", "Main Screen", "menu", null, "Demo Content",
"Conversion Demo");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("CustomEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onCustomEvent("/mainscreen", "Main Screen", null);
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("MediaEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onMediaEvent("/mainscreen", "Main Screen", "menu", null, "Media Content", "Demo Media",
"music", "p");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("ProductView", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onProductView("/mainscreen", "Main Screen", "menu", null, "Products", "item1", "SKU00001");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

addMenuItem(new SendAnalyticsEvent("SearchEvent", new Runnable() {

public void run() {
try {
WebtrendsDataCollector.getInstance().onSearchEvent("/mainscreen", "Main Screen", "menu", null, "demo search", "demo results");
} catch (IllegalWebtrendsParameterValueException e) {
System.out.println(e.toString());
}
}
}));

}

public boolean onClose() {
try {
WebtrendsDataCollector.getInstance().onApplicationTerminate("Application Terminate", null);
} catch (IllegalWebtrendsParameterValueException err) {
WebtrendsDataCollector.getLog().e(err.getMessage());
}
System.exit(0);
return true;
}

private class SendAnalyticsEvent extends MenuItem {

private Runnable action;

public SendAnalyticsEvent(String text, Runnable action) {
super(text, 100, 100);
this.action = action;
}

public void run() {
action.run();
}

}

}
39 changes: 39 additions & 0 deletions Analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# BlackBerry Analytics Sample

This is the same sample application that is included in the Analytics SDK package. It is open sourced here so that it can be extended and used by the community.

The sample code for this application is Open Source under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).

**Applies To**

* [BlackBerry Java SDK for Smartphones](http://us.blackberry.com/developers/javaappdev/)


**Author(s)**

* [Tim Windsor](https://github.com/timwindsor)


**Dependencies**

1. BlackBerry Java SDK 4.5.0 or higher required.
2. BlackBerry Analytics SDK 1.0 or higher required.



**To contribute code to this repository you must be [signed up as an official contributor](http://blackberry.github.com/howToContribute.html).**


## Contributing Changes

Please see the [README](https://github.com/blackberry/BlackBerry-Java) of the BlackBerry-Java repository for instructions on how to add new Samples or make modifications to existing Samples.


## Bug Reporting and Feature Requests

If you find a bug in a Sample, or have an enhancement request, simply file an [Issue](https://github.com/blackberry/BlackBerry-Java/issues) for the Sample and send a message (via github messages) to the Sample Author(s) to let them know that you have filed an [Issue](https://github.com/blackberry/BlackBerry-Java/issues).


## Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Empty file removed README
Empty file.
Loading

0 comments on commit 5f4a4fa

Please sign in to comment.