Skip to content

Renaming package to unified_analytics #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .github/ISSUE_TEMPLATE/dash_analytics.md

This file was deleted.

5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/unified_analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:unified_analytics"
about: "Create a bug or file a feature request against package:unified_analytics."
labels: "package:unified_analytics"
---
4 changes: 2 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
'type-infra':
- '.github/**'

'package:dash_analytics':
- 'pkgs/dash_analytics/**'
'package:unified_analytics':
- 'pkgs/unified_analytics/**'
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: package:dash_analytics
name: package:unified_analytics
permissions: read-all

on:
pull_request:
branches: [ main ]
paths:
- '.github/workflows/dash_analytics.yml'
- 'pkgs/dash_analytics/**'
- '.github/workflows/unified_analytics.yml'
- 'pkgs/unified_analytics/**'
push:
branches: [ main ]
paths:
- '.github/workflows/dash_analytics.yml'
- 'pkgs/dash_analytics/**'
- '.github/workflows/unified_analytics.yml'
- 'pkgs/unified_analytics/**'
schedule:
- cron: '0 0 * * 0' # weekly

Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: pkgs/dash_analytics
working-directory: pkgs/unified_analytics
strategy:
matrix:
sdk: [stable, dev] # {pkgs.versions}
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# for code within the repository
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

/pkgs/dash_analytics/ @eliasyishak
/pkgs/unified_analytics/ @eliasyishak
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ don't naturally belong to other topic monorepos (like

