-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathanalytics_web.dart
More file actions
32 lines (29 loc) · 872 Bytes
/
analytics_web.dart
File metadata and controls
32 lines (29 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2025 The Flutter Authors. 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:meta/meta.dart';
import 'package:universal_web/js_interop.dart';
import 'package:universal_web/web.dart' as web;
import '../util.dart';
import 'analytics.dart';
/// Web implementation of [Analytics].
///
/// Don't use directly. Access through [analytics] instead.
@internal
final class AnalyticsImplementation extends Analytics {
@override
void sendEvent(String eventName, Map<String, Object?> parameters) {
if (!productionBuild) {
return;
}
final dataLayer = web.window['dataLayer'];
if (dataLayer.isA<JSArray>()) {
(dataLayer as JSArray).toDart.add(
{
'event': eventName,
...parameters,
}.jsify(),
);
}
}
}