Skip to content

Commit

Permalink
Auto report ff (#1760)
Browse files Browse the repository at this point in the history
Auto retrieve Flutter Fire version for reporting usage to Firebase.
  • Loading branch information
kroikie committed Jun 19, 2019
1 parent b4a3cf9 commit 0a6b83d
Show file tree
Hide file tree
Showing 108 changed files with 783 additions and 32 deletions.
1 change: 1 addition & 0 deletions packages/cloud_firestore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ios/Classes/UserAgent.h
4 changes: 4 additions & 0 deletions packages/cloud_firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.5+2

* Automatically use version from pubspec.yaml when reporting usage to Firebase.

## 0.12.5+1
* Added support for combining any of `Query.startAtDocument` and `Query.startAfterDocument`
with any of `Query.endAtDocument` and `Query.endBeforeDocument`.
Expand Down
4 changes: 3 additions & 1 deletion packages/cloud_firestore/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gradle.buildFinished { buildResult ->
}
}

group 'io.flutter.plugins.firebase.firestore'
group 'io.flutter.plugins.firebase.cloudfirestore'
version '1.0-SNAPSHOT'

buildscript {
Expand Down Expand Up @@ -52,3 +52,5 @@ android {
implementation 'androidx.annotation:annotation:1.0.0'
}
}

apply from: file("./user-agent.gradle")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.firebase.firestore">
package="io.flutter.plugins.firebase.cloudfirestore">
<application>
<service android:name="com.google.firebase.components.ComponentDiscoveryService">
<meta-data android:name="com.google.firebase.components:io.flutter.plugins.firebase.cloudfirestore.FlutterFirebaseAppRegistrar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
import java.util.List;

public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
private static final String LIBRARY_NAME = "flutter-fire-fst";
private static final String LIBRARY_VERSION = "0.12.5+1";

@Override
public List<Component<?>> getComponents() {
return Collections.<Component<?>>singletonList(
LibraryVersionComponent.create(LIBRARY_NAME, LIBRARY_VERSION));
LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, BuildConfig.LIBRARY_VERSION));
}
}
22 changes: 22 additions & 0 deletions packages/cloud_firestore/android/user-agent.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.regex.Matcher
import java.util.regex.Pattern

String libraryVersionName = "UNKNOWN"
String libraryName = "flutter-fire-fst"
File pubspec = new File(project.projectDir.parentFile, 'pubspec.yaml')

if (pubspec.exists()) {
String yaml = pubspec.text
// Using \s*['|"]?([^\n|'|"]*)['|"]? to extract version number.
Matcher versionMatcher = Pattern.compile("^version:\\s*['|\"]?([^\\n|'|\"]*)['|\"]?\$", Pattern.MULTILINE).matcher(yaml)
if (versionMatcher.find()) libraryVersionName = versionMatcher.group(1).replaceAll("\\+", "-")
}

android {
defaultConfig {
// BuildConfig.VERSION_NAME
buildConfigField 'String', 'LIBRARY_VERSION', "\"${libraryVersionName}\""
// BuildConfig.LIBRARY_NAME
buildConfigField 'String', 'LIBRARY_NAME', "\"${libraryName}\""
}
}
4 changes: 1 addition & 3 deletions packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
// found in the LICENSE file.

#import "CloudFirestorePlugin.h"
#import "UserAgent.h"

#import <Firebase/Firebase.h>

#define LIBRARY_NAME @"flutter-firebase_cloud_firestore"
#define LIBRARY_VERSION @"0.12.5+1"

static FlutterError *getFlutterError(NSError *error) {
if (error == nil) return nil;

Expand Down
10 changes: 10 additions & 0 deletions packages/cloud_firestore/ios/cloud_firestore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
require 'yaml'
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))
libraryVersion = pubspec['version'].gsub('+', '-')

Pod::Spec.new do |s|
s.name = 'cloud_firestore'
s.version = '0.0.1'
Expand All @@ -19,4 +23,10 @@ Firestore plugin for Flutter.
s.dependency 'Firebase/Core'
s.dependency 'Firebase/Firestore', '~> 6.0'
s.static_framework = true

s.prepare_command = <<-CMD
echo // Generated file, do not edit > Classes/UserAgent.h
echo "#define LIBRARY_VERSION @\\"#{libraryVersion}\\"" >> Classes/UserAgent.h
echo "#define LIBRARY_NAME @\\"flutter-fire-fst\\"" >> Classes/UserAgent.h
CMD
end
2 changes: 1 addition & 1 deletion packages/cloud_firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database
live synchronization and offline support on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore
version: 0.12.5+1
version: 0.12.5+2

