react-native-clarity 0.0.1-beta.1
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/LICENSE +20 -0
- package/README.md +56 -0
- package/android/build.gradle +81 -0
- package/android/gradle.properties +6 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityModule.kt +62 -0
- package/android/src/main/java/com/microsoft/clarity/reactnative/ClarityPackage.kt +17 -0
- package/ios/Clarity.h +12 -0
- package/ios/Clarity.mm +15 -0
- package/ios/Clarity.xcodeproj/project.pbxproj +274 -0
- package/ios/Clarity.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/lib/commonjs/index.js +85 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/index.js +77 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/index.d.ts +34 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +160 -0
- package/react-native-clarity.podspec +35 -0
- package/src/index.tsx +91 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Microsoft - Clarity
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# react-native-clarity
|
|
2
|
+
|
|
3
|
+
A ReactNative plugin that allows integrating Clarity with your application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install react-native-clarity
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { initialize } from 'react-native-clarity';
|
|
15
|
+
import { setCustomUserId } from 'react-native-clarity';
|
|
16
|
+
import { getCurrentSessionId } from 'react-native-clarity';
|
|
17
|
+
|
|
18
|
+
// Initialize Clarity.
|
|
19
|
+
initialize("<ProjectId>", "<UserId>", "Verbose", true, true, ["*"]);
|
|
20
|
+
|
|
21
|
+
// Set custom user id.
|
|
22
|
+
setCustomUserId("react@native.com");
|
|
23
|
+
|
|
24
|
+
// Get current session id to correlate with other tools.
|
|
25
|
+
getCurrentSessionId().then((id) => {...});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Initialization arguments
|
|
29
|
+
```js
|
|
30
|
+
/**
|
|
31
|
+
* Initializes the Clarity plugin with the provided parameters.
|
|
32
|
+
*
|
|
33
|
+
* @param projectId The Clarity project id to send data to.
|
|
34
|
+
* @param userId A custom identifier for the current user. If passed as null, the user id
|
|
35
|
+
* will be auto generated. The user id in general is sticky across sessions.
|
|
36
|
+
* The provided user id must follow these conditions:
|
|
37
|
+
* 1. Cannot be an empty string.
|
|
38
|
+
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
39
|
+
* @param logLevel The level of logging to show in the device logcat stream ("Verbose", "Debug", "Info", "Warning", "Error", "None").
|
|
40
|
+
* @param allowMeteredNetworkUsage Allows uploading session data to the servers on device metered network.
|
|
41
|
+
* @param enableWebViewCapture Allows Clarity to capture the web views DOM content.
|
|
42
|
+
* @param allowedDomains The whitelisted domains to allow Clarity to capture their DOM content.
|
|
43
|
+
* If it contains "*" as an element, all domains will be captured.
|
|
44
|
+
*/
|
|
45
|
+
function initialize(
|
|
46
|
+
projectId: string,
|
|
47
|
+
userId: string,
|
|
48
|
+
logLevel: string,
|
|
49
|
+
allowMeteredNetworkUsage: boolean,
|
|
50
|
+
enableWebViewCapture: boolean,
|
|
51
|
+
allowedDomains: string[])
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Clarity_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: "kotlin-android"
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: "com.facebook.react"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Clarity_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Clarity_" + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
android {
|
|
37
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
38
|
+
|
|
39
|
+
defaultConfig {
|
|
40
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
41
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
42
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
43
|
+
}
|
|
44
|
+
buildTypes {
|
|
45
|
+
release {
|
|
46
|
+
minifyEnabled false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
lintOptions {
|
|
51
|
+
disable "GradleCompatible"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
compileOptions {
|
|
55
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
56
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
repositories {
|
|
62
|
+
mavenCentral()
|
|
63
|
+
google()
|
|
64
|
+
mavenLocal()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
68
|
+
|
|
69
|
+
dependencies {
|
|
70
|
+
implementation "com.facebook.react:react-native:+"
|
|
71
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
72
|
+
implementation "com.microsoft.clarity:clarity:1.2.1-beta1"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (isNewArchitectureEnabled()) {
|
|
76
|
+
react {
|
|
77
|
+
jsRootDir = file("../src/")
|
|
78
|
+
libraryName = "Clarity"
|
|
79
|
+
codegenJavaPackageName = "com.microsoft.clarity.reactnative"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package com.microsoft.clarity.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.microsoft.clarity.Clarity
|
|
5
|
+
import com.microsoft.clarity.ClarityConfig
|
|
6
|
+
import com.microsoft.clarity.models.ApplicationFramework
|
|
7
|
+
import com.microsoft.clarity.models.LogLevel
|
|
8
|
+
|
|
9
|
+
class ClarityModule(reactContext: ReactApplicationContext) :
|
|
10
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return NAME
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@ReactMethod
|
|
17
|
+
fun initialize(
|
|
18
|
+
projectId: String,
|
|
19
|
+
userId: String,
|
|
20
|
+
logLevel: String,
|
|
21
|
+
allowMeteredNetworkUsage: Boolean,
|
|
22
|
+
enableWebViewCapture: Boolean,
|
|
23
|
+
allowedDomains: ReadableArray,
|
|
24
|
+
promise: Promise
|
|
25
|
+
) {
|
|
26
|
+
val config = ClarityConfig(
|
|
27
|
+
projectId,
|
|
28
|
+
userId,
|
|
29
|
+
LogLevel.valueOf(logLevel),
|
|
30
|
+
allowMeteredNetworkUsage,
|
|
31
|
+
enableWebViewCapture,
|
|
32
|
+
readableArrayToList(allowedDomains),
|
|
33
|
+
ApplicationFramework.ReactNative
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
promise.resolve(Clarity.initialize(currentActivity, config))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
fun setCustomUserId(customUserId: String, promise: Promise) {
|
|
41
|
+
promise.resolve(Clarity.setCustomUserId(customUserId))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
fun getCurrentSessionId(promise: Promise) {
|
|
46
|
+
promise.resolve(Clarity.getCurrentSessionId())
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private fun readableArrayToList(arr: ReadableArray): List<String> {
|
|
50
|
+
val ret = mutableListOf<String>()
|
|
51
|
+
|
|
52
|
+
for (i in 0 until arr.size()) {
|
|
53
|
+
ret.add(arr.getString(i))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return ret
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
companion object {
|
|
60
|
+
const val NAME = "Clarity"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.microsoft.clarity.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.JavaScriptModule
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
class ClarityPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(ClarityModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
package/ios/Clarity.h
ADDED
package/ios/Clarity.mm
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#import "Clarity.h"
|
|
2
|
+
|
|
3
|
+
@implementation Clarity
|
|
4
|
+
RCT_EXPORT_MODULE()
|
|
5
|
+
|
|
6
|
+
// Don't compile this code when we build for the old architecture.
|
|
7
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
8
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
9
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
10
|
+
{
|
|
11
|
+
return std::make_shared<facebook::react::NativeClaritySpecJSI>(params);
|
|
12
|
+
}
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
@end
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 46;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXBuildFile section */
|
|
10
|
+
5E555C0D2413F4C50049A1A2 /* Clarity.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* Clarity.m */; };
|
|
11
|
+
/* End PBXBuildFile section */
|
|
12
|
+
|
|
13
|
+
/* Begin PBXCopyFilesBuildPhase section */
|
|
14
|
+
58B511D91A9E6C8500147676 /* CopyFiles */ = {
|
|
15
|
+
isa = PBXCopyFilesBuildPhase;
|
|
16
|
+
buildActionMask = 2147483647;
|
|
17
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
18
|
+
dstSubfolderSpec = 16;
|
|
19
|
+
files = (
|
|
20
|
+
);
|
|
21
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
22
|
+
};
|
|
23
|
+
/* End PBXCopyFilesBuildPhase section */
|
|
24
|
+
|
|
25
|
+
/* Begin PBXFileReference section */
|
|
26
|
+
134814201AA4EA6300B7C361 /* libClarity.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libClarity.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
27
|
+
B3E7B5881CC2AC0600A0062D /* Clarity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Clarity.h; sourceTree = "<group>"; };
|
|
28
|
+
B3E7B5891CC2AC0600A0062D /* Clarity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Clarity.m; sourceTree = "<group>"; };
|
|
29
|
+
/* End PBXFileReference section */
|
|
30
|
+
|
|
31
|
+
/* Begin PBXFrameworksBuildPhase section */
|
|
32
|
+
58B511D81A9E6C8500147676 /* Frameworks */ = {
|
|
33
|
+
isa = PBXFrameworksBuildPhase;
|
|
34
|
+
buildActionMask = 2147483647;
|
|
35
|
+
files = (
|
|
36
|
+
);
|
|
37
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
38
|
+
};
|
|
39
|
+
/* End PBXFrameworksBuildPhase section */
|
|
40
|
+
|
|
41
|
+
/* Begin PBXGroup section */
|
|
42
|
+
134814211AA4EA7D00B7C361 /* Products */ = {
|
|
43
|
+
isa = PBXGroup;
|
|
44
|
+
children = (
|
|
45
|
+
134814201AA4EA6300B7C361 /* libClarity.a */,
|
|
46
|
+
);
|
|
47
|
+
name = Products;
|
|
48
|
+
sourceTree = "<group>";
|
|
49
|
+
};
|
|
50
|
+
58B511D21A9E6C8500147676 = {
|
|
51
|
+
isa = PBXGroup;
|
|
52
|
+
children = (
|
|
53
|
+
B3E7B5881CC2AC0600A0062D /* Clarity.h */,
|
|
54
|
+
B3E7B5891CC2AC0600A0062D /* Clarity.m */,
|
|
55
|
+
134814211AA4EA7D00B7C361 /* Products */,
|
|
56
|
+
);
|
|
57
|
+
sourceTree = "<group>";
|
|
58
|
+
};
|
|
59
|
+
/* End PBXGroup section */
|
|
60
|
+
|
|
61
|
+
/* Begin PBXNativeTarget section */
|
|
62
|
+
58B511DA1A9E6C8500147676 /* Clarity */ = {
|
|
63
|
+
isa = PBXNativeTarget;
|
|
64
|
+
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */;
|
|
65
|
+
buildPhases = (
|
|
66
|
+
58B511D71A9E6C8500147676 /* Sources */,
|
|
67
|
+
58B511D81A9E6C8500147676 /* Frameworks */,
|
|
68
|
+
58B511D91A9E6C8500147676 /* CopyFiles */,
|
|
69
|
+
);
|
|
70
|
+
buildRules = (
|
|
71
|
+
);
|
|
72
|
+
dependencies = (
|
|
73
|
+
);
|
|
74
|
+
name = Clarity;
|
|
75
|
+
productName = RCTDataManager;
|
|
76
|
+
productReference = 134814201AA4EA6300B7C361 /* libClarity.a */;
|
|
77
|
+
productType = "com.apple.product-type.library.static";
|
|
78
|
+
};
|
|
79
|
+
/* End PBXNativeTarget section */
|
|
80
|
+
|
|
81
|
+
/* Begin PBXProject section */
|
|
82
|
+
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
83
|
+
isa = PBXProject;
|
|
84
|
+
attributes = {
|
|
85
|
+
LastUpgradeCheck = 0920;
|
|
86
|
+
ORGANIZATIONNAME = Facebook;
|
|
87
|
+
TargetAttributes = {
|
|
88
|
+
58B511DA1A9E6C8500147676 = {
|
|
89
|
+
CreatedOnToolsVersion = 6.1.1;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */;
|
|
94
|
+
compatibilityVersion = "Xcode 3.2";
|
|
95
|
+
developmentRegion = English;
|
|
96
|
+
hasScannedForEncodings = 0;
|
|
97
|
+
knownRegions = (
|
|
98
|
+
English,
|
|
99
|
+
en,
|
|
100
|
+
);
|
|
101
|
+
mainGroup = 58B511D21A9E6C8500147676;
|
|
102
|
+
productRefGroup = 58B511D21A9E6C8500147676;
|
|
103
|
+
projectDirPath = "";
|
|
104
|
+
projectRoot = "";
|
|
105
|
+
targets = (
|
|
106
|
+
58B511DA1A9E6C8500147676 /* Clarity */,
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
/* End PBXProject section */
|
|
110
|
+
|
|
111
|
+
/* Begin PBXSourcesBuildPhase section */
|
|
112
|
+
58B511D71A9E6C8500147676 /* Sources */ = {
|
|
113
|
+
isa = PBXSourcesBuildPhase;
|
|
114
|
+
buildActionMask = 2147483647;
|
|
115
|
+
files = (
|
|
116
|
+
B3E7B58A1CC2AC0600A0062D /* Clarity.m in Sources */,
|
|
117
|
+
);
|
|
118
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
119
|
+
};
|
|
120
|
+
/* End PBXSourcesBuildPhase section */
|
|
121
|
+
|
|
122
|
+
/* Begin XCBuildConfiguration section */
|
|
123
|
+
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
124
|
+
isa = XCBuildConfiguration;
|
|
125
|
+
buildSettings = {
|
|
126
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
127
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
128
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
129
|
+
CLANG_ENABLE_MODULES = YES;
|
|
130
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
131
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
132
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
133
|
+
CLANG_WARN_COMMA = YES;
|
|
134
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
135
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
136
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
137
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
138
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
139
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
140
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
141
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
142
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
143
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
144
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
145
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
146
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
147
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
148
|
+
COPY_PHASE_STRIP = NO;
|
|
149
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
150
|
+
ENABLE_TESTABILITY = YES;
|
|
151
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
152
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
153
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
154
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
155
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
156
|
+
GCC_PREPROCESSOR_DEFINITIONS = (
|
|
157
|
+
"DEBUG=1",
|
|
158
|
+
"$(inherited)",
|
|
159
|
+
);
|
|
160
|
+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
|
161
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
162
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
163
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
164
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
165
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
166
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
167
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
168
|
+
MTL_ENABLE_DEBUG_INFO = YES;
|
|
169
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
170
|
+
SDKROOT = iphoneos;
|
|
171
|
+
};
|
|
172
|
+
name = Debug;
|
|
173
|
+
};
|
|
174
|
+
58B511EE1A9E6C8500147676 /* Release */ = {
|
|
175
|
+
isa = XCBuildConfiguration;
|
|
176
|
+
buildSettings = {
|
|
177
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
178
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
179
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
180
|
+
CLANG_ENABLE_MODULES = YES;
|
|
181
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
182
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
183
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
184
|
+
CLANG_WARN_COMMA = YES;
|
|
185
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
186
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
187
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
188
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
189
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
190
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
191
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
192
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
193
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
194
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
195
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
196
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
197
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
198
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
199
|
+
COPY_PHASE_STRIP = YES;
|
|
200
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
201
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
202
|
+
"EXCLUDED_ARCHS[sdk=*]" = arm64;
|
|
203
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
204
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
205
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
206
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
207
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
208
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
209
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
210
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
211
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
212
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
213
|
+
SDKROOT = iphoneos;
|
|
214
|
+
VALIDATE_PRODUCT = YES;
|
|
215
|
+
};
|
|
216
|
+
name = Release;
|
|
217
|
+
};
|
|
218
|
+
58B511F01A9E6C8500147676 /* Debug */ = {
|
|
219
|
+
isa = XCBuildConfiguration;
|
|
220
|
+
buildSettings = {
|
|
221
|
+
HEADER_SEARCH_PATHS = (
|
|
222
|
+
"$(inherited)",
|
|
223
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
224
|
+
"$(SRCROOT)/../../../React/**",
|
|
225
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
226
|
+
);
|
|
227
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
228
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
229
|
+
PRODUCT_NAME = Clarity;
|
|
230
|
+
SKIP_INSTALL = YES;
|
|
231
|
+
};
|
|
232
|
+
name = Debug;
|
|
233
|
+
};
|
|
234
|
+
58B511F11A9E6C8500147676 /* Release */ = {
|
|
235
|
+
isa = XCBuildConfiguration;
|
|
236
|
+
buildSettings = {
|
|
237
|
+
HEADER_SEARCH_PATHS = (
|
|
238
|
+
"$(inherited)",
|
|
239
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
240
|
+
"$(SRCROOT)/../../../React/**",
|
|
241
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
242
|
+
);
|
|
243
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
244
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
245
|
+
PRODUCT_NAME = Clarity;
|
|
246
|
+
SKIP_INSTALL = YES;
|
|
247
|
+
};
|
|
248
|
+
name = Release;
|
|
249
|
+
};
|
|
250
|
+
/* End XCBuildConfiguration section */
|
|
251
|
+
|
|
252
|
+
/* Begin XCConfigurationList section */
|
|
253
|
+
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "Clarity" */ = {
|
|
254
|
+
isa = XCConfigurationList;
|
|
255
|
+
buildConfigurations = (
|
|
256
|
+
58B511ED1A9E6C8500147676 /* Debug */,
|
|
257
|
+
58B511EE1A9E6C8500147676 /* Release */,
|
|
258
|
+
);
|
|
259
|
+
defaultConfigurationIsVisible = 0;
|
|
260
|
+
defaultConfigurationName = Release;
|
|
261
|
+
};
|
|
262
|
+
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "Clarity" */ = {
|
|
263
|
+
isa = XCConfigurationList;
|
|
264
|
+
buildConfigurations = (
|
|
265
|
+
58B511F01A9E6C8500147676 /* Debug */,
|
|
266
|
+
58B511F11A9E6C8500147676 /* Release */,
|
|
267
|
+
);
|
|
268
|
+
defaultConfigurationIsVisible = 0;
|
|
269
|
+
defaultConfigurationName = Release;
|
|
270
|
+
};
|
|
271
|
+
/* End XCConfigurationList section */
|
|
272
|
+
};
|
|
273
|
+
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
|
|
274
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCurrentSessionId = getCurrentSessionId;
|
|
7
|
+
exports.initialize = initialize;
|
|
8
|
+
exports.setCustomUserId = setCustomUserId;
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
const LINKING_ERROR = `The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
11
|
+
ios: "- You have run 'pod install'\n",
|
|
12
|
+
default: ''
|
|
13
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
14
|
+
const Clarity = _reactNative.NativeModules.Clarity;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the Clarity plugin with the provided parameters.
|
|
18
|
+
*
|
|
19
|
+
* @param projectId The Clarity project id to send data to.
|
|
20
|
+
* @param userId A custom identifier for the current user. If passed as null, the user id
|
|
21
|
+
* will be auto generated. The user id in general is sticky across sessions.
|
|
22
|
+
* The provided user id must follow these conditions:
|
|
23
|
+
* 1. Cannot be an empty string.
|
|
24
|
+
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
25
|
+
* @param logLevel The level of logging to show in the device logcat stream ("Verbose", "Debug", "Info", "Warning", "Error", "None").
|
|
26
|
+
* @param allowMeteredNetworkUsage Allows uploading session data to the servers on device metered network.
|
|
27
|
+
* @param enableWebViewCapture Allows Clarity to capture the web views DOM content.
|
|
28
|
+
* @param allowedDomains The whitelisted domains to allow Clarity to capture their DOM content.
|
|
29
|
+
* If it contains "*" as an element, all domains will be captured.
|
|
30
|
+
*/
|
|
31
|
+
function initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains) {
|
|
32
|
+
if (Clarity === null) {
|
|
33
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (_reactNative.Platform.OS !== 'android') {
|
|
37
|
+
console.warn("Clarity supports Android only for now.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sets a custom user id that can be used to identify the user. It has less
|
|
45
|
+
* restrictions than the userId parameter. You can pass any string and
|
|
46
|
+
* you can filter on it on the dashboard side. If you need the most efficient
|
|
47
|
+
* filtering on the dashboard, use the userId parameter if possible.
|
|
48
|
+
* <p>
|
|
49
|
+
* Note: custom user id cannot be null or empty, or consists only of whitespaces.
|
|
50
|
+
* </p>
|
|
51
|
+
* @param customUserId The custom user id to set.
|
|
52
|
+
*/
|
|
53
|
+
function setCustomUserId(customUserId) {
|
|
54
|
+
if (Clarity === null) {
|
|
55
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (_reactNative.Platform.OS !== 'android') {
|
|
59
|
+
console.warn("Clarity supports Android only for now.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
Clarity.setCustomUserId(customUserId);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Returns the active session id. This can be used to correlate the Clarity session with other
|
|
67
|
+
* analytics tools that the developer may be using.
|
|
68
|
+
* @returns a promise that resolves to the current session id.
|
|
69
|
+
*/
|
|
70
|
+
function getCurrentSessionId() {
|
|
71
|
+
if (Clarity === null) {
|
|
72
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
73
|
+
return new Promise(resolve => {
|
|
74
|
+
resolve("Undefined");
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (_reactNative.Platform.OS !== 'android') {
|
|
78
|
+
console.warn("Clarity supports Android only for now.");
|
|
79
|
+
return new Promise(resolve => {
|
|
80
|
+
resolve("Undefined");
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return Clarity.getCurrentSessionId();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","Clarity","NativeModules","initialize","projectId","userId","logLevel","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","console","error","OS","warn","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":";;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAChB,+EAA8E,GAC/EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,OAAO,GAAGC,0BAAa,CAACD,OAAO;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CACxBC,SAAiB,EACjBC,MAAc,EACdC,QAAgB,EAChBC,wBAAiC,EACjCC,oBAA6B,EAC7BC,cAAwB,EAAE;EAC1B,IAAIR,OAAO,KAAK,IAAI,EAAE;IACpBS,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEf,aAAa,CAAC;IACpE;EACF;EAEA,IAAIC,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD;EACF;EAEAZ,OAAO,CAACE,UAAU,CAACC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,wBAAwB,EAAEC,oBAAoB,EAAEC,cAAc,CAAC;AACjH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,eAAeA,CAACC,YAAoB,EAAE;EACpD,IAAId,OAAO,KAAK,IAAI,EAAE;IACpBS,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEf,aAAa,CAAC;IACpE;EACF;EAEA,IAAIC,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD;EACF;EAEAZ,OAAO,CAACa,eAAe,CAACC,YAAY,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAA,EAAoB;EACrD,IAAIf,OAAO,KAAK,IAAI,EAAE;IACpBS,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEf,aAAa,CAAC;IACpE,OAAO,IAAIqB,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,IAAIrB,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD,OAAO,IAAII,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,OAAOjB,OAAO,CAACe,mBAAmB,EAAE;AACtC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
+
ios: "- You have run 'pod install'\n",
|
|
4
|
+
default: ''
|
|
5
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
6
|
+
const Clarity = NativeModules.Clarity;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the Clarity plugin with the provided parameters.
|
|
10
|
+
*
|
|
11
|
+
* @param projectId The Clarity project id to send data to.
|
|
12
|
+
* @param userId A custom identifier for the current user. If passed as null, the user id
|
|
13
|
+
* will be auto generated. The user id in general is sticky across sessions.
|
|
14
|
+
* The provided user id must follow these conditions:
|
|
15
|
+
* 1. Cannot be an empty string.
|
|
16
|
+
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
17
|
+
* @param logLevel The level of logging to show in the device logcat stream ("Verbose", "Debug", "Info", "Warning", "Error", "None").
|
|
18
|
+
* @param allowMeteredNetworkUsage Allows uploading session data to the servers on device metered network.
|
|
19
|
+
* @param enableWebViewCapture Allows Clarity to capture the web views DOM content.
|
|
20
|
+
* @param allowedDomains The whitelisted domains to allow Clarity to capture their DOM content.
|
|
21
|
+
* If it contains "*" as an element, all domains will be captured.
|
|
22
|
+
*/
|
|
23
|
+
export function initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains) {
|
|
24
|
+
if (Clarity === null) {
|
|
25
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (Platform.OS !== 'android') {
|
|
29
|
+
console.warn("Clarity supports Android only for now.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sets a custom user id that can be used to identify the user. It has less
|
|
37
|
+
* restrictions than the userId parameter. You can pass any string and
|
|
38
|
+
* you can filter on it on the dashboard side. If you need the most efficient
|
|
39
|
+
* filtering on the dashboard, use the userId parameter if possible.
|
|
40
|
+
* <p>
|
|
41
|
+
* Note: custom user id cannot be null or empty, or consists only of whitespaces.
|
|
42
|
+
* </p>
|
|
43
|
+
* @param customUserId The custom user id to set.
|
|
44
|
+
*/
|
|
45
|
+
export function setCustomUserId(customUserId) {
|
|
46
|
+
if (Clarity === null) {
|
|
47
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (Platform.OS !== 'android') {
|
|
51
|
+
console.warn("Clarity supports Android only for now.");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
Clarity.setCustomUserId(customUserId);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the active session id. This can be used to correlate the Clarity session with other
|
|
59
|
+
* analytics tools that the developer may be using.
|
|
60
|
+
* @returns a promise that resolves to the current session id.
|
|
61
|
+
*/
|
|
62
|
+
export function getCurrentSessionId() {
|
|
63
|
+
if (Clarity === null) {
|
|
64
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
65
|
+
return new Promise(resolve => {
|
|
66
|
+
resolve("Undefined");
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (Platform.OS !== 'android') {
|
|
70
|
+
console.warn("Clarity supports Android only for now.");
|
|
71
|
+
return new Promise(resolve => {
|
|
72
|
+
resolve("Undefined");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return Clarity.getCurrentSessionId();
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","Clarity","initialize","projectId","userId","logLevel","allowMeteredNetworkUsage","enableWebViewCapture","allowedDomains","console","error","OS","warn","setCustomUserId","customUserId","getCurrentSessionId","Promise","resolve"],"sourceRoot":"..\\..\\src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAEtD,MAAMC,aAAa,GAChB,+EAA8E,GAC/ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,OAAO,GAAGN,aAAa,CAACM,OAAO;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CACxBC,SAAiB,EACjBC,MAAc,EACdC,QAAgB,EAChBC,wBAAiC,EACjCC,oBAA6B,EAC7BC,cAAwB,EAAE;EAC1B,IAAIP,OAAO,KAAK,IAAI,EAAE;IACpBQ,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEb,aAAa,CAAC;IACpE;EACF;EAEA,IAAID,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD;EACF;EAEAX,OAAO,CAACC,UAAU,CAACC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,wBAAwB,EAAEC,oBAAoB,EAAEC,cAAc,CAAC;AACjH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,eAAeA,CAACC,YAAoB,EAAE;EACpD,IAAIb,OAAO,KAAK,IAAI,EAAE;IACpBQ,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEb,aAAa,CAAC;IACpE;EACF;EAEA,IAAID,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD;EACF;EAEAX,OAAO,CAACY,eAAe,CAACC,YAAY,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAoB;EACrD,IAAId,OAAO,KAAK,IAAI,EAAE;IACpBQ,OAAO,CAACC,KAAK,CAAC,sCAAsC,EAAEb,aAAa,CAAC;IACpE,OAAO,IAAImB,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,IAAIrB,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BF,OAAO,CAACG,IAAI,CAAC,wCAAwC,CAAC;IACtD,OAAO,IAAII,OAAO,CAAEC,OAAO,IAAK;MAC9BA,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,OAAOhB,OAAO,CAACc,mBAAmB,EAAE;AACtC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initializes the Clarity plugin with the provided parameters.
|
|
3
|
+
*
|
|
4
|
+
* @param projectId The Clarity project id to send data to.
|
|
5
|
+
* @param userId A custom identifier for the current user. If passed as null, the user id
|
|
6
|
+
* will be auto generated. The user id in general is sticky across sessions.
|
|
7
|
+
* The provided user id must follow these conditions:
|
|
8
|
+
* 1. Cannot be an empty string.
|
|
9
|
+
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
10
|
+
* @param logLevel The level of logging to show in the device logcat stream ("Verbose", "Debug", "Info", "Warning", "Error", "None").
|
|
11
|
+
* @param allowMeteredNetworkUsage Allows uploading session data to the servers on device metered network.
|
|
12
|
+
* @param enableWebViewCapture Allows Clarity to capture the web views DOM content.
|
|
13
|
+
* @param allowedDomains The whitelisted domains to allow Clarity to capture their DOM content.
|
|
14
|
+
* If it contains "*" as an element, all domains will be captured.
|
|
15
|
+
*/
|
|
16
|
+
export declare function initialize(projectId: string, userId: string, logLevel: string, allowMeteredNetworkUsage: boolean, enableWebViewCapture: boolean, allowedDomains: string[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Sets a custom user id that can be used to identify the user. It has less
|
|
19
|
+
* restrictions than the userId parameter. You can pass any string and
|
|
20
|
+
* you can filter on it on the dashboard side. If you need the most efficient
|
|
21
|
+
* filtering on the dashboard, use the userId parameter if possible.
|
|
22
|
+
* <p>
|
|
23
|
+
* Note: custom user id cannot be null or empty, or consists only of whitespaces.
|
|
24
|
+
* </p>
|
|
25
|
+
* @param customUserId The custom user id to set.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setCustomUserId(customUserId: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the active session id. This can be used to correlate the Clarity session with other
|
|
30
|
+
* analytics tools that the developer may be using.
|
|
31
|
+
* @returns a promise that resolves to the current session id.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCurrentSessionId(): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,wBAAwB,EAAE,OAAO,EACjC,oBAAoB,EAAE,OAAO,EAC7B,cAAc,EAAE,MAAM,EAAE,QAYzB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,QAYnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBrD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-clarity",
|
|
3
|
+
"version": "0.0.1-beta.1",
|
|
4
|
+
"description": "A plugin to provide the Clarity experience for the React Native applications.",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__fixtures__",
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"prepack": "bob build",
|
|
34
|
+
"release": "release-it",
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
37
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"react-native",
|
|
41
|
+
"ios",
|
|
42
|
+
"android"
|
|
43
|
+
],
|
|
44
|
+
"repository": "https://github.com/microsoft/clarity-apps",
|
|
45
|
+
"author": "Microsoft - Clarity <clarity-apps-support@microsoft.com> (https://github.com/microsoft/clarity-apps)",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/microsoft/clarity-apps/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/microsoft/clarity-apps",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
56
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
57
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
58
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
59
|
+
"@types/jest": "^28.1.2",
|
|
60
|
+
"@types/react": "~17.0.21",
|
|
61
|
+
"@types/react-native": "0.70.0",
|
|
62
|
+
"commitlint": "^17.0.2",
|
|
63
|
+
"del-cli": "^5.0.0",
|
|
64
|
+
"eslint": "^8.4.1",
|
|
65
|
+
"eslint-config-prettier": "^8.5.0",
|
|
66
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
67
|
+
"jest": "^28.1.1",
|
|
68
|
+
"pod-install": "^0.1.0",
|
|
69
|
+
"prettier": "^2.0.5",
|
|
70
|
+
"react": "18.2.0",
|
|
71
|
+
"react-native": "0.71.3",
|
|
72
|
+
"react-native-builder-bob": "^0.20.0",
|
|
73
|
+
"release-it": "^15.0.0",
|
|
74
|
+
"typescript": "^4.5.2"
|
|
75
|
+
},
|
|
76
|
+
"resolutions": {
|
|
77
|
+
"@types/react": "17.0.21"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"react": "*",
|
|
81
|
+
"react-native": "*"
|
|
82
|
+
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">= 16.0.0"
|
|
85
|
+
},
|
|
86
|
+
"packageManager": "^yarn@1.22.15",
|
|
87
|
+
"jest": {
|
|
88
|
+
"preset": "react-native",
|
|
89
|
+
"modulePathIgnorePatterns": [
|
|
90
|
+
"<rootDir>/example/node_modules",
|
|
91
|
+
"<rootDir>/lib/"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
"commitlint": {
|
|
95
|
+
"extends": [
|
|
96
|
+
"@commitlint/config-conventional"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"release-it": {
|
|
100
|
+
"git": {
|
|
101
|
+
"commitMessage": "chore: release ${version}",
|
|
102
|
+
"tagName": "v${version}"
|
|
103
|
+
},
|
|
104
|
+
"npm": {
|
|
105
|
+
"publish": true
|
|
106
|
+
},
|
|
107
|
+
"github": {
|
|
108
|
+
"release": true
|
|
109
|
+
},
|
|
110
|
+
"plugins": {
|
|
111
|
+
"@release-it/conventional-changelog": {
|
|
112
|
+
"preset": "angular"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"eslintConfig": {
|
|
117
|
+
"root": true,
|
|
118
|
+
"extends": [
|
|
119
|
+
"@react-native-community",
|
|
120
|
+
"prettier"
|
|
121
|
+
],
|
|
122
|
+
"rules": {
|
|
123
|
+
"prettier/prettier": [
|
|
124
|
+
"error",
|
|
125
|
+
{
|
|
126
|
+
"quoteProps": "consistent",
|
|
127
|
+
"singleQuote": true,
|
|
128
|
+
"tabWidth": 2,
|
|
129
|
+
"trailingComma": "es5",
|
|
130
|
+
"useTabs": false
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"eslintIgnore": [
|
|
136
|
+
"node_modules/",
|
|
137
|
+
"lib/"
|
|
138
|
+
],
|
|
139
|
+
"prettier": {
|
|
140
|
+
"quoteProps": "consistent",
|
|
141
|
+
"singleQuote": true,
|
|
142
|
+
"tabWidth": 2,
|
|
143
|
+
"trailingComma": "es5",
|
|
144
|
+
"useTabs": false
|
|
145
|
+
},
|
|
146
|
+
"react-native-builder-bob": {
|
|
147
|
+
"source": "src",
|
|
148
|
+
"output": "lib",
|
|
149
|
+
"targets": [
|
|
150
|
+
"commonjs",
|
|
151
|
+
"module",
|
|
152
|
+
[
|
|
153
|
+
"typescript",
|
|
154
|
+
{
|
|
155
|
+
"project": "tsconfig.build.json"
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-clarity"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "11.0" }
|
|
15
|
+
s.source = { :git => "https://msasg.visualstudio.com/Clarity/_git/clarity-react-native.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
|
+
|
|
19
|
+
s.dependency "React-Core"
|
|
20
|
+
|
|
21
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
22
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
23
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
24
|
+
s.pod_target_xcconfig = {
|
|
25
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
26
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
27
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
28
|
+
}
|
|
29
|
+
s.dependency "React-Codegen"
|
|
30
|
+
s.dependency "RCT-Folly"
|
|
31
|
+
s.dependency "RCTRequired"
|
|
32
|
+
s.dependency "RCTTypeSafety"
|
|
33
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
34
|
+
end
|
|
35
|
+
end
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package 'react-native-clarity' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
+
'- You rebuilt the app after installing the package\n' +
|
|
7
|
+
'- You are not using Expo Go\n';
|
|
8
|
+
|
|
9
|
+
const Clarity = NativeModules.Clarity;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initializes the Clarity plugin with the provided parameters.
|
|
13
|
+
*
|
|
14
|
+
* @param projectId The Clarity project id to send data to.
|
|
15
|
+
* @param userId A custom identifier for the current user. If passed as null, the user id
|
|
16
|
+
* will be auto generated. The user id in general is sticky across sessions.
|
|
17
|
+
* The provided user id must follow these conditions:
|
|
18
|
+
* 1. Cannot be an empty string.
|
|
19
|
+
* 2. Should be base36 and smaller than "1Z141Z4".
|
|
20
|
+
* @param logLevel The level of logging to show in the device logcat stream ("Verbose", "Debug", "Info", "Warning", "Error", "None").
|
|
21
|
+
* @param allowMeteredNetworkUsage Allows uploading session data to the servers on device metered network.
|
|
22
|
+
* @param enableWebViewCapture Allows Clarity to capture the web views DOM content.
|
|
23
|
+
* @param allowedDomains The whitelisted domains to allow Clarity to capture their DOM content.
|
|
24
|
+
* If it contains "*" as an element, all domains will be captured.
|
|
25
|
+
*/
|
|
26
|
+
export function initialize(
|
|
27
|
+
projectId: string,
|
|
28
|
+
userId: string,
|
|
29
|
+
logLevel: string,
|
|
30
|
+
allowMeteredNetworkUsage: boolean,
|
|
31
|
+
enableWebViewCapture: boolean,
|
|
32
|
+
allowedDomains: string[]) {
|
|
33
|
+
if (Clarity === null) {
|
|
34
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (Platform.OS !== 'android') {
|
|
39
|
+
console.warn("Clarity supports Android only for now.");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Clarity.initialize(projectId, userId, logLevel, allowMeteredNetworkUsage, enableWebViewCapture, allowedDomains);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets a custom user id that can be used to identify the user. It has less
|
|
48
|
+
* restrictions than the userId parameter. You can pass any string and
|
|
49
|
+
* you can filter on it on the dashboard side. If you need the most efficient
|
|
50
|
+
* filtering on the dashboard, use the userId parameter if possible.
|
|
51
|
+
* <p>
|
|
52
|
+
* Note: custom user id cannot be null or empty, or consists only of whitespaces.
|
|
53
|
+
* </p>
|
|
54
|
+
* @param customUserId The custom user id to set.
|
|
55
|
+
*/
|
|
56
|
+
export function setCustomUserId(customUserId: string) {
|
|
57
|
+
if (Clarity === null) {
|
|
58
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (Platform.OS !== 'android') {
|
|
63
|
+
console.warn("Clarity supports Android only for now.");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Clarity.setCustomUserId(customUserId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns the active session id. This can be used to correlate the Clarity session with other
|
|
72
|
+
* analytics tools that the developer may be using.
|
|
73
|
+
* @returns a promise that resolves to the current session id.
|
|
74
|
+
*/
|
|
75
|
+
export function getCurrentSessionId(): Promise<string> {
|
|
76
|
+
if (Clarity === null) {
|
|
77
|
+
console.error("Clarity did not initialize properly.", LINKING_ERROR);
|
|
78
|
+
return new Promise((resolve) => {
|
|
79
|
+
resolve("Undefined");
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (Platform.OS !== 'android') {
|
|
84
|
+
console.warn("Clarity supports Android only for now.");
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
resolve("Undefined");
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return Clarity.getCurrentSessionId();
|
|
91
|
+
}
|