Skip to content

Commit

Permalink
fix: plugin version in user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed Jan 1, 2023
1 parent 08fe73f commit a10e482
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
19 changes: 8 additions & 11 deletions ios/customer_io.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
# Run `pod lib lint customer_io.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'customer_io'
s.version = '0.0.1'
s.summary = 'A plugin for Customer.io'
s.description = <<-DESC
A plugin for Customer.io
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => '[email protected]' }
s.source = { :path => '.' }
s.name = 'customer_io'
s.version = '1.0.0-alpha.4'
s.summary = 'Customer.io plugin for Flutter'
s.homepage = 'https://customer.io/'
s.license = { :file => '../LICENSE' }
s.author = { "CustomerIO Team" => "[email protected]" }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '13.0'
Expand All @@ -22,4 +19,4 @@ A plugin for Customer.io
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end
end
17 changes: 16 additions & 1 deletion lib/customer_io_method_channel.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'customer_io_config.dart';
import 'customer_io_const.dart';
import 'customer_io_platform_interface.dart';
import 'customer_io_plugin_version.dart';

/// An implementation of [CustomerIOPlatform] that uses method channels.
class CustomerIOMethodChannel extends CustomerIOPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('customer_io');

/// To initialize the plugin
@override
Future<void> initialize({
required CustomerIOConfig config,
}) async {
try {
config.version = version;
await methodChannel.invokeMethod(MethodConsts.initialize, config.toMap());
} on PlatformException catch (exception) {
if (kDebugMode) {
Expand All @@ -24,6 +26,10 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// Identify a person using a unique identifier, eg. email id.
/// Note that you can identify only 1 profile at a time. In case, multiple
/// identifiers are attempted to be identified, then the last identified profile
/// will be removed automatically.
@override
void identify(
{required String identifier,
Expand All @@ -41,6 +47,8 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// To track user events like loggedIn, addedItemToCart etc.
/// You may also track events with additional yet optional data.
@override
void track(
{required String name,
Expand All @@ -58,6 +66,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// Track screen events to record the screens a user visits
@override
void screen(
{required String name,
Expand All @@ -75,6 +84,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// Call this function to stop identifying a person.
@override
void clearIdentify() {
try {
Expand All @@ -86,6 +96,8 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// Set custom user profile information such as user preference, specific
/// user actions etc
@override
void setProfileAttributes({required Map<String, dynamic> attributes}) {
try {
Expand All @@ -98,6 +110,8 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}

/// Use this function to send custom device attributes
/// such as app preferences, timezone etc
@override
void setDeviceAttributes({required Map<String, dynamic> attributes}) {
try {
Expand All @@ -109,4 +123,5 @@ class CustomerIOMethodChannel extends CustomerIOPlatform {
}
}
}

}
1 change: 1 addition & 0 deletions lib/customer_io_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ abstract class CustomerIOPlatform extends PlatformInterface {
_instance = instance;
}


Future<void> initialize({
required CustomerIOConfig config,
}) {
Expand Down
2 changes: 2 additions & 0 deletions lib/customer_io_plugin_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Don't modify this line - it's automatically updated
const version = "1.0.0-alpha.4";
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: customer_io
description: A plugin for Customer.io
description: An official flutter plugin for Customer.io, an automated messaging platform for tech-savvy marketers.
version: 1.0.0-alpha.4
homepage: https://customer.io
repository: https://github.com/customerio/customerio-flutter
Expand Down
15 changes: 13 additions & 2 deletions scripts/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ set -e

NEW_VERSION="$1"

echo "Updating pubspec.yaml to new version: $NEW_VERSION"
echo "Updating files to new version: $NEW_VERSION"

echo "Updating pubspec.yaml"
sed -i 's/^\(version: \).*$/\1'"$NEW_VERSION"'/' pubspec.yaml

echo "Check pubspec.yaml file. You should see version inside has been updated!"
echo "Updating customer_io.podspec"
LINE_PATTERN="s.version\s*=.*"
sed -i "s/$LINE_PATTERN/s.version = \'$NEW_VERSION\'/" "./ios/customer_io.podspec"

echo "Updating customer_io_plugin_version.dart"
# Given line: `const version = "1.0.0-alpha.4";`
# Regex string will match the line of the file that we can then substitute.
DART_LINE_PATTERN="const version = \"\(.*\)\""
sed -i "s/$DART_LINE_PATTERN/const version = \"$NEW_VERSION\"/" "./lib/customer_io_plugin_version.dart"

echo "Check files, you should see version inside has been updated!"

0 comments on commit a10e482

Please sign in to comment.