Skip to content

Commit 5b12a78

Browse files
committed
chore(analytics): migrate legacy data
Extract endpoint id from Amplify iOS and Android Analytics
1 parent b9d6d08 commit 5b12a78

35 files changed

+1051
-9
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
8+
channel: stable
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
17+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
18+
- platform: android
19+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
20+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
21+
- platform: ios
22+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
23+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
24+
- platform: linux
25+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
26+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
27+
- platform: macos
28+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
29+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
30+
- platform: web
31+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
32+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
33+
- platform: windows
34+
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
35+
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
36+
37+
# User provided section
38+
39+
# List of Local paths (relative to this file) that should be
40+
# ignored by the migrate tool.
41+
#
42+
# Files that are not part of the templates will be ignored by default.
43+
unmanaged_files:
44+
- 'lib/main.dart'
45+
- 'ios/Runner.xcodeproj/project.pbxproj'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:amplify_lints/library.yaml
2+
3+
analyzer:
4+
exclude:
5+
- "**/**/**/*.g.dart"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
group 'com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint'
2+
version '1.0-SNAPSHOT'
3+
4+
buildscript {
5+
ext.kotlin_version = '1.6.10'
6+
repositories {
7+
google()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
classpath 'com.android.tools.build:gradle:7.1.3'
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
}
15+
}
16+
17+
rootProject.allprojects {
18+
repositories {
19+
google()
20+
mavenCentral()
21+
}
22+
}
23+
24+
apply plugin: 'com.android.library'
25+
apply plugin: 'kotlin-android'
26+
27+
android {
28+
compileSdkVersion 33
29+
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
35+
kotlinOptions {
36+
jvmTarget = '1.8'
37+
}
38+
39+
sourceSets {
40+
main.java.srcDirs += 'src/main/kotlin'
41+
}
42+
43+
defaultConfig {
44+
minSdkVersion 23
45+
}
46+
}
47+
48+
dependencies {
49+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
50+
implementation 'androidx.security:security-crypto:1.0.0'
51+
}
52+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'amplify_analytics_pinpoint'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint">
3+
</manifest>

packages/analytics/amplify_analytics_pinpoint/android/src/main/java/com/amazonaws/amplify/amplify_analytics_pinpoint/amplify_analytics_pinpoint/Messages.java

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
package com.amazonaws.amplify.amplify_analytics_pinpoint.amplify_analytics_pinpoint
3+
4+
import android.content.Context
5+
import android.content.SharedPreferences
6+
import androidx.annotation.NonNull
7+
import io.flutter.embedding.engine.plugins.FlutterPlugin
8+
9+
class AmplifyAnalyticsPinpointPlugin: FlutterPlugin, Messages.PigeonDataProvider {
10+
11+
lateinit var context: Context
12+
lateinit var sharedPrefs: SharedPreferences
13+
14+
companion object {
15+
private const val PINPOINT_SHARED_PREFS_SUFFIX = "515d6767-01b7-49e5-8273-c8d11b0f331d"
16+
private const val UNIQUE_ID_KEY = "UniqueId";
17+
}
18+
19+
override fun onAttachedToEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
20+
context = binding.applicationContext
21+
Messages.PigeonDataProvider.setup(binding.binaryMessenger, this)
22+
}
23+
24+
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
25+
Messages.PigeonDataProvider.setup(binding.binaryMessenger, null)
26+
}
27+
28+
override fun initialize(pinpointAppId: String, result: Messages.Result<Void>){
29+
sharedPrefs = context.getSharedPreferences(
30+
"${pinpointAppId}$PINPOINT_SHARED_PREFS_SUFFIX",
31+
Context.MODE_PRIVATE
32+
)
33+
result.success(null)
34+
}
35+
36+
override fun getEndpointId(result: Messages.Result<String?>){
37+
result.success(sharedPrefs.getString(UNIQUE_ID_KEY, null))
38+
}
39+
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.idea/
2+
.vagrant/
3+
.sconsign.dblite
4+
.svn/
5+
6+
.DS_Store
7+
*.swp
8+
profile
9+
10+
DerivedData/
11+
build/
12+
GeneratedPluginRegistrant.h
13+
GeneratedPluginRegistrant.m
14+
15+
.generated/
16+
17+
*.pbxuser
18+
*.mode1v3
19+
*.mode2v3
20+
*.perspectivev3
21+
22+
!default.pbxuser
23+
!default.mode1v3
24+
!default.mode2v3
25+
!default.perspectivev3
26+
27+
xcuserdata
28+
29+
*.moved-aside
30+
31+
*.pyc
32+
*sync/
33+
Icon?
34+
.tags*
35+
36+
/Flutter/Generated.xcconfig
37+
/Flutter/ephemeral/
38+
/Flutter/flutter_export_environment.sh
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import <Flutter/Flutter.h>
2+
3+
@interface AmplifyAnalyticsPinpointPlugin : NSObject<FlutterPlugin>
4+
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#import "AmplifyAnalyticsPinpointPlugin.h"
2+
#if __has_include(<amplify_analytics_pinpoint/amplify_analytics_pinpoint-Swift.h>)
3+
#import <amplify_analytics_pinpoint/amplify_analytics_pinpoint-Swift.h>
4+
#else
5+
// Support project import fallback if the generated compatibility header
6+
// is not copied when this plugin is created as a library.
7+
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
8+
#import "amplify_analytics_pinpoint-Swift.h"
9+
#endif
10+
11+
@implementation AmplifyAnalyticsPinpointPlugin
12+
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
13+
[SwiftAmplifyAnalyticsPinpointPlugin registerWithRegistrar:registrar];
14+
}
15+
@end

0 commit comments

Comments
 (0)