flutter:
plugin:
Expand Down
4 changes: 3 additions & 1 deletion packages/cloud_functions/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
GeneratedPluginRegistrant.java
build/
.flutter-plugins
.flutter-plugins

ios/Classes/UserAgent.h
4 changes: 4 additions & 0 deletions packages/cloud_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0+2

* Automatically use version from pubspec.yaml when reporting usage to Firebase.

## 0.4.0+1

* Remove reference to unused header file.
Expand Down
5 changes: 4 additions & 1 deletion packages/cloud_functions/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gradle.buildFinished { buildResult ->
}
}

group 'io.flutter.plugins.firebase.cloudfunctions.cloudfunctions'
group 'io.flutter.plugins.firebase.cloudfunctions'
version '1.0-SNAPSHOT'

buildscript {
Expand Down Expand Up @@ -46,6 +46,9 @@ android {
}
dependencies {
api 'com.google.firebase:firebase-functions:17.0.0'
implementation 'com.google.firebase:firebase-common:16.1.0'
implementation 'androidx.annotation:annotation:1.0.0'
}
}

apply from: file("./user-agent.gradle")
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.firebase.cloudfunctions.cloudfunctions">
package="io.flutter.plugins.firebase.cloudfunctions">
<application>
<service android:name="com.google.firebase.components.ComponentDiscoveryService">
<meta-data android:name="com.google.firebase.components:io.flutter.plugins.firebase.cloudfunctions.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.flutter.plugins.firebase.cloudfunctions;

import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.platforminfo.LibraryVersionComponent;
import java.util.Collections;
import java.util.List;

public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
@Override
public List<Component<?>> getComponents() {
return Collections.<Component<?>>singletonList(
LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, BuildConfig.LIBRARY_VERSION));
}
}
22 changes: 22 additions & 0 deletions packages/cloud_functions/android/user-agent.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.regex.Matcher
import java.util.regex.Pattern

String libraryVersionName = "UNKNOWN"
String libraryName = "flutter-fire-fn"
File pubspec = new File(project.projectDir.parentFile, 'pubspec.yaml')

if (pubspec.exists()) {
String yaml = pubspec.text
// Using \s*['|"]?([^\n|'|"]*)['|"]? to extract version number.
Matcher versionMatcher = Pattern.compile("^version:\\s*['|\"]?([^\\n|'|\"]*)['|\"]?\$", Pattern.MULTILINE).matcher(yaml)
if (versionMatcher.find()) libraryVersionName = versionMatcher.group(1).replaceAll("\\+", "-")
}

android {
defaultConfig {
// BuildConfig.VERSION_NAME
buildConfigField 'String', 'LIBRARY_VERSION', "\"${libraryVersionName}\""
// BuildConfig.LIBRARY_NAME
buildConfigField 'String', 'LIBRARY_NAME', "\"${libraryName}\""
}
}
6 changes: 6 additions & 0 deletions packages/cloud_functions/ios/Classes/CloudFunctionsPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#import "CloudFunctionsPlugin.h"
#import "UserAgent.h"

#import "Firebase/Firebase.h"

Expand All @@ -18,6 +19,11 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
binaryMessenger:[registrar messenger]];
CloudFunctionsPlugin *instance = [[CloudFunctionsPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];

SEL sel = NSSelectorFromString(@"registerLibrary:withVersion:");
if ([FIRApp respondsToSelector:sel]) {
[FIRApp performSelector:sel withObject:LIBRARY_NAME withObject:LIBRARY_VERSION];
}
}

- (instancetype)init {
Expand Down
11 changes: 11 additions & 0 deletions packages/cloud_functions/ios/cloud_functions.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

require 'yaml'
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))
libraryVersion = pubspec['version'].gsub('+', '-')

Pod::Spec.new do |s|
s.name = 'cloud_functions'
s.version = '0.0.1'
Expand All @@ -19,5 +24,11 @@ A new flutter plugin project.
s.dependency 'Firebase/Core'
s.dependency 'Firebase/Functions', '~> 6.0'
s.static_framework = true

s.prepare_command = <<-CMD
echo // Generated file, do not edit > Classes/UserAgent.h
echo "#define LIBRARY_VERSION @\\"#{libraryVersion}\\"" >> Classes/UserAgent.h
echo "#define LIBRARY_NAME @\\"flutter-fire-fn\\"" >> Classes/UserAgent.h
CMD
end

2 changes: 1 addition & 1 deletion packages/cloud_functions/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cloud_functions
description: Flutter plugin for Cloud Functions.
version: 0.4.0+1
version: 0.4.0+2
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_functions

Expand Down
1 change: 1 addition & 0 deletions packages/firebase_analytics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ios/Classes/UserAgent.h
4 changes: 4 additions & 0 deletions packages/firebase_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.0.3

