Skip to content

Commit

Permalink
Merge pull request #1838 from instructure/release/teacher-1.22.0-55
Browse files Browse the repository at this point in the history
Release Teacher 1.22.0 (55)
  • Loading branch information
kristofnemere authored Jan 30, 2023
2 parents 25e32a9 + 7a73191 commit 933fcbd
Show file tree
Hide file tree
Showing 186 changed files with 3,730 additions and 1,693 deletions.
2 changes: 2 additions & 0 deletions PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
## Checklist

- [ ] Follow-up e2e test ticket created or not needed
- [ ] Tested in dark mode
- [ ] Tested in light mode
- [ ] A11y checked
- [ ] Approve from product or not needed
2 changes: 1 addition & 1 deletion android-vault
11 changes: 9 additions & 2 deletions apps/flutter_parent/lib/l10n/res/intl_ms.arb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@@last_modified": "2022-01-28T12:37:40.360857",
"@@last_modified": "2022-10-28T11:03:07.232972",
"alertsLabel": "Isyarat",
"@alertsLabel": {
"description": "The label for the Alerts tab",
Expand Down Expand Up @@ -259,6 +259,13 @@
"placeholders_order": [],
"placeholders": {}
},
"findAnotherSchool": "Cari sekolah lain",
"@findAnotherSchool": {
"description": "Text for the find-another-school button",
"type": "text",
"placeholders_order": [],
"placeholders": {}
},
"domainSearchInputHint": "Masukkan nama sekolah atau daerah...",
"@domainSearchInputHint": {
"description": "Input hint for the text box on the domain search screen",
Expand Down Expand Up @@ -2660,4 +2667,4 @@
"placeholders_order": [],
"placeholders": {}
}
}
}
32 changes: 32 additions & 0 deletions apps/flutter_parent/lib/models/feature_flags.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2023 - present Instructure, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';

part 'feature_flags.g.dart';

abstract class FeatureFlags implements Built<FeatureFlags, FeatureFlagsBuilder> {

@BuiltValueSerializer(serializeNulls: true) // Add this line to get nulls to serialize when we convert to JSON
static Serializer<FeatureFlags> get serializer => _$featureFlagsSerializer;

@BuiltValueField(wireName: 'send_usage_metrics')
bool get sendUsageMetrics;

FeatureFlags._();
factory FeatureFlags([void Function(FeatureFlagsBuilder) updates]) = _$FeatureFlags;

static void _initializeBuilder(FeatureFlagsBuilder b) => b..sendUsageMetrics = false;
}
134 changes: 134 additions & 0 deletions apps/flutter_parent/lib/models/feature_flags.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/flutter_parent/lib/models/serializers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import 'dataseeding/pairing_code.dart';
import 'dataseeding/seed_context.dart';
import 'dataseeding/seeded_user.dart';
import 'dataseeding/user_name_data.dart';
import 'feature_flags.dart';
import 'file_upload_config.dart';

part 'serializers.g.dart';
Expand Down Expand Up @@ -128,6 +129,7 @@ part 'serializers.g.dart';
CreateSubmissionWrapper,
CreateUserInfo,
Enrollment,
FeatureFlags,
FileUploadConfig,
Grade,
GradeSubmissionInfo,
Expand Down
1 change: 1 addition & 0 deletions apps/flutter_parent/lib/models/serializers.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions apps/flutter_parent/lib/network/api/features_api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (C) 2023 - present Instructure, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.


import 'package:flutter_parent/models/feature_flags.dart';
import 'package:flutter_parent/network/utils/dio_config.dart';
import 'package:flutter_parent/network/utils/fetch.dart';

class FeaturesApi {

Future<FeatureFlags> getFeatureFlags() {
var dio = canvasDio(forceRefresh: true);

return fetch(dio.get('/features/environment'));
}
}
44 changes: 44 additions & 0 deletions apps/flutter_parent/lib/network/api/heap_api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (C) 2023 - present Instructure, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:flutter_parent/network/utils/api_prefs.dart';
import 'package:flutter_parent/network/utils/dio_config.dart';
import 'package:flutter_parent/network/utils/fetch.dart';
import 'package:flutter_parent/network/utils/private_consts.dart';

class HeapApi {
Future<Response> track(String event, {Map<String, dynamic> extras = const {}}) {
final heapDio = DioConfig.heap();
final userId = ApiPrefs.getCurrentLogin().user.id;

final encrypter = encrypt.Encrypter(encrypt.AES(encrypt.Key.fromUtf8(ENCRYPT_KEY)));
final encryptedId = encrypter.encrypt(userId, iv: encrypt.IV.fromUtf8(ENCRYPT_IV)).base64;

var data = {
'app_id' : HEAP_PRODUCTION_ID,
'identity' : encryptedId,
'event' : event
};

if (extras.isNotEmpty) {
data['properties'] = json.encode(extras);
}

return fetch(heapDio.dio.post('/track', data: data));
}
}
14 changes: 10 additions & 4 deletions apps/flutter_parent/lib/network/utils/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import 'package:device_info/device_info.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_parent/network/api/heap_api.dart';
import 'package:flutter_parent/utils/features_utils.dart';
import 'package:flutter_parent/utils/debug_flags.dart';
import 'package:flutter_parent/utils/service_locator.dart';

