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

Request tracking authorization #41

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,6 @@ healthchecksdb
MigrationBackup/

# End of https://www.gitignore.io/api/git,dart,flutter,intellij,webstorm,visualstudio


.last_build_id
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Remember that the application lifecycle events won't have any special context se
<key>com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS</key>
<false/>
<key>com.claimsforce.segment.ENABLE_AMPLITUDE_INTEGRATION</key>
<false/>
<false/>
[...]
</dict>
</plist>
Expand Down
9 changes: 5 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.1'
}
}

Expand All @@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 30

defaultConfig {
minSdkVersion 16
Expand All @@ -33,7 +33,8 @@ android {
}

dependencies {
implementation 'com.segment.analytics.android:analytics:4.7.0'
implementation 'com.segment.analytics.android.integrations:amplitude:+'
implementation 'com.segment.analytics.android:analytics:4.8.2'
implementation 'com.segment.analytics.android.integrations:amplitude:3.0.3'
implementation 'com.google.android.gms:play-services-ads:19.5.0'
}
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private void setupChannels(Context applicationContext, BinaryMessenger messenger
Bundle bundle = ai.metaData;

String writeKey = bundle.getString("com.claimsforce.segment.WRITE_KEY");
Boolean trackApplicationLifecycleEvents = bundle.getBoolean("com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS");
Boolean isAmplitudeIntegrationEnabled = bundle.getBoolean("com.claimsforce.segment.ENABLE_AMPLITUDE_INTEGRATION", false);
Boolean debug = bundle.getBoolean("com.claimsforce.segment.DEBUG", false);
boolean trackApplicationLifecycleEvents = bundle.getBoolean("com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS");
boolean isAmplitudeIntegrationEnabled = bundle.getBoolean("com.claimsforce.segment.ENABLE_AMPLITUDE_INTEGRATION", false);
boolean debug = bundle.getBoolean("com.claimsforce.segment.DEBUG", false);

Analytics.Builder analyticsBuilder = new Analytics.Builder(applicationContext, writeKey);
if (trackApplicationLifecycleEvents) {
Expand All @@ -79,7 +79,7 @@ private void setupChannels(Context applicationContext, BinaryMessenger messenger

// Here we build a middleware that just appends data to the current context
// using the [deepMerge] strategy.
analyticsBuilder.middleware(
analyticsBuilder.useSourceMiddleware(
new Middleware() {
@Override
public void intercept(Chain chain) {
Expand Down Expand Up @@ -303,7 +303,7 @@ private void reset(Result result) {

private void setContext(MethodCall call, Result result) {
try {
this.appendToContextMiddleware = call.argument("context");
appendToContextMiddleware = call.argument("context");
result.success(true);
} catch (Exception e) {
result.error("FlutterSegmentException", e.getLocalizedMessage(), null);
Expand Down Expand Up @@ -335,8 +335,8 @@ private void disable(MethodCall call, Result result) {
/**
* Enables / disables / sets custom integration properties so Segment can properly
* interact with 3rd parties, such as Amplitude.
* @see https://segment.com/docs/connections/sources/catalog/libraries/mobile/android/#selecting-destinations
* @see https://github.com/segmentio/analytics-android/blob/master/analytics/src/main/java/com/segment/analytics/Options.java
* https://segment.com/docs/connections/sources/catalog/libraries/mobile/android/#selecting-destinations
* https://github.com/segmentio/analytics-android/blob/master/analytics/src/main/java/com/segment/analytics/Options.java
*/
@SuppressWarnings("unchecked")
private Options buildOptions(HashMap<String, Object> optionsData) {
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 30

lintOptions {
disable 'InvalidPackage'
Expand All @@ -35,7 +35,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_segment_example"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
6 changes: 5 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
Remember that the application lifecycle events won't have any
special context set for you by the time it is initialized. -->
<meta-data android:name="com.claimsforce.segment.WRITE_KEY" android:value="YOUR_WRITE_KEY_GOES_HERE" />
<meta-data android:name="com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS" android:value="false" />
<meta-data android:name="com.claimsforce.segment.TRACK_APPLICATION_LIFECYCLE_EVENTS" android:value="true" />

<meta-data
android:name="com.google.android.gms.ads.AD_MANAGER_APP"
android:value="true"/>
<!--
If you want to debug the plugin events. Default is false.
<meta-data android:name="com.claimsforce.segment.DEBUG" android:value="true" />
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.1'
}
}

Expand Down
1 change: 1 addition & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M

android.enableR8=true
android.useAndroidX=true
4 changes: 2 additions & 2 deletions example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Wed Nov 18 10:50:15 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
83 changes: 18 additions & 65 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand All @@ -10,79 +10,32 @@ project 'Runner', {
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end

target 'Runner' do
# Flutter Pod

copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

# Plugin Pods
flutter_ios_podfile_setup

# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
flutter_additional_ios_build_settings(target)
end
end
39 changes: 14 additions & 25 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
PODS:
- Amplitude-iOS (4.8.2)
- Analytics (3.7.0)
- Branch (0.33.1):
- Branch/Core (= 0.33.1)
- Branch/Core (0.33.1)
- Amplitude (7.0.1)
- Analytics (4.1.2)
- Flutter (1.0.0)
- flutter_segment (0.0.1):
- Analytics (= 3.7.0)
- Analytics (~> 4.1.2)
- Flutter
- Segment-Amplitude (= 3.0.1)
- Segment-Branch (= 0.1.22)
- Segment-Amplitude (3.0.1):
- Amplitude-iOS (~> 4.8.0)
- Analytics (~> 3.7.0)
- Segment-Branch (0.1.22):
- Segment-Amplitude (~> 3.2.3)
- Segment-Amplitude (3.2.3):
- Amplitude (~> 7.0.1)
- Analytics
- Branch (~> 0.33.0)

DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_segment (from `.symlinks/plugins/flutter_segment/ios`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- Amplitude-iOS
trunk:
- Amplitude
- Analytics
- Branch
- Segment-Amplitude
- Segment-Branch

EXTERNAL SOURCES:
Flutter:
Expand All @@ -36,14 +27,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_segment/ios"

SPEC CHECKSUMS:
Amplitude-iOS: 46c8e6e65c49bb1ad1909a9add1a68e1f8562b3f
Analytics: 77fd5fb102a4a5eedafa2c2b0245ceb7b7c15e45
Branch: 65d05ffb137ef504777cff6bd4fb6f770f17145a
Amplitude: 31a9038dca905b78294418ed277da9c2e07658ad
Analytics: 177da2c597aba83a6882b706ca6e0a071fd7cd26
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_segment: 2998835d0955a5d2c0708bed5c9d083db608efca
Segment-Amplitude: 1b3b02a2e92f4b08a413a72bf7aa44f78566ab3b
Segment-Branch: f255ba1354f6aa1bc8654d450b3b933380f2558d
flutter_segment: bff2732e94a563b275d4718ba8efd37fbe91f613
Segment-Amplitude: 79e13fa0aa58341212041f524f5f9679e40c23de

PODFILE CHECKSUM: 970bf863efb3fa7e2bb3e77c0ba50af7a1f3964d
PODFILE CHECKSUM: 76aaac2b301aa40241aa71d54b58fe3a3c060f7b

COCOAPODS: 1.7.4
COCOAPODS: 1.10.0
Loading