* Automatically use version from pubspec.yaml when reporting usage to Firebase.

## 3.0.2

* Bump minimum Flutter version to 1.5.0.
Expand Down
3 changes: 3 additions & 0 deletions packages/firebase_analytics/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ android {
}
dependencies {
api 'com.google.firebase:firebase-analytics:16.5.0'
implementation 'com.google.firebase:firebase-common:16.1.0'
}
}

apply from: file("./user-agent.gradle")
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<application>
<service android:name="com.google.firebase.components.ComponentDiscoveryService">
<meta-data android:name="com.google.firebase.components:io.flutter.plugins.firebaseanalytics.FlutterFirebaseAppRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.flutter.plugins.firebaseanalytics;

import com.google.firebase.components.Component;
import com.google.firebase.components.ComponentRegistrar;
import com.google.firebase.platforminfo.LibraryVersionComponent;
import java.util.Collections;
import java.util.List;

public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
@Override
public List<Component<?>> getComponents() {
return Collections.<Component<?>>singletonList(
LibraryVersionComponent.create(BuildConfig.LIBRARY_NAME, BuildConfig.LIBRARY_VERSION));
}
}
22 changes: 22 additions & 0 deletions packages/firebase_analytics/android/user-agent.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.regex.Matcher
import java.util.regex.Pattern

String libraryVersionName = "UNKNOWN"
String libraryName = "flutter-fire-analytics"
File pubspec = new File(project.projectDir.parentFile, 'pubspec.yaml')

if (pubspec.exists()) {
String yaml = pubspec.text
// Using \s*['|"]?([^\n|'|"]*)['|"]? to extract version number.
Matcher versionMatcher = Pattern.compile("^version:\\s*['|\"]?([^\\n|'|\"]*)['|\"]?\$", Pattern.MULTILINE).matcher(yaml)
if (versionMatcher.find()) libraryVersionName = versionMatcher.group(1).replaceAll("\\+", "-")
}

android {
defaultConfig {
// BuildConfig.VERSION_NAME
buildConfigField 'String', 'LIBRARY_VERSION', "\"${libraryVersionName}\""
// BuildConfig.LIBRARY_NAME
buildConfigField 'String', 'LIBRARY_NAME', "\"${libraryName}\""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

#import "FirebaseAnalyticsPlugin.h"
#import "UserAgent.h"

#import "Firebase/Firebase.h"

Expand All @@ -15,6 +16,11 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
binaryMessenger:[registrar messenger]];
FLTFirebaseAnalyticsPlugin *instance = [[FLTFirebaseAnalyticsPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];

SEL sel = NSSelectorFromString(@"registerLibrary:withVersion:");
if ([FIRApp respondsToSelector:sel]) {
[FIRApp performSelector:sel withObject:LIBRARY_NAME withObject:LIBRARY_VERSION];
}
}

- (instancetype)init {
Expand Down
11 changes: 11 additions & 0 deletions packages/firebase_analytics/ios/firebase_analytics.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

require 'yaml'
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))
libraryVersion = pubspec['version'].gsub('+', '-')

Pod::Spec.new do |s|
s.name = 'firebase_analytics'
s.version = '0.0.1'
Expand All @@ -19,4 +24,10 @@ Firebase Analytics plugin for Flutter.
s.dependency 'Firebase/Core'
s.dependency 'Firebase/Analytics', '~> 6.0'
s.static_framework = true

s.prepare_command = <<-CMD
echo // Generated file, do not edit > Classes/UserAgent.h
echo "#define LIBRARY_VERSION @\\"#{libraryVersion}\\"" >> Classes/UserAgent.h
echo "#define LIBRARY_NAME @\\"flutter-fire-analytics\\"" >> Classes/UserAgent.h
CMD
end
2 changes: 1 addition & 1 deletion packages/firebase_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Analytics for Firebase, an app measuremen
solution that provides insight on app usage and user engagement on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_analytics
version: 3.0.2
version: 3.0.3

flutter:
plugin:
Expand Down
1 change: 1 addition & 0 deletions packages/firebase_auth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ios/Classes/UserAgent.h
4 changes: 4 additions & 0 deletions packages/firebase_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.1+7

* Automatically use version from pubspec.yaml when reporting usage to Firebase.

## 0.11.1+6

* Add documentation of support email requirement to README.
Expand Down
3 changes: 3 additions & 0 deletions packages/firebase_auth/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ android {
}
dependencies {
api 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-common:16.1.0'
api 'com.google.code.gson:gson:2.8.5'
}
}

apply from: file("./user-agent.gradle")
Loading

0 comments on commit 0a6b83d

Please sign in to comment.