/// Event names
/// The naming scheme for the majority of these is found in a google doc so that we can be consistent
Expand Down Expand Up @@ -79,10 +82,12 @@ class AnalyticsParamConstants {

class Analytics {

HeapApi get _heap => HeapApi();
/// Set the current screen in analytics
void setCurrentScreen(String screenName) async {
if (kReleaseMode) {

final usageMetricsEnabled = await FeaturesUtils.getUsageMetricFeatureFlag();
if (kReleaseMode && usageMetricsEnabled) {
await _heap.track(screenName);
}

if (DebugFlags.isDebug) {
Expand All @@ -97,8 +102,9 @@ class Analytics {
/// * [event] should be one of [AnalyticsEventConstants]
/// * [extras] a map of keys [AnalyticsParamConstants] to values. Use sparingly, we only get 25 unique parameters
void logEvent(String event, {Map<String, dynamic> extras = const {}}) async {
if (kReleaseMode) {

final usageMetricsEnabled = await FeaturesUtils.getUsageMetricFeatureFlag();
if (kReleaseMode && usageMetricsEnabled) {
await _heap.track(event, extras: extras);
}

if (DebugFlags.isDebug) {
Expand Down
9 changes: 9 additions & 0 deletions apps/flutter_parent/lib/network/utils/dio_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ class DioConfig {
pageSize: pageSize);
}

static DioConfig heap() {
final baseUrl = "https://heapanalytics.com/api/";
final headers = {
'accept': 'application/json',
'content-type': 'application/json'
};
return DioConfig(baseUrl: baseUrl, baseHeaders: headers);
}

/// Clears the cache, deleting only the entries related to path OR clearing everything if path is null
Future<bool> clearCache({String path}) {
// The methods below are currently broken in unit tests due to sqflite (even when the sqflite MethodChannel has been
Expand Down
2 changes: 2 additions & 0 deletions apps/flutter_parent/lib/router/router_error_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:flutter_parent/router/panda_router.dart';
import 'package:flutter_parent/utils/design/canvas_icons.dart';
import 'package:flutter_parent/utils/design/parent_colors.dart';
import 'package:flutter_parent/utils/design/parent_theme.dart';
import 'package:flutter_parent/utils/features_utils.dart';
import 'package:flutter_parent/utils/quick_nav.dart';
import 'package:flutter_parent/utils/service_locator.dart';
import 'package:flutter_parent/utils/url_launcher.dart';
Expand Down Expand Up @@ -90,6 +91,7 @@ class RouterErrorScreen extends StatelessWidget {
_switchUsers(BuildContext context) async {
await ParentTheme.of(context).setSelectedStudent(null); // TODO - Test this, do we need it here?
await ApiPrefs.performLogout(switchingLogins: true, app: ParentApp.of(context));
await FeaturesUtils.performLogout();
locator<QuickNav>().pushRouteAndClearStack(context, PandaRouter.login());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import 'package:flutter_parent/utils/common_widgets/user_name.dart';
import 'package:flutter_parent/utils/design/canvas_icons.dart';
import 'package:flutter_parent/utils/design/parent_colors.dart';
import 'package:flutter_parent/utils/design/parent_theme.dart';
import 'package:flutter_parent/utils/features_utils.dart';
import 'package:flutter_parent/utils/quick_nav.dart';
import 'package:flutter_parent/utils/service_locator.dart';
import 'package:flutter_svg/flutter_svg.dart';
Expand Down Expand Up @@ -567,9 +568,10 @@ class DashboardState extends State<DashboardScreen> {
await ParentTheme.of(context).setSelectedStudent(null);
await ApiPrefs.performLogout(switchingLogins: switchingUsers, app: ParentApp.of(context));
MasqueradeUI.of(context).refresh();
locator<Analytics>()
await locator<Analytics>()
.logEvent(switchingUsers ? AnalyticsEventConstants.SWITCH_USERS : AnalyticsEventConstants.LOGOUT);
locator<QuickNav>().pushRouteAndClearStack(context, PandaRouter.login());
await FeaturesUtils.performLogout();
}

_navDrawerHeader(User user) => Column(
Expand Down
Loading

0 comments on commit 933fcbd

Please sign in to comment.