Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge #5932
Browse files Browse the repository at this point in the history
5932: Closes #5929: Emit facts during migration r=pocmo a=jonalmeida



Co-authored-by: Jonathan Almeida <jalmeida@mozilla.com>
  • Loading branch information
MozLando and jonalmeida committed Feb 14, 2020
2 parents 1a11c13 + 30c5b41 commit fc8f636
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ abstract class AbstractMigrationService : Service() {
private fun shutdown() {
store.dispatch(MigrationAction.Completed)

emitCompletedFact()

stopForeground(true)

showMigrationCompleteNotification()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ class FennecMigrator private constructor(
store.dispatch(MigrationAction.Started).join()
}
ContextCompat.startForegroundService(context, Intent(context, service))

emitStartedFact()
}

private fun getMigrationsToRun(): List<VersionedMigration> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* 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 mozilla.components.support.migration

import mozilla.components.support.base.Component
import mozilla.components.support.base.facts.Action
import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.facts.collect

/**
* Facts emitted for telemetry related to migration.
*/
class MigrationFacts {

/**
* Items that specify which portion of the migration was invoked.
*/
object Items {
const val MIGRATION_COMPLETED = "migration_completed"
const val MIGRATION_STARTED = "migration_started"
}
}

private fun emitMigrationFact(
action: Action,
item: String
) {
Fact(
Component.SUPPORT_MIGRATION,
action,
item
).collect()
}

internal fun emitCompletedFact() = emitMigrationFact(Action.INTERACTION, MigrationFacts.Items.MIGRATION_COMPLETED)
internal fun emitStartedFact() = emitMigrationFact(Action.INTERACTION, MigrationFacts.Items.MIGRATION_STARTED)
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ permalink: /changelog/
* **feature-awesomebar**
* Added `showDescription` parameter (default to `true`) to `SearchSuggestionProvider` constructors to add the possibility of removing search suggestion description.

* **support-migration**
* Emit facts during migration.

# 31.0.0

* [Commits](https://github.com/mozilla-mobile/android-components/compare/v30.0.0...v31.0.0)
Expand Down

0 comments on commit fc8f636

Please sign in to comment.