@metarouter/react-native-sdk 0.1.16 → 0.1.18
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 +91 -23
- 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 +51 -0
- package/lib/analytics/MetaRouterAnalyticsClient.d.ts +64 -0
- package/lib/analytics/MetaRouterAnalyticsClient.d.ts.map +1 -0
- package/lib/analytics/MetaRouterAnalyticsClient.js +196 -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 +36 -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 +54 -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 +26 -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 +5 -0
- package/lib/analytics/utils/logger.d.ts.map +1 -0
- package/lib/analytics/utils/logger.js +16 -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 +7 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -2
- package/lib/react/context.d.ts +8 -0
- package/lib/react/context.d.ts.map +1 -0
- package/lib/react/context.js +5 -0
- package/lib/react/useMetaRouter.d.ts +5 -0
- package/lib/react/useMetaRouter.d.ts.map +1 -0
- package/lib/react/useMetaRouter.js +10 -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 -26
- 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
|
@@ -8,7 +8,7 @@ A lightweight React Native analytics SDK that transmits events to your MetaRoute
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npm install @metarouter/react-native-sdk
|
|
11
|
+
npm install @metarouter/react-native-sdk @react-native-async-storage/async-storage react-native-device-info
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
@@ -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,61 @@ 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
|
|
179
|
+
- 🐛 **Debug Support**: Built-in debugging tools for troubleshooting
|
|
180
|
+
|
|
181
|
+
## Debugging
|
|
182
|
+
|
|
183
|
+
If you're not seeing API calls being made, here are some steps to troubleshoot:
|
|
184
|
+
|
|
185
|
+
### 1. Enable Debug Logging
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
// Initialize with debug enabled
|
|
189
|
+
const analytics = await MetaRouter.analytics.init({
|
|
190
|
+
writeKey: "your-write-key",
|
|
191
|
+
ingestionEndpoint: "https://your-ingestion-endpoint.com",
|
|
192
|
+
debug: true, // This enables detailed logging
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Or enable debug logging after initialization
|
|
196
|
+
analytics.enableDebugLogging?.();
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 2. Check Debug Information
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
// Get current state information
|
|
203
|
+
const debugInfo = analytics.getDebugInfo?.();
|
|
204
|
+
console.log("Analytics debug info:", debugInfo);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 3. Force Flush Events
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
// Manually flush events to see if they're being sent
|
|
211
|
+
await analytics.flush();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 4. Common Issues
|
|
215
|
+
|
|
216
|
+
- **Network Permissions**: Ensure your app has network permissions
|
|
217
|
+
- **AsyncStorage**: The SDK uses AsyncStorage for anonymous ID persistence
|
|
218
|
+
- **Endpoint URL**: Verify your ingestion endpoint is correct and accessible
|
|
219
|
+
- **Write Key**: Ensure your write key is valid
|
|
152
220
|
|
|
153
221
|
## License
|
|
154
222
|
|
|
@@ -160,4 +228,4 @@ MIT
|
|
|
160
228
|
|
|
161
229
|
This library includes code from the following third-party packages:
|
|
162
230
|
|
|
163
|
-
- [
|
|
231
|
+
- [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":"AAGA,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;IAY3B,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IAKvB,KAAK,CAAC,OAAO,EAAE,MAAM;IAKrB,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;CAMN"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getAnonymousId } from "./utils/anonymousId";
|
|
2
|
+
import { log, warn } from "./utils/logger";
|
|
3
|
+
export class IdentityManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.anonymousId = null;
|
|
6
|
+
}
|
|
7
|
+
async init() {
|
|
8
|
+
try {
|
|
9
|
+
this.anonymousId = await getAnonymousId(); // load or generate
|
|
10
|
+
log('IdentityManager initialized with anonymous ID:', this.anonymousId);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
warn('Failed to initialize IdentityManager, using fallback anonymous ID', error);
|
|
14
|
+
// Fallback: generate a temporary anonymous ID
|
|
15
|
+
this.anonymousId = `fallback-${Date.now()}-${Math.random().toString(36).substring(2, 10)}`;
|
|
16
|
+
log('Using fallback anonymous ID:', this.anonymousId);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
getAnonymousId() {
|
|
20
|
+
return this.anonymousId;
|
|
21
|
+
}
|
|
22
|
+
identify(userId) {
|
|
23
|
+
this.userId = userId;
|
|
24
|
+
log('User identified:', userId);
|
|
25
|
+
}
|
|
26
|
+
group(groupId) {
|
|
27
|
+
this.groupId = groupId;
|
|
28
|
+
log('User grouped:', groupId);
|
|
29
|
+
}
|
|
30
|
+
getUserId() {
|
|
31
|
+
return this.userId;
|
|
32
|
+
}
|
|
33
|
+
getGroupId() {
|
|
34
|
+
return this.groupId;
|
|
35
|
+
}
|
|
36
|
+
addIdentityInfo(event) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
return {
|
|
39
|
+
...event,
|
|
40
|
+
anonymousId: this.anonymousId,
|
|
41
|
+
userId: (_a = event.userId) !== null && _a !== void 0 ? _a : this.userId,
|
|
42
|
+
groupId: (_b = event.groupId) !== null && _b !== void 0 ? _b : this.groupId,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
reset() {
|
|
46
|
+
this.anonymousId = null;
|
|
47
|
+
this.userId = undefined;
|
|
48
|
+
this.groupId = undefined;
|
|
49
|
+
log('IdentityManager reset');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { InitOptions } from "./types";
|
|
2
|
+
export declare class MetaRouterAnalyticsClient {
|
|
3
|
+
private initialized;
|
|
4
|
+
private initPromise;
|
|
5
|
+
private queue;
|
|
6
|
+
private flushIntervalMs;
|
|
7
|
+
private flushTimer;
|
|
8
|
+
private endpoint;
|
|
9
|
+
private writeKey;
|
|
10
|
+
private appState;
|
|
11
|
+
private appStateSubscription;
|
|
12
|
+
private identityManager;
|
|
13
|
+
constructor(options: InitOptions);
|
|
14
|
+
private init;
|
|
15
|
+
waitForInitialization(): Promise<void>;
|
|
16
|
+
private startFlushLoop;
|
|
17
|
+
private now;
|
|
18
|
+
private enqueue;
|
|
19
|
+
private setupAppStateListener;
|
|
20
|
+
private handleAppStateChange;
|
|
21
|
+
track(event: string, properties?: Record<string, any>): void;
|
|
22
|
+
identify(userId: string, traits?: Record<string, any>): void;
|
|
23
|
+
page(name: string, properties?: Record<string, any>): void;
|
|
24
|
+
group(groupId: string, traits?: Record<string, any>): void;
|
|
25
|
+
screen(name: string, properties?: Record<string, any>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Alias an anonymous user to a known user ID.
|
|
28
|
+
* This updates internal identity state and enqueues an alias event.
|
|
29
|
+
*/
|
|
30
|
+
alias(newUserId: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Enable debug logging for troubleshooting
|
|
33
|
+
*/
|
|
34
|
+
enableDebugLogging(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Get current state for debugging
|
|
37
|
+
*/
|
|
38
|
+
getDebugInfo(): {
|
|
39
|
+
initialized: boolean;
|
|
40
|
+
queueLength: number;
|
|
41
|
+
endpoint: string;
|
|
42
|
+
writeKey: string | undefined;
|
|
43
|
+
flushIntervalMs: number;
|
|
44
|
+
anonymousId: string | null;
|
|
45
|
+
userId: string | undefined;
|
|
46
|
+
groupId: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
flush(): Promise<{
|
|
49
|
+
anonymousId: string;
|
|
50
|
+
writeKey: string;
|
|
51
|
+
messageId: string;
|
|
52
|
+
sentAt: string;
|
|
53
|
+
type: import("./types").EventType;
|
|
54
|
+
event?: string;
|
|
55
|
+
userId?: string;
|
|
56
|
+
groupId?: string;
|
|
57
|
+
traits?: Record<string, any>;
|
|
58
|
+
properties?: Record<string, any>;
|
|
59
|
+
timestamp?: string;
|
|
60
|
+
}[] | undefined>;
|
|
61
|
+
reset(): void;
|
|
62
|
+
cleanup(): void;
|
|
63
|
+
}
|
|
64
|
+
//# 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,WAAW,CAAgB;IACnC,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;YAalB,IAAI;IA4BZ,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C,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;IAMrD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOrD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMnD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAOnD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMrD;;;MAGE;IAEF,KAAK,CAAC,SAAS,EAAE,MAAM;IAOvB;;OAEG;IACH,kBAAkB;IAKlB;;OAEG;IACH,YAAY;;;;;;;;;;IAaN,KAAK;;;;;;;;;;;;;IA6DX,KAAK;IAML,OAAO;CAQR"}
|
|
@@ -0,0 +1,196 @@
|
|
|
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.initPromise = this.init();
|
|
28
|
+
log('Analytics client constructor completed, initialization in progress...');
|
|
29
|
+
}
|
|
30
|
+
async init() {
|
|
31
|
+
if (this.initialized) {
|
|
32
|
+
log('Analytics client already initialized');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
log('Starting analytics client initialization...');
|
|
36
|
+
try {
|
|
37
|
+
await this.identityManager.init();
|
|
38
|
+
log('IdentityManager initialized successfully');
|
|
39
|
+
this.startFlushLoop();
|
|
40
|
+
log('Flush loop started with interval:', this.flushIntervalMs, 'ms');
|
|
41
|
+
this.setupAppStateListener();
|
|
42
|
+
log('App state listener setup completed');
|
|
43
|
+
this.initialized = true;
|
|
44
|
+
log('Analytics client initialization completed successfully');
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
warn('Analytics client initialization failed:', error);
|
|
48
|
+
// Still mark as initialized to prevent infinite retries
|
|
49
|
+
this.initialized = true;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async waitForInitialization() {
|
|
54
|
+
await this.initPromise;
|
|
55
|
+
}
|
|
56
|
+
startFlushLoop() {
|
|
57
|
+
this.flushTimer = setInterval(() => this.flush(), this.flushIntervalMs);
|
|
58
|
+
}
|
|
59
|
+
now() {
|
|
60
|
+
return new Date().toISOString();
|
|
61
|
+
}
|
|
62
|
+
enqueue(event) {
|
|
63
|
+
const eventWithIdentity = this.identityManager.addIdentityInfo(event);
|
|
64
|
+
log('Enqueuing event', eventWithIdentity);
|
|
65
|
+
this.queue.push(eventWithIdentity);
|
|
66
|
+
}
|
|
67
|
+
setupAppStateListener() {
|
|
68
|
+
this.appStateSubscription = AppState.addEventListener('change', this.handleAppStateChange);
|
|
69
|
+
}
|
|
70
|
+
track(event, properties) {
|
|
71
|
+
log('Tracking event:', event, 'with properties:', properties);
|
|
72
|
+
this.enqueue({ type: 'track', event, properties, timestamp: this.now() });
|
|
73
|
+
log('Event enqueued, queue length:', this.queue.length);
|
|
74
|
+
}
|
|
75
|
+
identify(userId, traits) {
|
|
76
|
+
log('Identifying user:', userId, 'with traits:', traits);
|
|
77
|
+
this.identityManager.identify(userId);
|
|
78
|
+
this.enqueue({ type: 'identify', userId, traits, timestamp: this.now() });
|
|
79
|
+
log('Identify event enqueued, queue length:', this.queue.length);
|
|
80
|
+
}
|
|
81
|
+
page(name, properties) {
|
|
82
|
+
log('Tracking page:', name, 'with properties:', properties);
|
|
83
|
+
this.enqueue({ type: 'page', event: name, properties, timestamp: this.now() });
|
|
84
|
+
log('Page event enqueued, queue length:', this.queue.length);
|
|
85
|
+
}
|
|
86
|
+
group(groupId, traits) {
|
|
87
|
+
log('Grouping user:', groupId, 'with traits:', traits);
|
|
88
|
+
this.identityManager.group(groupId);
|
|
89
|
+
this.enqueue({ type: 'group', groupId, traits, timestamp: this.now() });
|
|
90
|
+
log('Group event enqueued, queue length:', this.queue.length);
|
|
91
|
+
}
|
|
92
|
+
screen(name, properties) {
|
|
93
|
+
log('Tracking screen:', name, 'with properties:', properties);
|
|
94
|
+
this.enqueue({ type: 'screen', event: name, properties, timestamp: this.now() });
|
|
95
|
+
log('Screen event enqueued, queue length:', this.queue.length);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Alias an anonymous user to a known user ID.
|
|
99
|
+
* This updates internal identity state and enqueues an alias event.
|
|
100
|
+
*/
|
|
101
|
+
alias(newUserId) {
|
|
102
|
+
log('Aliasing user to:', newUserId);
|
|
103
|
+
this.identityManager.identify(newUserId);
|
|
104
|
+
this.enqueue({ type: 'alias', userId: newUserId, timestamp: this.now() });
|
|
105
|
+
log('Alias event enqueued, queue length:', this.queue.length);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Enable debug logging for troubleshooting
|
|
109
|
+
*/
|
|
110
|
+
enableDebugLogging() {
|
|
111
|
+
setDebugLogging(true);
|
|
112
|
+
log('Debug logging enabled');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get current state for debugging
|
|
116
|
+
*/
|
|
117
|
+
getDebugInfo() {
|
|
118
|
+
return {
|
|
119
|
+
initialized: this.initialized,
|
|
120
|
+
queueLength: this.queue.length,
|
|
121
|
+
endpoint: this.endpoint,
|
|
122
|
+
writeKey: this.writeKey ? '***' + this.writeKey.slice(-4) : undefined,
|
|
123
|
+
flushIntervalMs: this.flushIntervalMs,
|
|
124
|
+
anonymousId: this.identityManager.getAnonymousId(),
|
|
125
|
+
userId: this.identityManager.getUserId(),
|
|
126
|
+
groupId: this.identityManager.getGroupId(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async flush() {
|
|
130
|
+
const anonId = this.identityManager.getAnonymousId();
|
|
131
|
+
if (!anonId) {
|
|
132
|
+
warn('Anonymous ID not yet ready, delaying flush');
|
|
133
|
+
// Anon ID not yet ready, delay flushing
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (this.queue.length === 0) {
|
|
137
|
+
log('No events to flush');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const batch = this.queue.map((event) => ({
|
|
141
|
+
...event,
|
|
142
|
+
anonymousId: anonId,
|
|
143
|
+
writeKey: this.writeKey,
|
|
144
|
+
messageId: `${Date.now()}-${Math.random().toString(36).substring(2, 10)}`,
|
|
145
|
+
sentAt: new Date().toISOString(),
|
|
146
|
+
}));
|
|
147
|
+
this.queue = [];
|
|
148
|
+
log(`Flushing ${batch.length} events to ${this.endpoint}/v1/batch`);
|
|
149
|
+
try {
|
|
150
|
+
await retryWithBackoff(async () => {
|
|
151
|
+
log('Making API call to:', this.endpoint + '/v1/batch');
|
|
152
|
+
const response = await fetch(this.endpoint + '/v1/batch', {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: {
|
|
155
|
+
'Content-Type': 'application/json',
|
|
156
|
+
},
|
|
157
|
+
body: JSON.stringify({ batch }),
|
|
158
|
+
});
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
161
|
+
}
|
|
162
|
+
log('API call successful, status:', response.status);
|
|
163
|
+
return response;
|
|
164
|
+
});
|
|
165
|
+
log('Flush completed successfully');
|
|
166
|
+
return batch;
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
warn('Flush failed, re-queueing events', err);
|
|
170
|
+
// Re-queue the original events (not the enriched ones)
|
|
171
|
+
this.queue.unshift(...this.queue.splice(0, 0, ...batch.map(event => ({
|
|
172
|
+
type: event.type,
|
|
173
|
+
event: event.event,
|
|
174
|
+
properties: event.properties,
|
|
175
|
+
userId: event.userId,
|
|
176
|
+
traits: event.traits,
|
|
177
|
+
groupId: event.groupId,
|
|
178
|
+
timestamp: event.timestamp,
|
|
179
|
+
}))));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
reset() {
|
|
183
|
+
this.identityManager.reset();
|
|
184
|
+
this.queue = [];
|
|
185
|
+
log('Analytics client reset');
|
|
186
|
+
}
|
|
187
|
+
cleanup() {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
log('Cleaning up analytics client');
|
|
190
|
+
if (this.flushTimer)
|
|
191
|
+
clearInterval(this.flushTimer);
|
|
192
|
+
this.queue = [];
|
|
193
|
+
this.flushTimer = null;
|
|
194
|
+
(_b = (_a = this.appStateSubscription) === null || _a === void 0 ? void 0 : _a.remove) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -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,CAuBrF;AAED,wBAAgB,kBAAkB,IAAI,kBAAkB,CAEvD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpD"}
|