@metarouter/react-native-sdk 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -22
- package/lib/MetaRouter.d.ts +2 -24
- package/lib/MetaRouter.d.ts.map +1 -1
- package/lib/MetaRouter.js +5 -52
- package/lib/analytics/IdentityManager.d.ts +14 -0
- package/lib/analytics/IdentityManager.d.ts.map +1 -0
- package/lib/analytics/IdentityManager.js +38 -0
- package/lib/analytics/MetaRouterAnalyticsClient.d.ts +45 -0
- package/lib/analytics/MetaRouterAnalyticsClient.d.ts.map +1 -0
- package/lib/analytics/MetaRouterAnalyticsClient.js +127 -0
- package/lib/analytics/enrichEvent.d.ts +3 -0
- package/lib/analytics/enrichEvent.d.ts.map +1 -0
- package/lib/analytics/enrichEvent.js +14 -0
- package/lib/analytics/init.d.ts +5 -0
- package/lib/analytics/init.d.ts.map +1 -0
- package/lib/analytics/init.js +32 -0
- package/lib/analytics/proxy/proxyClient.d.ts +4 -0
- package/lib/analytics/proxy/proxyClient.d.ts.map +1 -0
- package/lib/{proxyClient.js → analytics/proxy/proxyClient.js} +3 -4
- package/lib/analytics/types.d.ts +52 -0
- package/lib/analytics/types.d.ts.map +1 -0
- package/lib/analytics/types.js +1 -0
- package/lib/analytics/utils/anonymousId.d.ts +2 -0
- package/lib/analytics/utils/anonymousId.d.ts.map +1 -0
- package/lib/analytics/utils/anonymousId.js +11 -0
- package/lib/analytics/utils/contextInfo.d.ts +19 -0
- package/lib/analytics/utils/contextInfo.d.ts.map +1 -0
- package/lib/analytics/utils/contextInfo.js +35 -0
- package/lib/analytics/utils/logger.d.ts +4 -0
- package/lib/analytics/utils/logger.d.ts.map +1 -0
- package/lib/analytics/utils/logger.js +12 -0
- package/lib/analytics/utils/retry.d.ts +2 -0
- package/lib/analytics/utils/retry.d.ts.map +1 -0
- package/lib/analytics/utils/retry.js +17 -0
- package/lib/analytics/utils/timezone.d.ts +2 -0
- package/lib/analytics/utils/timezone.d.ts.map +1 -0
- package/lib/analytics/utils/timezone.js +8 -0
- package/lib/index.d.ts +6 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -2
- package/lib/react/context.d.ts +9 -0
- package/lib/react/context.d.ts.map +1 -0
- package/lib/react/context.js +12 -0
- package/lib/react/useMetaRouter.d.ts +3 -0
- package/lib/react/useMetaRouter.d.ts.map +1 -0
- package/lib/react/useMetaRouter.js +8 -0
- package/lib/types.d.ts +9 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/package.json +11 -12
- package/MetaRouterReactNativeSDK.podspec +0 -28
- package/android/build/generated/ksp/debug/java/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl.java +0 -244
- package/android/build/generated/ksp/debug/java/com/reactnativecommunity/asyncstorage/next/StorageDb_Impl.java +0 -165
- package/android/build/generated/source/buildConfig/debug/com/metarouter/reactnativesdk/BuildConfig.java +0 -10
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -7
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/metarouter/reactnativesdk/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/metarouter/reactnativesdk/MetaRouterReactNativeSDKPackage.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageErrorUtil.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageExpoMigration.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$3.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$4.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$5.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule$6.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStorageModule.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStoragePackage$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/NativeAsyncStorageModuleSpec.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/ReactDatabaseSupplier.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/SerialExecutor$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/SerialExecutor.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$2.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$3.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$4.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$5.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$6.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl$7.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDao_Impl.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDb_Impl$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativecommunity/asyncstorage/next/StorageDb_Impl.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/linusu/RNGetRandomValuesModule.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/org/linusu/RNGetRandomValuesPackage.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -7
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -7
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/java-sources-proto-map.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -16
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/META-INF/metarouter_react-native-sdk_debug.kotlin_module +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/ArgumentHelpersKt.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/AsyncStorageAccess.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/AsyncStorageError$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/AsyncStorageError.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/Entry.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/ErrorHelpersKt$createExceptionHandler$$inlined$CoroutineExceptionHandler$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/ErrorHelpersKt.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/MIGRATION_TO_NEXT.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageDao$DefaultImpls.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageDao$mergeValues$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageDao.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageDb$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageDb.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$clear$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$getAllKeys$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$multiGet$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$multiMerge$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$multiRemove$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule$multiSet$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageSupplier$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageSupplier.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/reactnativecommunity/asyncstorage/next/StorageSupplierKt.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/AnalyticsReactNativeModule$onInitialized$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/AnalyticsReactNativeModule$toHexString$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/AnalyticsReactNativePackage$createNativeModules$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/AnalyticsReactNativePackage.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/segmentanalyticsreactnative/ConnectionType.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/Sovran$Action.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/Sovran$createNativeModules$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/Sovran.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/SovranModule$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/SovranModule$onInitialized$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/sovranreactnative/SovranModule.class +0 -0
- package/android/build.gradle +0 -55
- package/android/consumer-rules.pro +0 -0
- package/android/src/main/java/com/metarouter/reactnativesdk/MetaRouterReactNativeSDKPackage.java +0 -54
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.java +0 -178
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageErrorUtil.java +0 -45
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageExpoMigration.java +0 -154
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java +0 -410
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java +0 -93
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/BuildConfig.java +0 -8
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/NativeAsyncStorageModuleSpec.java +0 -47
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/ReactDatabaseSupplier.java +0 -163
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/SerialExecutor.java +0 -40
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/build.gradle +0 -122
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/config.gradle +0 -125
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpers.kt +0 -86
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ErrorHelpers.kt +0 -39
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageModule.kt +0 -94
- package/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageSupplier.kt +0 -161
- package/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt +0 -267
- package/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativePackage.kt +0 -43
- package/android/src/main/java/com/sovranreactnative/Sovran.kt +0 -45
- package/android/src/main/java/com/sovranreactnative/SovranModule.kt +0 -55
- package/android/src/main/java/org/linusu/RNGetRandomValuesModule.java +0 -36
- package/android/src/main/java/org/linusu/RNGetRandomValuesPackage.java +0 -28
- package/lib/MetaRouterPlugin.d.ts +0 -10
- package/lib/MetaRouterPlugin.d.ts.map +0 -1
- package/lib/MetaRouterPlugin.js +0 -23
- package/lib/context.d.ts +0 -8
- package/lib/context.d.ts.map +0 -1
- package/lib/context.js +0 -9
- package/lib/createMetaRouterClient.d.ts +0 -3
- package/lib/createMetaRouterClient.d.ts.map +0 -1
- package/lib/createMetaRouterClient.js +0 -7
- package/lib/proxyClient.d.ts +0 -4
- package/lib/proxyClient.d.ts.map +0 -1
- package/react-native.config.js +0 -37
package/README.md
CHANGED
|
@@ -16,10 +16,10 @@ npm install @metarouter/react-native-sdk
|
|
|
16
16
|
### Basic Setup
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
|
-
import
|
|
19
|
+
import MetaRouter from "@metarouter/react-native-sdk";
|
|
20
20
|
|
|
21
21
|
// Initialize the analytics client
|
|
22
|
-
const analytics =
|
|
22
|
+
const analytics = await MetaRouter.analytics.init({
|
|
23
23
|
writeKey: "your-write-key",
|
|
24
24
|
ingestionEndpoint: "https://your-ingestion-endpoint.com/events",
|
|
25
25
|
debug: true, // Optional: enable debug mode
|
|
@@ -30,21 +30,38 @@ const analytics = createMetaRouterClient({
|
|
|
30
30
|
### React Context Usage
|
|
31
31
|
|
|
32
32
|
```jsx
|
|
33
|
-
import React from "react";
|
|
34
|
-
import {
|
|
35
|
-
createMetaRouterClient,
|
|
33
|
+
import React, { useEffect, useState } from "react";
|
|
34
|
+
import MetaRouter, {
|
|
36
35
|
MetaRouterProvider,
|
|
37
36
|
useMetaRouter,
|
|
38
37
|
} from "@metarouter/react-native-sdk";
|
|
39
38
|
|
|
40
39
|
const App = () => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const [metaRouterInstance, setMetaRouterInstance] = useState(null);
|
|
41
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const initializeAnalytics = async () => {
|
|
45
|
+
try {
|
|
46
|
+
// Initialize the analytics client
|
|
47
|
+
await MetaRouter.analytics.init({
|
|
48
|
+
writeKey: "your-write-key",
|
|
49
|
+
ingestionEndpoint: "https://your-ingestion-endpoint.com",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
setMetaRouterInstance(MetaRouter);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error("Failed to initialize analytics:", error);
|
|
55
|
+
} finally {
|
|
56
|
+
setIsLoading(false);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
initializeAnalytics();
|
|
61
|
+
}, []);
|
|
45
62
|
|
|
46
63
|
return (
|
|
47
|
-
<MetaRouterProvider
|
|
64
|
+
<MetaRouterProvider instance={metaRouterInstance}>
|
|
48
65
|
<YourApp />
|
|
49
66
|
</MetaRouterProvider>
|
|
50
67
|
);
|
|
@@ -52,7 +69,8 @@ const App = () => {
|
|
|
52
69
|
|
|
53
70
|
// Use analytics in any component
|
|
54
71
|
const MyComponent = () => {
|
|
55
|
-
const
|
|
72
|
+
const metaRouter = useMetaRouter();
|
|
73
|
+
const analytics = metaRouter.analytics.getClient();
|
|
56
74
|
|
|
57
75
|
const handleButtonPress = () => {
|
|
58
76
|
analytics.track("Button Pressed", {
|
|
@@ -68,10 +86,10 @@ const MyComponent = () => {
|
|
|
68
86
|
### Direct Usage
|
|
69
87
|
|
|
70
88
|
```js
|
|
71
|
-
import
|
|
89
|
+
import MetaRouter from "@metarouter/react-native-sdk";
|
|
72
90
|
|
|
73
91
|
// Initialize
|
|
74
|
-
const analytics =
|
|
92
|
+
const analytics = await MetaRouter.analytics.init({
|
|
75
93
|
writeKey: "your-write-key",
|
|
76
94
|
ingestionEndpoint: "https://your-ingestion-endpoint.com/events",
|
|
77
95
|
});
|
|
@@ -104,23 +122,31 @@ analytics.flush();
|
|
|
104
122
|
|
|
105
123
|
// Cleanup when done
|
|
106
124
|
analytics.cleanup();
|
|
125
|
+
|
|
126
|
+
// Reset analytics (useful for testing or logout)
|
|
127
|
+
await MetaRouter.analytics.reset();
|
|
107
128
|
```
|
|
108
129
|
|
|
109
130
|
## API Reference
|
|
110
131
|
|
|
111
|
-
###
|
|
132
|
+
### MetaRouter.analytics.init(options)
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
Initializes the analytics client and returns a promise that resolves to the client instance.
|
|
114
135
|
|
|
115
136
|
**Options:**
|
|
116
137
|
|
|
117
138
|
- `writeKey` (string, required): Your write key
|
|
118
139
|
- `ingestionEndpoint` (string, required): Your custom ingestion endpoint URL
|
|
119
140
|
- `debug` (boolean, optional): Enable debug mode
|
|
120
|
-
- `flushAt` (number, optional): Number of events to batch before sending
|
|
121
141
|
- `flushInterval` (number, optional): Interval in seconds to flush events
|
|
122
|
-
|
|
123
|
-
|
|
142
|
+
|
|
143
|
+
### MetaRouter.analytics.getClient()
|
|
144
|
+
|
|
145
|
+
Returns the current analytics client instance. Must be called after initialization.
|
|
146
|
+
|
|
147
|
+
### MetaRouter.analytics.reset()
|
|
148
|
+
|
|
149
|
+
Resets the analytics client and clears all stored data. Returns a promise.
|
|
124
150
|
|
|
125
151
|
### Analytics Interface
|
|
126
152
|
|
|
@@ -136,19 +162,20 @@ The analytics client provides the following methods:
|
|
|
136
162
|
|
|
137
163
|
### React Hooks
|
|
138
164
|
|
|
139
|
-
- `useMetaRouter()`: Hook to access the
|
|
165
|
+
- `useMetaRouter()`: Hook to access the MetaRouter instance within a `MetaRouterProvider`
|
|
140
166
|
|
|
141
167
|
### Components
|
|
142
168
|
|
|
143
|
-
- `MetaRouterProvider`: React context provider for
|
|
169
|
+
- `MetaRouterProvider`: React context provider for MetaRouter instance
|
|
144
170
|
|
|
145
171
|
## Features
|
|
146
172
|
|
|
147
173
|
- 🎯 **Custom Endpoints**: Send events to your own ingestion endpoints
|
|
148
|
-
- 📱 **React Native Optimized**: Built
|
|
174
|
+
- 📱 **React Native Optimized**: Built specifically for React Native
|
|
149
175
|
- 🎣 **React Hooks**: Easy integration with React components
|
|
150
176
|
- 🔧 **TypeScript Support**: Full TypeScript support included
|
|
151
177
|
- 🚀 **Lightweight**: Minimal overhead and dependencies
|
|
178
|
+
- 🔄 **Reset Capability**: Easily reset analytics state for testing or logout scenarios
|
|
152
179
|
|
|
153
180
|
## License
|
|
154
181
|
|
|
@@ -160,4 +187,4 @@ MIT
|
|
|
160
187
|
|
|
161
188
|
This library includes code from the following third-party packages:
|
|
162
189
|
|
|
163
|
-
- [
|
|
190
|
+
- [uuid](https://github.com/uuidjs/uuid), MIT License
|
package/lib/MetaRouter.d.ts
CHANGED
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
ingestionEndpoint: string;
|
|
4
|
-
debug?: boolean;
|
|
5
|
-
flushAt?: number;
|
|
6
|
-
flushInterval?: number;
|
|
7
|
-
trackLifecycleEvents?: boolean;
|
|
8
|
-
maxBatchSize?: number;
|
|
9
|
-
}
|
|
10
|
-
export type AnalyticsInterface = {
|
|
11
|
-
track: (event: string, props?: Record<string, any>) => void;
|
|
12
|
-
identify: (userId: string, traits?: Record<string, any>) => void;
|
|
13
|
-
group: (groupId: string, traits?: Record<string, any>) => void;
|
|
14
|
-
screen: (name: string, props?: Record<string, any>) => void;
|
|
15
|
-
alias: (newUserId: string) => void;
|
|
16
|
-
flush: () => void;
|
|
17
|
-
cleanup: () => void;
|
|
18
|
-
};
|
|
19
|
-
export declare const MetaRouter: {
|
|
20
|
-
init: (options: InitOptions) => Promise<AnalyticsInterface>;
|
|
21
|
-
getClient(): AnalyticsInterface;
|
|
22
|
-
create(opts: InitOptions): AnalyticsInterface;
|
|
23
|
-
reset: () => Promise<void>;
|
|
24
|
-
};
|
|
1
|
+
import type { MetaRouterInterface } from './types';
|
|
2
|
+
export declare const MetaRouter: MetaRouterInterface;
|
|
25
3
|
//# sourceMappingURL=MetaRouter.d.ts.map
|
package/lib/MetaRouter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaRouter.d.ts","sourceRoot":"","sources":["../src/MetaRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetaRouter.d.ts","sourceRoot":"","sources":["../src/MetaRouter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,UAAU,EAAE,mBAMxB,CAAC"}
|
package/lib/MetaRouter.js
CHANGED
|
@@ -1,55 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MetaRouterPlugin } from './MetaRouterPlugin';
|
|
3
|
-
import { proxyClient, setRealClient } from './proxyClient';
|
|
4
|
-
let analytics = null;
|
|
5
|
-
let analyticsInterface = null;
|
|
6
|
-
let initialized = false;
|
|
1
|
+
import { initAnalytics, getAnalyticsClient, resetAnalytics } from './analytics/init';
|
|
7
2
|
export const MetaRouter = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!options.writeKey)
|
|
13
|
-
throw new Error('writeKey is required');
|
|
14
|
-
if (!options.ingestionEndpoint)
|
|
15
|
-
throw new Error('ingestionEndpoint is required');
|
|
16
|
-
const config = {
|
|
17
|
-
writeKey: options.writeKey,
|
|
18
|
-
debug: options.debug,
|
|
19
|
-
flushInterval: options.flushInterval,
|
|
20
|
-
useSegmentEndpoints: false,
|
|
21
|
-
trackAppLifecycleEvents: (_a = options.trackLifecycleEvents) !== null && _a !== void 0 ? _a : true,
|
|
22
|
-
autoAddSegmentDestination: false,
|
|
23
|
-
};
|
|
24
|
-
analytics = createClient(config);
|
|
25
|
-
analytics.add({ plugin: new MetaRouterPlugin(options.ingestionEndpoint, options.writeKey) });
|
|
26
|
-
await analytics.init();
|
|
27
|
-
analyticsInterface = {
|
|
28
|
-
track: (event, props) => analytics.track(event, props),
|
|
29
|
-
identify: (userId, traits) => analytics.identify(userId, traits),
|
|
30
|
-
group: (groupId, traits) => analytics.group(groupId, traits),
|
|
31
|
-
screen: (name, props) => analytics.screen(name, props),
|
|
32
|
-
alias: (newUserId) => analytics.alias(newUserId),
|
|
33
|
-
flush: () => analytics.flush(),
|
|
34
|
-
cleanup: () => analytics.cleanup(),
|
|
35
|
-
};
|
|
36
|
-
initialized = true;
|
|
37
|
-
// Hand off to proxy
|
|
38
|
-
setRealClient(analyticsInterface);
|
|
39
|
-
return analyticsInterface;
|
|
40
|
-
},
|
|
41
|
-
getClient() {
|
|
42
|
-
return initialized ? analyticsInterface : proxyClient;
|
|
43
|
-
},
|
|
44
|
-
create(opts) {
|
|
45
|
-
void this.init(opts).catch(console.error);
|
|
46
|
-
return this.getClient();
|
|
47
|
-
},
|
|
48
|
-
reset: async () => {
|
|
49
|
-
await (analytics === null || analytics === void 0 ? void 0 : analytics.cleanup());
|
|
50
|
-
analytics = null;
|
|
51
|
-
analyticsInterface = null;
|
|
52
|
-
initialized = false;
|
|
53
|
-
setRealClient(null);
|
|
3
|
+
analytics: {
|
|
4
|
+
init: (opts) => initAnalytics(opts),
|
|
5
|
+
getClient: () => getAnalyticsClient(),
|
|
6
|
+
reset: () => resetAnalytics(),
|
|
54
7
|
},
|
|
55
8
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class IdentityManager {
|
|
2
|
+
private anonymousId;
|
|
3
|
+
private userId?;
|
|
4
|
+
private groupId?;
|
|
5
|
+
init(): Promise<void>;
|
|
6
|
+
getAnonymousId(): string | null;
|
|
7
|
+
identify(userId: string): void;
|
|
8
|
+
group(groupId: string): void;
|
|
9
|
+
getUserId(): string | undefined;
|
|
10
|
+
getGroupId(): string | undefined;
|
|
11
|
+
addIdentityInfo<T extends Record<string, any>>(event: T): T;
|
|
12
|
+
reset(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=IdentityManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdentityManager.d.ts","sourceRoot":"","sources":["../../src/analytics/IdentityManager.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;IACxB,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,OAAO,CAAC,CAAS;IAGnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IAKvB,KAAK,CAAC,OAAO,EAAE,MAAM;IAIrB,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B,UAAU,IAAI,MAAM,GAAG,SAAS;IAIhC,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;IAS3D,KAAK;CAKN"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getAnonymousId } from "./utils/anonymousId";
|
|
2
|
+
export class IdentityManager {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.anonymousId = null;
|
|
5
|
+
}
|
|
6
|
+
async init() {
|
|
7
|
+
this.anonymousId = await getAnonymousId(); // load or generate
|
|
8
|
+
}
|
|
9
|
+
getAnonymousId() {
|
|
10
|
+
return this.anonymousId;
|
|
11
|
+
}
|
|
12
|
+
identify(userId) {
|
|
13
|
+
this.userId = userId;
|
|
14
|
+
}
|
|
15
|
+
group(groupId) {
|
|
16
|
+
this.groupId = groupId;
|
|
17
|
+
}
|
|
18
|
+
getUserId() {
|
|
19
|
+
return this.userId;
|
|
20
|
+
}
|
|
21
|
+
getGroupId() {
|
|
22
|
+
return this.groupId;
|
|
23
|
+
}
|
|
24
|
+
addIdentityInfo(event) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return {
|
|
27
|
+
...event,
|
|
28
|
+
anonymousId: this.anonymousId,
|
|
29
|
+
userId: (_a = event.userId) !== null && _a !== void 0 ? _a : this.userId,
|
|
30
|
+
groupId: (_b = event.groupId) !== null && _b !== void 0 ? _b : this.groupId,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
reset() {
|
|
34
|
+
this.anonymousId = null;
|
|
35
|
+
this.userId = undefined;
|
|
36
|
+
this.groupId = undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { InitOptions } from "./types";
|
|
2
|
+
export declare class MetaRouterAnalyticsClient {
|
|
3
|
+
private initialized;
|
|
4
|
+
private queue;
|
|
5
|
+
private flushIntervalMs;
|
|
6
|
+
private flushTimer;
|
|
7
|
+
private endpoint;
|
|
8
|
+
private writeKey;
|
|
9
|
+
private appState;
|
|
10
|
+
private appStateSubscription;
|
|
11
|
+
private identityManager;
|
|
12
|
+
constructor(options: InitOptions);
|
|
13
|
+
private init;
|
|
14
|
+
private startFlushLoop;
|
|
15
|
+
private now;
|
|
16
|
+
private enqueue;
|
|
17
|
+
private setupAppStateListener;
|
|
18
|
+
private handleAppStateChange;
|
|
19
|
+
track(event: string, properties?: Record<string, any>): void;
|
|
20
|
+
identify(userId: string, traits?: Record<string, any>): void;
|
|
21
|
+
page(name: string, properties?: Record<string, any>): void;
|
|
22
|
+
group(groupId: string, traits?: Record<string, any>): void;
|
|
23
|
+
screen(name: string, properties?: Record<string, any>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Alias an anonymous user to a known user ID.
|
|
26
|
+
* This updates internal identity state and enqueues an alias event.
|
|
27
|
+
*/
|
|
28
|
+
alias(newUserId: string): void;
|
|
29
|
+
flush(): Promise<{
|
|
30
|
+
anonymousId: string;
|
|
31
|
+
writeKey: string;
|
|
32
|
+
messageId: string;
|
|
33
|
+
sentAt: string;
|
|
34
|
+
type: import("./types").EventType;
|
|
35
|
+
event?: string;
|
|
36
|
+
userId?: string;
|
|
37
|
+
groupId?: string;
|
|
38
|
+
traits?: Record<string, any>;
|
|
39
|
+
properties?: Record<string, any>;
|
|
40
|
+
timestamp?: string;
|
|
41
|
+
}[] | undefined>;
|
|
42
|
+
reset(): void;
|
|
43
|
+
cleanup(): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=MetaRouterAnalyticsClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetaRouterAnalyticsClient.d.ts","sourceRoot":"","sources":["../../src/analytics/MetaRouterAnalyticsClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,MAAM,SAAS,CAAC;AAOlD,qBAAa,yBAAyB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,oBAAoB,CAAwC;IACpE,OAAO,CAAC,eAAe,CAAkB;gBAE7B,OAAO,EAAE,WAAW;YAYlB,IAAI;IASlB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,oBAAoB,CAK1B;IAGF,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIrD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKrD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAInD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAKnD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIrD;;;MAGE;IAEF,KAAK,CAAC,SAAS,EAAE,MAAM;IAKjB,KAAK;;;;;;;;;;;;;IAyCX,KAAK;IAML,OAAO;CAQR"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { AppState } from 'react-native';
|
|
2
|
+
import { retryWithBackoff } from "./utils/retry";
|
|
3
|
+
import { log, setDebugLogging, warn } from "./utils/logger";
|
|
4
|
+
import { IdentityManager } from "./IdentityManager";
|
|
5
|
+
export class MetaRouterAnalyticsClient {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
var _a;
|
|
8
|
+
this.initialized = false;
|
|
9
|
+
this.queue = [];
|
|
10
|
+
this.flushIntervalMs = 10000;
|
|
11
|
+
this.flushTimer = null;
|
|
12
|
+
this.appState = AppState.currentState;
|
|
13
|
+
this.appStateSubscription = null;
|
|
14
|
+
this.handleAppStateChange = (nextState) => {
|
|
15
|
+
if (this.appState === 'active' && nextState.match(/inactive|background/)) {
|
|
16
|
+
this.flush();
|
|
17
|
+
}
|
|
18
|
+
this.appState = nextState;
|
|
19
|
+
};
|
|
20
|
+
log('Initializing analytics client', options);
|
|
21
|
+
const { writeKey, ingestionEndpoint, flushInterval } = options;
|
|
22
|
+
this.endpoint = ingestionEndpoint;
|
|
23
|
+
this.writeKey = writeKey;
|
|
24
|
+
this.flushIntervalMs = flushInterval !== null && flushInterval !== void 0 ? flushInterval : 10000;
|
|
25
|
+
setDebugLogging((_a = options.debug) !== null && _a !== void 0 ? _a : false);
|
|
26
|
+
this.identityManager = new IdentityManager();
|
|
27
|
+
this.init();
|
|
28
|
+
}
|
|
29
|
+
async init() {
|
|
30
|
+
if (this.initialized)
|
|
31
|
+
return;
|
|
32
|
+
await this.identityManager.init();
|
|
33
|
+
this.startFlushLoop();
|
|
34
|
+
this.setupAppStateListener();
|
|
35
|
+
this.initialized = true;
|
|
36
|
+
log('Analytics client initialized');
|
|
37
|
+
}
|
|
38
|
+
startFlushLoop() {
|
|
39
|
+
this.flushTimer = setInterval(() => this.flush(), this.flushIntervalMs);
|
|
40
|
+
}
|
|
41
|
+
now() {
|
|
42
|
+
return new Date().toISOString();
|
|
43
|
+
}
|
|
44
|
+
enqueue(event) {
|
|
45
|
+
const eventWithIdentity = this.identityManager.addIdentityInfo(event);
|
|
46
|
+
log('Enqueuing event', eventWithIdentity);
|
|
47
|
+
this.queue.push(eventWithIdentity);
|
|
48
|
+
}
|
|
49
|
+
setupAppStateListener() {
|
|
50
|
+
this.appStateSubscription = AppState.addEventListener('change', this.handleAppStateChange);
|
|
51
|
+
}
|
|
52
|
+
track(event, properties) {
|
|
53
|
+
this.enqueue({ type: 'track', event, properties, timestamp: this.now() });
|
|
54
|
+
}
|
|
55
|
+
identify(userId, traits) {
|
|
56
|
+
this.identityManager.identify(userId);
|
|
57
|
+
this.enqueue({ type: 'identify', userId, traits, timestamp: this.now() });
|
|
58
|
+
}
|
|
59
|
+
page(name, properties) {
|
|
60
|
+
this.enqueue({ type: 'page', event: name, properties, timestamp: this.now() });
|
|
61
|
+
}
|
|
62
|
+
group(groupId, traits) {
|
|
63
|
+
this.identityManager.group(groupId);
|
|
64
|
+
this.enqueue({ type: 'group', groupId, traits, timestamp: this.now() });
|
|
65
|
+
}
|
|
66
|
+
screen(name, properties) {
|
|
67
|
+
this.enqueue({ type: 'screen', event: name, properties, timestamp: this.now() });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Alias an anonymous user to a known user ID.
|
|
71
|
+
* This updates internal identity state and enqueues an alias event.
|
|
72
|
+
*/
|
|
73
|
+
alias(newUserId) {
|
|
74
|
+
this.identityManager.identify(newUserId);
|
|
75
|
+
this.enqueue({ type: 'alias', userId: newUserId, timestamp: this.now() });
|
|
76
|
+
}
|
|
77
|
+
async flush() {
|
|
78
|
+
const anonId = this.identityManager.getAnonymousId();
|
|
79
|
+
if (!anonId) {
|
|
80
|
+
log('Anonymous ID not yet ready, delaying flush');
|
|
81
|
+
// Anon ID not yet ready, delay flushing
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.queue.length === 0)
|
|
85
|
+
return;
|
|
86
|
+
const batch = this.queue.map((event) => ({
|
|
87
|
+
...event,
|
|
88
|
+
anonymousId: anonId,
|
|
89
|
+
writeKey: this.writeKey,
|
|
90
|
+
messageId: `${Date.now()}-${Math.random().toString(36).substring(2, 10)}`,
|
|
91
|
+
sentAt: new Date().toISOString(),
|
|
92
|
+
}));
|
|
93
|
+
this.queue = [];
|
|
94
|
+
log(`Flushing ${batch.length} events to ${this.endpoint}/v1/batch`);
|
|
95
|
+
try {
|
|
96
|
+
await retryWithBackoff(async () => {
|
|
97
|
+
await fetch(this.endpoint + '/v1/batch', {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
'Content-Type': 'application/json',
|
|
101
|
+
},
|
|
102
|
+
body: JSON.stringify({ batch }),
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
log('Flush completed');
|
|
106
|
+
return batch;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
warn('Flush failed, re-queueing events', err);
|
|
110
|
+
this.queue.unshift(...batch); // re-queue enriched events
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
reset() {
|
|
114
|
+
this.identityManager.reset();
|
|
115
|
+
this.queue = [];
|
|
116
|
+
log('Analytics client reset');
|
|
117
|
+
}
|
|
118
|
+
cleanup() {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
log('Cleaning up analytics client');
|
|
121
|
+
if (this.flushTimer)
|
|
122
|
+
clearInterval(this.flushTimer);
|
|
123
|
+
this.queue = [];
|
|
124
|
+
this.flushTimer = null;
|
|
125
|
+
(_b = (_a = this.appStateSubscription) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichEvent.d.ts","sourceRoot":"","sources":["../../src/analytics/enrichEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI7D,wBAAgB,WAAW,CACzB,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,oBAAoB,CAYtB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getContextInfo } from "./utils/contextInfo";
|
|
2
|
+
export function enrichEvent(event, anonymousId, writeKey) {
|
|
3
|
+
var _a;
|
|
4
|
+
const enriched = {
|
|
5
|
+
...event,
|
|
6
|
+
anonymousId,
|
|
7
|
+
writeKey,
|
|
8
|
+
messageId: `${Date.now()}-${crypto.randomUUID()}`,
|
|
9
|
+
sentAt: new Date().toISOString(),
|
|
10
|
+
timestamp: (_a = event.timestamp) !== null && _a !== void 0 ? _a : new Date().toISOString(),
|
|
11
|
+
context: getContextInfo(),
|
|
12
|
+
};
|
|
13
|
+
return enriched;
|
|
14
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InitOptions, AnalyticsInterface } from './types';
|
|
2
|
+
export declare function initAnalytics(options: InitOptions): Promise<AnalyticsInterface>;
|
|
3
|
+
export declare function getAnalyticsClient(): AnalyticsInterface;
|
|
4
|
+
export declare function resetAnalytics(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/analytics/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAM/D,wBAAsB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAiBrF;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAEvD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MetaRouterAnalyticsClient } from './MetaRouterAnalyticsClient';
|
|
2
|
+
import { proxyClient, setRealClient } from './proxy/proxyClient';
|
|
3
|
+
let initialized = false;
|
|
4
|
+
let client = null;
|
|
5
|
+
let analyticsInterface = null;
|
|
6
|
+
export async function initAnalytics(options) {
|
|
7
|
+
if (initialized)
|
|
8
|
+
return analyticsInterface;
|
|
9
|
+
client = new MetaRouterAnalyticsClient(options);
|
|
10
|
+
analyticsInterface = {
|
|
11
|
+
track: (event, props) => client.track(event, props),
|
|
12
|
+
identify: (userId, traits) => client.identify(userId, traits),
|
|
13
|
+
group: (groupId, traits) => client.group(groupId, traits),
|
|
14
|
+
screen: (name, props) => client.screen(name, props),
|
|
15
|
+
alias: (newUserId) => client.alias(newUserId),
|
|
16
|
+
flush: () => client.flush(),
|
|
17
|
+
cleanup: () => client.cleanup(),
|
|
18
|
+
};
|
|
19
|
+
initialized = true;
|
|
20
|
+
setRealClient(analyticsInterface);
|
|
21
|
+
return analyticsInterface;
|
|
22
|
+
}
|
|
23
|
+
export function getAnalyticsClient() {
|
|
24
|
+
return initialized ? analyticsInterface : proxyClient;
|
|
25
|
+
}
|
|
26
|
+
export async function resetAnalytics() {
|
|
27
|
+
await (client === null || client === void 0 ? void 0 : client.cleanup());
|
|
28
|
+
client = null;
|
|
29
|
+
analyticsInterface = null;
|
|
30
|
+
initialized = false;
|
|
31
|
+
setRealClient(null);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxyClient.d.ts","sourceRoot":"","sources":["../../../src/analytics/proxy/proxyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAiBnD,eAAO,MAAM,WAAW,EAAE,kBAQzB,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,QAM9D"}
|
|
@@ -4,7 +4,6 @@ function handleMethodCall(methodName, ...args) {
|
|
|
4
4
|
if (realClient) {
|
|
5
5
|
return realClient[methodName](...args);
|
|
6
6
|
}
|
|
7
|
-
// Queue the call for later execution
|
|
8
7
|
pendingCalls.push(() => {
|
|
9
8
|
if (realClient) {
|
|
10
9
|
realClient[methodName](...args);
|
|
@@ -20,9 +19,9 @@ export const proxyClient = {
|
|
|
20
19
|
flush: () => handleMethodCall('flush'),
|
|
21
20
|
cleanup: () => handleMethodCall('cleanup'),
|
|
22
21
|
};
|
|
23
|
-
export function setRealClient(
|
|
24
|
-
realClient =
|
|
25
|
-
if (
|
|
22
|
+
export function setRealClient(client) {
|
|
23
|
+
realClient = client;
|
|
24
|
+
if (client) {
|
|
26
25
|
pendingCalls.forEach((fn) => fn());
|
|
27
26
|
pendingCalls.length = 0;
|
|
28
27
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type EventType = 'track' | 'identify' | 'group' | 'screen' | 'alias' | 'page';
|
|
2
|
+
export interface EventPayload {
|
|
3
|
+
type: EventType;
|
|
4
|
+
event?: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
groupId?: string;
|
|
7
|
+
traits?: Record<string, any>;
|
|
8
|
+
properties?: Record<string, any>;
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface InitOptions {
|
|
12
|
+
writeKey: string;
|
|
13
|
+
ingestionEndpoint: string;
|
|
14
|
+
flushInterval?: number;
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface AnalyticsInterface {
|
|
18
|
+
track: (event: string, props?: Record<string, any>) => void;
|
|
19
|
+
identify: (userId: string, traits?: Record<string, any>) => void;
|
|
20
|
+
group: (groupId: string, traits?: Record<string, any>) => void;
|
|
21
|
+
screen: (name: string, props?: Record<string, any>) => void;
|
|
22
|
+
alias: (newUserId: string) => void;
|
|
23
|
+
flush: () => void;
|
|
24
|
+
cleanup: () => void;
|
|
25
|
+
}
|
|
26
|
+
export interface EventContext {
|
|
27
|
+
library: {
|
|
28
|
+
name: string;
|
|
29
|
+
version: string;
|
|
30
|
+
};
|
|
31
|
+
locale?: string;
|
|
32
|
+
timezone?: string;
|
|
33
|
+
device: {
|
|
34
|
+
manufacturer: string;
|
|
35
|
+
model: string;
|
|
36
|
+
osName: string;
|
|
37
|
+
osVersion: string;
|
|
38
|
+
};
|
|
39
|
+
app: {
|
|
40
|
+
version: string;
|
|
41
|
+
build: string;
|
|
42
|
+
};
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}
|
|
45
|
+
export interface EnrichedEventPayload extends EventPayload {
|
|
46
|
+
anonymousId: string;
|
|
47
|
+
messageId: string;
|
|
48
|
+
sentAt: string;
|
|
49
|
+
context: EventContext;
|
|
50
|
+
writeKey: string;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/analytics/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAErF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC5D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACjE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC/D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IAC5D,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,GAAG,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymousId.d.ts","sourceRoot":"","sources":["../../../src/analytics/utils/anonymousId.ts"],"names":[],"mappings":"AAKA,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAOtD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
const STORAGE_KEY = 'metarouter:anonymous_id';
|
|
4
|
+
export async function getAnonymousId() {
|
|
5
|
+
const existing = await AsyncStorage.getItem(STORAGE_KEY);
|
|
6
|
+
if (existing)
|
|
7
|
+
return existing;
|
|
8
|
+
const anonId = uuidv4();
|
|
9
|
+
await AsyncStorage.setItem(STORAGE_KEY, anonId);
|
|
10
|
+
return anonId;
|
|
11
|
+
}
|