@appmetrica/react-native-analytics 3.4.0 → 4.0.0
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/android/build.gradle +12 -16
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/AndroidManifestNew.xml +5 -0
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaModule.java +56 -49
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaPackage.java +26 -14
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeDeferredDeeplinkListener.java +1 -3
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeDeferredDeeplinkParametersListener.java +4 -5
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeStartupParamsListener.java +23 -7
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReporterModule.java +17 -18
- package/android/src/main/java/io/appmetrica/analytics/reactnative/Utils.java +10 -28
- package/appmetrica-react-native-analytics.podspec +2 -23
- package/ios/AMARNAppMetrica.h +6 -2
- package/ios/{AMARNAppMetrica.m → AMARNAppMetrica.mm} +65 -39
- package/ios/{AMARNAppMetricaUtils.m → AMARNAppMetricaUtils.mm} +4 -1
- package/ios/AMARNReporter.h +6 -2
- package/ios/{AMARNReporter.m → AMARNReporter.mm} +24 -20
- package/ios/AMARNStartupParamsUtils.mm +33 -0
- package/lib/commonjs/deferredDeeplink.js.map +1 -1
- package/lib/commonjs/ecommerce.js +1 -1
- package/lib/commonjs/ecommerce.js.map +1 -1
- package/lib/commonjs/error.js +1 -1
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/externalAttribution.js.map +1 -1
- package/lib/commonjs/index.js +63 -52
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/reporter.js +17 -25
- package/lib/commonjs/reporter.js.map +1 -1
- package/lib/commonjs/revenue.js +1 -0
- package/lib/commonjs/revenue.js.map +1 -1
- package/lib/commonjs/specs/NativeAppMetrica.js +9 -0
- package/lib/commonjs/specs/NativeAppMetrica.js.map +1 -0
- package/lib/commonjs/specs/NativeReporter.js +9 -0
- package/lib/commonjs/specs/NativeReporter.js.map +1 -0
- package/lib/commonjs/types.js +27 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/userProfile.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/deferredDeeplink.js +1 -1
- package/lib/module/deferredDeeplink.js.map +1 -1
- package/lib/module/ecommerce.js +3 -1
- package/lib/module/ecommerce.js.map +1 -1
- package/lib/module/error.js +3 -1
- package/lib/module/error.js.map +1 -1
- package/lib/module/externalAttribution.js +2 -0
- package/lib/module/externalAttribution.js.map +1 -1
- package/lib/module/index.js +24 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/reporter.js +3 -10
- package/lib/module/reporter.js.map +1 -1
- package/lib/module/revenue.js +3 -0
- package/lib/module/revenue.js.map +1 -1
- package/lib/module/specs/NativeAppMetrica.js +5 -0
- package/lib/module/specs/NativeAppMetrica.js.map +1 -0
- package/lib/module/specs/NativeReporter.js +5 -0
- package/lib/module/specs/NativeReporter.js.map +1 -0
- package/lib/module/types.js +21 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/userProfile.js +2 -0
- package/lib/module/userProfile.js.map +1 -1
- package/lib/module/utils.js +2 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/ecommerce.d.ts +1 -1
- package/lib/typescript/src/ecommerce.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -50
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reporter.d.ts.map +1 -1
- package/lib/typescript/src/revenue.d.ts +1 -0
- package/lib/typescript/src/revenue.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeAppMetrica.d.ts +41 -0
- package/lib/typescript/src/specs/NativeAppMetrica.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeReporter.d.ts +21 -0
- package/lib/typescript/src/specs/NativeReporter.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +64 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +22 -8
- package/src/ecommerce.ts +2 -2
- package/src/index.ts +36 -82
- package/src/reporter.ts +1 -18
- package/src/revenue.ts +1 -0
- package/src/specs/NativeAppMetrica.ts +52 -0
- package/src/specs/NativeReporter.ts +22 -0
- package/src/types.ts +95 -0
- package/ios/AMARNStartupParamsUtils.m +0 -53
- /package/ios/{AMARNExceptionSerializer.m → AMARNExceptionSerializer.mm} +0 -0
- /package/ios/{AMARNExternalAttribution.m → AMARNExternalAttribution.mm} +0 -0
- /package/ios/{AMARNUserProfileSerializer.m → AMARNUserProfileSerializer.mm} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appmetrica/react-native-analytics",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "React Native plugin for AppMetrica analytics tool",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -55,20 +55,20 @@
|
|
|
55
55
|
"registry": "https://registry.npmjs.org/"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@react-native/eslint-config": "^0.
|
|
59
|
-
"@types/jest": "^29.5.
|
|
58
|
+
"@react-native/eslint-config": "^0.76.0",
|
|
59
|
+
"@types/jest": "^29.5.12",
|
|
60
60
|
"@types/jsdom": "^21.1.7",
|
|
61
|
-
"@types/react": "^18.2.44",
|
|
62
61
|
"@types/node": "^22.10.0",
|
|
62
|
+
"@types/react": "^18.2.6",
|
|
63
63
|
"del-cli": "^5.1.0",
|
|
64
64
|
"eslint": "^8.51.0",
|
|
65
65
|
"eslint-config-prettier": "^9.0.0",
|
|
66
66
|
"eslint-plugin-prettier": "^5.0.1",
|
|
67
67
|
"jest": "^29.7.0",
|
|
68
68
|
"prettier": "^3.0.3",
|
|
69
|
-
"react": "18.
|
|
70
|
-
"react-native": "0.
|
|
71
|
-
"react-native-builder-bob": "^0.
|
|
69
|
+
"react": "18.3.1",
|
|
70
|
+
"react-native": "0.76.0",
|
|
71
|
+
"react-native-builder-bob": "^0.40.17",
|
|
72
72
|
"typescript": "^5.2.2"
|
|
73
73
|
},
|
|
74
74
|
"resolutions": {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react": "*",
|
|
79
|
-
"react-native": "
|
|
79
|
+
"react-native": ">=0.76.0 <1.0.0"
|
|
80
80
|
},
|
|
81
81
|
"jest": {
|
|
82
82
|
"preset": "react-native",
|
|
@@ -128,5 +128,19 @@
|
|
|
128
128
|
}
|
|
129
129
|
]
|
|
130
130
|
]
|
|
131
|
+
},
|
|
132
|
+
"codegenConfig": {
|
|
133
|
+
"name": "AppMetricaNativeSpec",
|
|
134
|
+
"type": "modules",
|
|
135
|
+
"jsSrcsDir": "src/specs",
|
|
136
|
+
"android": {
|
|
137
|
+
"javaPackageName": "io.appmetrica.analytics.reactnative"
|
|
138
|
+
},
|
|
139
|
+
"ios": {
|
|
140
|
+
"modulesProvider": {
|
|
141
|
+
"AppMetrica": "AMARNAppMetrica",
|
|
142
|
+
"AppMetricaReporter": "AMARNReporter"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
131
145
|
}
|
|
132
146
|
}
|
package/src/ecommerce.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type ECommerceOrder = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
export type ECommerceEventType =
|
|
56
|
-
| '
|
|
56
|
+
| 'showScreenEvent'
|
|
57
57
|
| 'showProductCardEvent'
|
|
58
58
|
| 'showProductDetailsEvent'
|
|
59
59
|
| 'addCartItemEvent'
|
|
@@ -73,7 +73,7 @@ export interface ECommerceEvent {
|
|
|
73
73
|
export class ECommerce {
|
|
74
74
|
static showScreenEvent(screen: ECommerceScreen): ECommerceEvent {
|
|
75
75
|
return {
|
|
76
|
-
ecommerceEvent: '
|
|
76
|
+
ecommerceEvent: 'showScreenEvent',
|
|
77
77
|
ecommerceScreen: normalizeECommerceScreen(screen),
|
|
78
78
|
};
|
|
79
79
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
import { Linking
|
|
1
|
+
import { Linking } from 'react-native';
|
|
2
|
+
import AppMetricaNative from './specs/NativeAppMetrica';
|
|
2
3
|
import type { ECommerceEvent } from './ecommerce';
|
|
3
4
|
import type { AdRevenue, Revenue } from './revenue';
|
|
4
5
|
import type { UserProfile } from './userProfile';
|
|
5
6
|
import type { ExternalAttribution } from './externalAttribution';
|
|
6
7
|
import { normalizeAdRevenue } from './utils';
|
|
7
8
|
import { AppMetricaError } from './error';
|
|
8
|
-
import { Reporter
|
|
9
|
+
import { Reporter } from './reporter';
|
|
10
|
+
import type { IReporter, ReporterConfig } from './reporter';
|
|
9
11
|
import type {
|
|
10
12
|
DeferredDeeplinkListener,
|
|
11
13
|
DeferredDeeplinkParametersListener,
|
|
14
|
+
DeferredDeeplinkError
|
|
12
15
|
} from './deferredDeeplink';
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
: new Proxy(
|
|
23
|
-
{},
|
|
24
|
-
{
|
|
25
|
-
get() {
|
|
26
|
-
throw new Error(LINKING_ERROR);
|
|
27
|
-
},
|
|
28
|
-
}
|
|
29
|
-
);
|
|
17
|
+
import type {
|
|
18
|
+
AppMetricaConfig,
|
|
19
|
+
StartupParamsReason,
|
|
20
|
+
StartupParamsCallback,
|
|
21
|
+
Location,
|
|
22
|
+
StartupParamsItem
|
|
23
|
+
} from './types';
|
|
24
|
+
import { StartupParams } from './types';
|
|
30
25
|
|
|
31
26
|
var activated = false;
|
|
32
27
|
|
|
@@ -44,68 +39,13 @@ function appOpenTracking() {
|
|
|
44
39
|
Linking.addEventListener('url', callback);
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
export type AppMetricaConfig = {
|
|
48
|
-
apiKey: string;
|
|
49
|
-
appVersion?: string;
|
|
50
|
-
crashReporting?: boolean;
|
|
51
|
-
firstActivationAsUpdate?: boolean;
|
|
52
|
-
location?: Location;
|
|
53
|
-
locationTracking?: boolean;
|
|
54
|
-
logs?: boolean;
|
|
55
|
-
sessionTimeout?: number;
|
|
56
|
-
statisticsSending?: boolean;
|
|
57
|
-
preloadInfo?: PreloadInfo;
|
|
58
|
-
maxReportsInDatabaseCount?: number;
|
|
59
|
-
nativeCrashReporting?: boolean; // Android only
|
|
60
|
-
activationAsSessionStart?: boolean; // iOS only
|
|
61
|
-
sessionsAutoTracking?: boolean; // iOS only
|
|
62
|
-
appOpenTrackingEnabled?: boolean;
|
|
63
|
-
userProfileID?: string;
|
|
64
|
-
|
|
65
|
-
errorEnvironment?: Record<string, string | undefined>;
|
|
66
|
-
appEnvironment?: Record<string, string | undefined>;
|
|
67
|
-
maxReportsCount?: number;
|
|
68
|
-
dispatchPeriodSeconds?: number;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type PreloadInfo = {
|
|
72
|
-
trackingId: string;
|
|
73
|
-
additionalInfo?: Record<string, string>;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export type Location = {
|
|
77
|
-
latitude: number;
|
|
78
|
-
longitude: number;
|
|
79
|
-
altitude?: number;
|
|
80
|
-
accuracy?: number;
|
|
81
|
-
course?: number;
|
|
82
|
-
speed?: number;
|
|
83
|
-
timestamp?: number;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export type StartupParamsReason = 'UNKNOWN' | 'NETWORK' | 'INVALID_RESPONSE';
|
|
87
|
-
|
|
88
|
-
export type StartupParams = {
|
|
89
|
-
deviceIdHash?: string;
|
|
90
|
-
deviceId?: string;
|
|
91
|
-
uuid?: string;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type StartupParamsCallback = (
|
|
95
|
-
params?: StartupParams,
|
|
96
|
-
reason?: StartupParamsReason
|
|
97
|
-
) => void;
|
|
98
|
-
|
|
99
|
-
export const DEVICE_ID_HASH_KEY = 'appmetrica_device_id_hash';
|
|
100
|
-
export const DEVICE_ID_KEY = 'appmetrica_device_id';
|
|
101
|
-
export const UUID_KEY = 'appmetrica_uuid';
|
|
102
|
-
|
|
103
42
|
export * from './ecommerce';
|
|
104
43
|
export * from './revenue';
|
|
105
44
|
export * from './userProfile';
|
|
106
45
|
export * from './externalAttribution';
|
|
107
46
|
export type { IReporter, ReporterConfig } from './reporter';
|
|
108
47
|
export * from './deferredDeeplink';
|
|
48
|
+
export * from './types';
|
|
109
49
|
|
|
110
50
|
export default class AppMetrica {
|
|
111
51
|
|
|
@@ -122,11 +62,11 @@ export default class AppMetrica {
|
|
|
122
62
|
}
|
|
123
63
|
|
|
124
64
|
// Android only
|
|
125
|
-
static
|
|
65
|
+
static getLibraryApiLevel(): number {
|
|
126
66
|
return AppMetricaNative.getLibraryApiLevel();
|
|
127
67
|
}
|
|
128
68
|
|
|
129
|
-
static
|
|
69
|
+
static getLibraryVersion(): string {
|
|
130
70
|
return AppMetricaNative.getLibraryVersion();
|
|
131
71
|
}
|
|
132
72
|
|
|
@@ -166,7 +106,11 @@ export default class AppMetrica {
|
|
|
166
106
|
listener: StartupParamsCallback,
|
|
167
107
|
identifiers: Array<string>
|
|
168
108
|
) {
|
|
169
|
-
|
|
109
|
+
const adapter = (params?: Object, reason?: Object) => {
|
|
110
|
+
const startupParams = params ? new StartupParams(params as Record<string, StartupParamsItem>) : undefined;
|
|
111
|
+
listener(startupParams, reason as StartupParamsReason);
|
|
112
|
+
};
|
|
113
|
+
AppMetricaNative.requestStartupParams(adapter, identifiers);
|
|
170
114
|
}
|
|
171
115
|
|
|
172
116
|
static resumeSession() {
|
|
@@ -240,17 +184,21 @@ export default class AppMetrica {
|
|
|
240
184
|
AppMetricaNative.activateReporter(config);
|
|
241
185
|
}
|
|
242
186
|
|
|
243
|
-
static getDeviceId():
|
|
187
|
+
static getDeviceId(): string | null {
|
|
244
188
|
return AppMetricaNative.getDeviceId();
|
|
245
189
|
}
|
|
246
190
|
|
|
247
|
-
static getUuid():
|
|
191
|
+
static getUuid(): string | null {
|
|
248
192
|
return AppMetricaNative.getUuid();
|
|
249
193
|
}
|
|
250
194
|
|
|
251
195
|
static requestDeferredDeeplink(listener: DeferredDeeplinkListener) {
|
|
196
|
+
const adaptedOnFailure = (error: string, referrer?: string) => {
|
|
197
|
+
listener.onFailure(error as DeferredDeeplinkError, referrer);
|
|
198
|
+
};
|
|
199
|
+
|
|
252
200
|
AppMetricaNative.requestDeferredDeeplink(
|
|
253
|
-
|
|
201
|
+
adaptedOnFailure,
|
|
254
202
|
listener.onSuccess
|
|
255
203
|
);
|
|
256
204
|
}
|
|
@@ -258,9 +206,15 @@ export default class AppMetrica {
|
|
|
258
206
|
static requestDeferredDeeplinkParameters(
|
|
259
207
|
listener: DeferredDeeplinkParametersListener
|
|
260
208
|
) {
|
|
209
|
+
const adaptedOnFailure = (error: string, referrer?: string) => {
|
|
210
|
+
listener.onFailure(error as DeferredDeeplinkError, referrer);
|
|
211
|
+
};
|
|
212
|
+
const adaptedOnSuccess = (parameters: Object) => {
|
|
213
|
+
listener.onSuccess(parameters as Record<string, string>);
|
|
214
|
+
};
|
|
261
215
|
AppMetricaNative.requestDeferredDeeplinkParameters(
|
|
262
|
-
|
|
263
|
-
|
|
216
|
+
adaptedOnFailure,
|
|
217
|
+
adaptedOnSuccess
|
|
264
218
|
);
|
|
265
219
|
}
|
|
266
220
|
}
|
package/src/reporter.ts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
|
2
1
|
import type { UserProfile } from './userProfile';
|
|
3
2
|
import type { AdRevenue, Revenue } from './revenue';
|
|
4
3
|
import type { ECommerceEvent } from './ecommerce';
|
|
5
4
|
import { AppMetricaError } from './error';
|
|
6
|
-
|
|
7
|
-
const LINKING_ERROR =
|
|
8
|
-
`The package '@appmetrica/react-native-analytics' doesn't seem to be linked. Make sure: \n\n` +
|
|
9
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
10
|
-
'- You rebuilt the app after installing the package\n' +
|
|
11
|
-
'- You are not using Expo Go\n';
|
|
12
|
-
|
|
13
|
-
const ReporterNativeModule = NativeModules.AppMetricaReporter
|
|
14
|
-
? NativeModules.AppMetricaReporter
|
|
15
|
-
: new Proxy(
|
|
16
|
-
{},
|
|
17
|
-
{
|
|
18
|
-
get() {
|
|
19
|
-
throw new Error(LINKING_ERROR);
|
|
20
|
-
},
|
|
21
|
-
}
|
|
22
|
-
);
|
|
5
|
+
import ReporterNativeModule from './specs/NativeReporter';
|
|
23
6
|
|
|
24
7
|
export interface IReporter {
|
|
25
8
|
reportError(identifier: string, message?: string, _reason?: Error | Object): void;
|
package/src/revenue.ts
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
activate(config: Object): void;
|
|
6
|
+
pauseSession(): void;
|
|
7
|
+
resumeSession(): void;
|
|
8
|
+
sendEventsBuffer(): void;
|
|
9
|
+
setDataSendingEnabled(enabled: boolean): void;
|
|
10
|
+
setLocationTracking(enabled: boolean): void;
|
|
11
|
+
setLocation(location?: Object): void;
|
|
12
|
+
setUserProfileID(userProfileID?: string): void;
|
|
13
|
+
reportAppOpen(deeplink?: string): void;
|
|
14
|
+
reportEvent(eventName: string, attributes?: Object): void;
|
|
15
|
+
reportECommerce(event: Object): void;
|
|
16
|
+
reportRevenue(revenue: Object): void;
|
|
17
|
+
reportAdRevenue(adRevenue: Object): void;
|
|
18
|
+
reportUserProfile(userProfile: Object): void;
|
|
19
|
+
reportExternalAttribution(attribution: Object): void;
|
|
20
|
+
reportError(identifier: string, message?: string, error?: Object): void;
|
|
21
|
+
reportErrorWithoutIdentifier(message: string | undefined, error: Object): void;
|
|
22
|
+
reportUnhandledException(error: Object): void;
|
|
23
|
+
putAppEnvironmentValue(key: string, value?: string): void;
|
|
24
|
+
putErrorEnvironmentValue(key: string, value?: string): void;
|
|
25
|
+
clearAppEnvironment(): void;
|
|
26
|
+
activateReporter(config: Object): void;
|
|
27
|
+
touchReporter(apiKey: string): void;
|
|
28
|
+
requestStartupParams(
|
|
29
|
+
listener: (params?: Object, reason?: Object) => void,
|
|
30
|
+
identifiers: Array<string>
|
|
31
|
+
): void;
|
|
32
|
+
requestDeferredDeeplink(
|
|
33
|
+
onFailure: (error: string, referrer?: string) => void,
|
|
34
|
+
onSuccess: (deeplink: string) => void
|
|
35
|
+
): void;
|
|
36
|
+
requestDeferredDeeplinkParameters(
|
|
37
|
+
onFailure: (error: string, referrer?: string) => void,
|
|
38
|
+
onSuccess: (parameters: Object) => void
|
|
39
|
+
): void;
|
|
40
|
+
getDeviceId(): string | null;
|
|
41
|
+
getUuid(): string | null;
|
|
42
|
+
getLibraryVersion(): string;
|
|
43
|
+
getLibraryApiLevel(): number;
|
|
44
|
+
|
|
45
|
+
readonly getConstants: () => {
|
|
46
|
+
DEVICE_ID_HASH_KEY: string;
|
|
47
|
+
DEVICE_ID_KEY: string;
|
|
48
|
+
UUID_KEY: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('AppMetrica');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface Spec extends TurboModule {
|
|
5
|
+
pauseSession(apiKey: string): void;
|
|
6
|
+
resumeSession(apiKey: string): void;
|
|
7
|
+
sendEventsBuffer(apiKey: string): void;
|
|
8
|
+
setDataSendingEnabled(apiKey: string, enabled: boolean): void;
|
|
9
|
+
setUserProfileID(apiKey: string, userProfileID?: string): void;
|
|
10
|
+
reportEvent(apiKey: string, eventName: string, attributes?: Object): void;
|
|
11
|
+
reportECommerce(apiKey: string, event: Object): void;
|
|
12
|
+
reportRevenue(apiKey: string, revenue: Object): void;
|
|
13
|
+
reportAdRevenue(apiKey: string, adRevenue: Object): void;
|
|
14
|
+
reportUserProfile(apiKey: string, userProfile: Object): void;
|
|
15
|
+
reportError(apiKey: string, identifier: string, message?: string, error?: Object): void;
|
|
16
|
+
reportErrorWithoutIdentifier(apiKey: string, message: string | undefined, error: Object): void;
|
|
17
|
+
reportUnhandledException(apiKey: string, error: Object): void;
|
|
18
|
+
putAppEnvironmentValue(apiKey: string, key: string, value?: string): void;
|
|
19
|
+
clearAppEnvironment(apiKey: string): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('AppMetricaReporter');
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import AppMetricaNative from './specs/NativeAppMetrica';
|
|
2
|
+
|
|
3
|
+
export type AppMetricaConfig = {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
appVersion?: string;
|
|
6
|
+
crashReporting?: boolean;
|
|
7
|
+
firstActivationAsUpdate?: boolean;
|
|
8
|
+
location?: Location;
|
|
9
|
+
locationTracking?: boolean;
|
|
10
|
+
logs?: boolean;
|
|
11
|
+
sessionTimeout?: number;
|
|
12
|
+
statisticsSending?: boolean;
|
|
13
|
+
preloadInfo?: PreloadInfo;
|
|
14
|
+
maxReportsInDatabaseCount?: number;
|
|
15
|
+
nativeCrashReporting?: boolean;
|
|
16
|
+
activationAsSessionStart?: boolean;
|
|
17
|
+
sessionsAutoTracking?: boolean;
|
|
18
|
+
appOpenTrackingEnabled?: boolean;
|
|
19
|
+
userProfileID?: string;
|
|
20
|
+
errorEnvironment?: Record<string, string | undefined>;
|
|
21
|
+
appEnvironment?: Record<string, string | undefined>;
|
|
22
|
+
maxReportsCount?: number;
|
|
23
|
+
dispatchPeriodSeconds?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type PreloadInfo = {
|
|
27
|
+
trackingId: string;
|
|
28
|
+
additionalInfo?: Record<string, string>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type Location = {
|
|
32
|
+
latitude: number;
|
|
33
|
+
longitude: number;
|
|
34
|
+
altitude?: number;
|
|
35
|
+
accuracy?: number;
|
|
36
|
+
course?: number;
|
|
37
|
+
speed?: number;
|
|
38
|
+
timestamp?: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type StartupParamsReason = 'UNKNOWN' | 'NETWORK' | 'INVALID_RESPONSE';
|
|
42
|
+
|
|
43
|
+
export class StartupParams {
|
|
44
|
+
|
|
45
|
+
private static constants = AppMetricaNative.getConstants()
|
|
46
|
+
static readonly DEVICE_ID_HASH_KEY = this.constants.DEVICE_ID_HASH_KEY;
|
|
47
|
+
static readonly DEVICE_ID_KEY = this.constants.DEVICE_ID_KEY;
|
|
48
|
+
static readonly UUID_KEY = this.constants.UUID_KEY;
|
|
49
|
+
|
|
50
|
+
readonly deviceIdHash?: string;
|
|
51
|
+
readonly deviceId?: string;
|
|
52
|
+
readonly uuid?: string;
|
|
53
|
+
|
|
54
|
+
constructor(
|
|
55
|
+
readonly params?: Record<string, StartupParamsItem>
|
|
56
|
+
) {
|
|
57
|
+
if (params) {
|
|
58
|
+
this.deviceIdHash = this.parameterForKey(StartupParams.DEVICE_ID_HASH_KEY);
|
|
59
|
+
this.deviceId = this.parameterForKey(StartupParams.DEVICE_ID_KEY);
|
|
60
|
+
this.uuid = this.parameterForKey(StartupParams.UUID_KEY);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
parameterForKey(key: string): string | undefined {
|
|
65
|
+
return this.params?.[key]?.id;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type StartupParamsCallback = (
|
|
70
|
+
params?: StartupParams,
|
|
71
|
+
reason?: StartupParamsReason
|
|
72
|
+
) => void;
|
|
73
|
+
|
|
74
|
+
export type ReporterConfig = {
|
|
75
|
+
apiKey: string;
|
|
76
|
+
sessionTimeout?: number;
|
|
77
|
+
statisticsSending?: boolean;
|
|
78
|
+
maxReportsCount?: number;
|
|
79
|
+
dispatchPeriodSeconds?: number;
|
|
80
|
+
logs?: boolean;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type StartupParamsItem = {
|
|
84
|
+
id?: string;
|
|
85
|
+
errorDetails?: string;
|
|
86
|
+
status: StartupParamsItemStatus;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type StartupParamsItemStatus =
|
|
90
|
+
| 'OK'
|
|
91
|
+
| 'FEATURE_DISABLED'
|
|
92
|
+
| 'INVALID_VALUE_FROM_PROVIDER'
|
|
93
|
+
| 'NETWORK_ERROR'
|
|
94
|
+
| 'PROVIDER_UNAVAILABLE'
|
|
95
|
+
| 'UNKNOWN_ERROR';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#import "AMARNStartupParamsUtils.h"
|
|
3
|
-
#import <AppMetricaCore/AppMetricaCore.h>
|
|
4
|
-
|
|
5
|
-
@implementation AMARNStartupParamsUtils
|
|
6
|
-
|
|
7
|
-
+ (NSArray *)toStartupKeys:(NSArray *)keys
|
|
8
|
-
{
|
|
9
|
-
NSMutableArray *keysArray = [[NSMutableArray alloc] init];
|
|
10
|
-
for (NSString *item in keys) {
|
|
11
|
-
if ([item isEqualToString:@"appmetrica_device_id_hash"]) {
|
|
12
|
-
[keysArray addObject:kAMADeviceIDHashKey];
|
|
13
|
-
}
|
|
14
|
-
if ([item isEqualToString:@"appmetrica_device_id"]) {
|
|
15
|
-
[keysArray addObject:kAMADeviceIDKey];
|
|
16
|
-
}
|
|
17
|
-
if ([item isEqualToString:@"appmetrica_uuid"]) {
|
|
18
|
-
[keysArray addObject:kAMAUUIDKey];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return keysArray;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
+ (NSDictionary *)toStrartupParamsResult:(NSDictionary *)resultDict
|
|
25
|
-
{
|
|
26
|
-
if (resultDict == nil) {
|
|
27
|
-
return nil;
|
|
28
|
-
}
|
|
29
|
-
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
|
|
30
|
-
if (resultDict[@"appmetrica_deviceIDHash"] != nil) {
|
|
31
|
-
[result setValue:resultDict[kAMADeviceIDHashKey] forKey:@"deviceIdHash"];
|
|
32
|
-
}
|
|
33
|
-
if (resultDict[@"appmetrica_deviceID"] != nil) {
|
|
34
|
-
[result setValue:resultDict[kAMADeviceIDKey] forKey:@"deviceId"];
|
|
35
|
-
}
|
|
36
|
-
if (resultDict[@"appmetrica_uuid"] != nil) {
|
|
37
|
-
[result setValue:resultDict[kAMAUUIDKey] forKey:@"uuid"];
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
+ (NSString *)stringFromRequestStartupParamsError:(NSError *)error
|
|
43
|
-
{
|
|
44
|
-
if (error == nil) {
|
|
45
|
-
return nil;
|
|
46
|
-
}
|
|
47
|
-
if ([error.domain isEqualToString:NSURLErrorDomain]) {
|
|
48
|
-
return @"NETWORK";
|
|
49
|
-
}
|
|
50
|
-
return @"UNKNOWN";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|