Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics): Legacy data migration of Pinpoint Endpoint ID (#2489)
Co-authored-by: dnys1, Jordan-Nelson Automatically migrate legacy pinpoint endpoint id from Amplify Android and iOS native storage.
- Loading branch information
Showing
34 changed files
with
651 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled. | ||
|
||
version: | ||
revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
channel: stable | ||
|
||
project_type: plugin | ||
|
||
# Tracks metadata for the flutter migrate command | ||
migration: | ||
platforms: | ||
- platform: root | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: android | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: ios | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: linux | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: macos | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: web | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
- platform: windows | ||
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 | ||
|
||
# User provided section | ||
|
||
# List of Local paths (relative to this file) that should be | ||
# ignored by the migrate tool. | ||
# | ||
# Files that are not part of the templates will be ignored by default. | ||
unmanaged_files: | ||
- 'lib/main.dart' | ||
- 'ios/Runner.xcodeproj/project.pbxproj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.PHONY: pigeons | ||
pigeons: | ||
flutter pub run pigeon --input pigeons/pigeon_config_android.dart | ||
flutter format --fix lib/src/legacy_native_data_provider/pigeon_legacy_data_provider.android.g.dart |
6 changes: 4 additions & 2 deletions
6
packages/analytics/amplify_analytics_pinpoint/analysis_options.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
include: package:amplify_lints/library.yaml | ||
|
||
analyzer: | ||
analyzer: | ||
errors: | ||
implementation_imports: error #TODO(equartey): Remove when lint is enforced project-wide | ||
implementation_imports: error #TODO(equartey): Remove when lint is enforced project-wide | ||
exclude: | ||
- "**/*.g.dart" |
8 changes: 8 additions & 0 deletions
8
packages/analytics/amplify_analytics_pinpoint/android/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
51 changes: 51 additions & 0 deletions
51
packages/analytics/amplify_analytics_pinpoint/android/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
group 'com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
ext.kotlin_version = '1.6.10' | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:7.1.3' | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
rootProject.allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 33 | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
|
||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion 23 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
packages/analytics/amplify_analytics_pinpoint/android/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = 'amplify_analytics_pinpoint' |
3 changes: 3 additions & 0 deletions
3
packages/analytics/amplify_analytics_pinpoint/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint"> | ||
</manifest> |
85 changes: 85 additions & 0 deletions
85
...com/amazonaws/amplify/amplify_analytics_pinpoint/amplify_analytics_pinpoint/Messages.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
...y/amplify_analytics_pinpoint/amplify_analytics_pinpoint/AmplifyAnalyticsPinpointPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint | ||
|
||
import android.content.Context | ||
import android.content.SharedPreferences | ||
import androidx.annotation.NonNull | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
|
||
class AmplifyAnalyticsPinpointPlugin: FlutterPlugin, Messages.PigeonLegacyDataProvider { | ||
|
||
private var context: Context? = null | ||
private var sharedPrefs: SharedPreferences? = null | ||
|
||
companion object { | ||
private const val PINPOINT_SHARED_PREFS_SUFFIX = "515d6767-01b7-49e5-8273-c8d11b0f331d" | ||
private const val UNIQUE_ID_KEY = "UniqueId"; | ||
} | ||
|
||
override fun onAttachedToEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
context = binding.applicationContext | ||
Messages.PigeonLegacyDataProvider.setup(binding.binaryMessenger, this) | ||
} | ||
|
||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
Messages.PigeonLegacyDataProvider.setup(binding.binaryMessenger, null) | ||
context = null | ||
} | ||
|
||
override fun getEndpointId(pinpointAppId: String, result: Messages.Result<String?>){ | ||
if (context == null) { | ||
result.error(Exception("Application context is null")) | ||
return | ||
} | ||
sharedPrefs = sharedPrefs ?: context!!.getSharedPreferences( | ||
"${pinpointAppId}$PINPOINT_SHARED_PREFS_SUFFIX", | ||
Context.MODE_PRIVATE | ||
) | ||
result.success(sharedPrefs!!.getString(UNIQUE_ID_KEY, null)) | ||
} | ||
|
||
} |
14 changes: 2 additions & 12 deletions
14
...ytics/amplify_analytics_pinpoint/example/integration_test/auto_session_tracking_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 2 additions & 12 deletions
14
...es/analytics/amplify_analytics_pinpoint/example/integration_test/enable_disable_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 2 additions & 12 deletions
14
...ges/analytics/amplify_analytics_pinpoint/example/integration_test/identify_user_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
...ytics/amplify_analytics_pinpoint/example/integration_test/utils/mock_key_value_store.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 2 additions & 12 deletions
14
...cs/amplify_analytics_pinpoint/example/integration_test/utils/mock_lifecycle_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
packages/analytics/amplify_analytics_pinpoint/example/integration_test/utils/test_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.