@appmetrica/react-native-analytics 3.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/LICENSE.md +21 -0
- package/README.md +29 -0
- package/android/build.gradle +89 -0
- package/android/gradle.properties +3 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaModule.java +139 -0
- package/android/src/main/java/io/appmetrica/analytics/reactnative/AppMetricaPackage.java +28 -0
- package/android/src/main/java/io/appmetrica/analytics/reactnative/ReactNativeStartupParamsListener.java +38 -0
- package/android/src/main/java/io/appmetrica/analytics/reactnative/Utils.java +483 -0
- package/appmetrica-react-native-analytics.podspec +43 -0
- package/ios/AMARNAppMetrica.h +6 -0
- package/ios/AMARNAppMetrica.m +120 -0
- package/ios/AMARNAppMetricaUtils.h +24 -0
- package/ios/AMARNAppMetricaUtils.m +368 -0
- package/ios/AMARNStartupParamsUtils.h +8 -0
- package/ios/AMARNStartupParamsUtils.m +53 -0
- package/lib/commonjs/ecommerce.js +54 -0
- package/lib/commonjs/ecommerce.js.map +1 -0
- package/lib/commonjs/index.js +125 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/revenue.js +16 -0
- package/lib/commonjs/revenue.js.map +1 -0
- package/lib/module/ecommerce.js +47 -0
- package/lib/module/ecommerce.js.map +1 -0
- package/lib/module/index.js +91 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/revenue.js +10 -0
- package/lib/module/revenue.js.map +1 -0
- package/lib/typescript/src/ecommerce.d.ts +58 -0
- package/lib/typescript/src/ecommerce.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +64 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/revenue.d.ts +34 -0
- package/lib/typescript/src/revenue.d.ts.map +1 -0
- package/package.json +130 -0
- package/src/ecommerce.ts +122 -0
- package/src/index.ts +169 -0
- package/src/revenue.ts +36 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class ECommerce {
|
|
2
|
+
static showScreenEvent(screen) {
|
|
3
|
+
return {
|
|
4
|
+
ecommerceEvent: 'showSceenEvent',
|
|
5
|
+
ecommerceScreen: screen
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
static showProductCardEvent(product, screen) {
|
|
9
|
+
return {
|
|
10
|
+
ecommerceEvent: 'showProductCardEvent',
|
|
11
|
+
ecommerceScreen: screen,
|
|
12
|
+
product: product
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static showProductDetailsEvent(product, referrer) {
|
|
16
|
+
return {
|
|
17
|
+
ecommerceEvent: 'showProductDetailsEvent',
|
|
18
|
+
product: product,
|
|
19
|
+
referrer: referrer
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static addCartItemEvent(item) {
|
|
23
|
+
return {
|
|
24
|
+
ecommerceEvent: 'addCartItemEvent',
|
|
25
|
+
cartItem: item
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static removeCartItemEvent(item) {
|
|
29
|
+
return {
|
|
30
|
+
ecommerceEvent: 'removeCartItemEvent',
|
|
31
|
+
cartItem: item
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
static beginCheckoutEvent(order) {
|
|
35
|
+
return {
|
|
36
|
+
ecommerceEvent: 'beginCheckoutEvent',
|
|
37
|
+
order: order
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
static purchaseEvent(order) {
|
|
41
|
+
return {
|
|
42
|
+
ecommerceEvent: 'purchaseEvent',
|
|
43
|
+
order: order
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ecommerce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ECommerce","showScreenEvent","screen","ecommerceEvent","ecommerceScreen","showProductCardEvent","product","showProductDetailsEvent","referrer","addCartItemEvent","item","cartItem","removeCartItemEvent","beginCheckoutEvent","order","purchaseEvent"],"sourceRoot":"../../src","sources":["ecommerce.ts"],"mappings":"AAgEA,OAAO,MAAMA,SAAS,CAAC;EACrB,OAAOC,eAAeA,CAACC,MAAuB,EAAkB;IAC9D,OAAO;MACLC,cAAc,EAAE,gBAAgB;MAChCC,eAAe,EAAEF;IACnB,CAAC;EACH;EAEA,OAAOG,oBAAoBA,CACzBC,OAAyB,EACzBJ,MAAuB,EACP;IAChB,OAAO;MACLC,cAAc,EAAE,sBAAsB;MACtCC,eAAe,EAAEF,MAAM;MACvBI,OAAO,EAAEA;IACX,CAAC;EACH;EAEA,OAAOC,uBAAuBA,CAC5BD,OAAyB,EACzBE,QAA4B,EACZ;IAChB,OAAO;MACLL,cAAc,EAAE,yBAAyB;MACzCG,OAAO,EAAEA,OAAO;MAChBE,QAAQ,EAAEA;IACZ,CAAC;EACH;EAEA,OAAOC,gBAAgBA,CAACC,IAAuB,EAAkB;IAC/D,OAAO;MACLP,cAAc,EAAE,kBAAkB;MAClCQ,QAAQ,EAAED;IACZ,CAAC;EACH;EAEA,OAAOE,mBAAmBA,CAACF,IAAuB,EAAkB;IAClE,OAAO;MACLP,cAAc,EAAE,qBAAqB;MACrCQ,QAAQ,EAAED;IACZ,CAAC;EACH;EAEA,OAAOG,kBAAkBA,CAACC,KAAqB,EAAkB;IAC/D,OAAO;MACLX,cAAc,EAAE,oBAAoB;MACpCW,KAAK,EAAEA;IACT,CAAC;EACH;EAEA,OAAOC,aAAaA,CAACD,KAAqB,EAAkB;IAC1D,OAAO;MACLX,cAAc,EAAE,eAAe;MAC/BW,KAAK,EAAEA;IACT,CAAC;EACH;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Linking, NativeModules, Platform } from 'react-native';
|
|
2
|
+
const LINKING_ERROR = `The package '@appmetrica/react-native-analytics' 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 AppMetricaNative = NativeModules.AppMetrica ? NativeModules.AppMetrica : new Proxy({}, {
|
|
7
|
+
get() {
|
|
8
|
+
throw new Error(LINKING_ERROR);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var activated = false;
|
|
12
|
+
function appOpenTracking() {
|
|
13
|
+
const getUrlAsync = async () => {
|
|
14
|
+
const initialUrl = await Linking.getInitialURL();
|
|
15
|
+
if (initialUrl != null) {
|
|
16
|
+
AppMetricaNative.reportAppOpen(initialUrl);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const callback = event => {
|
|
20
|
+
AppMetricaNative.reportAppOpen(event.url);
|
|
21
|
+
};
|
|
22
|
+
getUrlAsync();
|
|
23
|
+
Linking.addEventListener('url', callback);
|
|
24
|
+
}
|
|
25
|
+
export const DEVICE_ID_HASH_KEY = 'appmetrica_device_id_hash';
|
|
26
|
+
export const DEVICE_ID_KEY = 'appmetrica_device_id';
|
|
27
|
+
export const UUID_KEY = 'appmetrica_uuid';
|
|
28
|
+
export * from './ecommerce';
|
|
29
|
+
export * from './revenue';
|
|
30
|
+
export default class AppMetrica {
|
|
31
|
+
static activate(config) {
|
|
32
|
+
if (!activated) {
|
|
33
|
+
AppMetricaNative.activate(config);
|
|
34
|
+
if (config.appOpenTrackingEnabled !== false) {
|
|
35
|
+
appOpenTracking();
|
|
36
|
+
}
|
|
37
|
+
activated = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Android only
|
|
42
|
+
static async getLibraryApiLevel() {
|
|
43
|
+
return AppMetricaNative.getLibraryApiLevel();
|
|
44
|
+
}
|
|
45
|
+
static async getLibraryVersion() {
|
|
46
|
+
return AppMetricaNative.getLibraryVersion();
|
|
47
|
+
}
|
|
48
|
+
static pauseSession() {
|
|
49
|
+
AppMetricaNative.pauseSession();
|
|
50
|
+
}
|
|
51
|
+
static reportAppOpen(deeplink) {
|
|
52
|
+
AppMetricaNative.reportAppOpen(deeplink);
|
|
53
|
+
}
|
|
54
|
+
static reportError(identifier, message, _reason) {
|
|
55
|
+
AppMetricaNative.reportError(identifier, message);
|
|
56
|
+
}
|
|
57
|
+
static reportEvent(eventName, attributes) {
|
|
58
|
+
AppMetricaNative.reportEvent(eventName, attributes);
|
|
59
|
+
}
|
|
60
|
+
static requestStartupParams(listener, identifiers) {
|
|
61
|
+
AppMetricaNative.requestStartupParams(identifiers, listener);
|
|
62
|
+
}
|
|
63
|
+
static resumeSession() {
|
|
64
|
+
AppMetricaNative.resumeSession();
|
|
65
|
+
}
|
|
66
|
+
static sendEventsBuffer() {
|
|
67
|
+
AppMetricaNative.sendEventsBuffer();
|
|
68
|
+
}
|
|
69
|
+
static setLocation(location) {
|
|
70
|
+
AppMetricaNative.setLocation(location);
|
|
71
|
+
}
|
|
72
|
+
static setLocationTracking(enabled) {
|
|
73
|
+
AppMetricaNative.setLocationTracking(enabled);
|
|
74
|
+
}
|
|
75
|
+
static setDataSendingEnabled(enabled) {
|
|
76
|
+
AppMetricaNative.setDataSendingEnabled(enabled);
|
|
77
|
+
}
|
|
78
|
+
static setUserProfileID(userProfileID) {
|
|
79
|
+
AppMetricaNative.setUserProfileID(userProfileID);
|
|
80
|
+
}
|
|
81
|
+
static reportECommerce(event) {
|
|
82
|
+
AppMetricaNative.reportECommerce(event);
|
|
83
|
+
}
|
|
84
|
+
static reportRevenue(revenue) {
|
|
85
|
+
AppMetricaNative.reportRevenue(revenue);
|
|
86
|
+
}
|
|
87
|
+
static reportAdRevenue(adRevenue) {
|
|
88
|
+
AppMetricaNative.reportAdRevenue(adRevenue);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Linking","NativeModules","Platform","LINKING_ERROR","select","ios","default","AppMetricaNative","AppMetrica","Proxy","get","Error","activated","appOpenTracking","getUrlAsync","initialUrl","getInitialURL","reportAppOpen","callback","event","url","addEventListener","DEVICE_ID_HASH_KEY","DEVICE_ID_KEY","UUID_KEY","activate","config","appOpenTrackingEnabled","getLibraryApiLevel","getLibraryVersion","pauseSession","deeplink","reportError","identifier","message","_reason","reportEvent","eventName","attributes","requestStartupParams","listener","identifiers","resumeSession","sendEventsBuffer","setLocation","location","setLocationTracking","enabled","setDataSendingEnabled","setUserProfileID","userProfileID","reportECommerce","reportRevenue","revenue","reportAdRevenue","adRevenue"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,OAAO,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAI/D,MAAMC,aAAa,GACjB,6FAA6F,GAC7FD,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,gBAAgB,GAAGN,aAAa,CAACO,UAAU,GAC7CP,aAAa,CAACO,UAAU,GACxB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,IAAIS,SAAS,GAAG,KAAK;AAErB,SAASC,eAAeA,CAAA,EAAG;EACzB,MAAMC,WAAW,GAAG,MAAAA,CAAA,KAAY;IAC9B,MAAMC,UAAU,GAAG,MAAMf,OAAO,CAACgB,aAAa,CAAC,CAAC;IAChD,IAAID,UAAU,IAAI,IAAI,EAAE;MACtBR,gBAAgB,CAACU,aAAa,CAACF,UAAU,CAAC;IAC5C;EACF,CAAC;EACD,MAAMG,QAAQ,GAAIC,KAAsB,IAAK;IAC3CZ,gBAAgB,CAACU,aAAa,CAACE,KAAK,CAACC,GAAG,CAAC;EAC3C,CAAC;EACDN,WAAW,CAAC,CAAC;EACbd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ED,QAAQ,CAAC;EAC9D;EAEA,OAAOE,aAAaA,CAAA,EAAG;IACrBnC,gBAAgB,CAACmC,aAAa,CAAC,CAAC;EAClC;EAEA,OAAOC,gBAAgBA,CAAA,EAAG;IACxBpC,gBAAgB,CAACoC,gBAAgB,CAAC,CAAC;EACrC;EAEA,OAAOC,WAAWA,CAACC,QAAmB,EAAE;IACtCtC,gBAAgB,CAACqC,WAAW,CAACC,QAAQ,CAAC;EACxC;EAEA,OAAOC,mBAAmBA,CAACC,OAAgB,EAAE;IAC3CxC,gBAAgB,CAACuC,mBAAmB,CAACC,OAAO,CAAC;EAC/C;EAEA,OAAOC,qBAAqBA,CAACD,OAAgB,EAAE;IAC7CxC,gBAAgB,CAACyC,qBAAqB,CAACD,OAAO,CAAC;EACjD;EAEA,OAAOE,gBAAgBA,CAACC,aAAsB,EAAE;IAC9C3C,gBAAgB,CAAC0C,gBAAgB,CAACC,aAAa,CAAC;EAClD;EAEA,OAAOC,eAAeA,CAAChC,KAAqB,EAAE;IAC5CZ,gBAAgB,CAAC4C,eAAe,CAAChC,KAAK,CAAC;EACzC;EAEA,OAAOiC,aAAaA,CAACC,OAAgB,EAAE;IACrC9C,gBAAgB,CAAC6C,aAAa,CAACC,OAAO,CAAC;EACzC;EAEA,OAAOC,eAAeA,CAACC,SAAoB,EAAE;IAC3ChD,gBAAgB,CAAC+C,eAAe,CAACC,SAAS,CAAC;EAC7C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export let AdType = /*#__PURE__*/function (AdType) {
|
|
2
|
+
AdType["NATIVE"] = "native";
|
|
3
|
+
AdType["BANNER"] = "banner";
|
|
4
|
+
AdType["MREC"] = "mrec";
|
|
5
|
+
AdType["INTERSTITIAL"] = "interstitial";
|
|
6
|
+
AdType["REWARDED"] = "rewarded";
|
|
7
|
+
AdType["OTHER"] = "other";
|
|
8
|
+
return AdType;
|
|
9
|
+
}({});
|
|
10
|
+
//# sourceMappingURL=revenue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AdType"],"sourceRoot":"../../src","sources":["revenue.ts"],"mappings":"AA4BA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type ECommerceScreen = {
|
|
2
|
+
name: string;
|
|
3
|
+
searchQuery?: string;
|
|
4
|
+
payload?: Map<string, string>;
|
|
5
|
+
categoriesPath?: Array<string>;
|
|
6
|
+
};
|
|
7
|
+
export type ECommerceAmount = {
|
|
8
|
+
amount: number | string;
|
|
9
|
+
unit: string;
|
|
10
|
+
};
|
|
11
|
+
export type ECommercePrice = {
|
|
12
|
+
amount: ECommerceAmount;
|
|
13
|
+
internalComponents?: Array<ECommerceAmount>;
|
|
14
|
+
};
|
|
15
|
+
export type ECommerceProduct = {
|
|
16
|
+
sku: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
actualPrice?: ECommercePrice;
|
|
19
|
+
originalPrice?: ECommercePrice;
|
|
20
|
+
promocodes?: Array<string>;
|
|
21
|
+
categoriesPath?: Array<string>;
|
|
22
|
+
payload?: Map<string, string>;
|
|
23
|
+
};
|
|
24
|
+
export type ECommerceReferrer = {
|
|
25
|
+
type?: string;
|
|
26
|
+
identifier?: string;
|
|
27
|
+
screen?: ECommerceScreen;
|
|
28
|
+
};
|
|
29
|
+
export type ECommerceCartItem = {
|
|
30
|
+
product: ECommerceProduct;
|
|
31
|
+
price: ECommercePrice;
|
|
32
|
+
quantity: number | string;
|
|
33
|
+
referrer?: ECommerceReferrer;
|
|
34
|
+
};
|
|
35
|
+
export type ECommerceOrder = {
|
|
36
|
+
orderId: string;
|
|
37
|
+
products: Array<ECommerceCartItem>;
|
|
38
|
+
payload?: Map<string, string>;
|
|
39
|
+
};
|
|
40
|
+
export type ECommerceEventType = 'showSceenEvent' | 'showProductCardEvent' | 'showProductDetailsEvent' | 'addCartItemEvent' | 'removeCartItemEvent' | 'beginCheckoutEvent' | 'purchaseEvent';
|
|
41
|
+
export interface ECommerceEvent {
|
|
42
|
+
ecommerceEvent: ECommerceEventType;
|
|
43
|
+
ecommerceScreen?: ECommerceScreen;
|
|
44
|
+
product?: ECommerceProduct;
|
|
45
|
+
referrer?: ECommerceReferrer;
|
|
46
|
+
cartItem?: ECommerceCartItem;
|
|
47
|
+
order?: ECommerceOrder;
|
|
48
|
+
}
|
|
49
|
+
export declare class ECommerce {
|
|
50
|
+
static showScreenEvent(screen: ECommerceScreen): ECommerceEvent;
|
|
51
|
+
static showProductCardEvent(product: ECommerceProduct, screen: ECommerceScreen): ECommerceEvent;
|
|
52
|
+
static showProductDetailsEvent(product: ECommerceProduct, referrer?: ECommerceReferrer): ECommerceEvent;
|
|
53
|
+
static addCartItemEvent(item: ECommerceCartItem): ECommerceEvent;
|
|
54
|
+
static removeCartItemEvent(item: ECommerceCartItem): ECommerceEvent;
|
|
55
|
+
static beginCheckoutEvent(order: ECommerceOrder): ECommerceEvent;
|
|
56
|
+
static purchaseEvent(order: ECommerceOrder): ECommerceEvent;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ecommerce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecommerce.d.ts","sourceRoot":"","sources":["../../../src/ecommerce.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,MA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,kBAAkB,CAAC;IACnC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB;AAED,qBAAa,SAAS;IACpB,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc;IAO/D,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,eAAe,GACtB,cAAc;IAQjB,MAAM,CAAC,uBAAuB,CAC5B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,cAAc;IAQjB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc;IAOhE,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc;IAOnE,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc;IAOhE,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc;CAM5D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ECommerceEvent } from './ecommerce';
|
|
2
|
+
import type { AdRevenue, Revenue } from './revenue';
|
|
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
|
+
};
|
|
20
|
+
export type PreloadInfo = {
|
|
21
|
+
trackingId: string;
|
|
22
|
+
additionalInfo?: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
export type Location = {
|
|
25
|
+
latitude: number;
|
|
26
|
+
longitude: number;
|
|
27
|
+
altitude?: number;
|
|
28
|
+
accuracy?: number;
|
|
29
|
+
course?: number;
|
|
30
|
+
speed?: number;
|
|
31
|
+
timestamp?: number;
|
|
32
|
+
};
|
|
33
|
+
export type StartupParamsReason = 'UNKNOWN' | 'NETWORK' | 'INVALID_RESPONSE';
|
|
34
|
+
export type StartupParams = {
|
|
35
|
+
deviceIdHash?: string;
|
|
36
|
+
deviceId?: string;
|
|
37
|
+
uuid?: string;
|
|
38
|
+
};
|
|
39
|
+
export type StartupParamsCallback = (params?: StartupParams, reason?: StartupParamsReason) => void;
|
|
40
|
+
export declare const DEVICE_ID_HASH_KEY = "appmetrica_device_id_hash";
|
|
41
|
+
export declare const DEVICE_ID_KEY = "appmetrica_device_id";
|
|
42
|
+
export declare const UUID_KEY = "appmetrica_uuid";
|
|
43
|
+
export * from './ecommerce';
|
|
44
|
+
export * from './revenue';
|
|
45
|
+
export default class AppMetrica {
|
|
46
|
+
static activate(config: AppMetricaConfig): void;
|
|
47
|
+
static getLibraryApiLevel(): Promise<number>;
|
|
48
|
+
static getLibraryVersion(): Promise<string>;
|
|
49
|
+
static pauseSession(): void;
|
|
50
|
+
static reportAppOpen(deeplink?: string): void;
|
|
51
|
+
static reportError(identifier: string, message: string, _reason: Object): void;
|
|
52
|
+
static reportEvent(eventName: string, attributes?: Record<string, any>): void;
|
|
53
|
+
static requestStartupParams(listener: StartupParamsCallback, identifiers: Array<string>): void;
|
|
54
|
+
static resumeSession(): void;
|
|
55
|
+
static sendEventsBuffer(): void;
|
|
56
|
+
static setLocation(location?: Location): void;
|
|
57
|
+
static setLocationTracking(enabled: boolean): void;
|
|
58
|
+
static setDataSendingEnabled(enabled: boolean): void;
|
|
59
|
+
static setUserProfileID(userProfileID?: string): void;
|
|
60
|
+
static reportECommerce(event: ECommerceEvent): void;
|
|
61
|
+
static reportRevenue(revenue: Revenue): void;
|
|
62
|
+
static reportAdRevenue(adRevenue: AdRevenue): void;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmCpD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,CAA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M,CAAC,MAAM,EAAE,GAAG,CAAC;IAItE,MAAM,CAAC,oBAAoB,CACzB,QAAQ,EAAE,qBAAqB,EAC/B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;IAK5B,MAAM,CAAC,aAAa;IAIpB,MAAM,CAAC,gBAAgB;IAIvB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAItC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO;IAI3C,MAAM,CAAC,qBAAqB,CAAC,OAAO,EAAE,OAAO;IAI7C,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,MAAM;IAI9C,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,cAAc;IAI5C,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO;IAIrC,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS;CAG5C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Revenue = {
|
|
2
|
+
price: number;
|
|
3
|
+
currency: string;
|
|
4
|
+
productID?: string;
|
|
5
|
+
quantity?: number;
|
|
6
|
+
payload?: string;
|
|
7
|
+
receipt?: Receipt;
|
|
8
|
+
};
|
|
9
|
+
export type Receipt = {
|
|
10
|
+
transactionID?: string;
|
|
11
|
+
receiptData?: string;
|
|
12
|
+
signature?: string;
|
|
13
|
+
};
|
|
14
|
+
export type AdRevenue = {
|
|
15
|
+
price: number | string;
|
|
16
|
+
currency: string;
|
|
17
|
+
payload?: Map<string, string>;
|
|
18
|
+
adNetwork?: string;
|
|
19
|
+
adPlacementID?: string;
|
|
20
|
+
adPlacementName?: string;
|
|
21
|
+
adType?: AdType;
|
|
22
|
+
adUnitID?: string;
|
|
23
|
+
adUnitName?: string;
|
|
24
|
+
precision?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare enum AdType {
|
|
27
|
+
NATIVE = "native",
|
|
28
|
+
BANNER = "banner",
|
|
29
|
+
MREC = "mrec",
|
|
30
|
+
INTERSTITIAL = "interstitial",
|
|
31
|
+
REWARDED = "rewarded",
|
|
32
|
+
OTHER = "other"
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=revenue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenue.d.ts","sourceRoot":"","sources":["../../../src/revenue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,MAAM;IAChB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@appmetrica/react-native-analytics",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "React Native plugin for AppMetrica analytics tool",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/src/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
|
+
"!ios/build",
|
|
18
|
+
"!android/build",
|
|
19
|
+
"!android/gradle",
|
|
20
|
+
"!android/gradlew",
|
|
21
|
+
"!android/gradlew.bat",
|
|
22
|
+
"!android/local.properties",
|
|
23
|
+
"!**/__tests__",
|
|
24
|
+
"!**/__fixtures__",
|
|
25
|
+
"!**/__mocks__",
|
|
26
|
+
"!**/.*"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "jest",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
32
|
+
"clean": "del-cli android/build lib",
|
|
33
|
+
"prepare": "bob build"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"appmetrica",
|
|
37
|
+
"metrica",
|
|
38
|
+
"analytics",
|
|
39
|
+
"tracking",
|
|
40
|
+
"react-native",
|
|
41
|
+
"ios",
|
|
42
|
+
"android"
|
|
43
|
+
],
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/appmetrica/appmetrica-react-native-plugin.git"
|
|
47
|
+
},
|
|
48
|
+
"author": "AppMetrica <admin@appmetrica.io> (https://appmetrica.io)",
|
|
49
|
+
"license": "See LICENSE.md file",
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/appmetrica/appmetrica-react-native-plugin/issues"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://appmetrica.io/docs/en/sdk/react-native/analytics/quick-start/",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"registry": "https://registry.npmjs.org/"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
59
|
+
"@types/jest": "^29.5.5",
|
|
60
|
+
"@types/react": "^18.2.44",
|
|
61
|
+
"del-cli": "^5.1.0",
|
|
62
|
+
"eslint": "^8.51.0",
|
|
63
|
+
"eslint-config-prettier": "^9.0.0",
|
|
64
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
65
|
+
"jest": "^29.7.0",
|
|
66
|
+
"prettier": "^3.0.3",
|
|
67
|
+
"react": "18.2.0",
|
|
68
|
+
"react-native": "0.74.2",
|
|
69
|
+
"react-native-builder-bob": "^0.20.0",
|
|
70
|
+
"typescript": "^5.2.2"
|
|
71
|
+
},
|
|
72
|
+
"resolutions": {
|
|
73
|
+
"@types/react": "^18.2.44"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react": "*",
|
|
77
|
+
"react-native": "*"
|
|
78
|
+
},
|
|
79
|
+
"jest": {
|
|
80
|
+
"preset": "react-native",
|
|
81
|
+
"modulePathIgnorePatterns": [
|
|
82
|
+
"<rootDir>/example/node_modules",
|
|
83
|
+
"<rootDir>/lib/"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"eslintConfig": {
|
|
87
|
+
"root": true,
|
|
88
|
+
"extends": [
|
|
89
|
+
"@react-native",
|
|
90
|
+
"prettier"
|
|
91
|
+
],
|
|
92
|
+
"rules": {
|
|
93
|
+
"prettier/prettier": [
|
|
94
|
+
"error",
|
|
95
|
+
{
|
|
96
|
+
"quoteProps": "consistent",
|
|
97
|
+
"singleQuote": true,
|
|
98
|
+
"tabWidth": 2,
|
|
99
|
+
"trailingComma": "es5",
|
|
100
|
+
"useTabs": false
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"eslintIgnore": [
|
|
106
|
+
"node_modules/",
|
|
107
|
+
"lib/"
|
|
108
|
+
],
|
|
109
|
+
"prettier": {
|
|
110
|
+
"quoteProps": "consistent",
|
|
111
|
+
"singleQuote": true,
|
|
112
|
+
"tabWidth": 2,
|
|
113
|
+
"trailingComma": "es5",
|
|
114
|
+
"useTabs": false
|
|
115
|
+
},
|
|
116
|
+
"react-native-builder-bob": {
|
|
117
|
+
"source": "src",
|
|
118
|
+
"output": "lib",
|
|
119
|
+
"targets": [
|
|
120
|
+
"commonjs",
|
|
121
|
+
"module",
|
|
122
|
+
[
|
|
123
|
+
"typescript",
|
|
124
|
+
{
|
|
125
|
+
"project": "tsconfig.build.json"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/ecommerce.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export type ECommerceScreen = {
|
|
2
|
+
name: string;
|
|
3
|
+
searchQuery?: string;
|
|
4
|
+
payload?: Map<string, string>;
|
|
5
|
+
categoriesPath?: Array<string>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type ECommerceAmount = {
|
|
9
|
+
amount: number | string;
|
|
10
|
+
unit: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type ECommercePrice = {
|
|
14
|
+
amount: ECommerceAmount;
|
|
15
|
+
internalComponents?: Array<ECommerceAmount>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ECommerceProduct = {
|
|
19
|
+
sku: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
actualPrice?: ECommercePrice;
|
|
22
|
+
originalPrice?: ECommercePrice;
|
|
23
|
+
promocodes?: Array<string>;
|
|
24
|
+
categoriesPath?: Array<string>;
|
|
25
|
+
payload?: Map<string, string>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ECommerceReferrer = {
|
|
29
|
+
type?: string;
|
|
30
|
+
identifier?: string;
|
|
31
|
+
screen?: ECommerceScreen;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ECommerceCartItem = {
|
|
35
|
+
product: ECommerceProduct;
|
|
36
|
+
price: ECommercePrice;
|
|
37
|
+
quantity: number | string;
|
|
38
|
+
referrer?: ECommerceReferrer;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ECommerceOrder = {
|
|
42
|
+
orderId: string;
|
|
43
|
+
products: Array<ECommerceCartItem>;
|
|
44
|
+
payload?: Map<string, string>;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type ECommerceEventType =
|
|
48
|
+
| 'showSceenEvent'
|
|
49
|
+
| 'showProductCardEvent'
|
|
50
|
+
| 'showProductDetailsEvent'
|
|
51
|
+
| 'addCartItemEvent'
|
|
52
|
+
| 'removeCartItemEvent'
|
|
53
|
+
| 'beginCheckoutEvent'
|
|
54
|
+
| 'purchaseEvent';
|
|
55
|
+
|
|
56
|
+
export interface ECommerceEvent {
|
|
57
|
+
ecommerceEvent: ECommerceEventType;
|
|
58
|
+
ecommerceScreen?: ECommerceScreen;
|
|
59
|
+
product?: ECommerceProduct;
|
|
60
|
+
referrer?: ECommerceReferrer;
|
|
61
|
+
cartItem?: ECommerceCartItem;
|
|
62
|
+
order?: ECommerceOrder;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class ECommerce {
|
|
66
|
+
static showScreenEvent(screen: ECommerceScreen): ECommerceEvent {
|
|
67
|
+
return {
|
|
68
|
+
ecommerceEvent: 'showSceenEvent',
|
|
69
|
+
ecommerceScreen: screen,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static showProductCardEvent(
|
|
74
|
+
product: ECommerceProduct,
|
|
75
|
+
screen: ECommerceScreen
|
|
76
|
+
): ECommerceEvent {
|
|
77
|
+
return {
|
|
78
|
+
ecommerceEvent: 'showProductCardEvent',
|
|
79
|
+
ecommerceScreen: screen,
|
|
80
|
+
product: product,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static showProductDetailsEvent(
|
|
85
|
+
product: ECommerceProduct,
|
|
86
|
+
referrer?: ECommerceReferrer
|
|
87
|
+
): ECommerceEvent {
|
|
88
|
+
return {
|
|
89
|
+
ecommerceEvent: 'showProductDetailsEvent',
|
|
90
|
+
product: product,
|
|
91
|
+
referrer: referrer,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static addCartItemEvent(item: ECommerceCartItem): ECommerceEvent {
|
|
96
|
+
return {
|
|
97
|
+
ecommerceEvent: 'addCartItemEvent',
|
|
98
|
+
cartItem: item,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static removeCartItemEvent(item: ECommerceCartItem): ECommerceEvent {
|
|
103
|
+
return {
|
|
104
|
+
ecommerceEvent: 'removeCartItemEvent',
|
|
105
|
+
cartItem: item,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static beginCheckoutEvent(order: ECommerceOrder): ECommerceEvent {
|
|
110
|
+
return {
|
|
111
|
+
ecommerceEvent: 'beginCheckoutEvent',
|
|
112
|
+
order: order,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static purchaseEvent(order: ECommerceOrder): ECommerceEvent {
|
|
117
|
+
return {
|
|
118
|
+
ecommerceEvent: 'purchaseEvent',
|
|
119
|
+
order: order,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|