From 2632d41276e9af621ed5cf1111518bccf4ed4e66 Mon Sep 17 00:00:00 2001 From: YoloMao Date: Sat, 12 Oct 2024 16:12:24 +0800 Subject: [PATCH] feat: auto web js sdk bridge --- Example/Example.xcodeproj/project.pbxproj | 6 +- Example/Example/AppDelegate.m | 4 + Example/Example/GrowingIO-Prefix.pch | 6 ++ Example/Podfile | 1 + Example/Podfile.lock | 4 +- GrowingAnalytics.podspec | 7 +- Modules/Hybrid/GrowingHybridModule.m | 1 + .../Hybrid/GrowingWKWebViewJavascriptBridge.m | 26 +++++++ Modules/Hybrid/Public/GrowingHybridModule.h | 3 + Package.swift | 77 ++++++++++--------- .../iOS/GrowingAnalytics.bundle/gdp-full.js | 1 + .../Resources/GrowingAnalytics.bundle | 0 .../dummy.m | 6 ++ .../include/dummy.h | 4 + .../Resources/GrowingAnalytics.bundle | 0 .../dummy.m | 0 .../include/dummy.h | 0 .../Resources/GrowingAnalytics.bundle | 0 .../dummy.m | 0 .../include/dummy.h | 0 .../Resources/GrowingAnalytics.bundle | 0 .../dummy.m | 0 .../include/dummy.h | 0 .../Resources/GrowingAnalytics.bundle | 0 .../dummy.m | 0 .../include/dummy.h | 0 26 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 Resources/iOS/GrowingAnalytics.bundle/gdp-full.js rename SwiftPM-Wrap/{GrowingPrivacy-Wrapper => GrowingBundle-Wrapper}/Resources/GrowingAnalytics.bundle (100%) rename SwiftPM-Wrap/{GrowingPrivacy-macOS-Wrapper => GrowingBundle-Wrapper}/dummy.m (84%) rename SwiftPM-Wrap/{GrowingPrivacy-macOS-Wrapper => GrowingBundle-Wrapper}/include/dummy.h (88%) rename SwiftPM-Wrap/{GrowingPrivacy-macOS-Wrapper => GrowingBundle-macOS-Wrapper}/Resources/GrowingAnalytics.bundle (100%) rename SwiftPM-Wrap/{GrowingPrivacy-Wrapper => GrowingBundle-macOS-Wrapper}/dummy.m (100%) rename SwiftPM-Wrap/{GrowingPrivacy-Wrapper => GrowingBundle-macOS-Wrapper}/include/dummy.h (100%) rename SwiftPM-Wrap/{GrowingPrivacy-tvOS-Wrapper => GrowingBundle-tvOS-Wrapper}/Resources/GrowingAnalytics.bundle (100%) rename SwiftPM-Wrap/{GrowingPrivacy-tvOS-Wrapper => GrowingBundle-tvOS-Wrapper}/dummy.m (100%) rename SwiftPM-Wrap/{GrowingPrivacy-tvOS-Wrapper => GrowingBundle-tvOS-Wrapper}/include/dummy.h (100%) rename SwiftPM-Wrap/{GrowingPrivacy-visionOS-Wrapper => GrowingBundle-visionOS-Wrapper}/Resources/GrowingAnalytics.bundle (100%) rename SwiftPM-Wrap/{GrowingPrivacy-visionOS-Wrapper => GrowingBundle-visionOS-Wrapper}/dummy.m (100%) rename SwiftPM-Wrap/{GrowingPrivacy-visionOS-Wrapper => GrowingBundle-visionOS-Wrapper}/include/dummy.h (100%) rename SwiftPM-Wrap/{GrowingPrivacy-watchOS-Wrapper => GrowingBundle-watchOS-Wrapper}/Resources/GrowingAnalytics.bundle (100%) rename SwiftPM-Wrap/{GrowingPrivacy-watchOS-Wrapper => GrowingBundle-watchOS-Wrapper}/dummy.m (100%) rename SwiftPM-Wrap/{GrowingPrivacy-watchOS-Wrapper => GrowingBundle-watchOS-Wrapper}/include/dummy.h (100%) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 4544a8324..3911880e2 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ @@ -4602,7 +4602,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = SXBU677CPT; ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; GCC_NO_COMMON_BLOCKS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -4654,7 +4654,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = SXBU677CPT; ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_USER_SCRIPT_SANDBOXING = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_C_LANGUAGE_STANDARD = gnu17; GCC_NO_COMMON_BLOCKS = YES; GENERATE_INFOPLIST_FILE = YES; diff --git a/Example/Example/AppDelegate.m b/Example/Example/AppDelegate.m index cab408617..1f94b80ab 100644 --- a/Example/Example/AppDelegate.m +++ b/Example/Example/AppDelegate.m @@ -70,6 +70,10 @@ - (void)SDK3rdStart { configuration.abTestingRequestInterval = 5; #endif +#if defined(SDKHybridMODULE) + GrowingHybridModule.sharedInstance.autoJavaScriptBridgeEnabled = YES; +#endif + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnonnull" [GrowingSDK startWithConfiguration:configuration launchOptions:nil]; diff --git a/Example/Example/GrowingIO-Prefix.pch b/Example/Example/GrowingIO-Prefix.pch index 28f8f39b9..2d420bba3 100644 --- a/Example/Example/GrowingIO-Prefix.pch +++ b/Example/Example/GrowingIO-Prefix.pch @@ -27,6 +27,12 @@ #define GrowingSDKConfiguration GrowingTrackConfiguration #endif +#if __has_include("GrowingHybridModule.h") +// Hybrid Module +#import "GrowingHybridModule.h" +#define SDKHybridMODULE +#endif + #if __has_include("GrowingAdvertising.h") // Ads Module #import "GrowingAdvertising.h" diff --git a/Example/Podfile b/Example/Podfile index 22e047f93..7579f3b2b 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -3,6 +3,7 @@ platform :ios, '12.0' use_frameworks! +#use_modular_headers! install!'cocoapods',:deterministic_uuids=>false, :warn_for_unused_master_specs_repo=>false diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 7e8a6270c..49410f25b 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -160,7 +160,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - GrowingAnalytics: d50200337f7dbad6d087705119c6f0605cdc91a2 + GrowingAnalytics: e845c52ebff18c53659b5e37e75fb50e2097dc32 GrowingAPM: 3c4de0384935b654e6798b95606f47883a99418b GrowingToolsKit: 53160d19690da0b78e04a9242abde7af86442922 GrowingUtils: 68aee2c96849bf9b674740503da30c2da468e79d @@ -170,6 +170,6 @@ SPEC CHECKSUMS: SDCycleScrollView: a0d74c3384caa72bdfc81470bdbc8c14b3e1fbcf SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a -PODFILE CHECKSUM: 8ef4d85701caba0f5df403432dc182d34412ab4a +PODFILE CHECKSUM: dded21a1746985a3de3449c95f027e9071d8581a COCOAPODS: 1.15.2 diff --git a/GrowingAnalytics.podspec b/GrowingAnalytics.podspec index 1dd6fb174..0e66d3381 100644 --- a/GrowingAnalytics.podspec +++ b/GrowingAnalytics.podspec @@ -17,7 +17,7 @@ GrowingAnalytics具备自动采集基本的用户行为事件,比如访问和 s.ios.framework = 'WebKit' s.requires_arc = true s.default_subspec = "Autotracker" - s.pod_target_xcconfig = { 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"' } + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"' } s.subspec 'Autotracker' do |autotracker| autotracker.ios.deployment_target = '10.0' @@ -47,7 +47,10 @@ GrowingAnalytics具备自动采集基本的用户行为事件,比如访问和 trackerCore.dependency 'GrowingUtils/TrackerCore', '~> 1.2.3' trackerCore.source_files = 'GrowingTrackerCore/**/*{.h,.m,.c,.cpp,.mm}' trackerCore.public_header_files = 'GrowingTrackerCore/Public/*.h' - trackerCore.ios.resource_bundles = {'GrowingAnalytics' => ['Resources/iOS/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy']} + trackerCore.ios.resource_bundles = {'GrowingAnalytics' => [ + 'Resources/iOS/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy', + 'Resources/iOS/GrowingAnalytics.bundle/gdp-full.js' + ]} trackerCore.osx.resource_bundles = {'GrowingAnalytics' => ['Resources/macOS/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy']} trackerCore.watchos.resource_bundles = {'GrowingAnalytics' => ['Resources/watchOS/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy']} trackerCore.tvos.resource_bundles = {'GrowingAnalytics' => ['Resources/tvOS/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy']} diff --git a/Modules/Hybrid/GrowingHybridModule.m b/Modules/Hybrid/GrowingHybridModule.m index 032180898..9a1f7fb4d 100644 --- a/Modules/Hybrid/GrowingHybridModule.m +++ b/Modules/Hybrid/GrowingHybridModule.m @@ -48,6 +48,7 @@ + (instancetype)sharedInstance { - (instancetype)init { if (self = [super init]) { _autoBridgeEnabled = YES; + _autoJavaScriptBridgeEnabled = NO; _enableBridgeWebViews = [NSHashTable weakObjectsHashTable]; _disableBridgeWebViews = [NSHashTable weakObjectsHashTable]; } diff --git a/Modules/Hybrid/GrowingWKWebViewJavascriptBridge.m b/Modules/Hybrid/GrowingWKWebViewJavascriptBridge.m index 8b1d79365..c1f25d90f 100644 --- a/Modules/Hybrid/GrowingWKWebViewJavascriptBridge.m +++ b/Modules/Hybrid/GrowingWKWebViewJavascriptBridge.m @@ -33,6 +33,10 @@ #import "Modules/Hybrid/GrowingWebViewJavascriptBridgeConfiguration.h" #import "Modules/Hybrid/Public/GrowingHybridModule.h" +#if SWIFT_PACKAGE +@import GrowingBundle; +#endif + static NSString *const kGrowingWKWebViewJavascriptBridge = @"GrowingWKWebViewJavascriptBridge"; @interface GrowingWKWebViewJavascriptBridge () @@ -110,11 +114,33 @@ + (void)addUserScripts:(WKUserContentController *)contentController { injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO]; [contentController addUserScript:userScript]; + + if (GrowingHybridModule.sharedInstance.autoJavaScriptBridgeEnabled) { + NSBundle *bundle = [self resourcesBundle]; + NSString *filePath = [bundle pathForResource:@"gdp-full" ofType:@"js"]; + NSString *webJSContent = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; + webJSContent = [webJSContent stringByAppendingFormat:@"gdp('init', '%@', '%@');", accountId, dataSourceId]; + WKUserScript *userScript2 = [[WKUserScript alloc] initWithSource:webJSContent + injectionTime:WKUserScriptInjectionTimeAtDocumentEnd + forMainFrameOnly:NO]; + [contentController addUserScript:userScript2]; + } } } @catch (NSException *exception) { } } ++ (NSBundle *)resourcesBundle { +#if SWIFT_PACKAGE + return GrowingBundleWrapper_SWIFTPM_MODULE_BUNDLE(); +#else + NSBundle *bundle = [NSBundle bundleForClass:self.class]; + NSString *bundleName = @"GrowingAnalytics.bundle"; + NSString *path = [bundle.resourcePath stringByAppendingPathComponent:bundleName]; + return [NSBundle bundleWithPath:path]; +#endif +} + - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { if ([GrowingWKWebViewJavascriptBridge webViewDontTrackCheck:message.webView]) { diff --git a/Modules/Hybrid/Public/GrowingHybridModule.h b/Modules/Hybrid/Public/GrowingHybridModule.h index 6040b96ac..457afdfb1 100644 --- a/Modules/Hybrid/Public/GrowingHybridModule.h +++ b/Modules/Hybrid/Public/GrowingHybridModule.h @@ -35,6 +35,9 @@ NS_SWIFT_NAME(Hybrid) // 是否对所有webView自动注入Hybrid SDK,默认为YES @property (nonatomic, assign) BOOL autoBridgeEnabled; +// 是否对所有webView自动注入Web JS SDK,默认为NO +@property (nonatomic, assign) BOOL autoJavaScriptBridgeEnabled; + // 在autoBridgeEnabled为NO时,对单个webView启用Hybrid注入,请在主线程调用 - (void)enableBridgeForWebView:(WKWebView *)webView NS_SWIFT_NAME(enableBridge(_:)); diff --git a/Package.swift b/Package.swift index 962eb9643..4d48db9df 100644 --- a/Package.swift +++ b/Package.swift @@ -68,11 +68,11 @@ let package = Package( // MARK: - Resources - .Resources.privacy, - .Resources.privacy_macOS, - .Resources.privacy_tvOS, - .Resources.privacy_visionOS, - .Resources.privacy_watchOS, + .Resources.bundle, + .Resources.bundle_macOS, + .Resources.bundle_tvOS, + .Resources.bundle_visionOS, + .Resources.bundle_watchOS, // MARK: - Core @@ -149,24 +149,27 @@ extension Target { cSettings: [.hspFor(.Path.tracker_objc)]) enum Resources { - static let privacy = target(name: .privacy, - path: .Path.privacy, - resources: [.copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy")]) - - static let privacy_macOS = target(name: .privacy_macOS, - path: .Path.privacy_macOS, + static let bundle = target(name: .bundle, + path: .Path.bundle, + resources: [ + .copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy"), + .copy("Resources/GrowingAnalytics.bundle/gdp-full.js") + ]) + + static let bundle_macOS = target(name: .bundle_macOS, + path: .Path.bundle_macOS, resources: [.copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy")]) - static let privacy_tvOS = target(name: .privacy_tvOS, - path: .Path.privacy_tvOS, + static let bundle_tvOS = target(name: .bundle_tvOS, + path: .Path.bundle_tvOS, resources: [.copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy")]) - static let privacy_visionOS = target(name: .privacy_visionOS, - path: .Path.privacy_visionOS, + static let bundle_visionOS = target(name: .bundle_visionOS, + path: .Path.bundle_visionOS, resources: [.copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy")]) - static let privacy_watchOS = target(name: .privacy_watchOS, - path: .Path.privacy_watchOS, + static let bundle_watchOS = target(name: .bundle_watchOS, + path: .Path.bundle_watchOS, resources: [.copy("Resources/GrowingAnalytics.bundle/PrivacyInfo.xcprivacy")]) } @@ -183,11 +186,11 @@ extension Target { static let trackerCore = target(name: .trackerCore, dependencies: [ .trackerUtils, - .Resources.privacy, - .Resources.privacy_macOS, - .Resources.privacy_tvOS, - .Resources.privacy_visionOS, - .Resources.privacy_watchOS, + .Resources.bundle, + .Resources.bundle_macOS, + .Resources.bundle_tvOS, + .Resources.bundle_visionOS, + .Resources.bundle_watchOS, ], path: .Path.trackerCore, publicHeadersPath: .Path.publicHeaders, @@ -329,11 +332,11 @@ extension Target.Dependency { static let protobuf = product(name: "SwiftProtobuf", package: "swift-protobuf") enum Resources { - static let privacy = byName(name: .privacy, condition: .when(platforms: [.iOS, .macCatalyst])) - static let privacy_macOS = byName(name: .privacy_macOS, condition: .when(platforms: [.macOS])) - static let privacy_tvOS = byName(name: .privacy_tvOS, condition: .when(platforms: [.tvOS])) - static let privacy_visionOS = byName(name: .privacy_visionOS, condition: .when(platforms: [.visionOS])) - static let privacy_watchOS = byName(name: .privacy_watchOS, condition: .when(platforms: [.watchOS])) + static let bundle = byName(name: .bundle, condition: .when(platforms: [.iOS, .macCatalyst])) + static let bundle_macOS = byName(name: .bundle_macOS, condition: .when(platforms: [.macOS])) + static let bundle_tvOS = byName(name: .bundle_tvOS, condition: .when(platforms: [.tvOS])) + static let bundle_visionOS = byName(name: .bundle_visionOS, condition: .when(platforms: [.visionOS])) + static let bundle_watchOS = byName(name: .bundle_watchOS, condition: .when(platforms: [.watchOS])) } enum Core { @@ -381,11 +384,11 @@ extension String { static let tracker_objc = "GrowingTracker_Objc" // Resources - static let privacy = "GrowingPrivacy" - static let privacy_macOS = "GrowingPrivacy_macOS" - static let privacy_tvOS = "GrowingPrivacy_tvOS" - static let privacy_visionOS = "GrowingPrivacy_visionOS" - static let privacy_watchOS = "GrowingPrivacy_watchOS" + static let bundle = "GrowingBundle" + static let bundle_macOS = "GrowingBundle_macOS" + static let bundle_tvOS = "GrowingBundle_tvOS" + static let bundle_visionOS = "GrowingBundle_visionOS" + static let bundle_watchOS = "GrowingBundle_watchOS" // Core static let autotrackerCore = "GrowingAutotrackerCore" @@ -420,11 +423,11 @@ extension String { static let tracker_objc = "GrowingTracker" // Resources - static let privacy = "SwiftPM-Wrap/GrowingPrivacy-Wrapper" - static let privacy_macOS = "SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper" - static let privacy_tvOS = "SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper" - static let privacy_visionOS = "SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper" - static let privacy_watchOS = "SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper" + static let bundle = "SwiftPM-Wrap/GrowingBundle-Wrapper" + static let bundle_macOS = "SwiftPM-Wrap/GrowingBundle-macOS-Wrapper" + static let bundle_tvOS = "SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper" + static let bundle_visionOS = "SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper" + static let bundle_watchOS = "SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper" // Core static let autotrackerCore = "GrowingAutotrackerCore" diff --git a/Resources/iOS/GrowingAnalytics.bundle/gdp-full.js b/Resources/iOS/GrowingAnalytics.bundle/gdp-full.js new file mode 100644 index 000000000..90038b3da --- /dev/null +++ b/Resources/iOS/GrowingAnalytics.bundle/gdp-full.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).gdp=t()}(this,(function(){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},t=function(){return t=Object.assign||function(e){for(var t,n=1,i=arguments.length;i>n;n++)for(var r in t=arguments[n])({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)};function n(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;o>r;r++)!i&&r in t||(i||(i=[].slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||[].slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var i,r,o,a,s,u=/^(\.ac\.|\.br\.|\.co\.|\.com\.|\.edu\.|\.gov\.|\.org\.|\.net\.)/,c=/^data-gio-track-[a-z]+$/i,d=/^gioTrack(.+)/,g=/^[a-zA-Z][a-zA-Z0-9_]{0,99}$/,l=/.+_gdp_session_id_.{36}/,f="function"==typeof Array.from?Array.from:(r||(r=1,o=function(e){return"function"==typeof e},a=function(e){var t=function(e){var t=Number(e);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t}(e);return Math.min(Math.max(t,0),9007199254740991)},s=function(e){var t=e.next();return!t.done&&t},i=function(e){var t,n,i,r=this,u=arguments.length>1?arguments[1]:void 0;if(void 0!==u){if(!o(u))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(t=arguments[2])}var c=function(e,t){if(null!=e&&null!=t){var n=e[t];if(null==n)return;if(!o(n))throw new TypeError(n+" is not a function");return n}}(e,function(e){if(null!=e){if(["string","number","boolean","symbol"].indexOf(typeof e)>-1)return Symbol.iterator;if("undefined"!=typeof Symbol&&"iterator"in Symbol&&Symbol.iterator in e)return Symbol.iterator;if("@@iterator"in e)return"@@iterator"}}(e));if(void 0!==c){n=o(r)?Object(new r):[];var d,g,l=c.call(e);if(null==l)throw new TypeError("Array.from requires an array-like or iterable object");for(i=0;;){if(!(d=s(l)))return n.length=i,n;g=d.value,n[i]=u?u.call(t,g,i):g,i++}}else{var f=Object(e);if(null==e)throw new TypeError("Array.from requires an array-like object - not null or undefined");var v,h=a(f.length);for(n=o(r)?Object(new r(h)):Array(h),i=0;h>i;)v=f[i],n[i]=u?u.call(t,v,i):v,i++;n.length=h}return n}),i),v=function(e){return P(["undefined","null"],F(e))},h=function(e){return"string"===F(e)},p=function(e){return"number"===F(e)},m=function(e){return"NaN"===L(Number(e))},I=function(e){return"boolean"===F(e)},w=function(e){return"object"===F(e)&&!v(e)},y=function(e){return"regexp"===F(e)},b=function(e){return P(["function","asyncfunction"],F(e))},S=function(e){return Array.isArray(e)&&"array"===F(e)},O=function(e){return"date"===F(e)},_=function(e){try{return x(e)[0]}catch(e){return}},N=function(e){try{var t=x(e);return t[t.length-1]}catch(e){return}},k=function(e,t){return void 0===t&&(t=1),S(e)&&p(t)?e.slice(t>0?t:1,e.length):e},E=function(e,t){if(void 0===t&&(t=!1),S(e)){for(var n=0,i=[],r=0,o=e;r=0},x=f,L=function(e){return v(e)?"":"".concat(e)},U=function(e,t){return"string"==typeof e?e.split(t):e},A=function(e){if(h(e)){var t=U(e,"");return"".concat(_(t).toLowerCase()).concat(k(t).join(""))}return e},D=function(e,t){return!!h(e)&&e.slice(0,t.length)===t},q=function(e,t){if(h(e)){var n=e.length,i=n;i>n&&(i=n);var r=i;return(i-=t.length)>=0&&e.slice(i,r)===t}return!1},K={}.hasOwnProperty,V=function(e,t){return!v(e)&&K.call(e,t)},H=function(e){return w(e)?Object.keys(e):[]},B=function(e,t){H(e).forEach((function(n){return t(e[n],n)}))},R=function(e,t){var n=H(e);return!(!w(e)||!w(t)||n.length!==H(t).length||P(n.map((function(n){return w(e[n])?R(e[n],t[n]):e[n]===t[n]})),!1))},G=function(e,t){if(!w(e))return!1;try{return"string"===F(t)?delete e[t]:"array"===F(t)?t.map((function(t){return delete e[t]})):(y(t)&&H(e).forEach((function(n){t.test(n)&&G(e,n)})),!0)}catch(e){return!1}},j=function(e){return S(e)?0===e.length:w(e)?0===H(e).length:!e},F=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},M=function(e){if(O(e)){var t=function(e){return 10>e?"0"+e:e};return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}return e},W=Object.freeze({__proto__:null,isNil:v,isString:h,isNumber:p,isNaN:m,isBoolean:I,isObject:w,isRegExp:y,isFunction:b,isArray:S,isDate:O,fixed:function(e,t){return p(e)?Number(e.toFixed(p(t)?t:2)):h(e)&&"NaN"!==L(Number(e))?Number(Number(e).toFixed(p(t)?t:2)):e},head:_,last:N,drop:k,dropWhile:function(e,t){return S(e)?e.filter((function(e){return!t(e)})):e},compact:E,find:T,findIndex:C,includes:P,arrayFrom:x,toString:L,split:U,lowerFirst:A,upperFirst:function(e){if(h(e)){var t=U(e,"");return"".concat(_(t).toUpperCase()).concat(k(t).join(""))}return e},startsWith:D,endsWith:q,has:V,keys:H,forEach:B,isEqual:R,get:function(e,t,n){var i=e;return w(e)?(t.split(".").forEach((function(e){i=i?i[e]:n})),i):n},unset:G,isEmpty:j,typeOf:F,formatDate:M}),z=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},J=function(e,t){console.log("%c [GrowingIO]:".concat(e),{info:"color: #3B82F6;",error:"color: #EF4444;",warn:"color: #F59E0B;",success:"color: #10B981;"}[t]||"")},X=function(e){try{return e()}catch(e){return}},Q=function(e,t){if(b(e))try{e(t)}catch(e){J("回调执行失败!".concat(e),"error")}},Y=function(){var e,t=!!(null===(e=null===window||void 0===window?void 0:window.navigator)||void 0===e?void 0:e.sendBeacon),n=window.navigator.userAgent;if(n.match(/(iPad|iPhone|iPod)/g)){var i=Z(n);return t&&i>13}return t},Z=function(e){var t=e.toLowerCase().match(/cpu.*os (.*?) like mac os/i);return!t||2>t.length?0:+t[1].split("_").slice(0,2).join(".")},$=function(){var e=window.navigator.userAgent;return/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(e)&&!/chrome\/(\d+\.\d+)/i.test(e)},ee=function(){return/bot|crawler|spider|scrapy|jiankongbao|slurp|transcoder|networkbench/i.test(navigator.userAgent.toLowerCase())},te=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n="参数不合法"),J("".concat(t?"调用":"设置"," ").concat(e," 失败,").concat(n,"!"),"warn")},ne=function(e,n,i,r){void 0===r&&(r={}),document.addEventListener?e.addEventListener(n,i,t(t({},{capture:!0}),r)):e.attachEvent?e.attachEvent("on"+n,i):e["on"+n]=i},ie=function(e){return q(e,"_gioenc")?e.slice(0,-7):e},re=function(e){return isNaN(Number(e))&&X((function(){return JSON.parse(e)}))||e},oe=function(e){var t={};return w(e)&&(G(e,"&&sendTo"),B(e,(function(e,n){var i=L(n).slice(0,100);w(e)?t[i]=oe(e):S(e)?(t[i]=E(e.slice(0,100),!0),t[i]=t[i].join("||").slice(0,1e3)):O(e)?t[i]=M(e):t[i]=v(e)?"":L(e).slice(0,1e3)}))),t},ae=function(e){return v(e)||H(e).forEach((function(t){b(e[t])?e[t]=X((function(){return e[t]()})):w(e[t])?G(e,t):S(e[t])||(e[t]=L(e[t]))})),e},se=function(){var e,t=window._gio_local_vds||"vds";return null!==(e=window[t])&&void 0!==e?e:{}},ue=Object.freeze({__proto__:null,guid:z,consoleText:J,niceTry:X,niceCallback:Q,hashCode:function(e,t){void 0===t&&(t=!1);var n=0;if(j(e)||"boolean"==typeof e)return n;for(var i=0;iu;u++){var c=Number(a[u]),d=Number(s[u]);if(c>d)return 1;if(d>c)return-1;if(!isNaN(c)&&isNaN(d))return 1;if(isNaN(c)&&!isNaN(d))return-1}return 0},getDynamicAttributes:ae,getVds:se,getGioFunction:function(){var e,t,n,i,r=null!==(t=null===(e=se())||void 0===e?void 0:e.namespace)&&void 0!==t?t:"gdp";return b(window[r])?window[r]:null!==(i=null!==(n=window.gdp)&&void 0!==n?n:window.gio)&&void 0!==i?i:function(){}},getMainTrackingId:function(){var e;return null!==(e=se().trackingId)&&void 0!==e?e:"g0"}}),ce=function(e){return h(e)&&e.length>0||p(e)&&e>0},de=function(e,t){return h(e)&&!j(e)&&e.match(g)?t():(J("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1)},ge=["web","wxwv","Android","iOS","minp","alip","baidup","qq","bytedance","kuaishoup","jdp"],le={gsid:"_gdp_sequence_ids",originalSource:"_gdp_original_source",sentSign:"_gdp_session_id_sent",sessionId:"_gdp_session_id",userId:"_gdp_cs1_gioenc",userKey:"_gdp_user_key_gioenc",gioId:"_gdp_gio_id_gioenc",gqs:"_gdp_query_string_gioenc"},fe={autotrack:{type:"boolean",default:!0},appId:{type:"string",default:""},compress:{type:"boolean",default:!0},cookieDomain:{type:"string",default:""},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},embeddedIgnore:{type:"array",default:[]},forceLogin:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},gtouchHost:{type:"string",default:""},hashtag:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},originalSource:{type:"boolean",default:!0},packageName:{type:"string",default:""},penetrateHybrid:{type:"boolean",default:!0},performance:{type:"object",default:{monitor:!0,exception:!0}},platform:{type:"string",default:"web"},requestTimeout:{type:"number",default:5e3},sendType:{type:"string",default:"beacon"},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:30},storageType:{type:"string",default:"cookie"},touch:{type:"boolean",default:!1},trackBot:{type:"boolean",default:!0},trackPage:{type:"boolean",default:!0},version:{type:"string",default:"1.0.0"}},ve=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getOption","identify","removeTimer","sendPage","sendVisit","setBeforeSendListener","setGeneralProps","setOption","setPageAttributes","setPageListener","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],he=n(n(["init","registerPlugins"],["getPlugins","getDeviceId","updateImpression"],!0),ve,!0),pe={autotrack:"无埋点采集",dataCollect:"数据采集",dataSourceId:"数据源ID",debug:"调试模式",forceLogin:"强制登录",hashtag:"哈希解析",serverUrl:"数据上报服务地址"},me=["collectImp","enableDebug","enableHT","getVisitorId","send","setAutotrack","setConfig","setDataCollect","setPlatformProfile","setTrackerHost","setTrackerScheme"],Ie=["screenHeight","screenWidth"];function we(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var i in n)e[i]=n[i]}return e}var ye,be=function e(t,n){function i(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=we({},n,r)).expires&&(r.expires=new Date(Date.now()+864e5*r.expires)),r.expires&&(r.expires=r.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var a in r)r[a]&&(o+="; "+a,!0!==r[a]&&(o+="="+r[a].split(";")[0]));return document.cookie=e+"="+t.write(i,e)+o}}return Object.create({set:i,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],i={},r=0;r+Date.now()?re(_e(t.value)):void 0},this.setItem=function(e,t,n){var i=null!=n?n:+new Date((new Date).getFullYear()+3,(new Date).getMonth(),(new Date).getDay()).getTime();localStorage.setItem(ie(e),JSON.stringify({value:h(t)&&t.length&&q(e,"_gioenc")?Oe(t):t,expiredAt:i}))},this.removeItem=function(e){return localStorage.removeItem(ie(e))},this.hasItem=function(e){return!!localStorage.getItem(ie(e))},this.getKeys=function(){return x(Array(localStorage.length)).map((function(e,t){return localStorage.key(t)}))},this.type="localStorage"},Ce={},Pe=function(){this.getItem=function(e){var t=X((function(){return JSON.parse(Ce[ie(e)]||"")}));return w(t)&&t.expiredAt>+Date.now()?re(_e(t.value)):void 0},this.setItem=function(e,t,n){var i=null!=n?n:+new Date((new Date).getFullYear()+3,(new Date).getMonth(),(new Date).getDay()).getTime();Ce[ie(e)]=JSON.stringify({value:h(t)&&t.length?Oe(t):t,expiredAt:i})},this.removeItem=function(e){return G(Ce,ie(e))},this.hasItem=function(e){return V(Ce,ie(e))},this.getKeys=function(){return H(Ce)},this.type="memory"},xe=function(e){var t=[];try{var n=e.split("."),i=N(n);if(n.length>=2&&(isNaN(Number(i))||0>Number(i)||Number(i)>255)){var r=".".concat(n.slice(-2).join("."));u.test(r)?ye=r:t.push(r);var o=".".concat(n.slice(-3).join("."));u.test(o)||P(t,o)||t.push(o);var a=".".concat(n.slice(-4).join("."));u.test(a)||P(t,a)||t.push(a)}}catch(e){J(e,"error")}return t},Le=function(e){var t="";return e.some((function(e){return!!Ue(e)&&(t=e,!0)})),t},Ue=function(e){try{be.set("gioCookie","yes",{domain:e});var t=!!be.get("gioCookie",{domain:e});return be.remove("gioCookie",{domain:e}),t}catch(e){return!1}},Ae=function(e){var t,i,r,o=e.storageType,a=e.cookieDomain,s=e.projectId;if(P(["cookie","localstorage"],o)||(o="cookie"),"cookie"===o&&(i=!!(r=navigator.userAgent.indexOf("Electron")>-1||P(["","localhost","127.0.0.1"],window.location.hostname)||!P(["http:","https:"],window.location.protocol)?"":Le(n(n([],xe(window.location.hostname),!0),[window.location.hostname],!1)))),"cookie"===o&&i){var u=new Ee(r);if(a){var c=xe(a),d=Le(j(c)?[]:n([a],xe(a),!0));d&&Ue(d)?u.domain=d:J("指定Cookie域无效或无权限,使用默认域!","warn")}t=u}else t=function(){try{var e=window.localStorage,t="__storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(e){return!1}}()?new Te:new Pe;return"cookie"===o&&ye&&Ue(ye)&&function(e,t,n){if(t&&Ue(t)){var i=new Ee(t);["".concat(n,"_gdp_session_id"),"gdp_user_id_gioenc","".concat(n,"_gdp_cs1_gioenc"),"".concat(n,"_gdp_user_key_gioenc"),"".concat(n,"_gdp_gio_id_gioenc"),"".concat(n,"_gdp_sequence_ids"),"".concat(n,"_gdp_session_id_sent")].forEach((function(t){var n=i.getItem(t);i.hasItem(t)&&(e.setItem(t,n),i.removeItem(t))})),i=void 0}}(t,ye,s),t},De="ON_COMMIT_REQUEST",qe="ON_COMPOSE_AFTER",Ke="ON_COMPOSE_BEFORE",Ve="ON_ERROR",He="ON_INSTALL",Be="ON_SEND_AFTER",Re="ON_SEND_BEFORE",Ge="OPTION_CHANGE",je="OPTION_INITIALIZED",Fe="SDK_INITIALIZED",Me="SESSIONID_UPDATE",We="SET_USERID",ze="SET_USERKEY",Je=function(e){var n=this;this.growingIO=e,this.main=function(e,i){var r,o,a;void 0===i&&(i=!0),e||(e=n.growingIO.trackingId);var s=n.growingIO,u=s.sdkVersion,c=s.useEmbeddedInherit,d=s.userStore,g=s.dataStore,l=g.currentPage,f=l.path,v=l.query,h=l.title,p=l.getReferralPage,m=g.getTrackerVds(e),I=null!==(r=X((function(){return g.lastPageEvent[e]})))&&void 0!==r?r:{},w={appVersion:m.version,dataSourceId:m.dataSourceId,deviceId:d.getUid(),domain:e===c?m.appId:window.location.host,language:navigator.language,path:f,platform:m.platform,query:v,referralPage:p(e)||"",screenHeight:window.screen.height,screenWidth:window.screen.width,sdkVersion:u,sessionId:d.getSessionId(e),timestamp:+Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),title:null!==(a=null!==(o=I.title)&&void 0!==o?o:h)&&void 0!==a?a:X((function(){return document.title.slice(0,255)})),userId:d.getUserId(e)};return m.idMapping?w.userKey=d.getUserKey(e):w.userKey="",i&&!j(g.generalProps[e])&&(w.attributes=t({},g.generalProps[e]),j(w.attributes)||(w.attributes=oe(ae(t({},w.attributes))))),j(m.ignoreFields)||m.ignoreFields.forEach((function(e){G(w,e)})),c&&e===c&&!j(n.minpExtraParams)&&B(t(t({},w),n.minpExtraParams),(function(e,t){var i,r;P(m.embeddedIgnore,t)?(w[t]=null!==(i=null==m?void 0:m.originValues[t])&&void 0!==i?i:w[t],"domain"===t&&(w[t]=window.location.host)):w[t]=null!==(r=n.minpExtraParams[t])&&void 0!==r?r:w[t]})),w.trackingId=e,w},this.minpExtraParams={}},Xe=function(e){var n,i=this;this.growingIO=e,this.parsePage=function(){var e=i.growingIO.vdsConfig.hashtag,t=location.pathname,n=location.search,r=location.hash,o=r.indexOf("?");i.domain=window.location.host,i.title=document.title.slice(0,255),i.time=+Date.now(),i.path=t,i.query=n,e&&(o>-1?(i.path+=r.slice(0,o),i.query=i.query+"&"+r.slice(o+1)):i.path+=r),i.query&&P(["?","&"],i.query.charAt(0))&&(i.query=i.query.slice(1))},this._getNoHashHref=function(){var e=window.location,t=e.protocol,n=e.host,i=e.pathname,r=e.search;return"".concat(t,"://").concat(n).concat(i).concat(r)},this.getReferralPage=function(e){var t,n,r=i.growingIO.dataStore.lastPageEvent[e];return(null==r?void 0:r.path)===i.path&&(null!==(t=null==r?void 0:r.query)&&void 0!==t?t:"")===(null!==(n=i.query)&&void 0!==n?n:"")?null==r?void 0:r.referralPage:(null==r?void 0:r.path)?null==r?void 0:r.nextRefferer:document.referrer},this.handlePage=function(){var e=i.growingIO,t=e.vdsConfig.hashtag,n=e.dataStore,r=window.location.href,o=i.lastHref;t||(r=i._getNoHashHref(),o=i.lastNoHashHref),o!==r&&(i.parsePage(),n.initializedTrackingIds.forEach((function(e){n.sendVerifiedPage(e)})))},this.hookHistory=function(){var e=window.history.pushState,t=window.history.replaceState,n=i;e&&X((function(){return window.history.pushState=function(){e.apply(window.history,arguments),setTimeout(n.handlePage)}})),t&&X((function(){return window.history.replaceState=function(){t.apply(window.history,arguments),setTimeout(n.handlePage)}})),ne(window,"popstate",i.handlePage),i.growingIO.vdsConfig.hashtag&&ne(window,"hashchange",i.handlePage)},this.eventSetPageProps=function(e,n){var r=X((function(){return i.pageProps[e][i.path]}));return j(r)?n.attributes:oe(t(t({},n.attributes),ae(r)))},this.buildPageEvent=function(e,n){var r=i.growingIO.dataStore,o=r.eventContextBuilder,a=r.eventConverter,s=t(t({eventType:"PAGE"},o(e)),{title:i.title,protocolType:location.protocol.substring(0,location.protocol.length-1),referralPage:i.getReferralPage(e),timestamp:i.time});!j(n)&&n.title&&(s.title=n.title),s.attributes=i.eventSetPageProps(e,s),a(s),i.lastHref=window.location.href,i.lastNoHashHref=i._getNoHashHref(),i.lastLocation=t({},window.location)},this.title=null!==(n=X((function(){return document.title.slice(0,255)})))&&void 0!==n?n:"",this.lastLocation=t({},window.location),this.pageListeners={},this.pageProps={}},Qe=function(e){var n,i=this;this.growingIO=e,this.ALLOW_SETTING_KEYS=Object.keys(fe),this.trackTimers={},this.getTrackerVds=function(e){return i.growingIO.trackingId===e?t({},i.growingIO.vdsConfig):void 0},this.getKeyPrefix=function(e){return i.growingIO.vdsConfig.projectId},this.getStorageKey=function(e,t){return"".concat(i.getKeyPrefix(e)).concat(le[t])},this.getGsid=function(e){var t,n=i.growingIO.storage.getItem(i.getStorageKey(e,"gsid"))||{},r=Number(n.globalKey);return m(r)||r>=1e9||1>r?(t=1,i.setGsid(e,t)):t=r,t},this.setGsid=function(e,t){var n=m(Number(t))||t>=1e9||1>t?1:t;i.setSequenceIds(e,n)},this.setSequenceIds=function(e,t){var n=i.getStorageKey(e,"gsid"),r=i.growingIO.storage.getItem(n)||{};r.globalKey=t,i.growingIO.storage.setItem(n,r)},this.initTrackerOptions=function(e){var t=i.initOptions(e);return t.trackingId=e.trackingId,i.growingIO.trackingId=e.trackingId,i.growingIO.vdsConfig=t,window[i.growingIO.vdsName]=t,t},this.initOptions=function(e){var n,r,o,a,s,u,c,d=e.projectId,g=e.dataSourceId,l=e.appId,f={};return i.ALLOW_SETTING_KEYS.forEach((function(t){var n=fe[t].type,i=S(n)?!P(n,F(e[t])):F(e[t])!==n;"platform"!==t||P(ge,e[t])||(i=!0),i?f[t]=fe[t].default:"ignoreFields"===t?f.ignoreFields=e.ignoreFields.filter((function(e){return P(Ie,e)})):(f[t]=e[t],P(["dataCollect","autotrack"],t)&&!f[t]&&J("已关闭".concat(pe[t]),"info"))})),f.sessionExpires=Math.round(f.sessionExpires),(m(f.sessionExpires)||1>f.sessionExpires||f.sessionExpires>360)&&(f.sessionExpires=30),f.storageType=f.storageType.toLowerCase(),f.enableIdMapping&&!f.idMapping&&(f.idMapping=!0),G(f,"enableIdMapping"),f.sendType=f.sendType.toLowerCase(),P(["beacon","xhr","image"],f.sendType)||(f.sendType="beacon"),!f.trackBot&&ee()&&(f.dataCollect=!1),!m(Number(f.requestTimeout))&&f.requestTimeout>0||(f.requestTimeout=5e3),t(t(t({},null!==(n=window[i.growingIO.vdsName])&&void 0!==n?n:{}),f),{projectId:d,dataSourceId:g,appId:l,performance:{monitor:null===(o=null===(r=f.performance)||void 0===r?void 0:r.monitor)||void 0===o||o,exception:null===(s=null===(a=f.performance)||void 0===a?void 0:a.exception)||void 0===s||s,network:null!==(c=null===(u=f.performance)||void 0===u?void 0:u.network)&&void 0!==c&&c}})},this.setOriginalSource=function(e){var t=i.growingIO,n=t.storage,r=t.userStore,o=n.getItem(i.getStorageKey(e,"sentSign"));if(r.getSessionId(e)!==o&&j(i.getOriginalSource(e))){var a=i.currentPage,s=a.path,u=a.query,c=a.getReferralPage,d={path:s,query:u,referralPage:document.referrer||c(e)};localStorage.setItem(i.getStorageKey(e,"originalSource"),JSON.stringify(d))}},this.getOriginalSource=function(e){return X((function(){return JSON.parse(localStorage.getItem(i.getStorageKey(e,"originalSource")))}))},this.setOption=function(e,n,r){var o,a=i.growingIO,s=a.emitter,u=a.userStore,c=i.getTrackerVds(e),d=t({},c);i.updateVdsConfig(e,t(t({},c),((o={})[n]=r,o))),"dataCollect"===n&&d.dataCollect!==r&&(r?u.setSessionId(e,z()):i.growingIO.clearTrackTimer(e)),null==s||s.emit(Ge,{trackingId:e,optionName:n,optionValue:r})},this.getOption=function(e,t){var n=i.getTrackerVds(e);return t&&V(i.growingIO.vdsConfig,t)?V(n,t)?n[t]:i.growingIO.vdsConfig[t]:j(t)?n:void te("getOption > ".concat(t))},this.updateVdsConfig=function(e,n){var r=window[i.growingIO.vdsName];try{e===i.growingIO.trackingId?(i.growingIO.vdsConfig=t(t({},i.growingIO.vdsConfig),n),window[i.growingIO.vdsName]=t(t({},r),i.growingIO.vdsConfig)):(i.growingIO.subInstance[e]=t(t({},i.growingIO.subInstance[e]),n),window[i.growingIO.vdsName].subInstance[e]=t(t({},r.subInstance[e]),i.growingIO.subInstance[e]))}catch(e){J("Internal Error!更新配置项错误!","error")}},this.sendVerifiedVisit=function(e,t){var n=i.growingIO,r=n.userStore.getSessionId,o=n.storage.getItem(i.getStorageKey(e,"sentSign")),a=r(e)===o;!t&&a||i.buildVisitEvent(e)},this.sendVerifiedPage=function(e,t){void 0===t&&(t=!1),t&&i.currentPage.parsePage();var n=i.getTrackerVds(e).trackPage,r=i.currentPage,o=r.pageListeners,a=r.path,s=r.query,u=r.title,c=r.buildPageEvent;b(o[e])&&o[e]({path:a,query:s,title:u}),n&&c(e)},this.buildVisitEvent=function(e,n){var r=i.growingIO,o=r.dataStore,a=o.eventContextBuilder,s=o.eventConverter,u=o.currentPage,c=r.emitter,d=r.vdsConfig,g=i.getOriginalSource(e),l=t(t({eventType:"VISIT"},a(e)),{title:u.title,referralPage:document.referrer||i.currentPage.getReferralPage(e),timestamp:u.time-1});d.originalSource&&!v(g)&&(l=t(t({},l),g)),j(n)||B(l,(function(e,t){V(n,t)&&(p(n[t])?l[t]=n[t]:j(n[t])||(l[t]=n[t]||l[t]))})),c.on(Be,(function(t){var n=t.requestData,r=t.trackingId,o=i.growingIO,a=o.userStore,s=o.storage;if("VISIT"===n.eventType&&e===r){s.setItem(i.getStorageKey(n.trackingId,"sentSign"),n.sessionId),a.setUid(n.deviceId);var u=a.getUserId(r);u&&u===n.userId&&a.setUserId(r,a.getUserId(r));var c=a.getUserKey(r);c&&c===n.userKey&&a.setUserKey(r,a.getUserKey(r));var d=a.getGioId(r);d&&d===n.gioId&&a.setGioId(r,a.getGioId(r)),localStorage.removeItem(i.getStorageKey(r,"originalSource"))}})),s(l)},this.eventConverter=function(e){var n,r,o=i.growingIO.uploader;if(i.getTrackerVds(e.trackingId).dataCollect){e.eventSequenceId=i.getGsid(e.trackingId),"LOGIN_USER_ATTRIBUTES"===e.eventType?G(e,["timezoneOffset","eventSequenceId"]):i.setGsid(e.trackingId,i.getGsid(e.trackingId)+1);var a={};B(e,(function(e,t){var n;if("element"===t){var i=null!==(n=_(e))&&void 0!==n?n:{};B(i,(function(e,t){j(e)&&0!==e||(a[t]=e)}))}else(j(e)||v(e))&&0!==e||(a[t]=e)})),null===(n=i.growingIO.emitter)||void 0===n||n.emit(qe,{composedEvent:t({},a),trackingId:e.trackingId});var s=i.beforeSendListener[e.trackingId];if(!j(s)&&b(s)){var u=null!==(r=X((function(){return s(t({},a))})))&&void 0!==r?r:{};w(u)&&!j(u)&&u.eventType&&u.dataSourceId&&(["path","query","title"].forEach((function(e){u[e]&&h(u[e])&&(a[e]=u[e])})),u.attributes&&w(u.attributes)&&(j(u.attributes)?G(a,"attributes"):a.attributes=oe(u.attributes)))}o.commitRequest(t(t({},a),{requestId:z()}))}},this.currentPage=new Xe(this.growingIO),this.eventContextBuilderInst=new Je(this.growingIO),this.eventContextBuilder=null===(n=this.eventContextBuilderInst)||void 0===n?void 0:n.main,this.generalProps={},this.beforeSendListener={},this.lastPageEvent={};var r=this.growingIO.emitter;null==r||r.on(De,(function(e){var n=e.eventData,r=e.trackingId;"PAGE"!==n.eventType&&"page"!==n.t||(i.lastPageEvent[r]=t(t({},n),{nextRefferer:window.location.href}))})),this.initializedTrackingIds=[],r.on(Fe,(function(e){var t=e.trackingId;i.initializedTrackingIds.push(t)})),null==r||r.on(Me,(function(e){var t=e.trackingId;P(i.initializedTrackingIds,t)&&(i.growingIO.uploader.hoardingQueue[t]=[],i.currentPage.parsePage(),i.sendVerifiedVisit(t,!0),i.sendVerifiedPage(t,!0))})),this.growingIO.emitter.on(Ge,(function(e){var t=e.optionName,n=e.optionValue;"dataCollect"===t&&!1===n&&i.initializedTrackingIds.forEach((function(e){return i.growingIO.clearTrackTimer(e)}))}))},Ye={name:"gioCompress",method:function(e){var t=this;this.growingIO=e,this._compress=function(e,t,n){if(null===e)return"";var i,r,o,a={},s={},u="",c="",d="",g=2,l=3,f=2,v=[],h=0,p=0;for(o=0;od.charCodeAt(0)){for(i=0;f>i;i++)h<<=1,p===t-1?(p=0,v.push(n(h)),h=0):p++;for(r=d.charCodeAt(0),i=0;8>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1}else{for(r=1,i=0;f>i;i++)h=h<<1|r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r=0;for(r=d.charCodeAt(0),i=0;16>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1}0==--g&&(g=Math.pow(2,f),f++),delete s[d]}else for(r=a[d],i=0;f>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1;0==--g&&(g=Math.pow(2,f),f++),a[c]=l++,d=u+""}if(""!==d){if({}.hasOwnProperty.call(s,d)){if(256>d.charCodeAt(0)){for(i=0;f>i;i++)h<<=1,p===t-1?(p=0,v.push(n(h)),h=0):p++;for(r=d.charCodeAt(0),i=0;8>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1}else{for(r=1,i=0;f>i;i++)h=h<<1|r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r=0;for(r=d.charCodeAt(0),i=0;16>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1}0==--g&&(g=Math.pow(2,f),f++),delete s[d]}else for(r=a[d],i=0;f>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1;0==--g&&(g=Math.pow(2,f),f++)}for(r=2,i=0;f>i;i++)h=h<<1|1&r,p===t-1?(p=0,v.push(n(h)),h=0):p++,r>>=1;for(;;){if(h<<=1,p===t-1){v.push(n(h));break}p++}return v.join("")},this.compress=function(e){var n=t;return t._compress(e,16,(function(e){return n.f(e)}))},this.compressToUTF16=function(e){var n=t;return null===e?"":t._compress(e,15,(function(e){return n.f(e+32)}))+" "},this.compressToUint8Array=function(e){for(var n=t.compress(e),i=new Uint8Array(2*n.length),r=0,o=n.length;o>r;r++){var a=n.charCodeAt(r);i[2*r]=a>>>8,i[2*r+1]=a%256}return i},this.compressToEncodedURIComponent=function(e){if(null===e)return"";var n=t;return t._compress(e,6,(function(e){return n.keyStrUriSafe.charAt(e)}))},this.pluginVersion="__PLUGIN_VERSION__",this.f=String.fromCharCode,this.keyStrUriSafe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$"}},Ze={},$e={}.hasOwnProperty;function et(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function tt(e){try{return encodeURIComponent(e)}catch(e){return null}}Ze.stringify=function(e,t){t=t||"";var n,i,r=[];for(i in"string"!=typeof t&&(t="?"),e)if($e.call(e,i)){if((n=e[i])||null!=n&&!isNaN(n)||(n=""),i=tt(i),n=tt(n),null===i||null===n)continue;r.push(i+"="+n)}return r.length?t+r.join("&"):""},Ze.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,i={};t=n.exec(e);){var r=et(t[1]),o=et(t[2]);null===r||null===o||r in i||(i[r]=o)}return i};var nt={gioprojectid:"projectId",giodatacollect:"dataCollect",gioappid:"domain",giodatasourceid:"dataSourceId",gios:"sessionId",giou:"uid",giocs1:"userId",giouserkey:"userKey",gioappchannel:"appChannel",giodevicebrand:"deviceBrand",giodevicemodel:"deviceModel",giodevicetype:"deviceType",giolanguage:"language",gionetworkstate:"networkState",giooperatingsystem:"operatingSystem",gioplatform:"platform",gioplatformversion:"platformVersion",gioscreenheight:"screenHeight",gioscreenwidth:"screenWidth"},it=["gioprojectid","giodatacollect","giodatasourceid","gioplatform"],rt=["giodatasourceid","gioplatform","gioappchannel","giodevicebrand","giodevicemodel","giodevicetype","giolanguage","gionetworkstate","giooperatingsystem","gioplatformversion","gioscreenheight","gioscreenwidth"],ot=["giocs1","gios","giou","giouserkey"],at="gdp_query_string",st={name:"gioEmbeddedAdapter",method:function(e){var t=this;this.growingIO=e,this.onOptionsInit=function(e,n){var i,r,o=n.projectId,a=n.appId,s=e===t.growingIO.trackingId?n.hashtag:t.growingIO.vdsConfig.hashtag,u=t.getGQS(s);if(P(["search","hash"],t.qsFrom)&&!j(u)&&t.storage.setItem(at,u),!t.growingIO.useEmbeddedInherit&&"none"!==t.qsFrom&&u.gioprojectid===o&&u.gioappid===a){t.growingIO.useEmbeddedInherit=e;var c=t.growingIO.dataStore.getTrackerVds(e);it.forEach((function(e){if(V(u,e))if("giodatacollect"===e)c.dataCollect=P(["true",!0],u.giodatacollect);else{var t=nt[e];P(["domain","platform"],t)&&(c.originValues||(c.originValues={}),c.originValues[t]=c[t]),c[t]=u[e]}})),t.growingIO.dataStore.updateVdsConfig(e,c);var d=t.growingIO,g=d.userStore,l=d.dataStore.eventContextBuilderInst;g.setUid(u.giou),g.setSessionId(e,u.gios),g.setUserId(e,null!==(i=u.giocs1)&&void 0!==i?i:""),g.setUserKey(e,null!==(r=u.giouserkey)&&void 0!==r?r:""),window.setInterval((function(){g.setSessionId(e,u.gios)}),.8*n.sessionExpires*60*1e3),rt.forEach((function(e){V(u,e)&&(l.minpExtraParams[nt[e]]=u[e])}));var f=t.growingIO.setUserId;t.growingIO.setUserId=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];if(t[0]!==e)return f.apply(this,t)};var v=t.growingIO.clearUserId;if(t.growingIO.clearUserId=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];if(t[0]!==e)return v.apply(this,t)},V(u,"giodatacollect")){var h=t.growingIO.setOption;t.growingIO.setOption=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];if(t[0]!==e)return h.apply(this,t)}}}t.gioURLRewrite(),t.growingIO.dataStore.currentPage.parsePage()},this.getGQS=function(e){var i=window.location.search,r=window.location.hash,o=e?r.substring(r.indexOf("?")+1):"",a=t.storage.getItem(at),s=Ze.parse(i),u=Ze.parse(o),c=a,d={};if(V(s,"gioprojectid"))d=s,t.qsFrom="search";else if(V(u,"gioprojectid"))d=u,t.qsFrom="hash";else{if(!V(c,"gioprojectid"))return t.qsFrom="none",{};d=c,t.qsFrom="local"}var g={},l={},f=n(n(["gioappid","gioprojectid","giodatacollect"],ot,!0),rt,!0);return H(d).forEach((function(e){var t=e.toLowerCase();P(f,t)?P(["","undefined","null",void 0,null],d[e])?g[t]="":(g[t]=d[e],P(["true","TRUE",!0],d[e])&&(g[t]=!0),P(["false","FALSE",!1],d[e])&&(g[t]=!1)):l[e]=d[e]})),t.gqs=g,t.customerqs=l,g},this.gioURLRewrite=function(){var e=t.growingIO.vdsConfig.hashtag,n=window.location.search,i=window.location.hash,r=!1;if("search"===t.qsFrom&&(n=Ze.stringify(t.customerqs,!0),r=!0),e&&"hash"===t.qsFrom&&(i="".concat(i.split("?")[0]).concat(Ze.stringify(t.customerqs,!0)),r=!0),r){var o="".concat(window.location.pathname).concat(n||"").concat(i||"");window.history.replaceState(null,document.title,o)}},this.pluginVersion="__PLUGIN_VERSION__",this.gqs={},this.customerqs={},this.qsFrom="search",this.storage=new Te,this.growingIO.emitter.on(je,(function(e){var n=e.trackingId,i=e.vdsConfig;t.onOptionsInit(n,i)}))}},ut=function(){return ut=Object.assign||function(e){for(var t,n=1,i=arguments.length;i>n;n++)for(var r in t=arguments[n])({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ut.apply(this,arguments)};function ct(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;o>r;r++)!i&&r in t||(i||(i=[].slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||[].slice.call(t))}var dt,gt,lt,ft=function(e){try{return e()}catch(e){return}},vt=function(e){return"number"===Ot(e)},ht=function(e){return"object"===Ot(e)&&!function(e){return It(["undefined","null"],Ot(e))}(e)},pt=function(e){return Array.isArray(e)&&"array"===Ot(e)},mt=function(e,t){if(pt(e))for(var n=0;n=0},wt=f,yt=function(e){return ht(e)?Object.keys(e):[]},bt=function(e){return pt(e)?0===e.length:ht(e)?0===yt(e).length:!e},St=function(e){if(pt(e)){for(var t=0,n=[],i=0,r=e;it;if(n>t)return!0;for(var i=0;i0?t:void 0):""},$t=/[^/]*.(bmp|jpg|jpeg|png|gif|svg|psd|webp|apng)/gi,en=function(e,t){switch(t){case"a":return function(e){if(Ht(e,"href")){var t=Bt(e,"href");if(t&&0!==t.indexOf("javascript"))return t.slice(0,320)}return""}(e);case"img":return function(e){var t=e.src;if(t&&-1===t.indexOf("data:image")){var n=t.match($t),i=bt(n)?"":n[0];if(i.indexOf("%")>-1){var r=function(e,t){var n=-1;if(pt(e))for(var i=0;i0&&t.every((function(e){return function(e){if("svg"===e.tagName)return!0;var t=Ft(e);if(bt(t))return!0;var n=Xt(e);return!(!bt(t)&&!n)}(e)}))}(e)&&!Jt(e)?Zt(on(e)):Jt(e)?Zt(an(e)):""},rn=function(e,t){for(var n=e.parentElement;n&&!Wt(n);){if(t(n))return n;n=n.parentElement}},on=function(e){var t=Ft(e);return St(t.map((function(e){var t=Yt(e);if(Xt(e)&&t)return t}))).join(" ")},an=function(e){var t;return Ft(e).some((function(e){var n,i=nn(e,null===(n=e.tagName)||void 0===n?void 0:n.toLowerCase());return!!i&&(t=i,!0)})),t},sn=function(e,t){return It(["checkbox","radio"],e.type)?"".concat(t).concat((n=e.checked,"boolean"===Ot(n)?"("+e.checked+")":"")):t;var n},un=function e(t,n,i,r,o){void 0===r&&(r=!0),void 0===o&&(o=[]);var a,s=this;this.originNode=t,this.deviceInfo=n,this.actionType=i,this.trackable=r,this.parentNodes=o,this.isLimitViewport=!0,this._getIndex=function(){if(Ht(s.originNode,Kt)){var e=Bt(s.originNode,Kt);return/^\d{1,10}$/.test(e)&&e-0>0&&2147483647>e-0?+e:void(0>s.actionType.indexOf("circle")&&(u="".concat(e,",index标记应为 大于 0 且小于 2147483647 的整数!"),console.log("%c [GrowingIO]:".concat(u),"color: #F59E0B;")))}if(It(["dd","dt"],s.tagName)){var t=Mt(s.originNode),n=t?Ft(t):[];if("dl"===t.tagName.toLowerCase()&&n.length>0){if("dd"===s.tagName){var i=mt(n,(function(e){return e.isSameNode(s.originNode)}));if(i>-1)return(r=n.slice(0,i).filter((function(e){return"dt"===e.tagName.toLowerCase()}))).length-1+1}if("dt"===s.tagName){var r=n.filter((function(e){return"dt"===e.tagName.toLowerCase()}));return mt(r,(function(e){return e.isSameNode(s.originNode)}))+1}}}if(s.isPureList){var o=mt(s._pureList,(function(e){return e.isSameNode(s.originNode)}));return o>-1?(s.peerNodes=ct([],s._pureList,!0),s.peerNodes.splice(o,1),o+1):void 0}if(s.isPseudoList){var a=mt(s._pseudoList,(function(e){return e.isSameNode(s.originNode)}));return a>-1?(s.peerNodes=ct([],s._pseudoList,!0),s.peerNodes.splice(a,1),a+1):void 0}var u},this._getSiblingNode=function(e,t){var n,i=Mt(e);if(!i)return[];for(var r=null!==(n=ft((function(){return wt(i.children)})))&&void 0!==n?n:[],o=[],a=0;ae.length||!It(Ct,s.tagName)||(s._pureList=e,0))},this._getIsInPseudoList=function(){if(It(["th","td"],s.tagName))return!1;var e=s._getSiblingNode(s.originNode,(function(e,t){var n=e.tagName===t.tagName&&e.className===t.className,i=Ft(e),r=Ft(t),o=i.every((function(e,t){var n,i;return(null==e?void 0:e.tagName)===(null===(n=r[t])||void 0===n?void 0:n.tagName)&&(null==e?void 0:e.className)===(null===(i=r[t])||void 0===i?void 0:i.className)})),a=i.length===r.length&&o;return n&&a}));return e.length>=3&&(s._pseudoList=e,!0)},this._getClassList=function(e){var t;if(Ht(e,"name")&&Bt(e,"name"))return[Bt(e,"name")];var n=(null!==(t=Bt(e,"class"))&&void 0!==t?t:"").trim().split(" ");return bt(n)?[]:n.filter((function(e){return e&&!Ut.test(e)&&At.test(e)})).sort()},this._getCurrentXpath=function(){return"/".concat(s.tagName).concat(s.id?"#"+s.id:"").concat(bt(s.classList)?"":"."+s.classList.join("."))},this._getIsContainer=function(){return Ht(s.originNode,qt)||It(Pt,s.tagName)||"input"===s.tagName&&It(Nt,s.originNode.type)},this._getContent=function(){s.content=nn(s.originNode,s.tagName)},this._getIsOutFlow=function(){var e=window.getComputedStyle(s.originNode).position;return It(["fixed","sticky"],e)},this._getRect=function(){var e=s.originNode.getBoundingClientRect(),t=e.top,n=e.bottom,i=e.left,r=e.right-i,o=n-t,a=s.deviceInfo,u=a.winHeight,c=a.winWidth;return t+o>u&&(o=u-t),i+r>c&&(r=c-i),{top:t,left:i,width:r,height:o}},this._getListItemViewStatus=function(){var e=s.parentNodes.find((function(e){var t=e.originNode,n=t.scrollHeight,i=t.scrollWidth,r=t.clientHeight,o=t.clientWidth,a=e.rect,s=a.width,u=a.height;return r!==n&&n>u||o!==i&&i>s}));if(e){var t=e.rect,n=t.top,i=t.left,r=t.width,o=t.height,a=s.rect,u=a.top,c=a.left,d=a.width,g=a.height;return n>u+g||c>i+r||u>n+o||i>c+d?"OUTSIDE":u>=n&&c>=i&&n+o>u+g&&i+r>c+d?"DISPLAYED":"OBSCURED"}return""},this._getViewStatus=function(e){var t=window.getComputedStyle(s.originNode),n=t.opacity,i=t.visibility,r=t.display,o=t.width,a=t.height,u=s.rect,c=u.top,d=u.left,g=u.width,l=u.height,f=s.deviceInfo,v=f.winWidth,h=f.winHeight;if(0===Number(n)||"hidden"===i||"none"===r||"0px"===o||0===s.originNode.clientWidth||"0px"===a||0===s.originNode.clientHeight)return"HIDDEN";var p=ct([],e,!0).find((function(e){return e.trackable&&It(["DISPLAYED","OBSCURED"],e.viewStatus)}));if(s.isPureList||s.isPseudoList){var m=s._getListItemViewStatus();if(m)return m}if(p)return p.viewStatus;var I=function(e,t){return document.elementFromPoint(e,t)===s.originNode};return h>c&&v>d&&g>0&&l>0?I(d+g/2,c+l/2)||I(d+1,c+1)||I(d+g-1,c+1)||I(d+1,c+l-1)||I(d+g-1,c+l-1)?"DISPLAYED":s.isLimitViewport&&(0>c+l||0>d+g)?"OUTSIDE":"OBSCURED":"OUTSIDE"},this._getTriggerEvent=function(){return"input"===s.tagName&&It(Tt,s.originNode.type)||It(["select","textarea"],s.tagName)?"VIEW_CHANGE":"VIEW_CLICK"},this._getXParents=function(t,n){var i=t.parentElement,r=[];if(n.length>0)r.push.apply(r,n);else if(i&&!Wt(i)){var o=new e(i,void 0,s.actionType,jt(i,s.actionType));r.push(o),o.xParents&&r.push.apply(r,o.xParents)}return r},this.tagName=t.tagName.toLocaleLowerCase(),this.classList=this._getClassList(t),this.id=t.id,this.currentXpath=this._getCurrentXpath(),this.isIgnored=Ht(this.originNode,Dt),this.isContainer=this._getIsContainer(),this.isPureList=this._getIsPureList(),this.isPseudoList=this._getIsInPseudoList(),this.index=this._getIndex(),this.hyperlink=en(t,this.tagName),this.content=nn(this.originNode,this.tagName),this.triggerEvent=this._getTriggerEvent(),this.isOutFlow=this._getIsOutFlow(),n&&(this.isLimitViewport=null===(a=n.isLimitViewport)||void 0===a||a,this.rect=this._getRect(),this.viewStatus=this._getViewStatus(o)),this.xParents=this._getXParents(t,o)},cn=function e(t,n,i,r,o){var a=this;this.origin=t,this.action=n,this.lengthThreshold=i,this.deviceInfo=r,this.parentNode=o,this.trackNodes=function(){var e;if(!a.trackable)return[];var t=[a.xNode];if(It(["click","circleClick","change"],a.actionType))for(var n=a._getParent();n;){if(!(null==n?void 0:n.xNode)||(null===(e=n.xNode)||void 0===e?void 0:e.isIgnored))return[];n.trackable&&t.push(n.xNode),n=n._getParent()}var i,r=[];return t.reverse().forEach((function(e,n){if(Ht(e.originNode,qt)&&(r=[],i=void 0),vt(e.index)&&!vt(i)&&(i=e.index),vt(i)&&(e.index=i),n===t.length-1)r.push(a.getGioNodeInfo(e));else{var o=e.isPureList||e.isPseudoList;(e.isContainer||o)&&r.push(a.getGioNodeInfo(e))}})),r},this.getGioNodeInfo=function(e){var t=a.computeXpath(e),n=t.skeleton,i=t.fullXpath,r=t.xcontent,o=e.hyperlink,s=e.index,u=e.peerNodes,c=e.content,d=e.triggerEvent,g=e.originNode;return{skeleton:n,xpath:n,fullXpath:i,xcontent:r,hyperlink:o,index:s,peerNodes:null!=u?u:[],content:Zt(c),triggerEvent:d,originNode:g}},this.computeXpath=function(e){var t,n="/"+e.tagName,i=e.currentXpath,r="/"+((e.id?"#"+e.id:"")+(bt(e.classList)?"":"."+e.classList.join("."))||"-");return null===(t=e.xParents)||void 0===t||t.forEach((function(e,t){if(i=e.currentXpath+i,t-1||(null===(a=null==e?void 0:e.id)||void 0===a?void 0:a.indexOf("__giokit"))>-1)return!1;var u=new cn(e,"circleClick",c.xpathThreshold,c.deviceInfo,n),d=u.xNode;if(d.zLevel=c._getZLevel(e,t),u.trackable&&(It(["DISPLAYED","OBSCURED"],d.viewStatus)||i)){if(t.index&&(d.index=t.index),dn.find((function(e){return e.originNode.isSameNode(d.originNode)})))return!1;if("DISPLAYED"===d.viewStatus){var g=c._getGioHybridNodeInfo(u,t);dn.push(g)}else"OBSCURED"===d.viewStatus&&(d.isContainer||i)&&(g=c._getGioHybridNodeInfo(u,t),dn.push(g));if(Qt(e)||d.isContainer&&Xt(e))return!1}bt(Ft(e))||c._getTrackElements(e,null!==(s=u.xNode)&&void 0!==s?s:t,u,i)}))},this._getZLevel=function(e,t){var n=window.getComputedStyle(e),i=n.position,r=n.zIndex;if("auto"!==r){var o=Number(r||0);return(Number.isNaN(o)?0:o)+t.zLevel}switch(i){case"relative":return t.zLevel+2;case"sticky":return t.zLevel+3;case"absolute":return t.zLevel+4;case"fixed":return t.zLevel+5;default:return t.zLevel+1}},this._getGioHybridNodeInfo=function(e,t){var n=e.xNode,i=n.rect,r=n.zLevel,o=e.getGioNodeInfo(n),a=o.hyperlink,s={};return yt(i).forEach((function(e){return s[e]=i[e]*c.deviceInfo.scale})),s.top+=c.deviceInfo.webviewTop,s.left+=c.deviceInfo.webviewLeft,ut(ut(ut({},s),o),{zLevel:r+c.deviceInfo.webviewZLevel,href:a,parentXPath:t.trackable?e.computeXpath(t).xpath:void 0})},this.xpathThreshold=t,this.deviceInfo=(i=(n=e).webviewLeft,r=n.webviewTop,o=n.webviewWidth,a=n.webviewHeight,s=n.webviewZLevel,u=n.isLimitViewport,{winWidth:o,winHeight:a,scale:o/window.innerWidth,webviewTop:r,webviewLeft:i,webviewWidth:o,webviewHeight:a,webviewZLevel:s,isLimitViewport:u})},ln=function(){function e(e){this.handler=e;var t=navigator.userAgent,n=/chrome/i.exec(t),i=/android/i.exec(t);this.hasTouch="ontouchstart"in window&&!(n&&!i)}return e.prototype.main=function(){for(var e=this.hasTouch?["touchstart"]:["mousedown"],t=this.hasTouch?["touchend","touchcancel"]:["mouseup","mouseleave"],n=this.hasTouch?["touchmove"]:["mousemove"],i=0,r=e;r.length>i;i++)ne(window,r[i],this.touchStartHandler.bind(this));for(var o=0,a=n;a.length>o;o++)ne(window,a[o],this.touchMoveHandler.bind(this));for(var s=0,u=t;u.length>s;s++)ne(window,u[s],this.touchStopHandler.bind(this))},e.prototype.touchStartHandler=function(e){if(1>=e.which){var t=+Date.now();this.safeguard!==t&&(this.touchTimeout&&clearTimeout(this.touchTimeout),this.safeguard=t,this.touchEvent={time:t,target:e.target,x:this._page("x",e),y:this._page("y",e),isTrusted:!0,type:"click"})}},e.prototype.touchMoveHandler=function(e){var t=Math.abs(this._page("x",e)-(this.touchEvent&&this.touchEvent.x)||0),n=Math.abs(this._page("y",e)-(this.touchEvent&&this.touchEvent.y)||0);(t>10||n>10)&&(this.touchEvent=null)},e.prototype.touchStopHandler=function(e){var t=this,n=+Date.now()-(this.touchEvent&&this.touchEvent.time)||0;this.touchEvent&&200>n?this.touchTimeout=setTimeout((function(){t.handler(t.touchEvent),t.touchEvent=null}),200):this.touchEvent&&n>=200&&700>n&&(this.handler(this.touchEvent),this.touchEvent=null)},e.prototype._page=function(e,t){return(this.hasTouch?t.touches[0]:t)["page".concat(e.toUpperCase())]},e}(),fn={click:"VIEW_CLICK",change:"VIEW_CHANGE"},vn={name:"gioEventAutoTracking",method:function(e){var n,i=this;this.growingIO=e,this.main=function(){ne(document,"change",i._handleAction),i.growingIO.vdsConfig.touch?new ln(i._handleAction).main():ne(document,"click",i._handleAction)},this._handleAction=function(e,t){var n,r,o,a,s,u=i.growingIO,c=u.vdsConfig,d=u.emitter,g=e.target;if(!c.autotrack||!g)return!1;if(!(null==g?void 0:g.tagName)||"circle-shape"===(null===(n=null==g?void 0:g.tagName)||void 0===n?void 0:n.toLowerCase())||"circle-page"===(null===(r=null==g?void 0:g.tagName)||void 0===r?void 0:r.toLowerCase())||"heatmap-page"===(null===(o=null==g?void 0:g.tagName)||void 0===o?void 0:o.toLowerCase())||(null===(a=null==g?void 0:g.id)||void 0===a?void 0:a.indexOf("__vconsole"))>-1||(null===(s=null==g?void 0:g.id)||void 0===s?void 0:s.indexOf("__giokit"))>-1)return!1;var l=new cn(g,e.type).trackNodes();if(j(l))return!1;"click"!==e.type&&(l=[N(l)]),null==d||d.emit(Ke,{event:t,params:null!=e?e:{}}),l.forEach((function(t){var n=t.fullXpath;if(0>n.indexOf("#__giokit")&&0>n.indexOf("#__vconsole")&&(c.debug&&console.log("Action:",e.type,Date.now()),n)){var r=i.growingIO,o=r.trackingId,a=r.useEmbeddedInherit,s=r.useHybridInherit,u=r.dataStore;i.buildInteractiveEvent(o,e,t),a&&o!==a&&u.getTrackerVds(a).autotrack&&i.buildInteractiveEvent(a,e,t),s&&o!==s&&u.getTrackerVds(s).autotrack&&i.buildInteractiveEvent(s,e,t)}}))},this.buildInteractiveEvent=function(e,n,r){var o=i.growingIO.dataStore,a=o.eventContextBuilder,s=o.eventConverter,u=o.currentPage,c=r.skeleton,d=r.xcontent,g=r.index,l=r.content,f=r.hyperlink,v=t({eventType:fn[n.type],element:[{xpath:c,xcontent:d,textValue:l,index:g,hyperlink:f}]},a(e));v.attributes=u.eventSetPageProps(e,v),s(v)},this.pluginVersion="__PLUGIN_VERSION__",null===(n=this.growingIO.emitter)||void 0===n||n.on(je,(function(e){e.trackingId===i.growingIO.trackingId&&i.main()}))}},hn=["VIEW_CLICK","VIEW_CHANGE","PAGE","CUSTOM","LOGIN_USER_ATTRIBUTES"],pn=["LOGIN_USER_ATTRIBUTES"],mn=["DOMContentLoaded","onreadystatechange"],In=["scroll","resize","load","beforeunload","popstate","hashchange","pagehide","unload"],wn=function(){function e(e){var n=this;this.growingIO=e,this.penetrateHybrid=!0,this.onOptionsInit=function(e,t){var i,r=n.growingIO,o=r.emitter,a=r.plugins;if(I(t.penetrateHybrid)&&(n.penetrateHybrid=t.penetrateHybrid),n._initHybridBridge()&&(n.onSendBefore=n.sendBeforeListener,!n.growingIO.useHybridInherit)){var s=null!==(i=n.hybridConfig.packageName)&&void 0!==i?i:n.hybridConfig.appPackage;a.gioMultipleInstances||t.packageName?n.hybridConfig.projectId===t.projectId&&s===t.packageName&&(n.growingIO.useHybridInherit=e):n.hybridConfig.projectId===t.projectId&&(n.growingIO.useHybridInherit=e)}n.growingIO.useHybridInherit&&(null==o||o.on(We,(function(e){var t=e.newUserId,i=e.oldUserId,r=e.userKey;e.trackingId===n.growingIO.useHybridInherit&&n.penetrateHybrid&&(!t&&i?r?n._clearNativeUserIdAndUserKey():n._clearNativeUserId():r?n._setNativeUserIdAndUserKey(L(t),L(r)):n._setNativeUserId(L(t)))})),null==o||o.on(ze,(function(e){var t=e.newUserKey,i=e.oldUserKey,r=e.userId;e.trackingId===n.growingIO.useHybridInherit&&n.penetrateHybrid&&(!t&&i?n._clearNativeUserIdAndUserKey():n._setNativeUserIdAndUserKey(L(r),L(t)))})))},this._initHybridBridge=function(){var e,t,i,r=!1;return n.hasHybridBridge=!!window.GrowingWebViewJavascriptBridge,n.hasHybridBridge&&((null===(e=null===window||void 0===window?void 0:window.GrowingWebViewJavascriptBridge)||void 0===e?void 0:e.configuration)||(window.GrowingWebViewJavascriptBridge.configuration=JSON.parse(window.GrowingWebViewJavascriptBridge.getConfiguration())),(null===(t=null===window||void 0===window?void 0:window.GrowingWebViewJavascriptBridge)||void 0===t?void 0:t.configuration)&&(n.hybridConfig=null===(i=null===window||void 0===window?void 0:window.GrowingWebViewJavascriptBridge)||void 0===i?void 0:i.configuration),r=!0),r},this.sendBeforeListener=function(e){var i=e.requestData,r=e.trackingId;if(n.hasHybridBridge){var o=function(){var e=n.processAttributes(t({},i));P(hn,e.eventType)&&(P(pn,e.eventType)?n.penetrateHybrid&&n._dispatchEvent(e):(n.penetrateHybrid||G(e,["userId","userKey","cs1"]),n._dispatchEvent(e)))};n.growingIO.useHybridInherit?r===n.growingIO.useHybridInherit&&o():r!==n.growingIO.trackingId||n.growingIO.plugins.gioMultipleInstances||o()}},this.processAttributes=function(e){return B(e,(function(t,n){w(t)||S(t)?B(e[n],(function(t,i){w(t)||S(t)?e[n][i]=JSON.stringify(t):e[n][i]=L(t)})):e[n]=L(t)})),e},this._setNativeUserId=function(e){X((function(){return window.GrowingWebViewJavascriptBridge.setNativeUserId(e)}))},this._clearNativeUserId=function(){X((function(){return window.GrowingWebViewJavascriptBridge.clearNativeUserId()}))},this._setNativeUserIdAndUserKey=function(e,t){X((function(){return window.GrowingWebViewJavascriptBridge.setNativeUserIdAndUserKey(e,t)}))},this._clearNativeUserIdAndUserKey=function(){X((function(){return window.GrowingWebViewJavascriptBridge.clearNativeUserIdAndUserKey()}))},this._dispatchEvent=function(e){X((function(){var t;return null===(t=window.GrowingWebViewJavascriptBridge)||void 0===t?void 0:t.dispatchEvent(JSON.stringify(e))}))},this._getDomTree=function(e,t,i,r,o,a){var s=new gn({webviewLeft:e,webviewTop:t,webviewWidth:i,webviewHeight:r,webviewZLevel:o}).trackNodes(null!=a?a:document.body,{isContainer:!1,zLevel:0},!1).map((function(e){return G(e,["originNode","peerNodes"]),e})),u=n.growingIO.dataStore.currentPage;return{page:{domain:u.domain,path:u.path,query:u.query,title:u.title},elements:s}},this.pluginVersion="__PLUGIN_VERSION__",this.growingIO.emitter.on(je,(function(e){var t=e.trackingId,i=e.vdsConfig;if(n.onOptionsInit(t,i),n.growingIO.useHybridInherit&&window.GrowingWebViewJavascriptBridge){var r=n;window.GrowingWebViewJavascriptBridge.getDomTree=function(){if(arguments.length>=4)return r._getDomTree.apply(this,arguments)},n._addDomChangeListener()}}))}return e.prototype._addDomChangeListener=function(){var e,t=function(t){return void 0===t&&(t=""),function(){var n;"beforeunload"===t&&e&&e.disconnect(),null===(n=window.GrowingWebViewJavascriptBridge)||void 0===n||n.onDomChanged()}};(e=new MutationObserver(t("mutation"))).observe(document.body,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),mn.forEach((function(e){ne(document,e,t(e))})),In.forEach((function(e){ne(window,e,t(e))}))},e}(),yn={name:"gioHybridAdapter",method:wn},bn={name:"gioImpressionTracking",method:function(e){var n,i=this;this.growingIO=e,this.documentReady=!1,this.main=function(e){P(["listener","manual"],e)?(i.documentReady=!0,i.growingIO.gioSDKInitialized&&i.initMutationObserver()):"emitter"===e&&i.documentReady&&i.initMutationObserver()},this.initIntersectionObserver=function(){i.intersectionObserver=new IntersectionObserver((function(e){j(e)||e.map((function(e){var t=e.target,n=t.dataset,r=t.id;if(e.intersectionRatio>0){var o=i.getImpressionProperties(n);if(r){if("once"===n.gioImpType&&V(i.sentImps,r))return;i.sentImps[r]=o}if(o.eventName){var a=[];n.gioImpSendto&&(a=E(S(n.gioImpSendto)?n.gioImpSendto:X((function(){return JSON.parse(n.gioImpSendto)}))||[]),j(a)&&X((function(){return n.gioImpSendto.split(",").forEach((function(e){(e=h(e)&&e.trim().replace("[","").replace("]",""))&&a.push(e)}))}))),i.buildImpEvent(o,a)}}}))}))},this.initMutationObserver=function(){var e;i.mutationObserver&&(null===(e=i.mutationObserver)||void 0===e||e.disconnect());var t=document.querySelectorAll("[data-gio-imp-track]");x(t).map((function(e){var t;null===(t=i.intersectionObserver)||void 0===t||t.observe(e)})),i.mutationObserver=new MutationObserver((function(e){e.map((function(e){var t,n;"attributes"===e.type&&(null===(t=e.target.dataset)||void 0===t?void 0:t.gioImpTrack)&&(null===(n=i.intersectionObserver)||void 0===n||n.observe(e.target))}))})),i.mutationObserver.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeOldValue:!0,attributeFilter:["data-gio-imp-track","data-gio-imp-attrs",c,"data-gio-imp-sendto"]})},this.getImpressionProperties=function(e){var t={eventName:void 0,properties:{}};if(!(null==e?void 0:e.gioImpTrack))return t;if(t.eventName=e.gioImpTrack,V(e,"gioImpAttrs"))t.properties=X((function(){return w(e.gioImpAttrs)?e.gioImpAttrs:JSON.parse(e.gioImpAttrs)}));else for(var n in e){var i=void 0,r=n.match(d);r&&"track"!==(i=A(r[1]))&&(t.properties[i]=e[n])}return t.properties=oe(t.properties),g.test(t.eventName)&&!Number.isInteger(Number(_(t.eventName.split(""))))||(t.eventName=null,t={}),t},this.buildImpEvent=function(e,n){var r,o=e.eventName,a=e.properties,s=i.growingIO,u=s.trackingId,c=s.dataStore,d=c.eventContextBuilder,g=c.eventConverter,l=s.plugins,f=t({eventType:"CUSTOM",eventName:o},d(u));f.attributes=oe(t(t({},null!==(r=f.attributes)&&void 0!==r?r:{}),w(a)&&!j(a)?a:{})),l.gioMultipleInstances&&!j(n)&&(f["&&sendTo"]=n),g(f)},this.pluginVersion="__PLUGIN_VERSION__",this.sentImps={},window.IntersectionObserver&&window.MutationObserver?(this.initIntersectionObserver(),P(["interactive","complete"],document.readyState)?this.main("listener"):ne(document,"readystatechange",(function(){P(["interactive","complete"],document.readyState)&&i.main("listener")}),{once:!0}),null===(n=this.growingIO.emitter)||void 0===n||n.on(je,(function(e){e.trackingId===i.growingIO.trackingId&&i.main("emitter")})),ne(window,"unload",(function(){var e,t;null===(e=i.intersectionObserver)||void 0===e||e.disconnect(),null===(t=i.mutationObserver)||void 0===t||t.disconnect()}))):J("当前浏览器不支持半自动埋点,gioImpressionTracking已自动关闭!","warn")}},Sn=["gioPerformance"],On=function(t){function n(e){var n=t.call(this,e)||this;return n.growingIO=e,n.growingIO.gioSDKFull=!0,n.pluginsContext={plugins:{gioCompress:Ye,gioEmbeddedAdapter:st,gioEventAutoTracking:vn,gioHybridAdapter:yn,gioImpressionTracking:bn}},n}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+n+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(n,t),n}((function(e){var t,n,i,r,o,a,s=this;this.growingIO=e,this.innerPluginInit=function(){var e;Sn.forEach((function(e){var t;return G(null===(t=s.pluginsContext)||void 0===t?void 0:t.plugins,e)})),H(null===(e=s.pluginsContext)||void 0===e?void 0:e.plugins).forEach((function(e){var t,n,i=null!==(n=null===(t=s.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==n?n:{},r=i.name,o=i.method,a=T(s.pluginItems,(function(e){return e.name===r}));r&&o&&!a&&s.pluginItems.push({name:A(r||e),method:o||function(e){}})})),j(s.pluginItems)||s.installAll()},this.install=function(e,t,n){var i,r,o=s.growingIO.emitter,a=t||T(s.pluginItems,(function(t){return t.name===e}));if((null===(i=s.growingIO)||void 0===i?void 0:i.plugins)[e])return J("重复加载插件 ".concat(e," 或插件重名,已跳过加载!"),"warn"),!1;if(!a)return J("插件加载失败!不存在名为 ".concat(e," 的插件!"),"error"),!1;try{return(null===(r=s.growingIO)||void 0===r?void 0:r.plugins)[e]=new a.method(s.growingIO,n),t&&(o.emit(He,e),J("加载插件 ".concat(e),"info")),!0}catch(n){return s.lifeError(t,n),J("插件【".concat(e,"】加载异常 ").concat(n),"error"),!1}},this.installAll=function(e){(e||s.pluginItems).forEach((function(t){s.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!T(s.pluginItems,(function(e){return e.name===t.name}))&&s.pluginItems.push({name:A(t.name),method:t.method?t.method:function(){}})}))},this.uninstall=function(e){var t;G(s.pluginItems,e);var n=G(null===(t=s.growingIO)||void 0===t?void 0:t.plugins,e);return n||J("卸载插件 ".concat(e," 失败!"),"error"),n},this.uninstallAll=function(){s.pluginItems.forEach((function(e){return s.uninstall(e.name)}))},this.lifeError=function(e,t){s.growingIO.emitter.emit(Ve,{plugin:e,error:t}),J("插件执行错误 ".concat(e.name," ").concat(t),"error")},this.callLifeCycle=function(e,t){s.pluginItems.forEach((function(n){var i=s.growingIO.plugins[n.name]?s.growingIO.plugins[n.name][e]:void 0;if(i&&b(i))try{i(t)}catch(e){s.lifeError(n,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(He,(function(e){return s.callLifeCycle("onInstall",e)})),null===(n=this.growingIO.emitter)||void 0===n||n.on(Ve,(function(e){return s.callLifeCycle("onError",e)})),null===(i=this.growingIO.emitter)||void 0===i||i.on(Ke,(function(e){return s.callLifeCycle("onComposeBefore",e)})),null===(r=this.growingIO.emitter)||void 0===r||r.on(qe,(function(e){return s.callLifeCycle("onComposeAfter",e)})),null===(o=this.growingIO.emitter)||void 0===o||o.on(Re,(function(e){return s.callLifeCycle("onSendBefore",e)})),null===(a=this.growingIO.emitter)||void 0===a||a.on(Be,(function(e){return s.callLifeCycle("onSendAfter",e)}))})),_n=function(e){var i=this;this.growingIO=e,this.generateURL=function(e){var t=i.growingIO.dataStore.getTrackerVds(e),n=t.serverUrl,r=t.projectId;return D(n,"http")?"".concat(n,"/v3/projects/").concat(r,"/collect"):"https://".concat(n,"/v3/projects/").concat(r,"/collect")},this.getSendType=function(e){var t=i.growingIO.dataStore.getTrackerVds(e).sendType;return"beacon"===t?Y()?"beacon":"xhr":t},this.getHoardingQueue=function(e){var t;return null!==(t=i.hoardingQueue[e])&&void 0!==t?t:[]},this.commitRequest=function(e){var n,r=i.growingIO,o=r.vdsConfig;r.emitter.emit(De,{eventData:e,trackingId:e.trackingId});var a=t(t({},e),{requestType:i.getSendType(e.trackingId)});o.forceLogin?(i.hoardingQueue[e.trackingId]||(i.hoardingQueue[e.trackingId]=[]),null===(n=i.hoardingQueue[e.trackingId])||void 0===n||n.push(a)):(i.requestQueue.push(a),i.initiateRequest(e.trackingId))},this.initiateRequest=function(e){var r=i.getHoardingQueue(e);if(n(n([],r,!0),i.requestQueue,!0).length>0&&i.requestingNum-1}));a&&r.removeItem(a)}},this.prevIds={},this.growingIO.emitter.on(je,(function(e){var n=e.trackingId,i=e.growingIO;t.transferStorage(n,i)}))},En=function(){var e=this;this.init=function(t){var n,i;e.emitter.emit("ON_SDK_INITIALIZE_BEFORE");try{if(J("Gio Web SDK 初始化中...","info"),t.trackingId&&P(e.dataStore.initializedTrackingIds,t.trackingId))throw Error("已存在实例 ".concat(t.trackingId,",请勿重复初始化!"));if(e.trackingId&&!e.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");var r=e.dataStore,o=r.currentPage,a=r.sendVerifiedVisit,s=r.sendVerifiedPage,u=e.dataStore.initTrackerOptions(t);return(!e.trackingId||u.trackingId===e.trackingId)&&(e.storage=Ae(e.vdsConfig),o.hookHistory(),e.gioSDKInitialized=!0,e.vdsConfig.gioSDKInitialized=!0),null===(n=e.emitter)||void 0===n||n.emit(je,{growingIO:e,trackingId:u.trackingId,vdsConfig:u}),o.parsePage(),e.vdsConfig.originalSource&&e.dataStore.setOriginalSource(u.trackingId),J("Gio Web SDK 初始化完成!".concat(e.useEmbeddedInherit?"小程序模式":e.useHybridInherit?"Hybrid模式":"Web模式"),"success"),e.vdsConfig.forceLogin&&J("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),e.useEmbeddedInherit!==u.trackingId&&a(u.trackingId),s(u.trackingId),null===(i=e.emitter)||void 0===i||i.emit(Fe,{growingIO:e,trackingId:u.trackingId}),!0}catch(e){return J(e,"error"),!1}},this.handlerDistribute=function(t,i,r){e.dataStore.getTrackerVds(t)?e[i].apply(e,n([t],r,!1)):(b(N(r))&&Q(N(r),!1),J("不存在实例:".concat(t,",请检查!"),"warn"))},this.registerPlugins=function(n,i){S(n)?(n.forEach((function(e,i){var r,o;j(e)||v(e)?J("插件不合法,跳过加载!","warn"):(null===(r=e.js)||void 0===r?void 0:r.default)&&(n[i]=t(t({},null===(o=e.js)||void 0===o?void 0:o.default),{options:e.options}))})),n=E(n),e.plugins.installAll(n)):J("插件注册失败,请检查!","error"),Q(i,e.plugins.pluginItems)},this.getPlugins=function(t){Q(t,e.plugins.pluginItems)},this.getDeviceId=function(t){Q(t,e.userStore.getUid())},this.setOption=function(t,n,i,r){var o,a;P(H(pe),n)?typeof i===(null===(o=fe[n])||void 0===o?void 0:o.type)?(e.dataStore.setOption(t,n,i),J("已修改".concat(pe[n],": ").concat(i),"info"),a=!0):(J("参数格式不正确:".concat(i,",请检查后重试!"),"error"),a=!1):(J("不存在可修改的配置项:".concat(n,",请检查后重试!"),"error"),a=!1),Q(r,a)},this.getOption=function(t,n,i){b(n)&&v(i)&&(i=n,n=void 0),Q(i,e.dataStore.getOption(t,n))},this.sendVisit=function(n,i,r){e.dataStore.buildVisitEvent(t(t({},i),{trackingId:n})),Q(r)},this.setPageListener=function(t,n){var i=e.dataStore.currentPage;if(b(n)){i.pageListeners[t]=n;var r=e.dataStore.currentPage,o=r.path,a=r.query,s=r.title;Q(n,{path:o,query:a,title:s})}},this.setPageAttributes=function(t,n,i){var r;if(w(n)&&!j(n))if(e.dataStore.getTrackerVds(t).trackPage)r=!1,J("仅在关闭trackPage时允许调用setPageAttributes,请确认后修改初始化配置项!","error");else{var o=e.dataStore.currentPage;j(o.pageProps[t])&&(o.pageProps[t]={}),j(o.pageProps[t][o.path])&&(o.pageProps[t][o.path]={}),j(n)||B(n,(function(e,n){b(o.pageProps[t][o.path][n])&&!b(e)||(o.pageProps[t][o.path][n]=e)})),r=!0}else r=!1,te("setPageAttributes");Q(i,r)},this.clearPageAttributes=function(t,n,i){var r=!0;try{if(!j(e.dataStore.currentPage.pageProps[t])){var o=e.dataStore.currentPage;S(n)&&!j(n)?n.forEach((function(e){G(o.pageProps[t][o.path],e)})):o.pageProps[t][o.path]={}}}catch(e){te("clearPageAttributes"),r=!1}Q(i,r)},this.sendPage=function(t,n,i){e.dataStore.getTrackerVds(t).trackPage?J("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):(e.dataStore.currentPage.buildPageEvent(t,n),Q(i))},this.identify=function(t,n,i){if(t===e.trackingId){if(e.vdsConfig.forceLogin){if(!ce(n))return void te("identify");var r=L(n).slice(0,1e3);e.userStore.setUid(r),e.dataStore.initializedTrackingIds.forEach((function(t){var n=e.uploader.getHoardingQueue(t);n.forEach((function(e,t){return n[t].deviceId=r})),t===e.trackingId&&e.vdsConfig.forceLogin&&e.dataStore.setOption(t,"forceLogin",!1),e.uploader.initiateRequest(t)}))}else te("identify",!1,"forceLogin未开启");Q(i)}else te("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=function(n,i,r){var o,a;if(w(i)&&!j(i)){var s=e.dataStore,u=s.eventContextBuilder,c=s.eventConverter,d=t({eventType:"LOGIN_USER_ATTRIBUTES"},u(n));d.attributes=oe(t(t({},null!==(o=d.attributes)&&void 0!==o?o:{}),ae(i))),c(d),a=!0}else te("setUserAttributes"),a=!1;Q(r,a)},this.setUserId=function(t,n,i,r){var o;if(ce(L(n).trim())){var a=e.userStore.getGioId(t),s=!v(i)&&L(i).length>0?L(i).slice(0,1e3):"";e.dataStore.getTrackerVds(t).idMapping?e.userStore.setUserKey(t,s):s&&J("您设置了 userKey ,请初始化开启 idMapping!","warn"),e.userStore.setUserId(t,L(n).slice(0,1e3)),a&&a!==e.userStore.getUserId(t)&&e.userStore.setSessionId(t,""),o=!0}else e.clearUserId(t),te("setUserId"),o=!1;Q(r,o)},this.clearUserId=function(t,n){e.userStore.setUserId(t,""),e.userStore.setUserKey(t,""),Q(n)},this.setGeneralProps=function(t,n,i){var r;w(n)&&!j(n)?(j(e.dataStore.generalProps[t])&&(e.dataStore.generalProps[t]={}),B(n,(function(n,i){b(e.dataStore.generalProps[t][i])&&!b(n)||(e.dataStore.generalProps[t][i]=n)})),r=!0):(te("setGeneralProps"),r=!1),Q(i,r)},this.clearGeneralProps=function(t,n,i){j(e.dataStore.generalProps[t])||(S(n)&&!j(n)?n.forEach((function(n){G(e.dataStore.generalProps[t],n)})):e.dataStore.generalProps[t]={}),Q(i)},this.track=function(n,i,r,o){de(i,(function(){var o,a=e.dataStore,s=a.eventContextBuilder,u=a.eventConverter,c=t({eventType:"CUSTOM",eventName:i},s(n));c.attributes=oe(t(t({},null!==(o=c.attributes)&&void 0!==o?o:{}),ae(t({},w(r)&&!j(r)?r:{})))),e.plugins.gioMultipleInstances&&r&&r["&&sendTo"]&&(c["&&sendTo"]=r["&&sendTo"]),u(c)})),Q(o)},this.trackTimerStart=function(t,n,i){var r;e.dataStore.getTrackerVds(t).dataCollect?de(n,(function(){r=z(),e.dataStore.trackTimers[t]||(e.dataStore.trackTimers[t]={}),e.dataStore.trackTimers[t][r]={eventName:n,leng:0,start:+Date.now()}})):J("指定实例未开启数据采集,请检查!","error"),Q(i,r)},this.trackTimerPause=function(t,n,i){var r=e.dataStore.trackTimers[t];if(n&&r&&r[n]){var o=r[n];o.start&&(o.leng=o.leng+(+Date.now()-o.start)),o.start=0}else J("未查询到指定计时器,请检查!","error");Q(i)},this.trackTimerResume=function(t,n,i){var r=e.dataStore.trackTimers[t];if(n&&r&&r[n]){var o=r[n];0===o.start&&(o.start=+Date.now())}else J("未查询到指定计时器,请检查!","error");Q(i)},this.trackTimerEnd=function(n,i,r,o){var a,s,u=e.dataStore.getTrackerVds(n).dataCollect,c=e.dataStore.trackTimers[n];if(i&&c&&c[i]){if(u){var d=c[i];if(0!==d.start){var g=+Date.now()-d.start;d.leng=g>0?d.leng+g:0}var l=e.dataStore,f=l.eventContextBuilder,v=l.eventConverter,h=t({eventType:"CUSTOM",eventName:d.eventName},f(n));h.attributes=oe(t(t(t({},null!==(a=h.attributes)&&void 0!==a?a:{}),ae(t({},w(r)&&!j(r)?r:{}))),{event_duration:d.leng>864e5?0:d.leng/1e3})),e.plugins.gioMultipleInstances&&r&&r["&&sendTo"]&&(h["&&sendTo"]=r["&&sendTo"]),v(h),s=!0}else J("指定实例未开启数据采集,计时器已移除,请检查!","error"),s=!1;e.removeTimer(n,i)}else J("未查询到指定计时器,请检查!","error"),s=!1;Q(o,s)},this.removeTimer=function(t,n,i){var r=e.dataStore.trackTimers[t];n&&r&&r[n]?delete r[n]:J("未查询到指定计时器,请检查!","error"),Q(i)},this.clearTrackTimer=function(t,n){e.dataStore.trackTimers[t]={},Q(n)},this.updateImpression=function(t){var n,i,r=null===(i=null===(n=e.plugins)||void 0===n?void 0:n.gioImpressionTracking)||void 0===i?void 0:i.main;r?r("manual"):J("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error"),Q(t)},this.getABTest=function(e,t,n){J("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),Q(n,{})},this.setBeforeSendListener=function(t,n,i){b(n)?(e.dataStore.beforeSendListener[t]=n,Q(i)):Q(i,!1)},this.sdkVersion="4.2.2",this.vdsName=window._gio_local_vds||"vds",this.utils=t(t({},W),ue),this.emitter=function(e){return{all:e=e||new Map,on:function(t,n){var i=e.get(t);i?i.push(n):e.set(t,[n])},off:function(t,n){var i=e.get(t);i&&(n?i.splice(i.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var i=e.get(t);i&&i.slice().map((function(e){e(n)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,n)}))}}}(),this.useEmbeddedInherit="",this.useHybridInherit="",this.gioSDKInitialized=!1,this.plugins=new On(this),this.plugins.innerPluginInit(),this.dataStore=new Qe(this),this.userStore=new kn(this),this.uploader=new _n(this)},Tn=window._gio_local_vds||"vds",Cn=null!==(gt=null===(dt=window[Tn])||void 0===dt?void 0:dt.namespace)&&void 0!==gt?gt:"gdp";return function(){var e,i,r,o,a;if(null===(e=window[Tn])||void 0===e?void 0:e.gioSDKInstalled)return lt=window[Cn],void J("SDK重复加载,请检查是否重复加载SDK或接入其他平台SDK导致冲突!","warn");window[Tn]=t(t({},null!==(i=window[Tn])&&void 0!==i?i:{}),{gioSDKInstalled:!0});var s=new En,u=function(e){return P(he,e)&&!!s[e]};lt=function(){var e,i,r=arguments[0],o="g0",a=r;if(r.indexOf(".")>-1&&(o=null!==(e=r.split(".")[0])&&void 0!==e?e:"g0",a=r.split(".")[1]),h(a)&&P(he,a)&&s[a]){var c=k(x(arguments));if("init"===a){var d=function(e,t){if(P(["","localhost","127.0.0.1"],location.hostname)&&!window._gr_ignore_local_rule)return J("当前SDK不允许在本地环境初始化!","error"),!1;var n=L(t[0]),i=L(t[1]),r=(4===t.length?t[3]:t[2])||{};return n&&i?e.dataStore.initializedTrackingIds.some((function(t,r){var o=0===r?e.vdsConfig:e.subInstance[t];return o.projectId===n&&o.dataSourceId===i}))?(J("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:n,dataSourceId:i,appId:r.appId||L(4===t.length?t[2]:""),userOptions:r}:(J('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)}(s,c);if(d){var g=d.projectId,l=d.dataSourceId,f=d.appId,v=d.userOptions;return s.init(t(t({},v),{projectId:g,dataSourceId:l,appId:f||v.appId,trackingId:o}))}return!1}"registerPlugins"===a?s.registerPlugins.apply(s,c):P(["setGeneralProps","clearGeneralProps"],a)?s[a].apply(s,n([o],c,!1)):s.gioSDKInitialized&&s.vdsConfig?P(ve,a)?X((function(){return s.handlerDistribute(o,a,c)})):X((function(){return s[a].apply(s,c)})):(s.emitter.emit("UN_EXECUTE_CALL",arguments),J("SDK未初始化!","error"))}else if(P(me,a))J("方法 ".concat(L(a)," 已被弃用,请移除!"),"warn");else{if("canIUse"===a)return u(arguments[1]);J("不存在名为 ".concat(L(a)," 的方法调用!"),"error")}window[Tn]=t(t({},window[Tn]),{_gr_ignore_local_rule:null!==(i=window._gr_ignore_local_rule)&&void 0!==i&&i,gioSDKVersion:s.sdkVersion,gioSDKFull:s.gioSDKFull,canIUse:u})};var c=null===(r=window[Cn])||void 0===r?void 0:r.q,d=null===(o=window[Cn])||void 0===o?void 0:o.e,g=null===(a=window[Cn])||void 0===a?void 0:a.ef;window[Cn]=lt,window[Cn].e=d,window[Cn].ef=g,window.gdp=lt,window.gdp.e=d,window.gdp.ef=g,S(c)&&!j(c)&&x(Array(c.length)).forEach((function(){lt.apply(null,c.shift())}))}(),lt})); \ No newline at end of file diff --git a/SwiftPM-Wrap/GrowingPrivacy-Wrapper/Resources/GrowingAnalytics.bundle b/SwiftPM-Wrap/GrowingBundle-Wrapper/Resources/GrowingAnalytics.bundle similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-Wrapper/Resources/GrowingAnalytics.bundle rename to SwiftPM-Wrap/GrowingBundle-Wrapper/Resources/GrowingAnalytics.bundle diff --git a/SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/dummy.m b/SwiftPM-Wrap/GrowingBundle-Wrapper/dummy.m similarity index 84% rename from SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/dummy.m rename to SwiftPM-Wrap/GrowingBundle-Wrapper/dummy.m index 91876c9a7..97678a292 100644 --- a/SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/dummy.m +++ b/SwiftPM-Wrap/GrowingBundle-Wrapper/dummy.m @@ -16,3 +16,9 @@ // 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 + +NSBundle* GrowingBundleWrapper_SWIFTPM_MODULE_BUNDLE() { + return SWIFTPM_MODULE_BUNDLE; +} diff --git a/SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/include/dummy.h b/SwiftPM-Wrap/GrowingBundle-Wrapper/include/dummy.h similarity index 88% rename from SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/include/dummy.h rename to SwiftPM-Wrap/GrowingBundle-Wrapper/include/dummy.h index 385700820..b4570223b 100644 --- a/SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/include/dummy.h +++ b/SwiftPM-Wrap/GrowingBundle-Wrapper/include/dummy.h @@ -18,3 +18,7 @@ // limitations under the License. // Prevent a missing umbrella header warning. + +#import + +NSBundle* GrowingBundleWrapper_SWIFTPM_MODULE_BUNDLE(void); diff --git a/SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/Resources/GrowingAnalytics.bundle b/SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/Resources/GrowingAnalytics.bundle similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-macOS-Wrapper/Resources/GrowingAnalytics.bundle rename to SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/Resources/GrowingAnalytics.bundle diff --git a/SwiftPM-Wrap/GrowingPrivacy-Wrapper/dummy.m b/SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/dummy.m similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-Wrapper/dummy.m rename to SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/dummy.m diff --git a/SwiftPM-Wrap/GrowingPrivacy-Wrapper/include/dummy.h b/SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/include/dummy.h similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-Wrapper/include/dummy.h rename to SwiftPM-Wrap/GrowingBundle-macOS-Wrapper/include/dummy.h diff --git a/SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/Resources/GrowingAnalytics.bundle b/SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/Resources/GrowingAnalytics.bundle similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/Resources/GrowingAnalytics.bundle rename to SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/Resources/GrowingAnalytics.bundle diff --git a/SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/dummy.m b/SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/dummy.m similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/dummy.m rename to SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/dummy.m diff --git a/SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/include/dummy.h b/SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/include/dummy.h similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-tvOS-Wrapper/include/dummy.h rename to SwiftPM-Wrap/GrowingBundle-tvOS-Wrapper/include/dummy.h diff --git a/SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/Resources/GrowingAnalytics.bundle b/SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/Resources/GrowingAnalytics.bundle similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/Resources/GrowingAnalytics.bundle rename to SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/Resources/GrowingAnalytics.bundle diff --git a/SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/dummy.m b/SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/dummy.m similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/dummy.m rename to SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/dummy.m diff --git a/SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/include/dummy.h b/SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/include/dummy.h similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-visionOS-Wrapper/include/dummy.h rename to SwiftPM-Wrap/GrowingBundle-visionOS-Wrapper/include/dummy.h diff --git a/SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/Resources/GrowingAnalytics.bundle b/SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/Resources/GrowingAnalytics.bundle similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/Resources/GrowingAnalytics.bundle rename to SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/Resources/GrowingAnalytics.bundle diff --git a/SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/dummy.m b/SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/dummy.m similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/dummy.m rename to SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/dummy.m diff --git a/SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/include/dummy.h b/SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/include/dummy.h similarity index 100% rename from SwiftPM-Wrap/GrowingPrivacy-watchOS-Wrapper/include/dummy.h rename to SwiftPM-Wrap/GrowingBundle-watchOS-Wrapper/include/dummy.h