Skip to content

Commit

Permalink
Make ScreenView id optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mscwilson committed Jun 3, 2024
1 parent 23b9bff commit edeb7dc
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 59 deletions.
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/snowplow_tracker/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
integration_test: 13825b8a9334a850581300559b8839134b124670
snowplow_tracker: 7951e14a4c8c17de35ad58eaac17dd51efda054d
SnowplowTracker: e53f7eb7de911801b741af2bd9e079e091fa7f2b

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.15.2
COCOAPODS: 1.12.1
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1510;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 0 additions & 1 deletion example/lib/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
ElevatedButton(
onPressed: () {
const event = ScreenView(
id: '2c295365-eae9-4243-a3ee-5c4b7baccc8f',
name: 'home',
type: 'full',
transitionType: 'none');
Expand Down
72 changes: 24 additions & 48 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
version: "6.1.4"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -111,10 +111,10 @@ packages:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "31c12de79262b5431c5492e9c89948aa789158435f707d3519a7fdef6af28af7"
sha256: "5b24061317f850af858ef7151dadbb6eb77c1c449c954c7bb064e8a5e0e7d81f"
url: "https://pub.dev"
source: hosted
version: "0.6.22+1"
version: "0.6.20"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -159,30 +159,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.1"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -203,50 +179,50 @@ packages:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.10.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.8.3"
platform:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
url: "https://pub.dev"
source: hosted
version: "3.1.4"
version: "3.1.2"
process:
dependency: transitive
description:
name: process
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -351,26 +327,26 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "11.10.0"
web:
dependency: transitive
description:
name: web
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.4.2"
version: "0.3.0"
webdriver:
dependency: transitive
description:
name: webdriver
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.2"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
4 changes: 2 additions & 2 deletions lib/events/screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ScreenView implements Event {
final String name;

/// The id (UUID v4) of screen that was viewed.
final String id;
final String? id;

/// The type of screen that was viewed.
final String? type;
Expand All @@ -42,7 +42,7 @@ class ScreenView implements Event {

const ScreenView(
{required this.name,
required this.id,
this.id,
this.type,
this.previousName,
this.previousType,
Expand Down
10 changes: 9 additions & 1 deletion lib/src/web/readers/events/screen_view_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.

import 'package:snowplow_tracker/events/screen_view.dart';
import 'package:uuid/uuid.dart';
import 'event_reader.dart';

class ScreenViewReader extends ScreenView implements EventReader {
Expand All @@ -23,6 +24,13 @@ class ScreenViewReader extends ScreenView implements EventReader {
previousId: map['previousId'],
transitionType: map['transitionType']);

String? idUUID() {
if (id == null) {
return const Uuid().v4();
}
return id;
}

@override
String endpoint() {
return 'trackSelfDescribingEvent';
Expand All @@ -32,7 +40,7 @@ class ScreenViewReader extends ScreenView implements EventReader {
Map eventData() {
var data = {
'name': name,
'id': id,
'id': idUUID(),
'type': type,
'previousName': previousName,
'previousId': previousId,
Expand Down
6 changes: 3 additions & 3 deletions test/snowplow_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ void main() {
});

test('tracks screen view event', () async {
String id = const Uuid().v4();
Event event = ScreenView(name: 'screen1', id: id);
// String id = const Uuid().v4();
Event event = const ScreenView(name: 'screen1');
await Snowplow.track(event, tracker: 'tns2');

expect(
methodCall,
isMethodCall('trackScreenView', arguments: {
'tracker': 'tns2',
'eventData': {'name': 'screen1', 'id': id}
'eventData': {'name': 'screen1'}
}));
});

Expand Down

0 comments on commit edeb7dc

Please sign in to comment.