| Package | Description | Version |
| --- | --- | --- |
| [dash_analytics](pkgs/dash_analytics/) | A package for logging analytics for all dash related tooling to Google Analytics. | <!-- [![pub package](https://img.shields.io/pub/v/dash_analytics.svg)](https://pub.dev/packages/dash_analytics) --> |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | <!-- [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) --> |

## Publishing automation

Expand Down
15 changes: 0 additions & 15 deletions pkgs/dash_analytics/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions pkgs/unified_analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[![package:unified_analytics](https://github.com/dart-lang/tools/actions/workflows/unified_analytics.yml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/unified_analytics.yml)

## What's this?

This package is intended to be used on Dart and Flutter related
tooling only. It provides APIs to send events to Google Analytics using the
Measurement Protocol.

This is not intended to be general purpose or consumed by the community. It is
responsible for toggling analytics collection for related tooling on each
developer's machine.

## Using this package

Refer to the [usage guide](USAGE_GUIDE.md).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This package is intended to be used on Dash (Flutter, Dart, etc.) related tooling only.
This package is intended to be used on Dart and Flutter related tooling only.
It provides APIs to send events to Google Analytics using the Measurement Protocol.

## Usage
Expand All @@ -7,7 +7,7 @@ To get started using this package, import at the entrypoint dart file and
initialize with the required parameters

```dart
import 'dash_analytics';
import 'unified_analytics/unified_analytics.dart';

// Constants that should be resolved by the client using package
final DashTool tool = DashTool.flutterTools; // Restricted to enum provided by package
Expand Down Expand Up @@ -67,9 +67,9 @@ void main() {

## Opting In and Out of Analytics Collection

It will be important for each Dash tool to expose a trivial method to
It will be important for each tool to expose a trivial method to
disabling or enabling analytics collection. Based on how the user interacts
with the tool, this can be done through the CLI, IDE, etc. The Dash tool will
with the tool, this can be done through the CLI, IDE, etc. The tool will
then pass a boolean to an API exposed by the package as shown below

```dart
Expand All @@ -86,28 +86,28 @@ analytics.setTelemetry(status);

## Informing Users About Analytics Opt-In Status

When a user first uses any Dash tool with this package enabled, they
When a user first uses any tool with this package enabled, they
will be enrolled into Analytics collection. It will be the responsiblity
of the Dash tool using this package to display the proper Analytics messaging
of the tool using this package to display the proper Analytics messaging
and inform them on how to Opt-Out of Analytics collection if they wish. The
package will expose APIs that will make it easy to configure Opt-In status.

```dart
// Begin by initializing the class
final Analytics analytics = Analytics(...);

// This should be performed every time the Dash tool starts up
// This should be performed every time the tool starts up
if (analytics.shouldShowMessage) {

// How each Dash tool displays the message will be unique,
// How each tool displays the message will be unique,
// print statement used for trivial usage example
print(analytics.toolsMessage);
}
```

## Checking User Opt-In Status

Some Dash tools may need to know if the user has opted in for Analytics
Some tools may need to know if the user has opted in for Analytics
collection in order to enable additional functionality. The example below
shows how to check the status

Expand All @@ -122,11 +122,11 @@ print('This user's status: ${analytics.telemetryEnabled}'); // true if opted-in

## Advanced Usage: Querying Locally Persisted Logs

This package enables dash tools to persist the events that have been
sent to Google Analytics for logging by default. This can be very helpful if
dash tools would like to understand the user's activity level across all
dash related tooling. For example, if querying the locally persisted logs
shows that the user has not been active for N number of days, a dash tool that
This package enables tools to persist the events that have been sent
to Google Analytics for logging by default. This can be very helpful if
tools would like to understand the user's activity level across all
related tooling. For example, if querying the locally persisted logs
shows that the user has not been active for N number of days, a tool that
works within an IDE can prompt the user with a survey to understand why their
level of activity has dropped.

Expand Down Expand Up @@ -157,4 +157,4 @@ Explanation of the each key above
- endDateTime: the latest, most recent event that was sent
- sessionCount: count of sessions; sessions have a minimum time of 30 minutes
- flutterChannelCount: count of flutter channels (can be 0 if developer is a Dart dev only)
- toolCount: count of the dash tools sending analytics
- toolCount: count of the Dart and Flutter tools sending analytics
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:dash_analytics/dash_analytics.dart';
import 'package:unified_analytics/unified_analytics.dart';

final String measurementId = 'G-N1NXG28J5B';
final String apiSecret = '4yT8__oER3Cd84dtx6r-_A';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ enum DashEvent {
description: 'Number of times each lint is enabled',
toolOwner: DashTool.languageServer,
),
notification(
label: 'notification',
clientNotification(
label: 'client_notification',
description: 'Notifications sent from the client',
toolOwner: DashTool.languageServer,
),
Expand All @@ -30,13 +30,13 @@ enum DashEvent {
description: 'Request responses from plugins',
toolOwner: DashTool.languageServer,
),
request(
label: 'request',
clientRequest(
label: 'client_request',
description: 'Requests sent from the client',
toolOwner: DashTool.languageServer,
),
session(
label: 'session',
serverSession(
label: 'server_session',
description: 'Dart Analyzer Server session data',
toolOwner: DashTool.languageServer,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class UserProperty {
'host': host,
'flutter_version': flutterVersion,
'dart_version': dartVersion,
'dash_analytics_version': kPackageVersion,
'analytics_pkg_version': kPackageVersion,
'tool': tool,
'local_time': '${clock.now()}',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'user_property.dart';
/// ```
/// {
/// "client_id": "46cc0ba6-f604-4fd9-aa2f-8a20beb24cd4",
/// "events": [{ "name": "testing_from_dash", "params": { "time_ns": 345 } }],
/// "events": [{ "name": "testing", "params": { "time_ns": 345 } }],
/// "user_properties": {
/// "session_id": { "value": 1673466750423 },
/// "flutter_channel": { "value": "ey-test-channel" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: dash_analytics
name: unified_analytics
description: >-
A package for logging analytics for all dash related tooling to Google
Analytics.
A package for logging analytics for all Dart and Flutter related tooling
to Google Analytics.
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 0.1.0-dev
repository: https://github.com/dart-lang/tools/tree/main/pkgs/dash_analytics
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
sdk: '>=2.19.0 <3.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import 'dart:io' as io;
import 'dart:math';

import 'package:clock/clock.dart';
import 'package:dash_analytics/dash_analytics.dart';
import 'package:dash_analytics/src/config_handler.dart';
import 'package:dash_analytics/src/constants.dart';
import 'package:dash_analytics/src/session.dart';
import 'package:dash_analytics/src/user_property.dart';
import 'package:dash_analytics/src/utils.dart';
import 'package:unified_analytics/unified_analytics.dart';
import 'package:unified_analytics/src/config_handler.dart';
import 'package:unified_analytics/src/constants.dart';
import 'package:unified_analytics/src/session.dart';
import 'package:unified_analytics/src/user_property.dart';
import 'package:unified_analytics/src/utils.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -427,7 +427,7 @@ $initialToolName=${ConfigHandler.dateStamp},$toolsMessageVersion
'host',
'flutter_version',
'dart_version',
'dash_analytics_version',
'analytics_pkg_version',
'tool',
'local_time',
];
Expand Down Expand Up @@ -878,21 +878,21 @@ $initialToolName=${ConfigHandler.dateStamp},$toolsMessageVersion

test('max 36 characters for user prop values (only `tool` key)', () {
// Checks item 3
// All dash tools must be under 36 characters (and enforce each tool
// All tools must be under 36 characters (and enforce each tool
// begins with a letter)
final RegExp toolLabelPattern = RegExp(r'^[a-zA-Z][a-zA-Z\_]{0,35}$');
bool dashToolLengthValid = true;
bool toolLengthValid = true;
final List<DashTool> invalidTools = <DashTool>[];
for (DashTool tool in DashTool.values) {
if (!toolLabelPattern.hasMatch(tool.label)) {
dashToolLengthValid = false;
toolLengthValid = false;
invalidTools.add(tool);
}
}

expect(dashToolLengthValid, true,
expect(toolLengthValid, true,
reason:
'All dash tool labels must be under 36 characters and begin with a letter\n'
'All tool labels must be under 36 characters and begin with a letter\n'
'The following are invalid\n$invalidTools');
});

Expand Down