Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
auto_track_plugin
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Dubhe
2024-04-28 16:51:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-04-28 16:51:05 +0800
Commit
5e49600fda8e281cf09c4bfc2b8217d44e548f67
5e49600f
1 parent
c4b4f8b2
feat: add uniqueId and ignoreNullKey
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
14 deletions
lib/auto_track/click/click_info.dart
lib/auto_track/config/config.dart
lib/auto_track/config/manager.dart
lib/auto_track/config/queue.dart
lib/auto_track/index.dart
lib/auto_track/page_view/page_info.dart
lib/auto_track/click/click_info.dart
View file @
5e49600
...
...
@@ -35,10 +35,7 @@ class ClickInfo {
}
else
{
clickInfo
.
_elementManualKey
=
key
?.
toString
()
??
md5
.
convert
(
utf8
.
encode
(
'
${clickInfo._elementType}${clickInfo._elementPath}
'
)).
toString
();
}
clickInfo
.
_ignore
=
AutoTrackConfigManager
.
instance
.
isIgnoreElement
(
key
);
if
(
key
is
AutoTrackElementKey
&&
!
clickInfo
.
_ignore
)
{
clickInfo
.
_ignore
=
key
.
ignore
;
}
clickInfo
.
_ignore
=
clickInfo
.
_checkIgnore
(
key
,
clickInfo
);
return
clickInfo
;
}
...
...
@@ -72,6 +69,23 @@ class ClickInfo {
final
PageInfo
pageInfo
;
bool
_checkIgnore
(
Key
?
key
,
ClickInfo
clickInfo
)
{
if
(
AutoTrackConfigManager
.
instance
.
isIgnoreElement
(
key
))
{
return
true
;
}
if
(
key
is
AutoTrackElementKey
)
{
if
(
key
.
ignore
)
{
return
true
;
}
}
if
(
key
==
null
&&
AutoTrackConfigManager
.
instance
.
config
.
enableIgnoreNullKey
)
{
return
true
;
}
return
false
;
}
@override
String
toString
()
{
return
[
...
...
lib/auto_track/config/config.dart
View file @
5e49600
...
...
@@ -12,6 +12,7 @@ class AutoTrackConfig {
this
.
trackId
,
this
.
userId
,
this
.
signature
,
this
.
uniqueId
,
this
.
pageConfigs
=
const
[],
this
.
useCustomRoute
=
false
,
this
.
ignoreElementKeys
=
const
[],
...
...
@@ -20,7 +21,8 @@ class AutoTrackConfig {
this
.
enablePageLeave
=
false
,
this
.
enableClick
=
true
,
this
.
enableUpload
=
false
,
this
.
enableDrag
=
false
this
.
enableDrag
=
false
,
this
.
enableIgnoreNullKey
=
false
})
{
trackId
??=
const
Uuid
().
v4
().
replaceAll
(
'-'
,
''
);
signature
??=
(
t
)
=>
sha256
.
convert
(
utf8
.
encode
(
'
$appKey$t$appSecret
'
)).
toString
();
...
...
@@ -31,6 +33,8 @@ class AutoTrackConfig {
String
?
appSecret
;
String
?
trackId
;
String
?
userId
;
String
?
uniqueId
;
Function
?
signature
;
List
<
AutoTrackPageConfig
>
pageConfigs
;
...
...
@@ -58,6 +62,8 @@ class AutoTrackConfig {
bool
enableUpload
;
bool
enableDrag
;
bool
enableIgnoreNullKey
;
}
typedef
PageWidgetFunc
=
bool
Function
(
Widget
);
...
...
lib/auto_track/config/manager.dart
View file @
5e49600
import
'dart:convert'
;
import
'package:auto_track/auto_track/config/queue.dart'
;
import
'package:crypto/crypto.dart'
;
import
'package:device_info_plus/device_info_plus.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:package_info_plus/package_info_plus.dart'
;
...
...
@@ -8,19 +11,24 @@ import 'config.dart';
class
AutoTrackConfigManager
{
static
final
AutoTrackConfigManager
instance
=
AutoTrackConfigManager
.
_
();
AutoTrackConfigManager
.
_
()
{
PackageInfo
.
fromPlatform
().
then
((
value
)
=>
_appVersion
=
value
.
version
);
DeviceInfoPlugin
().
deviceInfo
.
then
((
value
)
=>
_deviceInfo
=
value
.
data
);
DeviceInfoPlugin
().
deviceInfo
.
then
((
value
)
{
_deviceInfo
=
value
.
data
;
baseDeviceInfo
=
value
;
});
}
String
_appVersion
=
''
;
String
get
appVersion
=>
_appVersion
;
BaseDeviceInfo
?
baseDeviceInfo
;
String
_deviceId
=
''
;
String
get
deviceId
=>
_deviceId
;
Map
<
String
,
dynamic
>
_deviceInfo
=
{};
Map
<
String
,
dynamic
>
get
deviceInfo
=>
_deviceInfo
;
AutoTrackConfig
_config
=
AutoTrackConfig
();
AutoTrackConfig
get
config
=>
_config
;
...
...
@@ -29,6 +37,13 @@ class AutoTrackConfigManager {
void
updateConfig
(
AutoTrackConfig
config
)
{
_config
=
config
;
if
(
baseDeviceInfo
is
IosDeviceInfo
)
{
_deviceId
=
md5
.
convert
(
utf8
.
encode
(
'
${(baseDeviceInfo as IosDeviceInfo).identifierForVendor}
#
${config.appKey}
'
)).
toString
();
}
else
if
(
baseDeviceInfo
is
AndroidDeviceInfo
)
{
_deviceId
=
md5
.
convert
(
utf8
.
encode
(
'
${(baseDeviceInfo as AndroidDeviceInfo).serialNumber}
#
${config.appKey}
'
)).
toString
();
}
else
{
_deviceId
=
''
;
}
if
(
config
.
enableUpload
)
{
AutoTrackQueue
.
instance
.
start
();
}
else
{
...
...
@@ -81,20 +96,24 @@ class AutoTrackConfigManager {
}
}
void
enableIgnoreNullKey
(
bool
enable
)
{
_config
.
enableIgnoreNullKey
=
enable
;
}
List
<
AutoTrackPageConfig
>
get
pageConfigs
=>
_config
.
pageConfigs
;
bool
get
useCustomRoute
=>
_config
.
useCustomRoute
;
AutoTrackPageConfig
getPageConfig
(
Widget
pageWidget
)
{
return
_config
.
pageConfigs
.
firstWhere
(
(
pageConfig
)
=>
pageConfig
.
isPageWidget
!(
pageWidget
),
orElse:
()
=>
AutoTrackPageConfig
()
);
(
pageConfig
)
=>
pageConfig
.
isPageWidget
!(
pageWidget
),
orElse:
()
=>
AutoTrackPageConfig
());
}
Set
<
Key
>
getIgnoreElementKeySet
()
=>
_config
.
getIgnoreElementKeySet
();
Set
<
String
>
getIgnoreElementStringKeySet
()
=>
_config
.
getIgnoreElementStringKeySet
();
Set
<
String
>
getIgnoreElementStringKeySet
()
=>
_config
.
getIgnoreElementStringKeySet
();
bool
isIgnoreElement
(
Key
?
key
)
{
if
(
key
==
null
)
{
...
...
@@ -121,4 +140,6 @@ class AutoTrackConfigManager {
bool
get
clickEnable
=>
_config
.
enableClick
;
bool
get
dragEnable
=>
_config
.
enableDrag
;
bool
get
ignoreNullKeyEnable
=>
_config
.
enableIgnoreNullKey
;
}
...
...
lib/auto_track/config/queue.dart
View file @
5e49600
...
...
@@ -47,6 +47,7 @@ class AutoTrackQueue {
't'
:
t
,
'user_id'
:
config
.
userId
??
''
,
'track_id'
:
config
.
trackId
??
''
,
'unique_id'
:
config
.
uniqueId
??
AutoTrackConfigManager
.
instance
.
deviceId
,
'data_list'
:
uploadList
.
map
((
e
)
=>
e
.
toMap
()).
toList
(),
'app_version'
:
AutoTrackConfigManager
.
instance
.
appVersion
,
'device_info'
:
AutoTrackConfigManager
.
instance
.
deviceInfo
...
...
lib/auto_track/index.dart
View file @
5e49600
...
...
@@ -67,6 +67,16 @@ class AutoTrack {
return
_instance
;
}
AutoTrack
enableIgnoreNullKey
()
{
AutoTrackConfigManager
.
instance
.
enableIgnoreNullKey
(
true
);
return
_instance
;
}
AutoTrack
disableIgnoreNullKey
()
{
AutoTrackConfigManager
.
instance
.
enableIgnoreNullKey
(
false
);
return
_instance
;
}
AutoTrack
enableUpload
()
{
AutoTrackConfigManager
.
instance
.
enableUpload
(
true
);
return
_instance
;
...
...
@@ -122,4 +132,4 @@ class AutoTrack {
}
return
_instance
;
}
}
}
\ No newline at end of file
...
...
lib/auto_track/page_view/page_info.dart
View file @
5e49600
...
...
@@ -17,7 +17,7 @@ class PageInfo {
pageInfo
.
_pagePath
=
pageConfig
.
pagePath
??
route
.
settings
.
name
??
''
;
pageInfo
.
_pageTitle
=
pageConfig
.
pageTitle
??
pageInfo
.
_findTitle
(
element
)
??
''
;
pageInfo
.
_pageManualKey
=
pageConfig
.
pageID
??
md5
.
convert
(
utf8
.
encode
(
'
${pageInfo._pageKey}${pageInfo._pagePath}${pageInfo._pageTitle}
'
)).
toString
();
pageInfo
.
ignore
=
page
Config
.
ignore
;
pageInfo
.
ignore
=
page
Info
.
_checkIgnore
(
pageConfig
)
;
return
pageInfo
;
}
...
...
@@ -37,6 +37,18 @@ class PageInfo {
String
_pagePath
=
''
;
String
get
pagePath
=>
_pagePath
;
bool
_checkIgnore
(
AutoTrackPageConfig
pageConfig
)
{
if
(
pageConfig
.
ignore
)
{
return
true
;
}
if
(
AutoTrackConfigManager
.
instance
.
config
.
enableIgnoreNullKey
&&
pageConfig
.
pageID
==
null
)
{
return
true
;
}
return
false
;
}
String
?
_findTitle
(
Element
element
)
{
String
?
title
;
ElementUtil
.
walkElement
(
element
,
(
child
,
_
)
{
...
...
Please
register
or
login
to post a comment