You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2023/01/10 11:54:13 UTC
[GitHub] [beam] nausharipov opened a new pull request, #24957: [ToB] [Frontend] Tour of Beam analytics
nausharipov opened a new pull request, #24957:
URL: https://github.com/apache/beam/pull/24957
Resolves #24924
Resolves #24901
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1097275120
##########
playground/frontend/playground_components/lib/src/widgets/run_or_cancel_button.dart:
##########
@@ -49,7 +50,10 @@ class RunOrCancelButton extends StatelessWidget {
(_) => PlaygroundComponents.toastNotifier.add(_getErrorToast()),
);
},
- runCode: () {
+ runCode: () async {
+ await AnalyticsService.get().trackRunExample(
+ playgroundController.selectedExample!.name,
+ );
Review Comment:
Should the event calls be wrapped into unawaited or `_safeSendEvent`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1094689926
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,7 +26,8 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
+const String kAnalyticsUA = 'G-349612187';
Review Comment:
The open [issue](https://github.com/dart-lang/usage/issues/185) indicates that it doesn't. I haven't found a wrapper package that supports GA4 other than firebase_analytics. Shall I use firebase_analytics?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131962401
##########
playground/frontend/playground_components/lib/src/controllers/window_close_notifier/window_close_notifier_web.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:html'; // ignore: avoid_web_libraries_in_flutter
+
+import 'package:flutter/foundation.dart';
+
+/// Notifies when the browser window is being closed.
+class WindowCloseNotifier extends ChangeNotifier {
Review Comment:
We cancel a possible run when the window is closed. Added comments there and to `StandalonePlaygroundNotifier` and `EmbeddedPlaygroundNotifier`.
##########
playground/frontend/playground_components/lib/src/enums/feedback_rating.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+enum FeedbackRating {
+ positive,
+ negative,
+}
Review Comment:
Yes, added a doc comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1097275120
##########
playground/frontend/playground_components/lib/src/widgets/run_or_cancel_button.dart:
##########
@@ -49,7 +50,10 @@ class RunOrCancelButton extends StatelessWidget {
(_) => PlaygroundComponents.toastNotifier.add(_getErrorToast()),
);
},
- runCode: () {
+ runCode: () async {
+ await AnalyticsService.get().trackRunExample(
+ playgroundController.selectedExample!.name,
+ );
Review Comment:
Should the event calls be wrapped into unawaited or only `_safeSendEvent`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105790749
##########
playground/frontend/playground_components/lib/src/services/analytics/generic/events.dart:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class GenericAnalyticsEvents {
+ static const run = 'click_run';
+ // TODO(nausharipov): rename example to snippet everywhere?
Review Comment:
Renamed since we break continuity anyway with the new GA version.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105785979
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
Review Comment:
Dropped `usage`, manually submitting to GA4.
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
+
+import '../../config.dart';
+import '../../models/module.dart';
+import '../../models/unit.dart';
+import 'categories.dart';
+import 'events.dart';
+import 'service.dart';
+
+class TobGoogleAnalyticsService extends GoogleAnalyticsService
+ implements TobAnalyticsService {
+ static const _appName = 'beam';
+ static const _appVersion = '1.0';
+ final _analytics = AnalyticsHtml(kAnalyticsUA, _appName, _appVersion);
+
+ static TobGoogleAnalyticsService get() {
+ return GetIt.instance.get<TobGoogleAnalyticsService>();
+ }
+
+ TobGoogleAnalyticsService()
+ : super(
+ appAnalytics: AnalyticsHtml(
+ kAnalyticsUA,
+ _appName,
+ _appVersion,
+ ),
+ );
+
+ @override
+ Future<void> openUnit(Sdk sdk, UnitModel unit) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.openUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unit.id}',
+ ),
+ );
+ }
+
+ @override
+ Future<void> closeUnit(Sdk sdk, String unitId, Duration timeSpent) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.closeUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unitId}_${timeSpent.inSeconds}s',
Review Comment:
Dropped `usage`, manually submitting to GA4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131229421
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,14 +26,10 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
-const String kApiClientURL =
- 'https://backend-router-beta-dot-apache-beam-testing.appspot.com';
-const String kApiJavaClientURL =
- 'https://backend-java-beta-dot-apache-beam-testing.appspot.com';
-const String kApiGoClientURL =
- 'https://backend-go-beta-dot-apache-beam-testing.appspot.com';
-const String kApiPythonClientURL =
- 'https://backend-python-beta-dot-apache-beam-testing.appspot.com';
-const String kApiScioClientURL =
- 'https://backend-scio-beta-dot-apache-beam-testing.appspot.com';
+const String kAnalyticsUA = 'G-BXFP2FNCKC';
Review Comment:
It is also in `config.example.dart`. This is changing in a series of steps starting with deleting the Gradle configuration in #25610
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1097212211
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
Review Comment:
The usage package will not be used, because it doesn't support GA4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102764700
##########
playground/frontend/integration_test/miscellaneous_ui/enjoy_playground_test.dart:
##########
@@ -58,14 +56,18 @@ Future<void> _checkEnjoyingAndSendFeedback(WidgetTester wt) async {
await wt.tap(find.feedbackDropdownSendButton());
await wt.pumpAndSettle();
- final context = wt.element(find.feedbackThumbUp());
- final lastSentEvent = AnalyticsService.get(context).lastSentEvent;
+ final lastEvent = PlaygroundComponents.analyticsService.lastEvent;
expect(
- lastSentEvent,
- AnalyticsEvent(
- category: kFeedbackCategory,
- action: kClickSendFeedbackEvent,
- label: text,
+ lastEvent,
+ const FeedbackFormAnalyticsEvent(
Review Comment:
This will change after #25034
I am keeping the merge simple.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105783422
##########
playground/frontend/lib/modules/analytics/service.dart:
##########
@@ -16,16 +16,12 @@
* limitations under the License.
*/
-import 'package:flutter/widgets.dart';
-import 'package:playground/modules/analytics/analytics_event.dart';
+import 'package:get_it/get_it.dart';
import 'package:playground_components/playground_components.dart';
-import 'package:provider/provider.dart';
-abstract class AnalyticsService {
- AnalyticsEvent? get lastSentEvent;
-
- static AnalyticsService get(BuildContext context) {
- return Provider.of<AnalyticsService>(context, listen: false);
+abstract class AnalyticsService extends GeneralAnalyticsService {
Review Comment:
Simplified back to to `AnalyticsService -> GoogleAnalyticsService.`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131054023
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
+class TobEventContext with EquatableMixin {
+ const TobEventContext({
+ required this.sdkId,
+ required this.unitId,
});
+ final String? sdkId;
+ final String? unitId;
+
+ static const empty = TobEventContext(
+ sdkId: null,
+ unitId: null,
+ );
Review Comment:
1. I would rather keep it `Tob` because we have many classes that need to emphasize their belonging to TourOfBeam. With this many classes we may assume the reader will soon be familiar with `Tob`. Some of the classes are long already. Some of them will become ambiguous if expanded, like is `TourOfBeamMarkdown` a 'Tour of BeamMarkdown'?

2. We need to compare objects in tests. `EqualityMixin` takes care of both `operator ==` and `hashCode`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131966537
##########
playground/frontend/lib/services/analytics/events/constants.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class PlaygroundAnalyticsEvents {
+ static const loaded = 'loaded';
+ static const newExample = 'new_example';
+ static const shareableCopied = 'shareable_copied';
+ static const shareCodeClicked = 'share_code_clicked';
+ static const shortcutsClicked = 'shortcuts_clicked';
+ static const snippetSelected = 'snippet_selected';
+}
+
+class PlaygroundEventParams {
+ static const shareFormat = 'shareFormat';
Review Comment:
We namespace the param name constants with classes like this one. In `playground_components` there is a twin class with more params: https://github.com/akvelon/beam/blob/fb34d74a72822c1cb4d251bc96065c5c69a6894c/playground/frontend/playground_components/lib/src/services/analytics/events/constants.dart#L33
In this case we only have one but still want to namespace it for symmetry. This will pay if we add more params to the playground-app-specific events.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131967702
##########
playground/frontend/lib/modules/actions/components/new_example_action.dart:
##########
@@ -38,7 +38,9 @@ class NewExampleAction extends StatelessWidget {
label: 'intents.playground.newExample'.tr(),
onPressed: () {
launchUrl(Uri.parse('/'));
- AnalyticsService.get(context).trackClickNewExample();
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
I also agree that `sendNewExampleEvent` makes more sense. But this sense comes at a cost. If `AnalyticsService` has a method per event, then we must have a service for Playground, and a service for Tour of Beam because they use different events, and a common ancestor for common events.
Multiply this by the abstract `AnalyticsService` and `GoogleAnalyticsService`, and you get 6 classes. Then these classes are mostly boilerplate because all they do in these methods is repackaging their named parameters to specific event objects. And they must do that because we need those objects to store `lastEvent` for testing.
This is why we chose a single `sendUnawaited` method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1130993765
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,14 +26,10 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
-const String kApiClientURL =
- 'https://backend-router-beta-dot-apache-beam-testing.appspot.com';
-const String kApiJavaClientURL =
- 'https://backend-java-beta-dot-apache-beam-testing.appspot.com';
-const String kApiGoClientURL =
- 'https://backend-go-beta-dot-apache-beam-testing.appspot.com';
-const String kApiPythonClientURL =
- 'https://backend-python-beta-dot-apache-beam-testing.appspot.com';
-const String kApiScioClientURL =
- 'https://backend-scio-beta-dot-apache-beam-testing.appspot.com';
+const String kAnalyticsUA = 'G-BXFP2FNCKC';
+
+const String kApiClientURL = 'https://router.play-dev.beam.apache.org';
+const String kApiJavaClientURL = 'https://java.play-dev.beam.apache.org';
+const String kApiGoClientURL = 'https://go.play-dev.beam.apache.org';
+const String kApiPythonClientURL = 'https://python.play-dev.beam.apache.org';
+const String kApiScioClientURL = 'https://scio.play-dev.beam.apache.org';
Review Comment:
Just two lines above it reads `// Copied from Playground's config.g.dart` which in turn has an explanation.
`config.g.dart` will be gone after merging #25610
It it happens before this merge, we will delete the ToB's `config.dart` when merging `master` here. Otherwise we will update #25610 accordingly if this is merged first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1097212465
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
+
+import '../../config.dart';
+import '../../models/module.dart';
+import '../../models/unit.dart';
+import 'categories.dart';
+import 'events.dart';
+import 'service.dart';
+
+class TobGoogleAnalyticsService extends GoogleAnalyticsService
+ implements TobAnalyticsService {
+ static const _appName = 'beam';
+ static const _appVersion = '1.0';
+ final _analytics = AnalyticsHtml(kAnalyticsUA, _appName, _appVersion);
+
+ static TobGoogleAnalyticsService get() {
+ return GetIt.instance.get<TobGoogleAnalyticsService>();
+ }
+
+ TobGoogleAnalyticsService()
+ : super(
+ appAnalytics: AnalyticsHtml(
+ kAnalyticsUA,
+ _appName,
+ _appVersion,
+ ),
+ );
+
+ @override
+ Future<void> openUnit(Sdk sdk, UnitModel unit) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.openUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unit.id}',
+ ),
+ );
+ }
+
+ @override
+ Future<void> closeUnit(Sdk sdk, String unitId, Duration timeSpent) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.closeUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unitId}_${timeSpent.inSeconds}s',
Review Comment:
The usage package will not be used, because it doesn't support GA4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131245939
##########
playground/frontend/playground_components/lib/src/models/event_snippet_context.dart:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import 'sdk.dart';
+
+const _none = 'none';
+
+/// Basic information of the Playground state at a particular moment of time
+/// to augment analytics events.
+class EventSnippetContext with EquatableMixin {
+ const EventSnippetContext({
+ required this.originalSnippet,
+ required this.sdk,
+ required this.snippet,
+ });
+
+ /// Any identifier of the snippet that the content was derived from.
+ ///
+ /// If the code was modified it is still the last snippet loaded or chosen
+ /// by the user.
+ final String? originalSnippet;
+
+ final Sdk? sdk;
+
+ /// Any identifier of the current snippet if it is unchanged.
+ final String? snippet;
Review Comment:
See the above comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1130993765
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,14 +26,10 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
-const String kApiClientURL =
- 'https://backend-router-beta-dot-apache-beam-testing.appspot.com';
-const String kApiJavaClientURL =
- 'https://backend-java-beta-dot-apache-beam-testing.appspot.com';
-const String kApiGoClientURL =
- 'https://backend-go-beta-dot-apache-beam-testing.appspot.com';
-const String kApiPythonClientURL =
- 'https://backend-python-beta-dot-apache-beam-testing.appspot.com';
-const String kApiScioClientURL =
- 'https://backend-scio-beta-dot-apache-beam-testing.appspot.com';
+const String kAnalyticsUA = 'G-BXFP2FNCKC';
+
+const String kApiClientURL = 'https://router.play-dev.beam.apache.org';
+const String kApiJavaClientURL = 'https://java.play-dev.beam.apache.org';
+const String kApiGoClientURL = 'https://go.play-dev.beam.apache.org';
+const String kApiPythonClientURL = 'https://python.play-dev.beam.apache.org';
+const String kApiScioClientURL = 'https://scio.play-dev.beam.apache.org';
Review Comment:
Just two lines above it reads `// Copied from Playground's config.g.dart` which in turn has an explanation.
`config.g.dart` will be gone after merging #25610
If it happens before this merge, we will delete the ToB's `config.dart` when merging `master` here. Otherwise we will update #25610 accordingly if this is merged first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131041017
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
+ propertyId: kAnalyticsUA,
+ );
+ GetIt.instance.registerSingleton<AnalyticsService>(
+ googleAnalyticsService,
+ );
Review Comment:
Although the analytics classes are inside the shared `playground_components` package, the instantiation of the service is external to it. This gives us the future flexibility to:
1. Change the implementations for Playground and ToB independently.
2. Write tests that mock the analytics service.
3. Use the shared Playground widgets in a new app that does not send analytics data by registering a null-object for analytics.
There are a number of ways to implement this:
1. Wrap Playground widgets in a `Provider` widget to provide them with a specific analytics service. But this gives no compile-time guarantee that the provider is in the tree and leads to bugs.
2. Use a service locator of which `get_it` is the most popular one. So we did.
> It isn't clear from this what is actually implementing the abstract AnalyticsService class without some digging.
We need easy swap to a potential `SomethingElseAnalyticsService`, so this abstraction is on purpose. We could register the service to be read as `get<GoogleAnalyticsService>()`, but then swapping would affect dozens of locations.
The promise `get_it` gives is that widgets no longer have to reference global variables or rely on `Provider`s. And this promise is fulfilled. `Provider` leads to even more digging while global variables bar the 3 opportunities above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131983400
##########
learning/tour-of-beam/frontend/lib/pages/tour/controllers/unit.dart:
##########
@@ -18,28 +18,40 @@
import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
import '../../../cache/unit_progress.dart';
+import '../../../models/event_context.dart';
+import '../../../models/unit.dart';
import '../../../repositories/client/client.dart';
+import '../../../services/analytics/events/unit_completed.dart';
class UnitController extends ChangeNotifier {
- final String unitId;
- final String sdkId;
+ final UnitModel unit;
Review Comment:
Added a comment to the two classes instead.
Regarding the library prefixes I answered above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131994265
##########
playground/frontend/playground_components/lib/src/services/analytics/analytics_service.dart:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:get_it/get_it.dart';
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+
+/// Abstract class to submit analytics events.
+abstract class AnalyticsService {
+ AnalyticsEvent? _lastEvent;
+ AnalyticsEvent? get lastEvent => _lastEvent;
+
+ final _defaultEventParameters = <String, dynamic>{};
+
+ /// The parameters sent with all events.
+ ///
+ /// Individual event parameters have higher priority on collisions.
+ Map<String, dynamic> get defaultEventParameters =>
+ UnmodifiableMapView(_defaultEventParameters);
+
+ set defaultEventParameters(Map<String, dynamic> newValue) {
+ _defaultEventParameters.clear();
+ _defaultEventParameters.addAll(newValue);
+ }
+
+ static AnalyticsService get() {
+ return GetIt.instance.get<AnalyticsService>();
Review Comment:
It does not because its goal is to decouple usage from implementation.
A reader familiar with GetIt would find-in-files 'GetIt.instance.register' to get to implementations.
As for swapping in mocks in tests, GetIt can do that for unit tests because there we can have different initialization. But we aim to not add new mocks to unit tests because we plan to migrate to another mocking library in the next phase.
Instead we test analytics with integration tests (since we anyway test everything by clicking through), and there we do not have the control of implementations because the real-app implementations are loaded. Thus we check `BeamAnalyticsService.lastEvent`.
The only real benefit of GetIt that we use for now is to make `playground_components` unaware of the implementation without using Provider and global variables, which justifies it to us.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102852355
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics4_web_service.dart:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:html'; // ignore: avoid_web_libraries_in_flutter
Review Comment:
No, it reminds us to make conditional imports.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131252467
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
Review Comment:
Currently yes. I do not want to spell this out in the comment because if we add more parameters in the future (like UI locale) we will forget to update this comment and it will contain an incomplete list.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131220896
##########
playground/frontend/playground_components/lib/src/models/event_snippet_context.dart:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import 'sdk.dart';
+
+const _none = 'none';
+
+/// Basic information of the Playground state at a particular moment of time
+/// to augment analytics events.
+class EventSnippetContext with EquatableMixin {
Review Comment:
To be comparable in tests. I generally prefer `with EquatableMixin` over `extends Equatable` because it allows to introduce a base class with less change if we ever need to.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131963071
##########
playground/frontend/lib/services/analytics/events/constants.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class PlaygroundAnalyticsEvents {
Review Comment:
`+`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damccorm merged pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm merged PR #24957:
URL: https://github.com/apache/beam/pull/24957
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102770577
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics4_non_web_service.dart:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+import 'google_analytics4_service.dart';
+
+@internal
+GoogleAnalytics4Service createGoogleAnalytics4Service({
+ required String propertyId,
+}) =>
+ GoogleAnalytics4NonWebService();
+
+/// The required placeholder for non-web builds, e.g. unit tests.
+class GoogleAnalytics4NonWebService extends GoogleAnalytics4Service {
+ GoogleAnalytics4NonWebService() : super.create();
+
+ @override
+ Future<void> sendProtected(AnalyticsEvent event) {
+ throw UnimplementedError();
Review Comment:
Because this code never runs. It is required only to build unit tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102852686
##########
playground/frontend/playground_components/lib/src/services/analytics/events/abstract.dart:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import '../../../models/event_context.dart';
+
+abstract class AnalyticsEvent with EquatableMixin {
+ const AnalyticsEvent({
+ required this.name,
+ });
+
+ final String name;
+
+ @override
+ List<Object?> get props => [
+ name,
+ ];
+
+ Map<String, dynamic> toJson() => const {};
+}
+
+/// An [AnalyticsEvent] with [EventContext].
+abstract class SnippetAnalyticsEvent extends AnalyticsEvent {
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] Malarg commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "Malarg (via GitHub)" <gi...@apache.org>.
Malarg commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102258523
##########
learning/tour-of-beam/frontend/lib/modules/analytics/events.dart:
##########
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsEvents {
Review Comment:
all these variables are not used. Suggest not insert to pr dead code
##########
learning/tour-of-beam/frontend/lib/modules/analytics/categories.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsCategories {
Review Comment:
all these variables are not used. Suggest not insert to pr dead code
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -29,7 +29,9 @@ import '../../cache/unit_progress.dart';
import '../../config.dart';
import '../../models/unit.dart';
import '../../models/unit_content.dart';
+// import '../../modules/analytics/google_analytics_service.dart';
Review Comment:
delete?
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics4_non_web_service.dart:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+import 'google_analytics4_service.dart';
+
+@internal
+GoogleAnalytics4Service createGoogleAnalytics4Service({
+ required String propertyId,
+}) =>
+ GoogleAnalytics4NonWebService();
+
+/// The required placeholder for non-web builds, e.g. unit tests.
+class GoogleAnalytics4NonWebService extends GoogleAnalytics4Service {
+ GoogleAnalytics4NonWebService() : super.create();
+
+ @override
+ Future<void> sendProtected(AnalyticsEvent event) {
+ throw UnimplementedError();
Review Comment:
why unimplemented?
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics4_web_service.dart:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:html'; // ignore: avoid_web_libraries_in_flutter
Review Comment:
lets remove this rule?
##########
playground/frontend/lib/modules/actions/components/new_example_action.dart:
##########
@@ -38,7 +38,9 @@ class NewExampleAction extends StatelessWidget {
label: 'intents.playground.newExample'.tr(),
onPressed: () {
launchUrl(Uri.parse('/'));
- AnalyticsService.get(context).trackClickNewExample();
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
`PlaygroundComponents.analyticsService.sendNewExampleEvent`
##########
learning/tour-of-beam/frontend/lib/modules/analytics/events.dart:
##########
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsEvents {
+ static const openUnit = 'open_unit'; // datetime?
Review Comment:
suppose this comments should be more clear to understand
##########
playground/frontend/lib/components/playground_run_or_cancel_button.dart:
##########
@@ -20,38 +20,38 @@ import 'package:flutter/widgets.dart';
import 'package:playground_components/playground_components.dart';
import 'package:provider/provider.dart';
-import '../modules/analytics/analytics_service.dart';
-import '../utils/analytics_utils.dart';
-
class PlaygroundRunOrCancelButton extends StatelessWidget {
const PlaygroundRunOrCancelButton();
@override
Widget build(BuildContext context) {
return Consumer<PlaygroundController>(
- builder: (context, playgroundController, child) {
- final analyticsService = AnalyticsService.get(context);
- final stopwatch = Stopwatch();
- final exampleName = getAnalyticsExampleName(playgroundController);
-
- return RunOrCancelButton(
- playgroundController: playgroundController,
- beforeCancel: () {
- final exampleName = getAnalyticsExampleName(playgroundController);
- analyticsService.trackClickCancelRunEvent(exampleName);
- },
- beforeRun: () {
- stopwatch.start();
- analyticsService.trackClickRunEvent(exampleName);
- },
- onComplete: () {
- analyticsService.trackRunTimeEvent(
- exampleName,
- stopwatch.elapsedMilliseconds,
- );
- },
- );
- }
+ builder: (context, playgroundController, child) => RunOrCancelButton(
+ playgroundController: playgroundController,
+ beforeCancel: (runner) {
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
Lets make this interface more laconic?
Suggest make it like this: `PlaygroundComponents.analyticsService.sendCancelRun`, which will call `sendUnawaited` with `CancelRunAnalyticsEvent` param
##########
playground/frontend/lib/pages/standalone_playground/widgets/feedback/feedback_dropdown_content.dart:
##########
@@ -40,11 +39,15 @@ class FeedbackDropdownContent extends StatelessWidget {
static const sendButtonKey = Key('sendFeedbackButtonKey');
final void Function() close;
+ final EventContext eventContext;
+ final FeedbackRating feedbackRating;
final TextEditingController textController;
const FeedbackDropdownContent({
Key? key,
Review Comment:
`super.key`, or remove
##########
playground/frontend/integration_test/miscellaneous_ui/enjoy_playground_test.dart:
##########
@@ -58,14 +56,18 @@ Future<void> _checkEnjoyingAndSendFeedback(WidgetTester wt) async {
await wt.tap(find.feedbackDropdownSendButton());
await wt.pumpAndSettle();
- final context = wt.element(find.feedbackThumbUp());
- final lastSentEvent = AnalyticsService.get(context).lastSentEvent;
+ final lastEvent = PlaygroundComponents.analyticsService.lastEvent;
expect(
- lastSentEvent,
- AnalyticsEvent(
- category: kFeedbackCategory,
- action: kClickSendFeedbackEvent,
- label: text,
+ lastEvent,
+ const FeedbackFormAnalyticsEvent(
Review Comment:
lets implements DRY principle. Suggest extract this to a method
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131205345
##########
playground/frontend/playground_components/lib/playground_components.dart:
##########
@@ -40,20 +47,40 @@ export 'src/models/example_view_options.dart';
export 'src/models/intents.dart';
export 'src/models/loading_status.dart';
export 'src/models/outputs.dart';
+export 'src/models/run_shortcut.dart';
export 'src/models/sdk.dart';
export 'src/models/shortcut.dart';
export 'src/models/snippet_file.dart';
export 'src/models/toast.dart';
export 'src/models/toast_type.dart';
+
export 'src/playground_components.dart';
+
export 'src/repositories/code_client/grpc_code_client.dart';
export 'src/repositories/code_repository.dart';
export 'src/repositories/example_client/grpc_example_client.dart';
export 'src/repositories/example_repository.dart';
+
export 'src/router/router_delegate.dart';
+
+export 'src/services/analytics/analytics_service.dart';
+export 'src/services/analytics/events/abstract.dart';
+export 'src/services/analytics/events/app_rated.dart';
+export 'src/services/analytics/events/constants.dart';
+export 'src/services/analytics/events/external_url_navigated.dart';
+export 'src/services/analytics/events/feedback_form_sent.dart';
+export 'src/services/analytics/events/report_issue_clicked.dart';
+export 'src/services/analytics/events/run_cancelled.dart';
+export 'src/services/analytics/events/run_finished.dart';
+export 'src/services/analytics/events/run_started.dart';
+export 'src/services/analytics/events/sdk_selected.dart';
+export 'src/services/analytics/events/snippet_reset.dart';
+export 'src/services/analytics/google_analytics4_service/google_analytics4_service.dart';
Review Comment:
We needed an umbrella name for everything that is shared by Playground and ToB. This includes not only services but also widgets and stateful objects. "components" because it is a less specific term than "services", "modules", etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131041017
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
+ propertyId: kAnalyticsUA,
+ );
+ GetIt.instance.registerSingleton<AnalyticsService>(
+ googleAnalyticsService,
+ );
Review Comment:
Although the analytics classes are inside the shared `playground_components` package, the instantiation of the service is external to it. This gives us the future flexibility to:
1. Change the implementations for Playground and ToB independently.
2. Write tests that mock the analytics service.
3. Use the shared Playground widgets in a new app that does not send analytics data by registering a null-object for analytics.
There are a number of ways to implement this:
1. Wrap Playground widgets in a `Provider` widget to provide them with a specific analytics service. But this gives no compile-time guarantee that the provider is in the tree and leads to bugs.
2. Use a service locator of which `get_it` is the most popular one. So we did.
> It isn't clear from this what is actually implementing the abstract AnalyticsService class without some digging.
We need easy swap to a potential `SomethingElseAnalyticsService`, so this abstraction is on purpose. We could register the service to be read as `get<GoogleAnalyticsService>()`, but then swapping would affect dozens of locations.
The promise `get_it` gives is that widgets no longer have to reference global variables or rely on `Provider`s. And this promise is fulfilled. `Provider` leads is even more digging while global variables bar the 3 opportunities above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131069649
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
Review Comment:
2. Renamed to `BeamAnalyticsService` and `BeamGoogleAnalyticsSevice`. I like it better then `library.Class` because the latter is rarely used, stands out, and questions why not import everything like that. And then we lose the Dart simplicity.
1. In that case we will make `BeamSomethingElseAnalyticsService extends BeamAnalyticsService`, instantiate it here and register it in `GetIt` under the same `BeamAnalyticsService` interface. Renamed the variable to `analyticsService` to further simplify the migration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1094689926
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,7 +26,8 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
+const String kAnalyticsUA = 'G-349612187';
Review Comment:
The open [issue](https://github.com/dart-lang/usage/issues/185) indicates that it doesn't. I haven't found a wrapper package that supports GA4 other than firebase_analytics.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1130975127
##########
playground/frontend/lib/components/playground_run_or_cancel_button.dart:
##########
@@ -20,38 +20,38 @@ import 'package:flutter/widgets.dart';
import 'package:playground_components/playground_components.dart';
import 'package:provider/provider.dart';
-import '../modules/analytics/analytics_service.dart';
-import '../utils/analytics_utils.dart';
-
class PlaygroundRunOrCancelButton extends StatelessWidget {
const PlaygroundRunOrCancelButton();
@override
Widget build(BuildContext context) {
return Consumer<PlaygroundController>(
- builder: (context, playgroundController, child) {
- final analyticsService = AnalyticsService.get(context);
- final stopwatch = Stopwatch();
- final exampleName = getAnalyticsExampleName(playgroundController);
-
- return RunOrCancelButton(
- playgroundController: playgroundController,
- beforeCancel: () {
- final exampleName = getAnalyticsExampleName(playgroundController);
- analyticsService.trackClickCancelRunEvent(exampleName);
- },
- beforeRun: () {
- stopwatch.start();
- analyticsService.trackClickRunEvent(exampleName);
- },
- onComplete: () {
- analyticsService.trackRunTimeEvent(
- exampleName,
- stopwatch.elapsedMilliseconds,
- );
- },
- );
- }
+ builder: (context, playgroundController, child) => RunOrCancelButton(
+ playgroundController: playgroundController,
+ beforeCancel: (runner) {
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
`sendUnawaited` is to wrap the sending function with an `unawaited` call so we do not get the lint of a lost Future (just added to the doc comment). This is better than wrapping all analytics calls with explicit `unawaited`. So the first thing to get it is to think of it as just `send` which is simpler to understand.
`AnalyticsService.sendRunOrCancel` is not an option because the service must then be aware of the running state, but we aim to keep it thin, thus the separate methods.
I do not see a problem here because `RunOrCancelButton` has the separate callbacks so the three specific events can be fired there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131962254
##########
learning/tour-of-beam/frontend/lib/services/analytics/events/unit_opened.dart:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'abstract.dart';
+import 'constants.dart';
+
+class UnitOpenedTobAnalyticsEvent extends AnalyticsEventWithTobContext {
Review Comment:
`+`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131069649
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
Review Comment:
2. Renamed to `BeamAnalyticsService` and `BeamGoogleAnalyticsSevice`. I like it better then `library.Class` because the latter is rarely used, stands out, and questions why not import everything like that. And then we lose the Dart simplicity.
I. In that case we will make `BeamSomethingElseAnalyticsService extends BeamAnalyticsService`, instantiate it here and register it in `GetIt` under the same `BeamAnalyticsService` interface. Renamed the variable to `analyticsService` to further simplify the migration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by GitBox <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1065782592
##########
playground/frontend/lib/pages/standalone_playground/widgets/feedback/feedback_dropdown_content.dart:
##########
@@ -172,9 +174,16 @@ class FeedbackDropdownContent extends StatelessWidget {
key: sendButtonKey,
onPressed: () {
if (textController.text.isNotEmpty) {
- AnalyticsService.get(context).trackClickSendFeedback(
- textController.text,
- );
+ final text = textController.text;
+ if (isPositive) {
+ AnalyticsService.get().trackClickSendPositiveFeedback(
+ text,
+ );
+ } else {
Review Comment:
Second thoughts, this is too much of investment into boolean. I suggest making an `enum FeedbackRating` with `positive` and `negative`.
##########
playground/frontend/lib/modules/analytics/service.dart:
##########
@@ -16,16 +16,12 @@
* limitations under the License.
*/
-import 'package:flutter/widgets.dart';
-import 'package:playground/modules/analytics/analytics_event.dart';
+import 'package:get_it/get_it.dart';
import 'package:playground_components/playground_components.dart';
-import 'package:provider/provider.dart';
-abstract class AnalyticsService {
- AnalyticsEvent? get lastSentEvent;
-
- static AnalyticsService get(BuildContext context) {
- return Provider.of<AnalyticsService>(context, listen: false);
+abstract class AnalyticsService extends GeneralAnalyticsService {
Review Comment:
How about this?
```
AnalyticsService -> PlaygroundAnalyticsService -> PlaygroundGoogleAnalyticsService
-> TobAnalyticsService -> TobGoogleAnalyticsService
```
##########
playground/frontend/lib/locator.dart:
##########
@@ -57,3 +59,7 @@ void _initializeState() {
),
);
}
+
+void _initializeAnalyticsService() {
Review Comment:
```suggestion
void _initializeServices() {
```
##########
playground/frontend/lib/locator.dart:
##########
@@ -57,3 +59,7 @@ void _initializeState() {
),
);
}
+
+void _initializeAnalyticsService() {
+ GetIt.instance.registerSingleton(GoogleAnalyticsService());
Review Comment:
You can register a single object under two handles:
```suggestion
GetIt.instance.registerSingleton<AnalyticsService>(service);
GetIt.instance.registerSingleton<PlaygroundAnalyticsService>(service);
```
This way `playground_components` will request `<AnalyticsService>` and be able to submit generic events, while Playground and ToB will fetch their own subclasses to submit their specific events.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1097275120
##########
playground/frontend/playground_components/lib/src/widgets/run_or_cancel_button.dart:
##########
@@ -49,7 +50,10 @@ class RunOrCancelButton extends StatelessWidget {
(_) => PlaygroundComponents.toastNotifier.add(_getErrorToast()),
);
},
- runCode: () {
+ runCode: () async {
+ await AnalyticsService.get().trackRunExample(
+ playgroundController.selectedExample!.name,
+ );
Review Comment:
Should the event calls be wrapped into unawaited or `_safeSendEvent`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102851131
##########
playground/frontend/lib/pages/standalone_playground/widgets/feedback/feedback_dropdown_content.dart:
##########
@@ -40,11 +39,15 @@ class FeedbackDropdownContent extends StatelessWidget {
static const sendButtonKey = Key('sendFeedbackButtonKey');
final void Function() close;
+ final EventContext eventContext;
+ final FeedbackRating feedbackRating;
final TextEditingController textController;
const FeedbackDropdownContent({
Key? key,
Review Comment:
Deleted.
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -29,7 +29,9 @@ import '../../cache/unit_progress.dart';
import '../../config.dart';
import '../../models/unit.dart';
import '../../models/unit_content.dart';
+// import '../../modules/analytics/google_analytics_service.dart';
Review Comment:
Deleted.
##########
learning/tour-of-beam/frontend/lib/modules/analytics/categories.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsCategories {
Review Comment:
Deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102769307
##########
playground/frontend/lib/components/playground_run_or_cancel_button.dart:
##########
@@ -20,38 +20,38 @@ import 'package:flutter/widgets.dart';
import 'package:playground_components/playground_components.dart';
import 'package:provider/provider.dart';
-import '../modules/analytics/analytics_service.dart';
-import '../utils/analytics_utils.dart';
-
class PlaygroundRunOrCancelButton extends StatelessWidget {
const PlaygroundRunOrCancelButton();
@override
Widget build(BuildContext context) {
return Consumer<PlaygroundController>(
- builder: (context, playgroundController, child) {
- final analyticsService = AnalyticsService.get(context);
- final stopwatch = Stopwatch();
- final exampleName = getAnalyticsExampleName(playgroundController);
-
- return RunOrCancelButton(
- playgroundController: playgroundController,
- beforeCancel: () {
- final exampleName = getAnalyticsExampleName(playgroundController);
- analyticsService.trackClickCancelRunEvent(exampleName);
- },
- beforeRun: () {
- stopwatch.start();
- analyticsService.trackClickRunEvent(exampleName);
- },
- onComplete: () {
- analyticsService.trackRunTimeEvent(
- exampleName,
- stopwatch.elapsedMilliseconds,
- );
- },
- );
- }
+ builder: (context, playgroundController, child) => RunOrCancelButton(
+ playgroundController: playgroundController,
+ beforeCancel: (runner) {
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
ToB and Playground have different events. We will have to implement bridge with ToB and Playground interfaces for abstractions and abstract + Google for implementations. Then we gain methods with named parameters which is a bit simpler interface than constructing events, except that we anyway have to construct events to store them and to manipulate their properties as a map.
So I prefer constructing event objects here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131245478
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
+class TobEventContext with EquatableMixin {
+ const TobEventContext({
+ required this.sdkId,
+ required this.unitId,
});
+ final String? sdkId;
+ final String? unitId;
Review Comment:
We want a parameter to be nullable when 'no value' is a valid case.
We want a parameter to be required when it is important enough that we want a compile-time guarantee that we never forget it and never let it silently default to something.
In this case we want both given how hard analytics is to debug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1087443932
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -57,6 +62,7 @@ class TourNotifier extends ChangeNotifier with PageStateMixin<void> {
_appNotifier.addListener(_onAppNotifierChanged);
_authNotifier.addListener(_onUnitProgressChanged);
_onUnitChanged();
+ window.onBeforeUnload.listen(_onTabClosed);
Review Comment:
Make a `CloseNotifier` and do not import `dart:html` here?
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
Review Comment:
Is there a way to use a platform-agnostic implementation?
##########
learning/tour-of-beam/frontend/lib/modules/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+import 'package:usage/usage_html.dart';
+
+import '../../config.dart';
+import '../../models/module.dart';
+import '../../models/unit.dart';
+import 'categories.dart';
+import 'events.dart';
+import 'service.dart';
+
+class TobGoogleAnalyticsService extends GoogleAnalyticsService
+ implements TobAnalyticsService {
+ static const _appName = 'beam';
+ static const _appVersion = '1.0';
+ final _analytics = AnalyticsHtml(kAnalyticsUA, _appName, _appVersion);
+
+ static TobGoogleAnalyticsService get() {
+ return GetIt.instance.get<TobGoogleAnalyticsService>();
+ }
+
+ TobGoogleAnalyticsService()
+ : super(
+ appAnalytics: AnalyticsHtml(
+ kAnalyticsUA,
+ _appName,
+ _appVersion,
+ ),
+ );
+
+ @override
+ Future<void> openUnit(Sdk sdk, UnitModel unit) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.openUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unit.id}',
+ ),
+ );
+ }
+
+ @override
+ Future<void> closeUnit(Sdk sdk, String unitId, Duration timeSpent) async {
+ await _safeSendEvent(
+ AnalyticsEvent(
+ action: TobAnalyticsEvents.closeUnit,
+ category: TobAnalyticsCategories.unit,
+ label: '${sdk.title}_${unitId}_${timeSpent.inSeconds}s',
Review Comment:
Is there a way to send raw property values for `sdk.title`, `unit.id`, and seconds to filter the events later?
##########
learning/tour-of-beam/frontend/lib/modules/analytics/service.dart:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+
+import '../../models/module.dart';
+import '../../models/unit.dart';
+
+abstract class TobAnalyticsService extends AnalyticsService {
+ static TobAnalyticsService get() {
+ return GetIt.instance.get<TobAnalyticsService>();
+ }
+
+ Future<void> openUnit(Sdk sdk, UnitModel unit);
+ Future<void> closeUnit(Sdk sdk, String unitId, Duration timeSpent);
+ Future<void> completeUnit(Sdk sdk, UnitModel unit);
+ // TODO(nausharipov): implement
Review Comment:
?
##########
playground/frontend/lib/config.g.dart:
##########
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
Review Comment:
- We are not yet allowed to commit this file. See https://github.com/apache/beam/pull/25022
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,7 +26,8 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
+const String kAnalyticsUA = 'G-349612187';
Review Comment:
Does the `usage` package work with the Analytics-4 new counters?
##########
playground/frontend/lib/modules/analytics/categories.dart:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class AnalyticsCategories {
+ static const common = 'Common';
+ // TODO(nausharipov): runCode and example are duplicated in PGC
Review Comment:
Then can we remove them from here? Same with events like `click_cancel_run` etc.
##########
playground/frontend/playground_components/lib/src/services/analytics/generic/categories.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class GenericAnalyticsCategories {
Review Comment:
```suggestion
class BeamAnalyticsCategories {
```
?
##########
playground/frontend/lib/pages/standalone_playground/widgets/feedback/rating_enum.dart:
##########
@@ -0,0 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+enum FeedbackRating { positive, negative }
Review Comment:
Trailing comma, auto-format.
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics_service.dart:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:usage/usage_html.dart';
+
+import 'event.dart';
+import 'generic/categories.dart';
+import 'generic/events.dart';
+import 'service.dart';
+
+class GoogleAnalyticsService implements AnalyticsService {
+ late AnalyticsHtml _appAnalytics;
+
+ GoogleAnalyticsService({
+ required AnalyticsHtml appAnalytics,
+ }) {
+ _appAnalytics = appAnalytics;
+ }
+
+ @override
+ AnalyticsEvent? lastSentEvent;
+
Review Comment:
There should be more events common for the two projects. Cancelling comes to mind.
I suggest also adding feedback here. This way we make sure that both ToB and Playground handle the feedback the same way.
##########
playground/frontend/lib/pages/standalone_playground/widgets/feedback/playground_feedback.dart:
##########
@@ -67,7 +63,7 @@ class PlaygroundFeedback extends StatelessWidget {
_setEnjoying(BuildContext context, bool isEnjoying) {
return () {
_getFeedbackState(context, false).setEnjoying(isEnjoying);
- AnalyticsService.get(context).trackClickEnjoyPlayground(isEnjoying);
+ PlaygroundAnalyticsService.get().trackClickEnjoyPlayground(isEnjoying);
Review Comment:
Use `FeedbackRating` everywhere instead of bool?
##########
playground/frontend/playground_components/lib/src/services/analytics/generic/events.dart:
##########
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class GenericAnalyticsEvents {
+ static const run = 'click_run';
+ // TODO(nausharipov): rename example to snippet everywhere?
Review Comment:
I suggest keeping it to not break the continuity of statistics.
##########
playground/frontend/playground_components/lib/src/widgets/run_or_cancel_button.dart:
##########
@@ -49,7 +50,10 @@ class RunOrCancelButton extends StatelessWidget {
(_) => PlaygroundComponents.toastNotifier.add(_getErrorToast()),
);
},
- runCode: () {
+ runCode: () async {
+ await AnalyticsService.get().trackRunExample(
+ playgroundController.selectedExample!.name,
+ );
Review Comment:
Maybe not await most of the events? Except maybe feedback because the event is the business logic there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105789899
##########
playground/frontend/lib/modules/analytics/categories.dart:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class AnalyticsCategories {
+ static const common = 'Common';
+ // TODO(nausharipov): runCode and example are duplicated in PGC
Review Comment:
Deleted categories altogether as the older analytics artifact.
##########
playground/frontend/playground_components/lib/src/services/analytics/generic/categories.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class GenericAnalyticsCategories {
Review Comment:
Deleted categories altogether as the older analytics artifact.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105787747
##########
learning/tour-of-beam/frontend/lib/pages/tour/state.dart:
##########
@@ -57,6 +62,7 @@ class TourNotifier extends ChangeNotifier with PageStateMixin<void> {
_appNotifier.addListener(_onAppNotifierChanged);
_authNotifier.addListener(_onUnitProgressChanged);
_onUnitChanged();
+ window.onBeforeUnload.listen(_onTabClosed);
Review Comment:
Made `WindowCloseNotifier`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105788724
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,7 +26,8 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
+const String kAnalyticsUA = 'G-349612187';
Review Comment:
Dropped `usage`, manually submitting to GA4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] github-actions[bot] commented on pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24957:
URL: https://github.com/apache/beam/pull/24957#issuecomment-1435239372
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102693669
##########
playground/frontend/playground_components/lib/src/services/analytics/events/abstract.dart:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import '../../../models/event_context.dart';
+
+abstract class AnalyticsEvent with EquatableMixin {
+ const AnalyticsEvent({
+ required this.name,
+ });
+
+ final String name;
+
+ @override
+ List<Object?> get props => [
+ name,
+ ];
+
+ Map<String, dynamic> toJson() => const {};
+}
+
+/// An [AnalyticsEvent] with [EventContext].
+abstract class SnippetAnalyticsEvent extends AnalyticsEvent {
Review Comment:
SnippetAnalyticsEvent => AnalyticsEventWithContext
or
EventContext => SnippetEventContext
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1102851414
##########
learning/tour-of-beam/frontend/lib/modules/analytics/events.dart:
##########
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsEvents {
Review Comment:
Deleted.
##########
learning/tour-of-beam/frontend/lib/modules/analytics/events.dart:
##########
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY IND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class TobAnalyticsEvents {
+ static const openUnit = 'open_unit'; // datetime?
Review Comment:
Deleted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1105813875
##########
playground/frontend/lib/components/dropdown_button/dropdown_button.dart:
##########
@@ -154,7 +157,7 @@ class _AppDropdownButtonState extends State<AppDropdownButton>
color: Theme.of(context).backgroundColor,
borderRadius: BorderRadius.circular(kMdBorderRadius),
),
- child: widget.createDropdown(_close),
+ child: child,
Review Comment:
`chlid` had been creating multiple times here by `OverlayEntry` builder leading to false positive analytics events.
##########
playground/frontend/Dockerfile:
##########
@@ -28,6 +28,7 @@ RUN apt-get update && apt-get install -y wget xz-utils git
RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$FLUTTER_VERSION-stable.tar.xz &&\
tar -xf flutter_linux_$FLUTTER_VERSION-stable.tar.xz &&\
mv flutter /opt/ &&\
+ git config --global --add safe.directory /opt/flutter &&\
Review Comment:
The recent version of Debian 11.6 has newer `git` that by default does not allow operations outside of home directories. Flutter uses `git` to download dependencies when it is ran for the first time, so this is required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] nausharipov commented on a diff in pull request #24957: [ToB] [Frontend] Tour of Beam analytics
Posted by "nausharipov (via GitHub)" <gi...@apache.org>.
nausharipov commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1088309874
##########
learning/tour-of-beam/frontend/lib/modules/analytics/service.dart:
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
+
+import '../../models/module.dart';
+import '../../models/unit.dart';
+
+abstract class TobAnalyticsService extends AnalyticsService {
+ static TobAnalyticsService get() {
+ return GetIt.instance.get<TobAnalyticsService>();
+ }
+
+ Future<void> openUnit(Sdk sdk, UnitModel unit);
+ Future<void> closeUnit(Sdk sdk, String unitId, Duration timeSpent);
+ Future<void> completeUnit(Sdk sdk, UnitModel unit);
+ // TODO(nausharipov): implement
Review Comment:
Deleted `completeModule` after the discussion with Oleh.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131996185
##########
playground/frontend/playground_components/lib/src/services/analytics/analytics_service.dart:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:get_it/get_it.dart';
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+
+/// Abstract class to submit analytics events.
+abstract class AnalyticsService {
+ AnalyticsEvent? _lastEvent;
+ AnalyticsEvent? get lastEvent => _lastEvent;
+
+ final _defaultEventParameters = <String, dynamic>{};
+
+ /// The parameters sent with all events.
+ ///
+ /// Individual event parameters have higher priority on collisions.
+ Map<String, dynamic> get defaultEventParameters =>
+ UnmodifiableMapView(_defaultEventParameters);
+
+ set defaultEventParameters(Map<String, dynamic> newValue) {
+ _defaultEventParameters.clear();
+ _defaultEventParameters.addAll(newValue);
+ }
+
+ static AnalyticsService get() {
+ return GetIt.instance.get<AnalyticsService>();
+ }
+
+ /// Sends [event] asynchronously without returning a [Future].
+ void sendUnawaited(AnalyticsEvent event) {
Review Comment:
Because when we call it and discard the future, we get a `discarded_future` lint. We would have to do one of the following with it:
- Disable the lint project-wide, which we do not want to, because it guards from logic errors.
- Disable it at each occurrence with which is harder to read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] damondouglas commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "damondouglas (via GitHub)" <gi...@apache.org>.
damondouglas commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1130147671
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
+ propertyId: kAnalyticsUA,
+ );
+ GetIt.instance.registerSingleton<AnalyticsService>(
+ googleAnalyticsService,
+ );
Review Comment:
Instead of using GetIt why not just reference googleAnalyticsService? The project claims
> As your App grows, at some point you will need to put your app's logic in classes that are separated from your Widgets. Keeping your widgets from having direct dependencies makes your code better organized and easier to test and maintain.
It isn't clear from this what is actually implementing the abstract AnalyticsService class without some digging. The promise to make the code better organized, at least in my attempt at reading the code, didn't seem to happen.
##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_tabs/share_tabs.dart:
##########
@@ -27,11 +27,13 @@ import 'snippet_save_and_share_tabs.dart';
/// content widget accordingly.
// TODO(alexeyinkin): Refactor code sharing, https://github.com/apache/beam/issues/24637
class ShareTabs extends StatelessWidget {
+ final EventSnippetContext eventSnippetContext;
final VoidCallback onError;
final TabController tabController;
const ShareTabs({
super.key,
+ required this.eventSnippetContext,
Review Comment:
What is an eventSnippetContext? Could we see a code comment?
##########
playground/frontend/playground_components/lib/src/controllers/window_close_notifier/window_close_notifier_web.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:html'; // ignore: avoid_web_libraries_in_flutter
+
+import 'package:flutter/foundation.dart';
+
+/// Notifies when the browser window is being closed.
+class WindowCloseNotifier extends ChangeNotifier {
Review Comment:
It isn't clear why this class is needed. Quick search through this PR, I only see adding and removing of listeners but no code in response to this event. Is it above with `PlaygroundComponents.analyticsService.sendUnawaited(LoadedAnalyticsEvent`? In other words are we wanting to analyze when the user closed the window and ended their interaction with the application?
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
+class TobEventContext with EquatableMixin {
+ const TobEventContext({
+ required this.sdkId,
+ required this.unitId,
});
+ final String? sdkId;
+ final String? unitId;
Review Comment:
From a code design perspective, why are these nullable when required in the constructor?
##########
playground/frontend/playground_components/lib/src/services/analytics/google_analytics4_service/google_analytics4_service_web.dart:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:html'; // ignore: avoid_web_libraries_in_flutter
+import 'dart:js' as js; // ignore: avoid_web_libraries_in_flutter
+
+import 'package:meta/meta.dart';
+
+import '../events/abstract.dart';
+import 'google_analytics4_service.dart';
+
+final _urlTemplate = Uri.parse('https://www.googletagmanager.com/gtag/js');
+const _eventNameParam = 'eventName';
+
+/// The global JS function to submit analytics data.
+const _function = 'gtag';
+
+@internal
+GoogleAnalytics4Service createGoogleAnalytics4Service({
+ required String propertyId,
+}) =>
+ GoogleAnalytics4ServiceWeb(propertyId: propertyId);
+
+/// Submits data to a Google Analytics 4 property using JavaScript.
+class GoogleAnalytics4ServiceWeb extends GoogleAnalytics4Service {
Review Comment:
Can we see tests for this class? I see on the GetIt README, the author writes, "I missed the ability to easily switch the implementation for a mocked version without changing the UI". It seems to suggest that using GetIt seems to provide the ability, as the author writes on the README, "make tests easier".
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
+class TobEventContext with EquatableMixin {
+ const TobEventContext({
+ required this.sdkId,
+ required this.unitId,
});
+ final String? sdkId;
+ final String? unitId;
+
+ static const empty = TobEventContext(
+ sdkId: null,
+ unitId: null,
+ );
Review Comment:
Could we spell out Tob to TourOfBeam and it isn't clear why it needs to implement EquatableMixin? Is it because there are two nullable properties and doing equals on this is challenging?
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
Review Comment:
What if the analytics service changes again from GoogleAnalytics4Service to something else?
##########
learning/tour-of-beam/frontend/lib/services/analytics/events/unit_opened.dart:
##########
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'abstract.dart';
+import 'constants.dart';
+
+class UnitOpenedTobAnalyticsEvent extends AnalyticsEventWithTobContext {
Review Comment:
Could we see a code comment explaining its purpose?
##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_tabs/share_format_enum.dart:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
Review Comment:
I realize that the enum is obvious from its members but could we see a code comment describing its purpose which I'm assuming is in the context of Analytics events?
##########
playground/frontend/playground_components/lib/playground_components.dart:
##########
@@ -40,20 +47,40 @@ export 'src/models/example_view_options.dart';
export 'src/models/intents.dart';
export 'src/models/loading_status.dart';
export 'src/models/outputs.dart';
+export 'src/models/run_shortcut.dart';
export 'src/models/sdk.dart';
export 'src/models/shortcut.dart';
export 'src/models/snippet_file.dart';
export 'src/models/toast.dart';
export 'src/models/toast_type.dart';
+
export 'src/playground_components.dart';
+
export 'src/repositories/code_client/grpc_code_client.dart';
export 'src/repositories/code_repository.dart';
export 'src/repositories/example_client/grpc_example_client.dart';
export 'src/repositories/example_repository.dart';
+
export 'src/router/router_delegate.dart';
+
+export 'src/services/analytics/analytics_service.dart';
+export 'src/services/analytics/events/abstract.dart';
+export 'src/services/analytics/events/app_rated.dart';
+export 'src/services/analytics/events/constants.dart';
+export 'src/services/analytics/events/external_url_navigated.dart';
+export 'src/services/analytics/events/feedback_form_sent.dart';
+export 'src/services/analytics/events/report_issue_clicked.dart';
+export 'src/services/analytics/events/run_cancelled.dart';
+export 'src/services/analytics/events/run_finished.dart';
+export 'src/services/analytics/events/run_started.dart';
+export 'src/services/analytics/events/sdk_selected.dart';
+export 'src/services/analytics/events/snippet_reset.dart';
+export 'src/services/analytics/google_analytics4_service/google_analytics4_service.dart';
Review Comment:
Wouldn't this make sense to be part of a `playground_services` library instead of a `playground_components` library?
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,14 +26,10 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
-const String kApiClientURL =
- 'https://backend-router-beta-dot-apache-beam-testing.appspot.com';
-const String kApiJavaClientURL =
- 'https://backend-java-beta-dot-apache-beam-testing.appspot.com';
-const String kApiGoClientURL =
- 'https://backend-go-beta-dot-apache-beam-testing.appspot.com';
-const String kApiPythonClientURL =
- 'https://backend-python-beta-dot-apache-beam-testing.appspot.com';
-const String kApiScioClientURL =
- 'https://backend-scio-beta-dot-apache-beam-testing.appspot.com';
+const String kAnalyticsUA = 'G-BXFP2FNCKC';
+
+const String kApiClientURL = 'https://router.play-dev.beam.apache.org';
+const String kApiJavaClientURL = 'https://java.play-dev.beam.apache.org';
+const String kApiGoClientURL = 'https://go.play-dev.beam.apache.org';
+const String kApiPythonClientURL = 'https://python.play-dev.beam.apache.org';
+const String kApiScioClientURL = 'https://scio.play-dev.beam.apache.org';
Review Comment:
Code comment where these come from and how they are derived? Someone should read this and know how to change if needed.
##########
playground/frontend/lib/services/analytics/events/constants.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class PlaygroundAnalyticsEvents {
+ static const loaded = 'loaded';
+ static const newExample = 'new_example';
+ static const shareableCopied = 'shareable_copied';
+ static const shareCodeClicked = 'share_code_clicked';
+ static const shortcutsClicked = 'shortcuts_clicked';
+ static const snippetSelected = 'snippet_selected';
+}
+
+class PlaygroundEventParams {
+ static const shareFormat = 'shareFormat';
Review Comment:
Why is there a class with a single static const property?
##########
playground/frontend/lib/pages/enum.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+enum PagesEnum {
+ embeddedPlayground,
+ standalonePlayground,
+}
Review Comment:
May we see a code comment describing the purpose of this enum and its members, perhaps in the context of analytics?
##########
playground/frontend/lib/services/analytics/events/constants.dart:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class PlaygroundAnalyticsEvents {
Review Comment:
Comment
##########
learning/tour-of-beam/frontend/lib/config.dart:
##########
@@ -26,14 +26,10 @@ const cloudFunctionsBaseUrl = 'https://'
// Copied from Playground's config.g.dart
-const String kAnalyticsUA = 'UA-73650088-2';
-const String kApiClientURL =
- 'https://backend-router-beta-dot-apache-beam-testing.appspot.com';
-const String kApiJavaClientURL =
- 'https://backend-java-beta-dot-apache-beam-testing.appspot.com';
-const String kApiGoClientURL =
- 'https://backend-go-beta-dot-apache-beam-testing.appspot.com';
-const String kApiPythonClientURL =
- 'https://backend-python-beta-dot-apache-beam-testing.appspot.com';
-const String kApiScioClientURL =
- 'https://backend-scio-beta-dot-apache-beam-testing.appspot.com';
+const String kAnalyticsUA = 'G-BXFP2FNCKC';
Review Comment:
Why is this value here and also configured in the gradle?
##########
playground/frontend/playground_components/lib/src/models/event_snippet_context.dart:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import 'sdk.dart';
+
+const _none = 'none';
+
+/// Basic information of the Playground state at a particular moment of time
+/// to augment analytics events.
+class EventSnippetContext with EquatableMixin {
Review Comment:
Why does this need to implement EquatableMixin mixin?
##########
playground/frontend/playground_components/lib/src/enums/feedback_rating.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+enum FeedbackRating {
+ positive,
+ negative,
+}
Review Comment:
Is this being sent to the analytics service?
##########
playground/frontend/playground_components/lib/src/models/event_snippet_context.dart:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:equatable/equatable.dart';
+
+import 'sdk.dart';
+
+const _none = 'none';
+
+/// Basic information of the Playground state at a particular moment of time
+/// to augment analytics events.
+class EventSnippetContext with EquatableMixin {
+ const EventSnippetContext({
+ required this.originalSnippet,
+ required this.sdk,
+ required this.snippet,
+ });
+
+ /// Any identifier of the snippet that the content was derived from.
+ ///
+ /// If the code was modified it is still the last snippet loaded or chosen
+ /// by the user.
+ final String? originalSnippet;
+
+ final Sdk? sdk;
+
+ /// Any identifier of the current snippet if it is unchanged.
+ final String? snippet;
Review Comment:
From a code design perspective, why was it decided to make these nullable but required in the constructor?
##########
playground/frontend/lib/services/analytics/events/loaded.dart:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:playground_components/playground_components.dart';
+
+import 'constants.dart';
+
+/// Playground is loaded.
+class LoadedAnalyticsEvent extends AnalyticsEvent {
Review Comment:
When you change this PR to add more tests, it would be nice to see this included. It looks like this and its base AnalyticsEvent class are just value classes without any exciting functionality so perhaps we can see coverage in the context of other analytics tests such as a test that loads the Playground and asserts that the LoadedAnalyticsEvent has the assigned sdk and/or snippet.
##########
learning/tour-of-beam/frontend/lib/pages/tour/controllers/unit.dart:
##########
@@ -18,28 +18,40 @@
import 'package:flutter/widgets.dart';
import 'package:get_it/get_it.dart';
+import 'package:playground_components/playground_components.dart';
import '../../../cache/unit_progress.dart';
+import '../../../models/event_context.dart';
+import '../../../models/unit.dart';
import '../../../repositories/client/client.dart';
+import '../../../services/analytics/events/unit_completed.dart';
class UnitController extends ChangeNotifier {
- final String unitId;
- final String sdkId;
+ final UnitModel unit;
Review Comment:
What is a UnitModel? Is this the model class representing the unit? Should this be documented here as a code comment? Also to improve code readability, could we prefix all classes coming from outside with the library it is imported from? For example, I would have to open each imported file here to find where UnitModel comes from or do a search for its symbol.
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
Review Comment:
What Tour of Beam state? The SdkId and the UnitId?
##########
playground/frontend/lib/services/analytics/events/new_example.dart:
##########
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'package:playground_components/playground_components.dart';
+
+import 'constants.dart';
+
+/// 'New Example' button is clicked in the app header.
+class NewExampleAnalyticsEvent extends AnalyticsEvent {
Review Comment:
It would be great to see more test coverage for this. Like other extensions of AnalyticsEvent seemingly just data classes, it would be great to assert that the values are what is expected (I see the name property for example). In this context I would like to see a test mocking New Example button clicked and that the assertion passes that the name is what it should be.
##########
playground/frontend/playground_components/lib/src/services/analytics/analytics_service.dart:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:get_it/get_it.dart';
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+
+/// Abstract class to submit analytics events.
+abstract class AnalyticsService {
+ AnalyticsEvent? _lastEvent;
+ AnalyticsEvent? get lastEvent => _lastEvent;
+
+ final _defaultEventParameters = <String, dynamic>{};
+
+ /// The parameters sent with all events.
+ ///
+ /// Individual event parameters have higher priority on collisions.
+ Map<String, dynamic> get defaultEventParameters =>
+ UnmodifiableMapView(_defaultEventParameters);
+
+ set defaultEventParameters(Map<String, dynamic> newValue) {
+ _defaultEventParameters.clear();
+ _defaultEventParameters.addAll(newValue);
+ }
+
+ static AnalyticsService get() {
+ return GetIt.instance.get<AnalyticsService>();
+ }
+
+ /// Sends [event] asynchronously without returning a [Future].
+ void sendUnawaited(AnalyticsEvent event) {
Review Comment:
Why can't we just have `Future<void> send(AnalyticsEvent event) async { ... }`?
##########
learning/tour-of-beam/frontend/lib/models/event_context.dart:
##########
@@ -18,27 +18,31 @@
import 'package:equatable/equatable.dart';
-class AnalyticsEvent with EquatableMixin {
- final String action;
- final String category;
- final String? label;
- final Map<String, String>? parameters;
- final int? value;
+const _none = 'none';
- AnalyticsEvent({
- required this.action,
- required this.category,
- this.label,
- this.parameters,
- this.value,
+/// Basic information of the Tour of Beam state to augment analytics events.
+class TobEventContext with EquatableMixin {
Review Comment:
Could we spell out TourOfBeam instead of using the abbreviation?
##########
playground/frontend/playground_components/lib/src/services/analytics/analytics_service.dart:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import 'dart:async';
+import 'dart:collection';
+
+import 'package:get_it/get_it.dart';
+import 'package:meta/meta.dart';
+
+import 'events/abstract.dart';
+
+/// Abstract class to submit analytics events.
+abstract class AnalyticsService {
+ AnalyticsEvent? _lastEvent;
+ AnalyticsEvent? get lastEvent => _lastEvent;
+
+ final _defaultEventParameters = <String, dynamic>{};
+
+ /// The parameters sent with all events.
+ ///
+ /// Individual event parameters have higher priority on collisions.
+ Map<String, dynamic> get defaultEventParameters =>
+ UnmodifiableMapView(_defaultEventParameters);
+
+ set defaultEventParameters(Map<String, dynamic> newValue) {
+ _defaultEventParameters.clear();
+ _defaultEventParameters.addAll(newValue);
+ }
+
+ static AnalyticsService get() {
+ return GetIt.instance.get<AnalyticsService>();
Review Comment:
I don't see how GetIt is making it clear where the actual implementation exists. I had to search quite a bit until I found the actual implementation. Nonetheless, if we decide to keep and use GetIt, can we make good use of it and expand our test coverage as the package promises to make easier?
##########
playground/frontend/lib/modules/actions/components/new_example_action.dart:
##########
@@ -38,7 +38,9 @@ class NewExampleAction extends StatelessWidget {
label: 'intents.playground.newExample'.tr(),
onPressed: () {
launchUrl(Uri.parse('/'));
- AnalyticsService.get(context).trackClickNewExample();
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
I agree with @Malarg here that sendNewExampleEvent makes sense instead of sendUnawaited.
##########
learning/tour-of-beam/frontend/lib/locator.dart:
##########
@@ -61,3 +64,12 @@ void _initializeState() {
),
);
}
+
+void _initializeServices() {
+ final googleAnalyticsService = GoogleAnalytics4Service(
Review Comment:
Also, is it possible to alias the library imports so someone knows where the class is from? So instead of `SomeClass()`, we have `library.SomeClass()`? Yes, in an IDE one could navigate to definition but many times people are reading code on GitHub directly; it's symbol lookup doesn't always work.
##########
playground/frontend/lib/components/playground_run_or_cancel_button.dart:
##########
@@ -20,38 +20,38 @@ import 'package:flutter/widgets.dart';
import 'package:playground_components/playground_components.dart';
import 'package:provider/provider.dart';
-import '../modules/analytics/analytics_service.dart';
-import '../utils/analytics_utils.dart';
-
class PlaygroundRunOrCancelButton extends StatelessWidget {
const PlaygroundRunOrCancelButton();
@override
Widget build(BuildContext context) {
return Consumer<PlaygroundController>(
- builder: (context, playgroundController, child) {
- final analyticsService = AnalyticsService.get(context);
- final stopwatch = Stopwatch();
- final exampleName = getAnalyticsExampleName(playgroundController);
-
- return RunOrCancelButton(
- playgroundController: playgroundController,
- beforeCancel: () {
- final exampleName = getAnalyticsExampleName(playgroundController);
- analyticsService.trackClickCancelRunEvent(exampleName);
- },
- beforeRun: () {
- stopwatch.start();
- analyticsService.trackClickRunEvent(exampleName);
- },
- onComplete: () {
- analyticsService.trackRunTimeEvent(
- exampleName,
- stopwatch.elapsedMilliseconds,
- );
- },
- );
- }
+ builder: (context, playgroundController, child) => RunOrCancelButton(
+ playgroundController: playgroundController,
+ beforeCancel: (runner) {
+ PlaygroundComponents.analyticsService.sendUnawaited(
Review Comment:
I agree with @Malarg that sendCancelRun makes a little more sense than sendUnawaited but is still unclear to me. Should it be called sendRunOrCancel to be consistent with the RunOrCancelButton?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [beam] alexeyinkin commented on a diff in pull request #24957: [Playground] [Frontend] Migrate Playground to Google Analytics 4
Posted by "alexeyinkin (via GitHub)" <gi...@apache.org>.
alexeyinkin commented on code in PR #24957:
URL: https://github.com/apache/beam/pull/24957#discussion_r1131068740
##########
playground/frontend/lib/pages/enum.dart:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+enum PagesEnum {
+ embeddedPlayground,
+ standalonePlayground,
+}
Review Comment:
`+`
##########
playground/frontend/lib/modules/editor/components/share_dropdown/share_tabs/share_format_enum.dart:
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
Review Comment:
`+`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org