Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
ab6eb462
Commit
ab6eb462
authored
Feb 01, 2019
by
Michael Droettboom
Committed by
Alessio Placitelli
Feb 08, 2019
Browse files
1505395: Add a third-party test library to samples-glean
parent
b83fae2c
Changes
8
Hide whitespace changes
Inline
Side-by-side
.buildconfig.yml
View file @
ab6eb462
...
...
@@ -252,6 +252,10 @@ projects:
path
:
samples/glean
description
:
'
An
app
demoing
how
to
use
the
Glean
library
to
collect
and
send
telemetry
data.'
publish
:
false
samples-glean-library
:
path
:
samples/glean/samples-glean-library
description
:
'
A
third-party
library
used
by
samples-glean
to
demonstrate
multi-library
support
for
Glean.'
publish
:
false
samples-sync-history
:
path
:
samples/sync-history
description
:
'
A
simple
app
demoing
Firefox
Sync
(History)
integration.'
...
...
samples/glean/build.gradle
View file @
ab6eb462
...
...
@@ -40,6 +40,8 @@ dependencies {
implementation
Dependencies
.
support_appcompat
implementation
Dependencies
.
support_customtabs
implementation
project
(
':samples-glean-library'
)
}
apply
from:
'../../components/service/glean/scripts/sdk_generator.gradle'
samples/glean/samples-glean-library/README.md
0 → 100644
View file @
ab6eb462
samples_glean_library is a toy library that uses glean to record metrics. It
exists simply to show how libraries that are neither the application or glean
itself can record metrics, and those metrics will be stored and sent as part of
the
[
main pings
](
../../../components/service/glean/docs/pings.md
)
that glean
provides.
samples/glean/samples-glean-library/build.gradle
0 → 100644
View file @
ab6eb462
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
plugins
{
id
"com.jetbrains.python.envs"
version
"0.0.26"
}
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
android
{
compileSdkVersion
config
.
compileSdkVersion
defaultConfig
{
minSdkVersion
config
.
minSdkVersion
targetSdkVersion
config
.
targetSdkVersion
}
buildTypes
{
release
{
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
dependencies
{
implementation
Dependencies
.
kotlin_stdlib
implementation
project
(
':service-glean'
)
}
apply
from:
'../../../components/service/glean/scripts/sdk_generator.gradle'
samples/glean/samples-glean-library/metrics.yaml
0 → 100644
View file @
ab6eb462
# This file defines the metrics that are recorded by glean telemetry. They are
# automatically converted to Kotlin code at build time using the `glean_parser`
# PyPI package.
$schema
:
moz://mozilla.org/schemas/glean/metrics/1-0-0
sample_metrics
:
test
:
type
:
counter
description
:
>
A simple counter defined in a third-party library
send_in_pings
:
-
baseline
bugs
:
-
123456789
data_reviews
:
-
N/A
notification_emails
:
-
telemetry-client-dev@mozilla.com
samples/glean/samples-glean-library/src/main/AndroidManifest.xml
0 → 100644
View file @
ab6eb462
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"mozilla.samples.glean.library"
/>
samples/glean/samples-glean-library/src/main/java/org/mozilla/samples/glean/library/SamplesGleanLibrary.kt
0 → 100644
View file @
ab6eb462
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package
org.mozilla.samples.glean.library
import
mozilla.samples.glean.library.GleanMetrics.SampleMetrics
import
mozilla.components.service.glean.Glean
/**
* These are just simple functions to test calling the Glean API
* from a third-party library.
*/
object
SamplesGleanLibrary
{
/**
* Record to a metric defined in *this* library's metrics.yaml file.
*/
fun
recordMetric
()
{
SampleMetrics
.
test
.
add
()
}
/**
* Notate an active experiment.
*/
fun
recordExperiment
()
{
Glean
.
setExperimentActive
(
"third_party_library"
,
"enabled"
)
}
}
samples/glean/src/main/java/org/mozilla/samples/glean/MainActivity.kt
View file @
ab6eb462
...
...
@@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.activity_main.*
import
mozilla.components.service.glean.Glean
import
org.mozilla.samples.glean.GleanMetrics.Test
import
org.mozilla.samples.glean.GleanMetrics.BrowserEngagement
import
org.mozilla.samples.glean.library.SamplesGleanLibrary
open
class
MainActivity
:
AppCompatActivity
()
{
...
...
@@ -51,5 +52,9 @@ open class MainActivity : AppCompatActivity() {
}
Test
.
testTimespan
.
stopAndSum
()
// Update some metrics from a third-party library
SamplesGleanLibrary
.
recordMetric
()
SamplesGleanLibrary
.
recordExperiment
()
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment