🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@amplitude/react-native

Package Overview
Dependencies
Maintainers
20
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplitude/react-native - npm Package Compare versions

Comparing version
2.6.0
to
2.17.2
+44
lib/commonjs/middlewareRunner.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.MiddlewareRunner = void 0;
class MiddlewareRunner {
_middlewares = [];
/**
* Add a @middleware to the chain.
*
* The provided middleware must call next(payload) for the chain to continue.
* Otherwise any following middleware and next method will not be called.
*
* @param middleware A Middleware function
*/
add(middleware) {
this._middlewares.push(middleware);
}
/**
* Runs the middleware chain with the given payload.
*
* @param payload The payload data for the middleware to receive
* @param next The function to call after all middleware completes. Only runs if next(payload) is called by all middlewares.
*/
run(payload, next) {
let curMiddlewareIndex = -1;
const middlewareCount = this._middlewares.length;
const middlewareNext = curPayload => {
curMiddlewareIndex += 1;
if (curMiddlewareIndex < middlewareCount) {
this._middlewares[curMiddlewareIndex](curPayload, _next);
} else {
next(curPayload);
}
};
const _next = middlewareCount > 0 ? middlewareNext : next;
_next(payload);
}
}
exports.MiddlewareRunner = MiddlewareRunner;
//# sourceMappingURL=middlewareRunner.js.map
{"version":3,"names":["MiddlewareRunner","_middlewares","add","middleware","push","run","payload","next","curMiddlewareIndex","middlewareCount","length","middlewareNext","curPayload","_next","exports"],"sourceRoot":"../../src","sources":["middlewareRunner.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,CAAC;EACXC,YAAY,GAAiB,EAAE;;EAEhD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAACC,UAAsB,EAAQ;IAChC,IAAI,CAACF,YAAY,CAACG,IAAI,CAACD,UAAU,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,GAAGA,CAACC,OAA0B,EAAEC,IAAoB,EAAQ;IAC1D,IAAIC,kBAAkB,GAAG,CAAC,CAAC;IAC3B,MAAMC,eAAe,GAAG,IAAI,CAACR,YAAY,CAACS,MAAM;IAEhD,MAAMC,cAA8B,GAAIC,UAAU,IAAK;MACrDJ,kBAAkB,IAAI,CAAC;MACvB,IAAIA,kBAAkB,GAAGC,eAAe,EAAE;QACxC,IAAI,CAACR,YAAY,CAACO,kBAAkB,CAAC,CAACI,UAAU,EAAEC,KAAK,CAAC;MAC1D,CAAC,MAAM;QACLN,IAAI,CAACK,UAAU,CAAC;MAClB;IACF,CAAC;IAED,MAAMC,KAAqB,GAAGJ,eAAe,GAAG,CAAC,GAAGE,cAAc,GAAGJ,IAAI;IAEzEM,KAAK,CAACP,OAAO,CAAC;EAChB;AACF;AAACQ,OAAA,CAAAd,gBAAA,GAAAA,gBAAA"}
export class MiddlewareRunner {
_middlewares = [];
/**
* Add a @middleware to the chain.
*
* The provided middleware must call next(payload) for the chain to continue.
* Otherwise any following middleware and next method will not be called.
*
* @param middleware A Middleware function
*/
add(middleware) {
this._middlewares.push(middleware);
}
/**
* Runs the middleware chain with the given payload.
*
* @param payload The payload data for the middleware to receive
* @param next The function to call after all middleware completes. Only runs if next(payload) is called by all middlewares.
*/
run(payload, next) {
let curMiddlewareIndex = -1;
const middlewareCount = this._middlewares.length;
const middlewareNext = curPayload => {
curMiddlewareIndex += 1;
if (curMiddlewareIndex < middlewareCount) {
this._middlewares[curMiddlewareIndex](curPayload, _next);
} else {
next(curPayload);
}
};
const _next = middlewareCount > 0 ? middlewareNext : next;
_next(payload);
}
}
//# sourceMappingURL=middlewareRunner.js.map
{"version":3,"names":["MiddlewareRunner","_middlewares","add","middleware","push","run","payload","next","curMiddlewareIndex","middlewareCount","length","middlewareNext","curPayload","_next"],"sourceRoot":"../../src","sources":["middlewareRunner.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,CAAC;EACXC,YAAY,GAAiB,EAAE;;EAEhD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAGA,CAACC,UAAsB,EAAQ;IAChC,IAAI,CAACF,YAAY,CAACG,IAAI,CAACD,UAAU,CAAC;EACpC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,GAAGA,CAACC,OAA0B,EAAEC,IAAoB,EAAQ;IAC1D,IAAIC,kBAAkB,GAAG,CAAC,CAAC;IAC3B,MAAMC,eAAe,GAAG,IAAI,CAACR,YAAY,CAACS,MAAM;IAEhD,MAAMC,cAA8B,GAAIC,UAAU,IAAK;MACrDJ,kBAAkB,IAAI,CAAC;MACvB,IAAIA,kBAAkB,GAAGC,eAAe,EAAE;QACxC,IAAI,CAACR,YAAY,CAACO,kBAAkB,CAAC,CAACI,UAAU,EAAEC,KAAK,CAAC;MAC1D,CAAC,MAAM;QACLN,IAAI,CAACK,UAAU,CAAC;MAClB;IACF,CAAC;IAED,MAAMC,KAAqB,GAAGJ,eAAe,GAAG,CAAC,GAAGE,cAAc,GAAGJ,IAAI;IAEzEM,KAAK,CAACP,OAAO,CAAC;EAChB;AACF"}
export {};
//# sourceMappingURL=middleware.test.d.ts.map
{"version":3,"file":"middleware.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/middleware.test.ts"],"names":[],"mappings":""}
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,EAAE;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CAIxB,CAAC"}
{"version":3,"file":"identify.d.ts","sourceRoot":"","sources":["../../src/identify.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,GAAG,SAAS;IACZ,QAAQ,aAAa;IACrB,GAAG,SAAS;IACZ,MAAM,YAAY;IAClB,SAAS,eAAe;IACxB,UAAU,gBAAgB;IAC1B,KAAK,WAAW;CACjB;AAED,MAAM,WAAW,eAAe;IAE9B,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MA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C,OAAO,CAAC;IAO5E,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS;IAKrD;;;;OAIG;IACH,aAAa,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvD;;;;;;;OAOG;IAEH,cAAc,CACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAC3C,mBAAmB;IAItB;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/C,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,eAAe;CAWxB"}
import { Middleware, MiddlewarePayload, MiddlewareNext } from './types';
export declare class MiddlewareRunner {
private readonly _middlewares;
/**
* Add a @middleware to the chain.
*
* The provided middleware must call next(payload) for the chain to continue.
* Otherwise any following middleware and next method will not be called.
*
* @param middleware A Middleware function
*/
add(middleware: Middleware): void;
/**
* Runs the middleware chain with the given payload.
*
* @param payload The payload data for the middleware to receive
* @param next The function to call after all middleware completes. Only runs if next(payload) is called by all middlewares.
*/
run(payload: MiddlewarePayload, next: MiddlewareNext): void;
}
//# sourceMappingURL=middlewareRunner.d.ts.map
{"version":3,"file":"middlewareRunner.d.ts","sourceRoot":"","sources":["../../src/middlewareRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoB;IAEjD;;;;;;;OAOG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAIjC;;;;;OAKG;IACH,GAAG,CAAC,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI;CAiB5D"}
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,K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zB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,cAAc,KACjB,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
import { MiddlewareRunner } from '../middlewareRunner';
import { MiddlewarePayload } from '../types';
const PAYLOAD_EVENT_ONLY = { event: { eventType: 'Test ' } };
describe('middleware behavior', () => {
let next: jest.Mock;
let runner: MiddlewareRunner;
beforeEach(() => {
next = jest.fn();
runner = new MiddlewareRunner();
});
it('should call next() with no middleware', () => {
runner.run(PAYLOAD_EVENT_ONLY, next);
expect(next).toHaveBeenCalledTimes(1);
expect(next).toHaveBeenCalledWith(PAYLOAD_EVENT_ONLY);
});
it('should call next() with single middleware', () => {
const middleware = jest.fn((payload, nxt) => {
nxt(payload);
});
runner.add(middleware);
runner.run(PAYLOAD_EVENT_ONLY, next);
expect(middleware).toHaveBeenCalledTimes(1);
expect(middleware.mock.calls[0][0]).toEqual(PAYLOAD_EVENT_ONLY);
expect(next).toHaveBeenCalledTimes(1);
expect(next).toHaveBeenCalledWith(PAYLOAD_EVENT_ONLY);
});
it('should not call next() with blocking middleware', () => {
// Middleware doesn't call next, stops the chain
const middleware = jest.fn();
runner.add(middleware);
runner.run(PAYLOAD_EVENT_ONLY, next);
expect(middleware).toHaveBeenCalledTimes(1);
expect(middleware.mock.calls[0][0]).toEqual(PAYLOAD_EVENT_ONLY);
expect(next).toHaveBeenCalledTimes(0);
});
it('should run middleware in order', () => {
const middlewareCount = 10;
const middleware = [];
const getPayloadWithCount = (count: number): MiddlewarePayload => ({
event: { eventType: 'Test' },
extra: { count },
});
// Create a number of middleware, each one increments the extra.count
for (let i = 0; i < middlewareCount; i += 1) {
middleware[i] = jest.fn((payload, nxt) => {
let { count = 0 } = { ...payload.extra };
count = +count + 1;
nxt({ ...payload, extra: { count } });
});
runner.add(middleware[i]);
}
// Run with payload with count = 0
runner.run(getPayloadWithCount(0), next);
// Check all middleware was called in order
for (let i = 0; i < middlewareCount; i += 1) {
const nextMethod = i < middlewareCount - 1 ? middleware[i + 1] : next;
// Check middlware was called
expect(middleware[i]).toHaveBeenCalledTimes(1);
// Check payload
expect(middleware[i].mock.calls[0][0]).toEqual(getPayloadWithCount(i));
// Check this middleware method ran before the next one in the chain
expect(middleware[i].mock.invocationCallOrder[0]).toBeLessThan(
nextMethod.mock.invocationCallOrder[0],
);
}
// Check next function call
expect(next).toHaveBeenCalledTimes(1);
expect(next).toHaveBeenCalledWith(getPayloadWithCount(middlewareCount));
});
});
import { Middleware, MiddlewarePayload, MiddlewareNext } from './types';
export class MiddlewareRunner {
private readonly _middlewares: Middleware[] = [];
/**
* Add a @middleware to the chain.
*
* The provided middleware must call next(payload) for the chain to continue.
* Otherwise any following middleware and next method will not be called.
*
* @param middleware A Middleware function
*/
add(middleware: Middleware): void {
this._middlewares.push(middleware);
}
/**
* Runs the middleware chain with the given payload.
*
* @param payload The payload data for the middleware to receive
* @param next The function to call after all middleware completes. Only runs if next(payload) is called by all middlewares.
*/
run(payload: MiddlewarePayload, next: MiddlewareNext): void {
let curMiddlewareIndex = -1;
const middlewareCount = this._middlewares.length;
const middlewareNext: MiddlewareNext = (curPayload) => {
curMiddlewareIndex += 1;
if (curMiddlewareIndex < middlewareCount) {
this._middlewares[curMiddlewareIndex](curPayload, _next);
} else {
next(curPayload);
}
};
const _next: MiddlewareNext = middlewareCount > 0 ? middlewareNext : next;
_next(payload);
}
}
+5
-3

@@ -5,3 +5,3 @@ buildscript {

google()
jcenter()
mavenCentral()
}

@@ -22,2 +22,4 @@

android {
namespace "com.amplitude.reactnative"
compileSdkVersion safeExtGet('compileSdkVersion', 29)

@@ -54,3 +56,3 @@ buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')

google()
jcenter()
mavenCentral()
}

@@ -61,3 +63,3 @@

implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.amplitude:android-sdk:2.34.0"
implementation "com.amplitude:android-sdk:2.39.5"
}

@@ -1,3 +0,2 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amplitude.reactnative">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

@@ -7,4 +7,7 @@ package com.amplitude.reactnative;

import com.amplitude.api.AmplitudeClient;
import com.amplitude.api.AmplitudeLogCallback;
import com.amplitude.api.AmplitudeServerZone;
import com.amplitude.api.Identify;
import com.amplitude.api.Plan;
import com.amplitude.api.IngestionMetadata;
import com.amplitude.api.Revenue;

@@ -15,4 +18,7 @@ import com.facebook.react.bridge.Promise;

import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.Callback;
import com.facebook.react.modules.core.DeviceEventManagerModule;

@@ -288,2 +294,117 @@ import org.json.JSONObject;

@ReactMethod
public void setEventUploadMaxBatchSize(String instanceName, int eventUploadMaxBatchSize, Promise promise) {
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setEventUploadMaxBatchSize(eventUploadMaxBatchSize);
promise.resolve(true);
}
}
@ReactMethod
public void setEventUploadPeriodMillis(String instanceName, int eventUploadPeriodMillis, Promise promise) {
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setEventUploadPeriodMillis(eventUploadPeriodMillis);
promise.resolve(true);
}
}
@ReactMethod
public void setEventUploadThreshold(String instanceName, int eventUploadThreshold, Promise promise) {
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setEventUploadThreshold(eventUploadThreshold);
promise.resolve(true);
}
}
@ReactMethod
public void setPlan(String instanceName, ReadableMap planProperties, Promise promise) {
Plan plan = new Plan();
if (planProperties.hasKey("branch")) {
plan.setBranch(planProperties.getString("branch"));
}
if (planProperties.hasKey("source")) {
plan.setSource(planProperties.getString("source"));
}
if (planProperties.hasKey("version")) {
plan.setVersion(planProperties.getString("version"));
}
if (planProperties.hasKey("versionId")) {
plan.setVersionId(planProperties.getString("versionId"));
}
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setPlan(plan);
promise.resolve(true);
}
}
@ReactMethod
public void setIngestionMetadata(String instanceName, ReadableMap ingestionMetadataProperties, Promise promise) {
IngestionMetadata ingestionMetadata = new IngestionMetadata();
if (ingestionMetadataProperties.hasKey("sourceName")) {
ingestionMetadata.setSourceName(ingestionMetadataProperties.getString("sourceName"));
}
if (ingestionMetadataProperties.hasKey("sourceVersion")) {
ingestionMetadata.setSourceVersion(ingestionMetadataProperties.getString("sourceVersion"));
}
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setIngestionMetadata(ingestionMetadata);
promise.resolve(true);
}
}
@ReactMethod
public void enableLogging(String instanceName, Boolean enableLogging, Promise promise) {
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.enableLogging(enableLogging);
if (enableLogging) {
client.setLogCallback(new AmplitudeLogCallback() {
@Override
public void onError(String tag, String message) {
WritableNativeMap payload = new WritableNativeMap();
payload.putString("tag", tag);
payload.putString("message", message);
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(
"AmplitudeLogError",
payload
);
}
});
} else {
client.setLogCallback(null);
}
promise.resolve(true);
}
}
@ReactMethod
public void setLogLevel(String instanceName, Integer logLevel, Promise promise) {
AmplitudeClient client = Amplitude.getInstance(instanceName);
synchronized (client) {
client.setLogLevel(logLevel);
promise.resolve(true);
}
}
@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}
@ReactMethod
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}
private Revenue createRevenue(JSONObject properties) {

@@ -356,2 +477,4 @@ Revenue revenue = new Revenue();

identify.append(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.append(key, userPropertiesObj.getBoolean(key));
}

@@ -371,3 +494,37 @@ case "$prepend":

identify.prepend(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.prepend(key, userPropertiesObj.getBoolean(key));
}
case "$preInsert":
if ((Object)userPropertiesObj.get(key) instanceof Double){
identify.preInsert(key, userPropertiesObj.getDouble(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Integer){
identify.preInsert(key, userPropertiesObj.getInt(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Long) {
identify.preInsert(key, userPropertiesObj.getLong(key));
} else if ((Object)userPropertiesObj.get(key) instanceof String) {
identify.preInsert(key, userPropertiesObj.getString(key));
} else if ((Object)userPropertiesObj.get(key) instanceof JSONObject) {
identify.preInsert(key, userPropertiesObj.getJSONObject(key));
} else if ((Object)userPropertiesObj.get(key) instanceof JSONArray) {
identify.preInsert(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.preInsert(key, userPropertiesObj.getBoolean(key));
}
case "$postInsert":
if ((Object)userPropertiesObj.get(key) instanceof Double){
identify.postInsert(key, userPropertiesObj.getDouble(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Integer){
identify.postInsert(key, userPropertiesObj.getInt(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Long) {
identify.postInsert(key, userPropertiesObj.getLong(key));
} else if ((Object)userPropertiesObj.get(key) instanceof String) {
identify.postInsert(key, userPropertiesObj.getString(key));
} else if ((Object)userPropertiesObj.get(key) instanceof JSONObject) {
identify.postInsert(key, userPropertiesObj.getJSONObject(key));
} else if ((Object)userPropertiesObj.get(key) instanceof JSONArray) {
identify.postInsert(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.postInsert(key, userPropertiesObj.getBoolean(key));
}
case "$set":

@@ -386,2 +543,4 @@ if ((Object)userPropertiesObj.get(key) instanceof Double){

identify.set(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.set(key, userPropertiesObj.getBoolean(key));
}

@@ -401,2 +560,4 @@ case "$setOnce":

identify.setOnce(key, userPropertiesObj.getJSONArray(key));
} else if ((Object)userPropertiesObj.get(key) instanceof Boolean) {
identify.setOnce(key, userPropertiesObj.getBoolean(key));
}

@@ -403,0 +564,0 @@ case "$unset":

@@ -1,5 +0,1 @@

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

@@ -59,2 +59,26 @@ #import <React/RCTBridgeModule.h>

RCT_EXTERN_METHOD(setEventUploadMaxBatchSize:(NSString *)instanceName eventUploadMaxBatchSize:(int)eventUploadMaxBatchSize resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setEventUploadPeriodMillis:(NSString *)instanceName eventUploadPeriodMillis:(int)eventUploadPeriodMillis resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setEventUploadThreshold:(NSString *)instanceName eventUploadThreshold:(int)eventUploadThreshold resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setPlan:(NSString *)instanceName planProperties:(NSDictionary *)planProperties resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setIngestionMetadata:(NSString *)instanceName ingestionMetadataProperties:(NSDictionary *)ingestionMetadataProperties resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(enableLogging:(NSString *)instanceName enableLogging:(BOOL *)enableLogging resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setLogCallback:(NSString *)instanceName callback:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(setLogLevel:(NSString *)instanceName logLevel:(NSInteger *)logLevel resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXPORT_METHOD(addListener:(NSString *)eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}
RCT_EXPORT_METHOD(removeListeners:(NSInteger)count) {
// Keep: Required for RN built in Event Emitter Calls.
}
@end

@@ -63,3 +63,3 @@ import Foundation

rejecter reject: RCTPromiseRejectBlock) -> Void {
resolve(false)
resolve(Amplitude.instance(withName: instanceName).useAdvertisingIdForDeviceId())
}

@@ -82,3 +82,3 @@

}
@objc

@@ -92,3 +92,3 @@ func setLibraryName(_ instanceName: String,

}
@objc

@@ -102,3 +102,3 @@ func setLibraryVersion(_ instanceName: String,

}
@objc

@@ -112,3 +112,3 @@ func trackingSessionEvents(_ instanceName: String,

}
@objc

@@ -122,3 +122,3 @@ func setUseDynamicConfig(_ instanceName: String,

}
@objc

@@ -132,3 +132,3 @@ func setUserId(_ instanceName: String,

}
@objc

@@ -142,3 +142,3 @@ func setServerUrl(_ instanceName: String,

}
@objc

@@ -152,3 +152,3 @@ func logEvent(_ instanceName: String,

}
@objc

@@ -163,3 +163,3 @@ func logEventWithProperties(_ instanceName: String,

}
@objc

@@ -184,3 +184,3 @@ func logRevenueV2(_ instanceName: String,

}
@objc

@@ -199,3 +199,3 @@ func groupIdentify(_ instanceName: String,

}
@objc

@@ -210,3 +210,3 @@ func setGroup(_ instanceName: String,

}
@objc

@@ -220,3 +220,3 @@ func setUserProperties(_ instanceName: String,

}
@objc

@@ -229,3 +229,3 @@ func clearUserProperties(_ instanceName: String,

}
@objc

@@ -265,3 +265,91 @@ func uploadEvents(_ instanceName: String,

}
@objc
func setEventUploadMaxBatchSize(_ instanceName: String,
eventUploadMaxBatchSize: Int32,
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
Amplitude.instance(withName: instanceName).updateEventUploadMaxBatchSize(eventUploadMaxBatchSize);
resolve(true)
}
@objc
func setEventUploadPeriodMillis(_ instanceName: String,
eventUploadPeriodMillis: Int32,
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
Amplitude.instance(withName: instanceName).eventUploadPeriodSeconds = eventUploadPeriodMillis / 1000;
resolve(true)
}
@objc
func setEventUploadThreshold(_ instanceName: String,
eventUploadThreshold: Int32,
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
Amplitude.instance(withName: instanceName).eventUploadThreshold = eventUploadThreshold;
resolve(true)
}
@objc
func setPlan(_ instanceName: String,
planProperties: [String: Any],
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
let plan = AMPPlan()
if (planProperties["branch"] != nil) {
plan.setBranch(planProperties["branch"] as! String)
}
if (planProperties["source"] != nil) {
plan.setSource(planProperties["source"] as! String)
}
if (planProperties["version"] != nil) {
plan.setVersion(planProperties["version"] as! String)
}
if (planProperties["versionId"] != nil) {
plan.setVersionId(planProperties["versionId"] as! String)
}
Amplitude.instance(withName: instanceName).setPlan(plan)
resolve(true)
}
@objc
func setIngestionMetadata(_ instanceName: String,
ingestionMetadataProperties: [String: Any],
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
let ingestionMetadata = AMPIngestionMetadata()
if (ingestionMetadataProperties["sourceName"] != nil) {
ingestionMetadata.setSourceName(ingestionMetadataProperties["sourceName"] as! String)
}
if (ingestionMetadataProperties["sourceVersion"] != nil) {
ingestionMetadata.setSourceVersion(ingestionMetadataProperties["sourceVersion"] as! String)
}
Amplitude.instance(withName: instanceName).setIngestionMetadata(ingestionMetadata)
resolve(true)
}
@objc
func enableLogging(_ instanceName: String,
enableLogging: Bool,
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
// TODO: add the set log callback logic after iOS log enable logging implementation
}
@objc
func setLogCallback(_ instanceName: String,
callback: RCTResponseSenderBlock) -> Void {
// TODO: add the set log callback logic after iOS log callback implementation
}
@objc
func setLogLevel(_ instanceName: String,
logLevel: Int,
resolver resolve: RCTPromiseResolveBlock,
rejecter reject: RCTPromiseRejectBlock) -> Void {
// TODO: add the set log callback logic after iOS log level implementation
resolve(false)
}
private func createRevenue(_ userProperties: [String: Any]) -> AMPRevenue {

@@ -271,3 +359,3 @@ let revenue = AMPRevenue()

revenue.setProductIdentifier((userProperties["productId"] as! String))
}
}
if userProperties["price"] != nil {

@@ -304,2 +392,6 @@ revenue.setPrice((userProperties["price"] as! NSNumber))

identify.prepend(key, value: value)
case "$preInsert":
identify.preInsert(key, value: value)
case "$postInsert":
identify.postInsert(key, value: value)
case "$set":

@@ -306,0 +398,0 @@ identify.set(key, value: value)

@@ -9,5 +9,5 @@ "use strict";

packageSourceName: 'amplitude-react-native',
packageVersion: '2.6.0'
packageVersion: '2.17.2'
};
exports.Constants = Constants;
//# sourceMappingURL=constants.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["constants.ts"],"names":["Constants","packageSourceName","packageVersion"],"mappings":";;;;;;AAAO,MAAMA,SAGZ,GAAG;AACFC,EAAAA,iBAAiB,EAAE,wBADjB;AAEFC,EAAAA,cAAc,EAAE;AAFd,CAHG","sourcesContent":["export const Constants: {\n packageSourceName: string;\n packageVersion: string;\n} = {\n packageSourceName: 'amplitude-react-native',\n packageVersion: '2.6.0',\n};\n"]}
{"version":3,"names":["Constants","packageSourceName","packageVersion","exports"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":";;;;;;AAAO,MAAMA,SAGZ,GAAG;EACFC,iBAAiB,EAAE,wBAAwB;EAC3CC,cAAc,EAAE;AAClB,CAAC;AAACC,OAAA,CAAAH,SAAA,GAAAA,SAAA"}

@@ -6,64 +6,54 @@ "use strict";

});
exports.Identify = void 0;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
exports.IdentifyOperation = exports.Identify = void 0;
let IdentifyOperation = /*#__PURE__*/function (IdentifyOperation) {
IdentifyOperation["SET"] = "$set";
IdentifyOperation["SET_ONCE"] = "$setOnce";
IdentifyOperation["ADD"] = "$add";
IdentifyOperation["APPEND"] = "$append";
IdentifyOperation["PREINSERT"] = "$preInsert";
IdentifyOperation["POSTINSERT"] = "$postInsert";
IdentifyOperation["UNSET"] = "$unset";
return IdentifyOperation;
}({});
exports.IdentifyOperation = IdentifyOperation;
class Identify {
static ALL_OPS = [IdentifyOperation.SET, IdentifyOperation.SET_ONCE, IdentifyOperation.ADD, IdentifyOperation.APPEND, IdentifyOperation.PREINSERT, IdentifyOperation.POSTINSERT, IdentifyOperation.UNSET];
constructor() {
_defineProperty(this, "payload", void 0);
this.payload = {};
}
set(key, value) {
this.addOp(Identify.OP_SET, key, value);
this.addOp(IdentifyOperation.SET, key, value);
}
setOnce(key, value) {
this.addOp(Identify.OP_SET_ONCE, key, value);
this.addOp(IdentifyOperation.SET_ONCE, key, value);
}
add(key, value) {
this.addOp(Identify.OP_ADD, key, value);
this.addOp(IdentifyOperation.ADD, key, value);
}
unset(key) {
this.addOp(Identify.OP_UNSET, key, '-');
this.addOp(IdentifyOperation.UNSET, key, '-');
}
append(key, value) {
this.addOp(Identify.OP_APPEND, key, value);
this.addOp(IdentifyOperation.APPEND, key, value);
}
preInsert(key, value) {
this.addOp(IdentifyOperation.PREINSERT, key, value);
}
postInsert(key, value) {
this.addOp(IdentifyOperation.POSTINSERT, key, value);
}
addOp(op, key, value) {
if (!Identify.ALL_OPS.includes(op)) {
throw new Error("Unknown Identify operation: ".concat(op, " called with key: ").concat(key, " value: ").concat(String(value)));
throw new Error(`Unknown Identify operation: ${op} called with key: ${key} value: ${String(value)}`);
}
this.opMap(op)[key] = value;
}
opMap(key) {
if (!Object.prototype.hasOwnProperty.call(this.payload, key)) {
this.payload[key] = {};
opMap(op) {
if (!Object.prototype.hasOwnProperty.call(this.payload, op)) {
this.payload[op] = {};
}
return this.payload[key];
return this.payload[op];
}
}
exports.Identify = Identify;
_defineProperty(Identify, "OP_SET", '$set');
_defineProperty(Identify, "OP_SET_ONCE", '$setOnce');
_defineProperty(Identify, "OP_ADD", '$add');
_defineProperty(Identify, "OP_APPEND", '$append');
_defineProperty(Identify, "OP_UNSET", '$unset');
_defineProperty(Identify, "ALL_OPS", [Identify.OP_SET, Identify.OP_SET_ONCE, Identify.OP_ADD, Identify.OP_APPEND, Identify.OP_UNSET]);
//# sourceMappingURL=identify.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["identify.ts"],"names":["Identify","constructor","payload","set","key","value","addOp","OP_SET","setOnce","OP_SET_ONCE","add","OP_ADD","unset","OP_UNSET","append","OP_APPEND","op","ALL_OPS","includes","Error","String","opMap","Object","prototype","hasOwnProperty","call"],"mappings":";;;;;;;;;AAAO,MAAMA,QAAN,CAAe;AAiBpBC,EAAAA,WAAW,GAAG;AAAA;;AACZ,SAAKC,OAAL,GAAe,EAAf;AACD;;AAEDC,EAAAA,GAAG,CAACC,GAAD,EAAcC,KAAd,EAAoC;AACrC,SAAKC,KAAL,CAAWN,QAAQ,CAACO,MAApB,EAA4BH,GAA5B,EAAiCC,KAAjC;AACD;;AAEDG,EAAAA,OAAO,CAACJ,GAAD,EAAcC,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vBA,QAAQ,CAACO,MADc,EAEvBP,QAAQ,CAACS,WAFc,EAGvBT,QAAQ,CAACW,MAHc,EAIvBX,QAAQ,CAACe,SAJc,EAKvBf,QAAQ,CAACa,QALc,C","sourcesContent":["export class Identify {\n payload: Record<string, Record<string, unknown>>;\n\n private static OP_SET = '$set';\n private static OP_SET_ONCE = '$setOnce';\n private static OP_ADD = '$add';\n private static OP_APPEND = '$append';\n private static OP_UNSET = '$unset';\n\n private static ALL_OPS = [\n Identify.OP_SET,\n Identify.OP_SET_ONCE,\n Identify.OP_ADD,\n Identify.OP_APPEND,\n Identify.OP_UNSET,\n ];\n\n constructor() {\n this.payload = {};\n }\n\n set(key: string, value: unknown): void {\n this.addOp(Identify.OP_SET, key, value);\n }\n\n setOnce(key: string, value: unknown): void {\n this.addOp(Identify.OP_SET_ONCE, key, value);\n }\n\n add(key: string, value: number): void {\n this.addOp(Identify.OP_ADD, key, value);\n }\n\n unset(key: string): void {\n this.addOp(Identify.OP_UNSET, key, '-');\n }\n\n append(key: string, value: unknown): void {\n this.addOp(Identify.OP_APPEND, key, value);\n }\n\n private addOp(op: string, key: string, value: unknown): void {\n if (!Identify.ALL_OPS.includes(op)) {\n throw new Error(\n `Unknown Identify operation: ${op} called with key: ${key} value: ${String(\n value,\n )}`,\n );\n }\n this.opMap(op)[key] = value;\n }\n\n private opMap(key: string): Record<string, unknown> {\n if (!Object.prototype.hasOwnProperty.call(this.payload, key)) {\n this.payload[key] = {};\n }\n return this.payload[key];\n }\n}\n"]}
{"version":3,"names":["IdentifyOperation","exports","Identify","ALL_OPS","SET","SET_ONCE","ADD","APPEND","PREINSERT","POSTINSERT","UNSET","constructor","payload","set","key","value","addOp","setOnce","add","unset","append","preInsert","postInsert","op","includes","Error","String","opMap","Object","prototype","hasOwnProperty","call"],"sourceRoot":"../../src","sources":["identify.ts"],"mappings":";;;;;;IAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,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AAChB,iBAAiB,CAACQ,SAAS,EAAEM,GAAG,EAAEC,KAAK,CAAC;EACrD;EAEAO,UAAUA,CAACR,GAAW,EAAEC,KAAc,EAAQ;IAC5C,IAAI,CAACC,KAAK,CAAChB,iBAAiB,CAACS,UAAU,EAAEK,GAAG,EAAEC,KAAK,CAAC;EACtD;EAEQC,KAAKA,CAACO,EAAqB,EAAET,GAAW,EAAEC,KAAc,EAAQ;IACtE,IAAI,CAACb,QAAQ,CAACC,OAAO,CAACqB,QAAQ,CAACD,EAAE,CAAC,EAAE;MAClC,MAAM,IAAIE,KAAK,CACZ,+BAA8BF,EAAG,qBAAoBT,GAAI,WAAUY,MAAM,CACxEX,KAAK,CACL,EAAC,CACJ;IACH;IACA,IAAI,CAACY,KAAK,CAACJ,EAAE,CAAC,CAACT,GAAG,CAAC,GAAGC,KAAK;EAC7B;EAEQY,KAAKA,CAACJ,EAAqB,EAA2B;IAC5D,IAAI,CAACK,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAAC,IAAI,CAACnB,OAAO,EAAEW,EAAE,CAAC,EAAE;MAC3D,IAAI,CAACX,OAAO,CAACW,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB;IACA,OAAO,IAAI,CAACX,OAAO,CAACW,EAAE,CAAC;EACzB;AACF;AAACtB,OAAA,CAAAC,QAAA,GAAAA,QAAA"}

@@ -6,2 +6,21 @@ "use strict";

});
exports.Amplitude = void 0;
Object.defineProperty(exports, "BaseEvent", {
enumerable: true,
get: function () {
return _types.BaseEvent;
}
});
Object.defineProperty(exports, "Event", {
enumerable: true,
get: function () {
return _types.Event;
}
});
Object.defineProperty(exports, "GroupIdentifyEvent", {
enumerable: true,
get: function () {
return _types.GroupIdentifyEvent;
}
});
Object.defineProperty(exports, "Identify", {

@@ -13,40 +32,79 @@ enumerable: true,

});
exports.Amplitude = void 0;
Object.defineProperty(exports, "IdentifyEvent", {
enumerable: true,
get: function () {
return _types.IdentifyEvent;
}
});
Object.defineProperty(exports, "IdentifyOperation", {
enumerable: true,
get: function () {
return _identify.IdentifyOperation;
}
});
Object.defineProperty(exports, "IdentifyPayload", {
enumerable: true,
get: function () {
return _identify.IdentifyPayload;
}
});
Object.defineProperty(exports, "IngestionMetadata", {
enumerable: true,
get: function () {
return _types.IngestionMetadata;
}
});
Object.defineProperty(exports, "Middleware", {
enumerable: true,
get: function () {
return _types.Middleware;
}
});
Object.defineProperty(exports, "MiddlewareExtra", {
enumerable: true,
get: function () {
return _types.MiddlewareExtra;
}
});
Object.defineProperty(exports, "Plan", {
enumerable: true,
get: function () {
return _types.Plan;
}
});
Object.defineProperty(exports, "SpecialEventType", {
enumerable: true,
get: function () {
return _types.SpecialEventType;
}
});
var _reactNative = require("react-native");
var _constants = require("./constants");
var _identify = require("./identify");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _types = require("./types");
var _middlewareRunner = require("./middlewareRunner");
const AmplitudeReactNative = _reactNative.NativeModules.AmplitudeReactNative;
class Amplitude {
static _defaultInstanceName = '$default_instance';
constructor(instanceName) {
_defineProperty(this, "instanceName", void 0);
this.instanceName = instanceName;
this._middlewareRunner = new _middlewareRunner.MiddlewareRunner();
this._setLibraryName(_constants.Constants.packageSourceName);
this._setLibraryVersion(_constants.Constants.packageVersion);
this._nativeEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.AmplitudeReactNative);
}
static getInstance(instanceName = this._defaultInstanceName) {
static getInstance() {
let instanceName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._defaultInstanceName;
if (!this._instances) {
this._instances = {};
}
if (!Object.prototype.hasOwnProperty.call(this._instances, instanceName)) {
this._instances[instanceName] = new Amplitude(instanceName);
}
return this._instances[instanceName];
}
init(apiKey) {
return AmplitudeReactNative.initialize(this.instanceName, apiKey);
}
/**

@@ -58,12 +116,25 @@ * Tracks an event. Events are saved locally.

* @param eventType The name of the event you wish to track.
* @param eventProperties The event's properties.
* @param extra Extra untyped parameters for use in middleware.
*/
logEvent(eventType, eventProperties) {
if (eventProperties && Object.keys(eventProperties).length > 0) {
return AmplitudeReactNative.logEventWithProperties(this.instanceName, eventType, eventProperties);
async logEvent(eventType, eventProperties, extra) {
const event = {
eventType,
eventProperties
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
if (event.eventProperties && Object.keys(event.eventProperties).length > 0) {
return AmplitudeReactNative.logEventWithProperties(this.instanceName, event.eventType, event.eventProperties);
}
return AmplitudeReactNative.logEvent(this.instanceName, event.eventType);
}
return AmplitudeReactNative.logEvent(this.instanceName, eventType);
}
/**

@@ -76,7 +147,6 @@ * Enable COPPA (Children's Online Privacy Protection Act) restrictions on

*/
enableCoppaControl() {
return AmplitudeReactNative.enableCoppaControl(this.instanceName);
}
/**

@@ -86,15 +156,13 @@ * Disable COPPA (Children's Online Privacy Protection Act) restrictions on

*/
disableCoppaControl() {
return AmplitudeReactNative.disableCoppaControl(this.instanceName);
}
/**
* Regenerate the DeviceId
*/
regenerateDeviceId() {
return AmplitudeReactNative.regenerateDeviceId(this.instanceName);
}
/**

@@ -105,7 +173,6 @@ * Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>

*/
setDeviceId(deviceId) {
return AmplitudeReactNative.setDeviceId(this.instanceName, deviceId);
}
/**

@@ -115,7 +182,6 @@ * Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.

*/
getDeviceId() {
return AmplitudeReactNative.getDeviceId(this.instanceName);
}
/**

@@ -125,7 +191,6 @@ * Use the Advertising ID on Android if available from Google Play Services.

*/
setAdvertisingIdForDeviceId() {
return AmplitudeReactNative.setAdvertisingIdForDeviceId(this.instanceName);
}
/**

@@ -135,7 +200,6 @@ * Use the App Set ID (fall back to this if `useAdvertisingIdForDeviceId` is used) for device ID.

*/
setAppSetIdForDeviceId() {
return AmplitudeReactNative.setAppSetIdForDeviceId(this.instanceName);
}
/**

@@ -152,7 +216,6 @@ * Enables tracking opt out.

*/
setOptOut(optOut) {
return AmplitudeReactNative.setOptOut(this.instanceName, optOut);
}
/**

@@ -164,7 +227,6 @@ * Whether to automatically log start and end session events corresponding to

*/
trackingSessionEvents(trackSessionEvents) {
return AmplitudeReactNative.trackingSessionEvents(this.instanceName, trackSessionEvents);
}
/**

@@ -176,7 +238,6 @@ * If your app has its own login system that you want to track users with,

*/
setUserId(userId) {
return AmplitudeReactNative.setUserId(this.instanceName, userId);
}
/**

@@ -187,7 +248,6 @@ * Customize the destination for server url.

*/
setServerUrl(serverUrl) {
return AmplitudeReactNative.setServerUrl(this.instanceName, serverUrl);
}
/**

@@ -198,7 +258,6 @@ * Dynamically adjust server URL

*/
setUseDynamicConfig(useDynamicConfig) {
return AmplitudeReactNative.setUseDynamicConfig(this.instanceName, useDynamicConfig);
}
/**

@@ -212,7 +271,6 @@ * Log revenue data.

*/
logRevenue(userProperties) {
return AmplitudeReactNative.logRevenueV2(this.instanceName, userProperties);
}
/**

@@ -222,8 +280,23 @@ * Send an identify call containing user property operations to Amplitude servers.

* @param identifyInstance
* @param extra
*/
async identify(identifyInstance, extra) {
const event = {
eventType: _types.SpecialEventType.IDENTIFY,
userProperties: {
...identifyInstance.payload
}
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.identify(this.instanceName, event.userProperties);
}
identify(identifyInstance) {
return AmplitudeReactNative.identify(this.instanceName, identifyInstance.payload);
}
/**

@@ -234,7 +307,6 @@ * Adds a user to a group or groups. You need to specify a groupType and groupName(s).

*/
setGroup(groupType, groupName) {
return AmplitudeReactNative.setGroup(this.instanceName, groupType, groupName);
}
/**

@@ -246,8 +318,25 @@ * Set or update properties of particular groups

* @param identifyInstance
* @param extra
*/
async groupIdentify(groupType, groupName, identifyInstance, extra) {
const event = {
eventType: _types.SpecialEventType.GROUP_IDENTIFY,
groupType,
groupName,
groupProperties: {
...identifyInstance.payload
}
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.groupIdentify(this.instanceName, event.groupType, event.groupName, event.groupProperties);
}
groupIdentify(groupType, groupName, identifyInstance) {
return AmplitudeReactNative.groupIdentify(this.instanceName, groupType, groupName, identifyInstance.payload);
}
/**

@@ -259,7 +348,6 @@ * Adds properties that are tracked on the user level.

*/
setUserProperties(userProperties) {
return AmplitudeReactNative.setUserProperties(this.instanceName, userProperties);
}
/**

@@ -270,15 +358,13 @@ * Clears all properties that are tracked on the user level.

*/
clearUserProperties() {
return AmplitudeReactNative.clearUserProperties(this.instanceName);
}
/**
* Upload all unsent events.
*/
uploadEvents() {
return AmplitudeReactNative.uploadEvents(this.instanceName);
}
/**

@@ -288,7 +374,6 @@ * Fetches the sessionId, a timestamp used for log session event.

*/
getSessionId() {
return AmplitudeReactNative.getSessionId(this.instanceName);
}
/**

@@ -300,7 +385,6 @@ * Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.

*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis) {
return AmplitudeReactNative.setMinTimeBetweenSessionsMillis(this.instanceName, minTimeBetweenSessionsMillis);
}
/**

@@ -314,24 +398,112 @@ * Set Amplitude Server Zone, switch to zone related configuration,

*/
setServerZone(serverZone) {
let updateServerUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return AmplitudeReactNative.setServerZone(this.instanceName, serverZone, updateServerUrl);
}
/**
* Sets event upload max batch size. This controls the maximum number of events sent with
* each upload request.
*
* @param eventUploadMaxBatchSize the event upload max batch size
*/
setEventUploadMaxBatchSize(eventUploadMaxBatchSize) {
return AmplitudeReactNative.setEventUploadMaxBatchSize(this.instanceName, eventUploadMaxBatchSize);
}
setServerZone(serverZone, updateServerUrl = true) {
return AmplitudeReactNative.setServerZone(this.instanceName, serverZone, updateServerUrl);
} // Private bridging calls
/**
* Sets event upload period millis. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadPeriodMillis the event upload period millis
*/
setEventUploadPeriodMillis(eventUploadPeriodMillis) {
return AmplitudeReactNative.setEventUploadPeriodMillis(this.instanceName, eventUploadPeriodMillis);
}
/**
* Sets event upload threshold. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadThreshold the event upload threshold
*/
setEventUploadThreshold(eventUploadThreshold) {
return AmplitudeReactNative.setEventUploadThreshold(this.instanceName, eventUploadThreshold);
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan) {
return AmplitudeReactNative.setPlan(this.instanceName, plan);
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata) {
return AmplitudeReactNative.setIngestionMetadata(this.instanceName, ingestionMetadata);
}
addEventMiddleware(middleware) {
this._middlewareRunner.add(middleware);
return this;
}
/**
* Enable/disable message logging by the SDK.
*
* @param enableLogging whether to enable message logging by the SDK.
*/
enableLogging(enableLogging) {
return AmplitudeReactNative.enableLogging(this.instanceName, enableLogging);
}
/**
* Add log callback, it can help read and collect error message from sdk. The call back function like the following format
* ({ tag, message }: { tag: string, message: string }) => {
* //implement your own logic
* }
*
* @param callback
*/
addLogCallback(callback) {
return this._nativeEventEmitter.addListener('AmplitudeLogError', callback);
}
/**
* Sets the logging level. Logging messages will only appear if they are the same severity
* level or higher than the set log level.
*
* @param logLevel the log level
*/
setLogLevel(logLevel) {
return AmplitudeReactNative.setLogLevel(this.instanceName, logLevel);
}
// Private bridging calls
_setLibraryName(libraryName) {
return AmplitudeReactNative.setLibraryName(this.instanceName, libraryName);
}
_setLibraryVersion(libraryVersion) {
return AmplitudeReactNative.setLibraryVersion(this.instanceName, libraryVersion);
}
_runMiddlewares(event, extra) {
let middlewareCompleted = false;
this._middlewareRunner.run({
event,
extra
}, () => {
middlewareCompleted = true;
});
return middlewareCompleted;
}
}
exports.Amplitude = Amplitude;
_defineProperty(Amplitude, "_instances", void 0);
_defineProperty(Amplitude, "_defaultInstanceName", '$default_instance');
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["index.ts"],"names":["AmplitudeReactNative","NativeModules","Amplitude","constructor","instanceName","_setLibraryName","Constants","packageSourceName","_setLibraryVersion","packageVersion","getInstance","_defaultInstanceName","_instances","Object","prototype","hasOwnProperty","call","init","apiKey","initialize","logEvent","eventType","eventProperties","keys","length","logEventWithProperties","enableCoppaControl","disableCoppaControl","regenerateDeviceId","setDeviceId","deviceId","getDeviceId","setAdvertisingIdForDeviceId","setAppSetIdForDeviceId","setOptOut","optOut","trackingSessionEvents","trackSessionEvents","setUserId","userId","setServerUrl","serverUrl","setUseDynamicConfig","useDynamicConfig","logRevenue","userProperties","logRevenueV2","identify","identifyInstance","payload","setGroup","groupType","groupName","groupIdentify","setUserProperties","clearUserProperties","uploadEvents","getSessionId","setMinTimeBetweenSessionsMillis","minTimeBetweenSessionsMillis","setServerZone","serverZone","updateServerUrl","libraryName","setLibraryName","libraryVersion","setLibraryVersion"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;AAGA,MAAMA,oBAAgD,GACpDC,2BAAcD,oBADhB;;AAKO,MAAME,SAAN,CAAgB;AAKbC,EAAAA,WAAR,CAAoBC,YAApB,EAA0C;AAAA;;AACxC,SAAKA,YAAL,GAAoBA,YAApB;;AACA,SAAKC,eAAL,CAAqBC,qBAAUC,iBAA/B;;AACA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wD,YAArB,CAAkC,KAAKpD,YAAvC,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACEqD,EAAAA,YAAY,GAAoB;AAC9B,WAAOzD,oBAAoB,CAACyD,YAArB,CAAkC,KAAKrD,YAAvC,CAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;AACEsD,EAAAA,+BAA+B,CAC7BC,4BAD6B,EAEX;AAClB,WAAO3D,oBAAoB,CAAC0D,+BAArB,CACL,KAAKtD,YADA,EAELuD,4BAFK,CAAP;AAID;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AACEC,EAAAA,aAAa,CACXC,UADW,EAEXC,eAAwB,GAAG,IAFhB,EAGO;AAClB,WAAO9D,oBAAoB,CAAC4D,aAArB,CACL,KAAKxD,YADA,EAELyD,UAFK,EAGLC,eAHK,CAAP;AAKD,GA7SoB,CA+SrB;;;AACQzD,EAAAA,eAAR,CAAwB0D,WAAxB,EAA+D;AAC7D,WAAO/D,oBAAoB,CAACgE,cAArB,CAAoC,KAAK5D,YAAzC,EAAuD2D,WAAvD,CAAP;AACD;;AAEOvD,EAAAA,kBAAR,CAA2ByD,cAA3B,EAAqE;AACnE,WAAOjE,oBAAoB,CAACkE,iBAArB,CACL,KAAK9D,YADA,EAEL6D,cAFK,CAAP;AAID;;AAzToB;;;;gBAAV/D,S;;gBAAAA,S,0BAE2B,mB","sourcesContent":["import { NativeModules } from 'react-native';\n\nimport { Constants } from './constants';\nimport { Identify } from './identify';\nimport { AmplitudeReactNativeModule } from './types';\n\nconst AmplitudeReactNative: AmplitudeReactNativeModule =\n NativeModules.AmplitudeReactNative;\n\nexport { Identify };\n\nexport class Amplitude {\n private static _instances: Record<string, Amplitude>;\n private static _defaultInstanceName = '$default_instance';\n instanceName: string;\n\n private constructor(instanceName: string) {\n this.instanceName = instanceName;\n this._setLibraryName(Constants.packageSourceName);\n this._setLibraryVersion(Constants.packageVersion);\n }\n\n static getInstance(\n instanceName: string = this._defaultInstanceName,\n ): Amplitude {\n if (!this._instances) {\n this._instances = {};\n }\n if (!Object.prototype.hasOwnProperty.call(this._instances, instanceName)) {\n this._instances[instanceName] = new Amplitude(instanceName);\n }\n\n return this._instances[instanceName];\n }\n\n init(apiKey: string): Promise<boolean> {\n return AmplitudeReactNative.initialize(this.instanceName, apiKey);\n }\n\n /**\n * Tracks an event. Events are saved locally.\n * Uploads are batched to occur every 30 events or every 30 seconds\n * (whichever comes first), as well as on app close.\n *\n * @param eventType The name of the event you wish to track.\n */\n logEvent(\n eventType: string,\n eventProperties?: Record<string, unknown>,\n ): Promise<boolean> {\n if (eventProperties && Object.keys(eventProperties).length > 0) {\n return AmplitudeReactNative.logEventWithProperties(\n this.instanceName,\n eventType,\n eventProperties,\n );\n }\n return AmplitudeReactNative.logEvent(this.instanceName, eventType);\n }\n\n /**\n * Enable COPPA (Children's Online Privacy Protection Act) restrictions on\n * IDFA, IDFV, city, IP address and location tracking.\n *\n * This can be used by any customer that does not want to collect IDFA, IDFV,\n * city, IP address and location tracking.\n */\n enableCoppaControl(): Promise<boolean> {\n return AmplitudeReactNative.enableCoppaControl(this.instanceName);\n }\n\n /**\n * Disable COPPA (Children's Online Privacy Protection Act) restrictions on\n * IDFA, IDFV, city, IP address and location tracking.\n */\n disableCoppaControl(): Promise<boolean> {\n return AmplitudeReactNative.disableCoppaControl(this.instanceName);\n }\n\n /**\n * Regenerate the DeviceId\n */\n regenerateDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.regenerateDeviceId(this.instanceName);\n }\n\n /**\n * Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>\n *\n * @param deviceId The device id.\n */\n setDeviceId(deviceId: string): Promise<boolean> {\n return AmplitudeReactNative.setDeviceId(this.instanceName, deviceId);\n }\n\n /**\n * Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.\n * @returns the deviceId.\n */\n getDeviceId(): Promise<string> {\n return AmplitudeReactNative.getDeviceId(this.instanceName);\n }\n\n /**\n * Use the Advertising ID on Android if available from Google Play Services.\n * Must be called before init.\n */\n setAdvertisingIdForDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.setAdvertisingIdForDeviceId(this.instanceName);\n }\n\n /**\n * Use the App Set ID (fall back to this if `useAdvertisingIdForDeviceId` is used) for device ID.\n * Must be called before init.\n */\n setAppSetIdForDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.setAppSetIdForDeviceId(this.instanceName);\n }\n\n /**\n * Enables tracking opt out.\n *\n * If the user wants to opt out of all tracking, use this method to enable\n * opt out for them. Once opt out is enabled, no events will be saved locally\n * or sent to the server.\n *\n * Calling this method again with enabled set to false will turn tracking back on for the user.\n *\n * @param optOut\n */\n setOptOut(optOut: boolean): Promise<boolean> {\n return AmplitudeReactNative.setOptOut(this.instanceName, optOut);\n }\n\n /**\n * Whether to automatically log start and end session events corresponding to\n * the start and end of a user's session.\n *\n * @param trackSessionEvents\n */\n trackingSessionEvents(trackSessionEvents: boolean): Promise<boolean> {\n return AmplitudeReactNative.trackingSessionEvents(\n this.instanceName,\n trackSessionEvents,\n );\n }\n\n /**\n * If your app has its own login system that you want to track users with,\n * you can set the userId.\n *\n * @param userId\n */\n setUserId(userId: string | null): Promise<boolean> {\n return AmplitudeReactNative.setUserId(this.instanceName, userId);\n }\n\n /**\n * Customize the destination for server url.\n *\n * @param serverUrl\n */\n setServerUrl(serverUrl: string): Promise<boolean> {\n return AmplitudeReactNative.setServerUrl(this.instanceName, serverUrl);\n }\n\n /**\n * Dynamically adjust server URL\n *\n * @param useDynamicConfig\n */\n setUseDynamicConfig(useDynamicConfig: boolean): Promise<boolean> {\n return AmplitudeReactNative.setUseDynamicConfig(\n this.instanceName,\n useDynamicConfig,\n );\n }\n\n /**\n * Log revenue data.\n *\n * Note: price is a required field to log revenue events.\n * If quantity is not specified then defaults to 1.\n *\n * @param userProperties\n */\n logRevenue(userProperties: {\n price: number;\n productId?: string;\n quantity?: number;\n revenueType?: string;\n receipt?: string;\n receiptSignature?: string;\n eventProperties?: { [key: string]: any };\n }): Promise<boolean> {\n return AmplitudeReactNative.logRevenueV2(this.instanceName, userProperties);\n }\n\n /**\n * Send an identify call containing user property operations to Amplitude servers.\n *\n * @param identifyInstance\n */\n identify(identifyInstance: Identify): Promise<boolean> {\n return AmplitudeReactNative.identify(\n this.instanceName,\n identifyInstance.payload,\n );\n }\n\n /**\n * Adds a user to a group or groups. You need to specify a groupType and groupName(s).\n * @param groupType\n * @param groupName\n */\n setGroup(groupType: string, groupName: string | string[]): Promise<boolean> {\n return AmplitudeReactNative.setGroup(\n this.instanceName,\n groupType,\n groupName,\n );\n }\n\n /**\n * Set or update properties of particular groups\n *\n * @param groupType\n * @param groupName\n * @param identifyInstance\n */\n groupIdentify(\n groupType: string,\n groupName: string | string[],\n identifyInstance: Identify,\n ): Promise<boolean> {\n return AmplitudeReactNative.groupIdentify(\n this.instanceName,\n groupType,\n groupName,\n identifyInstance.payload,\n );\n }\n\n /**\n * Adds properties that are tracked on the user level.\n * Note: Property keys must be [String] objects and values must be serializable.\n *\n * @param userProperties\n */\n setUserProperties(userProperties: Record<string, unknown>): Promise<boolean> {\n return AmplitudeReactNative.setUserProperties(\n this.instanceName,\n userProperties,\n );\n }\n\n /**\n * Clears all properties that are tracked on the user level.\n *\n * Note: This operation is irreversible!!\n */\n clearUserProperties(): Promise<boolean> {\n return AmplitudeReactNative.clearUserProperties(this.instanceName);\n }\n\n /**\n * Upload all unsent events.\n */\n uploadEvents(): Promise<boolean> {\n return AmplitudeReactNative.uploadEvents(this.instanceName);\n }\n\n /**\n * Fetches the sessionId, a timestamp used for log session event.\n * @returns the sessionId.\n */\n getSessionId(): Promise<number> {\n return AmplitudeReactNative.getSessionId(this.instanceName);\n }\n\n /**\n * Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.\n * The default time is 5 minutes.\n *\n * @param minTimeBetweenSessionsMillis\n */\n setMinTimeBetweenSessionsMillis(\n minTimeBetweenSessionsMillis: number,\n ): Promise<boolean> {\n return AmplitudeReactNative.setMinTimeBetweenSessionsMillis(\n this.instanceName,\n minTimeBetweenSessionsMillis,\n );\n }\n\n /**\n * Set Amplitude Server Zone, switch to zone related configuration,\n * including dynamic configuration. If updateServerUrl is true, including server url as well.\n * Recommend to keep updateServerUrl to be true for alignment.\n *\n * @param serverZone amplitude serverZone, US or EU, default is US\n * @param updateServerUrl if update server url when update server zone, recommend setting true\n */\n setServerZone(\n serverZone: string,\n updateServerUrl: boolean = true,\n ): Promise<boolean> {\n return AmplitudeReactNative.setServerZone(\n this.instanceName,\n serverZone,\n updateServerUrl,\n );\n }\n\n // Private bridging calls\n private _setLibraryName(libraryName: string): Promise<boolean> {\n return AmplitudeReactNative.setLibraryName(this.instanceName, libraryName);\n }\n\n private _setLibraryVersion(libraryVersion: string): Promise<boolean> {\n return AmplitudeReactNative.setLibraryVersion(\n this.instanceName,\n libraryVersion,\n );\n }\n}\n"]}
{"version":3,"names":["_reactNative","require","_constants","_identify","_types","_middlewareRunner","AmplitudeReactNative","NativeModules","Amplitude","_defaultInstanceName","constructor","instanceName","MiddlewareRunner","_setLibraryName","Constants","packageSourceName","_setLibraryVersion","packageVersion","_nativeEventEmitter","NativeEventEmitter","getInstance","arguments","length","undefined","_instances","Object","prototype","hasOwnProperty","call","init","apiKey","initialize","logEvent","eventType","eventProperties","extra","event","_runMiddlewares","Promise","resolve","userId","setUserId","deviceId","setDeviceId","keys","logEventWithProperties","enableCoppaControl","disableCoppaControl","regenerateDeviceId","getDeviceId","setAdvertisingIdForDeviceId","setAppSetIdForDeviceId","setOptOut","optOut","trackingSessionEvents","trackSessionEvents","setServerUrl","serverUrl","setUseDynamicConfig","useDynamicConfig","logRevenue","userProperties","logRevenueV2","identify","identifyInstance","SpecialEventType","IDENTIFY","payload","setGroup","groupType","groupName","groupIdentify","GROUP_IDENTIFY","groupProperties","setUserProperties","clearUserProperties","uploadEvents","getSessionId","setMinTimeBetweenSessionsMillis","minTimeBetweenSessionsMillis","setServerZone","serverZone","updateServerUrl","setEventUploadMaxBatchSize","eventUploadMaxBatchSize","setEventUploadPeriodMillis","eventUploadPeriodMillis","setEventUploadThreshold","eventUploadThreshold","setPlan","plan","setIngestionMetadata","ingestionMetadata","addEventMiddleware","middleware","add","enableLogging","addLogCallback","callback","addListener","setLogLevel","logLevel","libraryName","setLibraryName","libraryVersion","setLibraryVersion","middlewareCompleted","run","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAaA,IAAAI,iBAAA,GAAAJ,OAAA;AAEA,MAAMK,oBAAgD,GACpDC,0BAAa,CAACD,oBAAoB;AAiB7B,MAAME,SAAS,CAAC;EAErB,OAAeC,oBAAoB,GAAG,mBAAmB;EAKjDC,WAAWA,CAACC,YAAoB,EAAE;IACxC,IAAI,CAACA,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACN,iBAAiB,GAAG,IAAIO,kCAAgB,EAAE;IAC/C,IAAI,CAACC,eAAe,CAACC,oBAAS,CAACC,iBAAiB,CAAC;IACjD,IAAI,CAACC,kBAAkB,CAACF,oBAAS,CAACG,cAAc,CAAC;IAEjD,IAAI,CAACC,mBAAmB,GAAG,IAAIC,+BAAkB,CAC/CZ,0BAAa,CAACD,oBAAoB,CACnC;EACH;EAEA,OAAOc,WAAWA,CAAA,EAEL;IAAA,IADXT,YAAoB,GAAAU,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI,CAACZ,oBAAoB;IAEhD,IAAI,CAAC,IAAI,CAACe,UAAU,EAAE;MACpB,IAAI,CAACA,UAAU,GAAG,CAAC,CAAC;IACtB;IACA,IAAI,CAACC,MAAM,CAACC,SAAS,CAACC,cAAc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AEQtF,kBAAkBA,CAACwF,cAAsB,EAAoB;IACnE,OAAOlG,oBAAoB,CAACmG,iBAAiB,CAC3C,IAAI,CAAC9F,YAAY,EACjB6F,cAAc,CACf;EACH;EAEQnE,eAAeA,CACrBD,KAAY,EACZD,KAAkC,EACzB;IACT,IAAIuE,mBAAmB,GAAG,KAAK;IAC/B,IAAI,CAACrG,iBAAiB,CAACsG,GAAG,CAAC;MAAEvE,KAAK;MAAED;IAAM,CAAC,EAAE,MAAM;MACjDuE,mBAAmB,GAAG,IAAI;IAC5B,CAAC,CAAC;IAEF,OAAOA,mBAAmB;EAC5B;AACF;AAACE,OAAA,CAAApG,SAAA,GAAAA,SAAA"}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SpecialEventType = void 0;
/**
* Strings that have special meaning when used as an event's type
* and have different specifications.
*/
let SpecialEventType = /*#__PURE__*/function (SpecialEventType) {
SpecialEventType["IDENTIFY"] = "$identify";
SpecialEventType["GROUP_IDENTIFY"] = "$groupidentify";
return SpecialEventType;
}({});
exports.SpecialEventType = SpecialEventType;
//# sourceMappingURL=types.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
{"version":3,"names":["SpecialEventType","exports"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;;;;;AA4GA;AACA;AACA;AACA;AAHA,IAIYA,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAAAC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA"}
export const Constants = {
packageSourceName: 'amplitude-react-native',
packageVersion: '2.6.0'
packageVersion: '2.17.2'
};
//# sourceMappingURL=constants.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["constants.ts"],"names":["Constants","packageSourceName","packageVersion"],"mappings":"AAAA,OAAO,MAAMA,SAGZ,GAAG;AACFC,EAAAA,iBAAiB,EAAE,wBADjB;AAEFC,EAAAA,cAAc,EAAE;AAFd,CAHG","sourcesContent":["export const Constants: {\n packageSourceName: string;\n packageVersion: string;\n} = {\n packageSourceName: 'amplitude-react-native',\n packageVersion: '2.6.0',\n};\n"]}
{"version":3,"names":["Constants","packageSourceName","packageVersion"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":"AAAA,OAAO,MAAMA,SAGZ,GAAG;EACFC,iBAAiB,EAAE,wBAAwB;EAC3CC,cAAc,EAAE;AAClB,CAAC"}

@@ -1,59 +0,50 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export let IdentifyOperation = /*#__PURE__*/function (IdentifyOperation) {
IdentifyOperation["SET"] = "$set";
IdentifyOperation["SET_ONCE"] = "$setOnce";
IdentifyOperation["ADD"] = "$add";
IdentifyOperation["APPEND"] = "$append";
IdentifyOperation["PREINSERT"] = "$preInsert";
IdentifyOperation["POSTINSERT"] = "$postInsert";
IdentifyOperation["UNSET"] = "$unset";
return IdentifyOperation;
}({});
export class Identify {
static ALL_OPS = [IdentifyOperation.SET, IdentifyOperation.SET_ONCE, IdentifyOperation.ADD, IdentifyOperation.APPEND, IdentifyOperation.PREINSERT, IdentifyOperation.POSTINSERT, IdentifyOperation.UNSET];
constructor() {
_defineProperty(this, "payload", void 0);
this.payload = {};
}
set(key, value) {
this.addOp(Identify.OP_SET, key, value);
this.addOp(IdentifyOperation.SET, key, value);
}
setOnce(key, value) {
this.addOp(Identify.OP_SET_ONCE, key, value);
this.addOp(IdentifyOperation.SET_ONCE, key, value);
}
add(key, value) {
this.addOp(Identify.OP_ADD, key, value);
this.addOp(IdentifyOperation.ADD, key, value);
}
unset(key) {
this.addOp(Identify.OP_UNSET, key, '-');
this.addOp(IdentifyOperation.UNSET, key, '-');
}
append(key, value) {
this.addOp(Identify.OP_APPEND, key, value);
this.addOp(IdentifyOperation.APPEND, key, value);
}
preInsert(key, value) {
this.addOp(IdentifyOperation.PREINSERT, key, value);
}
postInsert(key, value) {
this.addOp(IdentifyOperation.POSTINSERT, key, value);
}
addOp(op, key, value) {
if (!Identify.ALL_OPS.includes(op)) {
throw new Error("Unknown Identify operation: ".concat(op, " called with key: ").concat(key, " value: ").concat(String(value)));
throw new Error(`Unknown Identify operation: ${op} called with key: ${key} value: ${String(value)}`);
}
this.opMap(op)[key] = value;
}
opMap(key) {
if (!Object.prototype.hasOwnProperty.call(this.payload, key)) {
this.payload[key] = {};
opMap(op) {
if (!Object.prototype.hasOwnProperty.call(this.payload, op)) {
this.payload[op] = {};
}
return this.payload[key];
return this.payload[op];
}
}
_defineProperty(Identify, "OP_SET", '$set');
_defineProperty(Identify, "OP_SET_ONCE", '$setOnce');
_defineProperty(Identify, "OP_ADD", '$add');
_defineProperty(Identify, "OP_APPEND", '$append');
_defineProperty(Identify, "OP_UNSET", '$unset');
_defineProperty(Identify, "ALL_OPS", [Identify.OP_SET, Identify.OP_SET_ONCE, Identify.OP_ADD, Identify.OP_APPEND, Identify.OP_UNSET]);
//# sourceMappingURL=identify.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["identify.ts"],"names":["Identify","constructor","payload","set","key","value","addOp","OP_SET","setOnce","OP_SET_ONCE","add","OP_ADD","unset","OP_UNSET","append","OP_APPEND","op","ALL_OPS","includes","Error","String","opMap","Object","prototype","hasOwnProperty","call"],"mappings":";;AAAA,OAAO,MAAMA,QAAN,CAAe;AAiBpBC,EAAAA,WAAW,GAAG;AAAA;;AACZ,SAAKC,OAAL,GAAe,EAAf;AACD;;AAEDC,EAAAA,GAAG,CAACC,GAAD,EAAcC,KAAd,EAAoC;AACrC,SAAKC,KAAL,CAAWN,QAAQ,CAACO,MAApB,EAA4BH,GAA5B,EAAiCC,KAAjC;AACD;;AAEDG,EAAAA,OAAO,CAACJ,GAAD,EAAcC,KAAd,EAAoC;AACzC,SAAKC,KAAL,CAAWN,QAAQ,CAACS,WAApB,EAAiCL,GAAjC,EAAsCC,KAAtC;A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CAACe,SAJc,EAKvBf,QAAQ,CAACa,QALc,C","sourcesContent":["export class Identify {\n payload: Record<string, Record<string, unknown>>;\n\n private static OP_SET = '$set';\n private static OP_SET_ONCE = '$setOnce';\n private static OP_ADD = '$add';\n private static OP_APPEND = '$append';\n private static OP_UNSET = '$unset';\n\n private static ALL_OPS = [\n Identify.OP_SET,\n Identify.OP_SET_ONCE,\n Identify.OP_ADD,\n Identify.OP_APPEND,\n Identify.OP_UNSET,\n ];\n\n constructor() {\n this.payload = {};\n }\n\n set(key: string, value: unknown): void {\n this.addOp(Identify.OP_SET, key, value);\n }\n\n setOnce(key: string, value: unknown): void {\n this.addOp(Identify.OP_SET_ONCE, key, value);\n }\n\n add(key: string, value: number): void {\n this.addOp(Identify.OP_ADD, key, value);\n }\n\n unset(key: string): void {\n this.addOp(Identify.OP_UNSET, key, '-');\n }\n\n append(key: string, value: unknown): void {\n this.addOp(Identify.OP_APPEND, key, value);\n }\n\n private addOp(op: string, key: string, value: unknown): void {\n if (!Identify.ALL_OPS.includes(op)) {\n throw new Error(\n `Unknown Identify operation: ${op} called with key: ${key} value: ${String(\n value,\n )}`,\n );\n }\n this.opMap(op)[key] = value;\n }\n\n private opMap(key: string): Record<string, unknown> {\n if (!Object.prototype.hasOwnProperty.call(this.payload, key)) {\n this.payload[key] = {};\n }\n return this.payload[key];\n }\n}\n"]}
{"version":3,"names":["IdentifyOperation","Identify","ALL_OPS","SET","SET_ONCE","ADD","APPEND","PREINSERT","POSTINSERT","UNSET","constructor","payload","set","key","value","addOp","setOnce","add","unset","append","preInsert","postInsert","op","includes","Error","String","opMap","Object","prototype","hasOwnProperty","call"],"sourceRoot":"../../src","sources":["identify.ts"],"mappings":"AAAA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB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ACf,iBAAiB,CAACQ,UAAU,EAAEK,GAAG,EAAEC,KAAK,CAAC;EACtD;EAEQC,KAAKA,CAACO,EAAqB,EAAET,GAAW,EAAEC,KAAc,EAAQ;IACtE,IAAI,CAACb,QAAQ,CAACC,OAAO,CAACqB,QAAQ,CAACD,EAAE,CAAC,EAAE;MAClC,MAAM,IAAIE,KAAK,CACZ,+BAA8BF,EAAG,qBAAoBT,GAAI,WAAUY,MAAM,CACxEX,KAAK,CACL,EAAC,CACJ;IACH;IACA,IAAI,CAACY,KAAK,CAACJ,EAAE,CAAC,CAACT,GAAG,CAAC,GAAGC,KAAK;EAC7B;EAEQY,KAAKA,CAACJ,EAAqB,EAA2B;IAC5D,IAAI,CAACK,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAAC,IAAI,CAACnB,OAAO,EAAEW,EAAE,CAAC,EAAE;MAC3D,IAAI,CAACX,OAAO,CAACW,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB;IACA,OAAO,IAAI,CAACX,OAAO,CAACW,EAAE,CAAC;EACzB;AACF"}

@@ -1,34 +0,31 @@

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { NativeModules } from 'react-native';
import { NativeModules, NativeEventEmitter } from 'react-native';
import { Constants } from './constants';
import { Identify } from './identify';
import { Identify, IdentifyPayload, IdentifyOperation } from './identify';
import { Event, BaseEvent, IdentifyEvent, GroupIdentifyEvent, Middleware, MiddlewareExtra, SpecialEventType, Plan, IngestionMetadata } from './types';
import { MiddlewareRunner } from './middlewareRunner';
const AmplitudeReactNative = NativeModules.AmplitudeReactNative;
export { Identify };
export { Identify, Event, BaseEvent, IdentifyEvent, GroupIdentifyEvent, Middleware, MiddlewareExtra, SpecialEventType, IdentifyPayload, IdentifyOperation, Plan, IngestionMetadata };
export class Amplitude {
static _defaultInstanceName = '$default_instance';
constructor(instanceName) {
_defineProperty(this, "instanceName", void 0);
this.instanceName = instanceName;
this._middlewareRunner = new MiddlewareRunner();
this._setLibraryName(Constants.packageSourceName);
this._setLibraryVersion(Constants.packageVersion);
this._nativeEventEmitter = new NativeEventEmitter(NativeModules.AmplitudeReactNative);
}
static getInstance(instanceName = this._defaultInstanceName) {
static getInstance() {
let instanceName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._defaultInstanceName;
if (!this._instances) {
this._instances = {};
}
if (!Object.prototype.hasOwnProperty.call(this._instances, instanceName)) {
this._instances[instanceName] = new Amplitude(instanceName);
}
return this._instances[instanceName];
}
init(apiKey) {
return AmplitudeReactNative.initialize(this.instanceName, apiKey);
}
/**

@@ -40,12 +37,25 @@ * Tracks an event. Events are saved locally.

* @param eventType The name of the event you wish to track.
* @param eventProperties The event's properties.
* @param extra Extra untyped parameters for use in middleware.
*/
logEvent(eventType, eventProperties) {
if (eventProperties && Object.keys(eventProperties).length > 0) {
return AmplitudeReactNative.logEventWithProperties(this.instanceName, eventType, eventProperties);
async logEvent(eventType, eventProperties, extra) {
const event = {
eventType,
eventProperties
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
if (event.eventProperties && Object.keys(event.eventProperties).length > 0) {
return AmplitudeReactNative.logEventWithProperties(this.instanceName, event.eventType, event.eventProperties);
}
return AmplitudeReactNative.logEvent(this.instanceName, event.eventType);
}
return AmplitudeReactNative.logEvent(this.instanceName, eventType);
}
/**

@@ -58,7 +68,6 @@ * Enable COPPA (Children's Online Privacy Protection Act) restrictions on

*/
enableCoppaControl() {
return AmplitudeReactNative.enableCoppaControl(this.instanceName);
}
/**

@@ -68,15 +77,13 @@ * Disable COPPA (Children's Online Privacy Protection Act) restrictions on

*/
disableCoppaControl() {
return AmplitudeReactNative.disableCoppaControl(this.instanceName);
}
/**
* Regenerate the DeviceId
*/
regenerateDeviceId() {
return AmplitudeReactNative.regenerateDeviceId(this.instanceName);
}
/**

@@ -87,7 +94,6 @@ * Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>

*/
setDeviceId(deviceId) {
return AmplitudeReactNative.setDeviceId(this.instanceName, deviceId);
}
/**

@@ -97,7 +103,6 @@ * Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.

*/
getDeviceId() {
return AmplitudeReactNative.getDeviceId(this.instanceName);
}
/**

@@ -107,7 +112,6 @@ * Use the Advertising ID on Android if available from Google Play Services.

*/
setAdvertisingIdForDeviceId() {
return AmplitudeReactNative.setAdvertisingIdForDeviceId(this.instanceName);
}
/**

@@ -117,7 +121,6 @@ * Use the App Set ID (fall back to this if `useAdvertisingIdForDeviceId` is used) for device ID.

*/
setAppSetIdForDeviceId() {
return AmplitudeReactNative.setAppSetIdForDeviceId(this.instanceName);
}
/**

@@ -134,7 +137,6 @@ * Enables tracking opt out.

*/
setOptOut(optOut) {
return AmplitudeReactNative.setOptOut(this.instanceName, optOut);
}
/**

@@ -146,7 +148,6 @@ * Whether to automatically log start and end session events corresponding to

*/
trackingSessionEvents(trackSessionEvents) {
return AmplitudeReactNative.trackingSessionEvents(this.instanceName, trackSessionEvents);
}
/**

@@ -158,7 +159,6 @@ * If your app has its own login system that you want to track users with,

*/
setUserId(userId) {
return AmplitudeReactNative.setUserId(this.instanceName, userId);
}
/**

@@ -169,7 +169,6 @@ * Customize the destination for server url.

*/
setServerUrl(serverUrl) {
return AmplitudeReactNative.setServerUrl(this.instanceName, serverUrl);
}
/**

@@ -180,7 +179,6 @@ * Dynamically adjust server URL

*/
setUseDynamicConfig(useDynamicConfig) {
return AmplitudeReactNative.setUseDynamicConfig(this.instanceName, useDynamicConfig);
}
/**

@@ -194,7 +192,6 @@ * Log revenue data.

*/
logRevenue(userProperties) {
return AmplitudeReactNative.logRevenueV2(this.instanceName, userProperties);
}
/**

@@ -204,8 +201,23 @@ * Send an identify call containing user property operations to Amplitude servers.

* @param identifyInstance
* @param extra
*/
async identify(identifyInstance, extra) {
const event = {
eventType: SpecialEventType.IDENTIFY,
userProperties: {
...identifyInstance.payload
}
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.identify(this.instanceName, event.userProperties);
}
identify(identifyInstance) {
return AmplitudeReactNative.identify(this.instanceName, identifyInstance.payload);
}
/**

@@ -216,7 +228,6 @@ * Adds a user to a group or groups. You need to specify a groupType and groupName(s).

*/
setGroup(groupType, groupName) {
return AmplitudeReactNative.setGroup(this.instanceName, groupType, groupName);
}
/**

@@ -228,8 +239,25 @@ * Set or update properties of particular groups

* @param identifyInstance
* @param extra
*/
async groupIdentify(groupType, groupName, identifyInstance, extra) {
const event = {
eventType: SpecialEventType.GROUP_IDENTIFY,
groupType,
groupName,
groupProperties: {
...identifyInstance.payload
}
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.groupIdentify(this.instanceName, event.groupType, event.groupName, event.groupProperties);
}
groupIdentify(groupType, groupName, identifyInstance) {
return AmplitudeReactNative.groupIdentify(this.instanceName, groupType, groupName, identifyInstance.payload);
}
/**

@@ -241,7 +269,6 @@ * Adds properties that are tracked on the user level.

*/
setUserProperties(userProperties) {
return AmplitudeReactNative.setUserProperties(this.instanceName, userProperties);
}
/**

@@ -252,15 +279,13 @@ * Clears all properties that are tracked on the user level.

*/
clearUserProperties() {
return AmplitudeReactNative.clearUserProperties(this.instanceName);
}
/**
* Upload all unsent events.
*/
uploadEvents() {
return AmplitudeReactNative.uploadEvents(this.instanceName);
}
/**

@@ -270,7 +295,6 @@ * Fetches the sessionId, a timestamp used for log session event.

*/
getSessionId() {
return AmplitudeReactNative.getSessionId(this.instanceName);
}
/**

@@ -282,7 +306,6 @@ * Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.

*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis) {
return AmplitudeReactNative.setMinTimeBetweenSessionsMillis(this.instanceName, minTimeBetweenSessionsMillis);
}
/**

@@ -296,22 +319,111 @@ * Set Amplitude Server Zone, switch to zone related configuration,

*/
setServerZone(serverZone) {
let updateServerUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return AmplitudeReactNative.setServerZone(this.instanceName, serverZone, updateServerUrl);
}
/**
* Sets event upload max batch size. This controls the maximum number of events sent with
* each upload request.
*
* @param eventUploadMaxBatchSize the event upload max batch size
*/
setEventUploadMaxBatchSize(eventUploadMaxBatchSize) {
return AmplitudeReactNative.setEventUploadMaxBatchSize(this.instanceName, eventUploadMaxBatchSize);
}
setServerZone(serverZone, updateServerUrl = true) {
return AmplitudeReactNative.setServerZone(this.instanceName, serverZone, updateServerUrl);
} // Private bridging calls
/**
* Sets event upload period millis. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadPeriodMillis the event upload period millis
*/
setEventUploadPeriodMillis(eventUploadPeriodMillis) {
return AmplitudeReactNative.setEventUploadPeriodMillis(this.instanceName, eventUploadPeriodMillis);
}
/**
* Sets event upload threshold. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadThreshold the event upload threshold
*/
setEventUploadThreshold(eventUploadThreshold) {
return AmplitudeReactNative.setEventUploadThreshold(this.instanceName, eventUploadThreshold);
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan) {
return AmplitudeReactNative.setPlan(this.instanceName, plan);
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata) {
return AmplitudeReactNative.setIngestionMetadata(this.instanceName, ingestionMetadata);
}
addEventMiddleware(middleware) {
this._middlewareRunner.add(middleware);
return this;
}
/**
* Enable/disable message logging by the SDK.
*
* @param enableLogging whether to enable message logging by the SDK.
*/
enableLogging(enableLogging) {
return AmplitudeReactNative.enableLogging(this.instanceName, enableLogging);
}
/**
* Add log callback, it can help read and collect error message from sdk. The call back function like the following format
* ({ tag, message }: { tag: string, message: string }) => {
* //implement your own logic
* }
*
* @param callback
*/
addLogCallback(callback) {
return this._nativeEventEmitter.addListener('AmplitudeLogError', callback);
}
/**
* Sets the logging level. Logging messages will only appear if they are the same severity
* level or higher than the set log level.
*
* @param logLevel the log level
*/
setLogLevel(logLevel) {
return AmplitudeReactNative.setLogLevel(this.instanceName, logLevel);
}
// Private bridging calls
_setLibraryName(libraryName) {
return AmplitudeReactNative.setLibraryName(this.instanceName, libraryName);
}
_setLibraryVersion(libraryVersion) {
return AmplitudeReactNative.setLibraryVersion(this.instanceName, libraryVersion);
}
_runMiddlewares(event, extra) {
let middlewareCompleted = false;
this._middlewareRunner.run({
event,
extra
}, () => {
middlewareCompleted = true;
});
return middlewareCompleted;
}
}
_defineProperty(Amplitude, "_instances", void 0);
_defineProperty(Amplitude, "_defaultInstanceName", '$default_instance');
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["index.ts"],"names":["NativeModules","Constants","Identify","AmplitudeReactNative","Amplitude","constructor","instanceName","_setLibraryName","packageSourceName","_setLibraryVersion","packageVersion","getInstance","_defaultInstanceName","_instances","Object","prototype","hasOwnProperty","call","init","apiKey","initialize","logEvent","eventType","eventProperties","keys","length","logEventWithProperties","enableCoppaControl","disableCoppaControl","regenerateDeviceId","setDeviceId","deviceId","getDeviceId","setAdvertisingIdForDeviceId","setAppSetIdForDeviceId","setOptOut","optOut","trackingSessionEvents","trackSessionEvents","setUserId","userId","setServerUrl","serverUrl","setUseDynamicConfig","useDynamicConfig","logRevenue","userProperties","logRevenueV2","identify","identifyInstance","payload","setGroup","groupType","groupName","groupIdentify","setUserProperties","clearUserProperties","uploadEvents","getSessionId","setMinTimeBetweenSessionsMillis","minTimeBetweenSessionsMillis","setServerZone","serverZone","updateServerUrl","libraryName","setLibraryName","libraryVersion","setLibraryVersion"],"mappings":";;AAAA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,QAAT,QAAyB,YAAzB;AAGA,MAAMC,oBAAgD,GACpDH,aAAa,CAACG,oBADhB;AAGA,SAASD,QAAT;AAEA,OAAO,MAAME,SAAN,CAAgB;AAKbC,EAAAA,WAAR,CAAoBC,YAApB,EAA0C;AAAA;;AACxC,SAAKA,YAAL,GAAoBA,YAApB;;AACA,SAAKC,eAAL,CAAqBN,SAAS,CAACO,iBAA/B;;AACA,SAAKC,kBAAL,CAAwBR,SAAS,CAACS,cAAlC;AACD;;AAED,SAAOC,WAAP,CACEL,YAAoB,GAAG,KAAKM,oBAD9B,EAEa;AACX,QAAI,CAAC,KAAKC,UAAV,EAAsB;AACpB,WAAKA,UAAL,GAAkB,EAAlB;AACD;;AACD,QAAI,CAACC,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqC,KAAKJ,UAA1C,EAAsDP,YAAtD,CAAL,EAA0E;AACxE,WAAKO,UAAL,CAAgBP,YAAhB,IAAgC,IAAIF,SAAJ,CAAcE,YAAd,CAAhC;AACD;;AAED,WAAO,KAAKO,UAAL,CAAgBP,YAAhB,CAAP;AACD;;AAEDY,EAAAA,IAAI,CAACC,MAAD,EAAmC;AACrC,WAAOhB,oBAAoB,CAACiB,UAArB,CAAgC,KAAKd,YAArC,EAAmDa,MAAnD,CAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACEE,EAAAA,QAAQ,CACNC,SADM,EAENC,eAFM,EAGY;AAClB,QAAIA,eAAe,IAAIT,MAAM,CAACU,IAAP,CA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,CAA2ByD,cAA3B,EAAqE;AACnE,WAAO/D,oBAAoB,CAACgE,iBAArB,CACL,KAAK7D,YADA,EAEL4D,cAFK,CAAP;AAID;;AAzToB;;gBAAV9D,S;;gBAAAA,S,0BAE2B,mB","sourcesContent":["import { NativeModules } from 'react-native';\n\nimport { Constants } from './constants';\nimport { Identify } from './identify';\nimport { AmplitudeReactNativeModule } from './types';\n\nconst AmplitudeReactNative: AmplitudeReactNativeModule =\n NativeModules.AmplitudeReactNative;\n\nexport { Identify };\n\nexport class Amplitude {\n private static _instances: Record<string, Amplitude>;\n private static _defaultInstanceName = '$default_instance';\n instanceName: string;\n\n private constructor(instanceName: string) {\n this.instanceName = instanceName;\n this._setLibraryName(Constants.packageSourceName);\n this._setLibraryVersion(Constants.packageVersion);\n }\n\n static getInstance(\n instanceName: string = this._defaultInstanceName,\n ): Amplitude {\n if (!this._instances) {\n this._instances = {};\n }\n if (!Object.prototype.hasOwnProperty.call(this._instances, instanceName)) {\n this._instances[instanceName] = new Amplitude(instanceName);\n }\n\n return this._instances[instanceName];\n }\n\n init(apiKey: string): Promise<boolean> {\n return AmplitudeReactNative.initialize(this.instanceName, apiKey);\n }\n\n /**\n * Tracks an event. Events are saved locally.\n * Uploads are batched to occur every 30 events or every 30 seconds\n * (whichever comes first), as well as on app close.\n *\n * @param eventType The name of the event you wish to track.\n */\n logEvent(\n eventType: string,\n eventProperties?: Record<string, unknown>,\n ): Promise<boolean> {\n if (eventProperties && Object.keys(eventProperties).length > 0) {\n return AmplitudeReactNative.logEventWithProperties(\n this.instanceName,\n eventType,\n eventProperties,\n );\n }\n return AmplitudeReactNative.logEvent(this.instanceName, eventType);\n }\n\n /**\n * Enable COPPA (Children's Online Privacy Protection Act) restrictions on\n * IDFA, IDFV, city, IP address and location tracking.\n *\n * This can be used by any customer that does not want to collect IDFA, IDFV,\n * city, IP address and location tracking.\n */\n enableCoppaControl(): Promise<boolean> {\n return AmplitudeReactNative.enableCoppaControl(this.instanceName);\n }\n\n /**\n * Disable COPPA (Children's Online Privacy Protection Act) restrictions on\n * IDFA, IDFV, city, IP address and location tracking.\n */\n disableCoppaControl(): Promise<boolean> {\n return AmplitudeReactNative.disableCoppaControl(this.instanceName);\n }\n\n /**\n * Regenerate the DeviceId\n */\n regenerateDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.regenerateDeviceId(this.instanceName);\n }\n\n /**\n * Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>\n *\n * @param deviceId The device id.\n */\n setDeviceId(deviceId: string): Promise<boolean> {\n return AmplitudeReactNative.setDeviceId(this.instanceName, deviceId);\n }\n\n /**\n * Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.\n * @returns the deviceId.\n */\n getDeviceId(): Promise<string> {\n return AmplitudeReactNative.getDeviceId(this.instanceName);\n }\n\n /**\n * Use the Advertising ID on Android if available from Google Play Services.\n * Must be called before init.\n */\n setAdvertisingIdForDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.setAdvertisingIdForDeviceId(this.instanceName);\n }\n\n /**\n * Use the App Set ID (fall back to this if `useAdvertisingIdForDeviceId` is used) for device ID.\n * Must be called before init.\n */\n setAppSetIdForDeviceId(): Promise<boolean> {\n return AmplitudeReactNative.setAppSetIdForDeviceId(this.instanceName);\n }\n\n /**\n * Enables tracking opt out.\n *\n * If the user wants to opt out of all tracking, use this method to enable\n * opt out for them. Once opt out is enabled, no events will be saved locally\n * or sent to the server.\n *\n * Calling this method again with enabled set to false will turn tracking back on for the user.\n *\n * @param optOut\n */\n setOptOut(optOut: boolean): Promise<boolean> {\n return AmplitudeReactNative.setOptOut(this.instanceName, optOut);\n }\n\n /**\n * Whether to automatically log start and end session events corresponding to\n * the start and end of a user's session.\n *\n * @param trackSessionEvents\n */\n trackingSessionEvents(trackSessionEvents: boolean): Promise<boolean> {\n return AmplitudeReactNative.trackingSessionEvents(\n this.instanceName,\n trackSessionEvents,\n );\n }\n\n /**\n * If your app has its own login system that you want to track users with,\n * you can set the userId.\n *\n * @param userId\n */\n setUserId(userId: string | null): Promise<boolean> {\n return AmplitudeReactNative.setUserId(this.instanceName, userId);\n }\n\n /**\n * Customize the destination for server url.\n *\n * @param serverUrl\n */\n setServerUrl(serverUrl: string): Promise<boolean> {\n return AmplitudeReactNative.setServerUrl(this.instanceName, serverUrl);\n }\n\n /**\n * Dynamically adjust server URL\n *\n * @param useDynamicConfig\n */\n setUseDynamicConfig(useDynamicConfig: boolean): Promise<boolean> {\n return AmplitudeReactNative.setUseDynamicConfig(\n this.instanceName,\n useDynamicConfig,\n );\n }\n\n /**\n * Log revenue data.\n *\n * Note: price is a required field to log revenue events.\n * If quantity is not specified then defaults to 1.\n *\n * @param userProperties\n */\n logRevenue(userProperties: {\n price: number;\n productId?: string;\n quantity?: number;\n revenueType?: string;\n receipt?: string;\n receiptSignature?: string;\n eventProperties?: { [key: string]: any };\n }): Promise<boolean> {\n return AmplitudeReactNative.logRevenueV2(this.instanceName, userProperties);\n }\n\n /**\n * Send an identify call containing user property operations to Amplitude servers.\n *\n * @param identifyInstance\n */\n identify(identifyInstance: Identify): Promise<boolean> {\n return AmplitudeReactNative.identify(\n this.instanceName,\n identifyInstance.payload,\n );\n }\n\n /**\n * Adds a user to a group or groups. You need to specify a groupType and groupName(s).\n * @param groupType\n * @param groupName\n */\n setGroup(groupType: string, groupName: string | string[]): Promise<boolean> {\n return AmplitudeReactNative.setGroup(\n this.instanceName,\n groupType,\n groupName,\n );\n }\n\n /**\n * Set or update properties of particular groups\n *\n * @param groupType\n * @param groupName\n * @param identifyInstance\n */\n groupIdentify(\n groupType: string,\n groupName: string | string[],\n identifyInstance: Identify,\n ): Promise<boolean> {\n return AmplitudeReactNative.groupIdentify(\n this.instanceName,\n groupType,\n groupName,\n identifyInstance.payload,\n );\n }\n\n /**\n * Adds properties that are tracked on the user level.\n * Note: Property keys must be [String] objects and values must be serializable.\n *\n * @param userProperties\n */\n setUserProperties(userProperties: Record<string, unknown>): Promise<boolean> {\n return AmplitudeReactNative.setUserProperties(\n this.instanceName,\n userProperties,\n );\n }\n\n /**\n * Clears all properties that are tracked on the user level.\n *\n * Note: This operation is irreversible!!\n */\n clearUserProperties(): Promise<boolean> {\n return AmplitudeReactNative.clearUserProperties(this.instanceName);\n }\n\n /**\n * Upload all unsent events.\n */\n uploadEvents(): Promise<boolean> {\n return AmplitudeReactNative.uploadEvents(this.instanceName);\n }\n\n /**\n * Fetches the sessionId, a timestamp used for log session event.\n * @returns the sessionId.\n */\n getSessionId(): Promise<number> {\n return AmplitudeReactNative.getSessionId(this.instanceName);\n }\n\n /**\n * Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.\n * The default time is 5 minutes.\n *\n * @param minTimeBetweenSessionsMillis\n */\n setMinTimeBetweenSessionsMillis(\n minTimeBetweenSessionsMillis: number,\n ): Promise<boolean> {\n return AmplitudeReactNative.setMinTimeBetweenSessionsMillis(\n this.instanceName,\n minTimeBetweenSessionsMillis,\n );\n }\n\n /**\n * Set Amplitude Server Zone, switch to zone related configuration,\n * including dynamic configuration. If updateServerUrl is true, including server url as well.\n * Recommend to keep updateServerUrl to be true for alignment.\n *\n * @param serverZone amplitude serverZone, US or EU, default is US\n * @param updateServerUrl if update server url when update server zone, recommend setting true\n */\n setServerZone(\n serverZone: string,\n updateServerUrl: boolean = true,\n ): Promise<boolean> {\n return AmplitudeReactNative.setServerZone(\n this.instanceName,\n serverZone,\n updateServerUrl,\n );\n }\n\n // Private bridging calls\n private _setLibraryName(libraryName: string): Promise<boolean> {\n return AmplitudeReactNative.setLibraryName(this.instanceName, libraryName);\n }\n\n private _setLibraryVersion(libraryVersion: string): Promise<boolean> {\n return AmplitudeReactNative.setLibraryVersion(\n this.instanceName,\n libraryVersion,\n );\n }\n}\n"]}
{"version":3,"names":["NativeModules","NativeEventEmitter","Constants","Identify","IdentifyPayload","IdentifyOperation","Event","BaseEvent","IdentifyEvent","GroupIdentifyEvent","Middleware","MiddlewareExtra","SpecialEventType","Plan","IngestionMetadata","MiddlewareRunner","AmplitudeReactNative","Amplitude","_defaultInstanceName","constructor","instanceName","_middlewareRunner","_setLibraryName","packageSourceName","_setLibraryVersion","packageVersion","_nativeEventEmitter","getInstance","arguments","length","undefined","_instances","Object","prototype","hasOwnProperty","call","init","apiKey","initialize","logEvent","eventType","eventProperties","extra","event","_runMiddlewares","Promise","resolve","userId","setUserId","deviceId","setDeviceId","keys","logEventWithProperties","enableCoppaControl","disableCoppaControl","regenerateDeviceId","getDeviceId","setAdvertisingIdForDeviceId","setAppSetIdForDeviceId","setOptOut","optOut","trackingSessionEvents","trackSessionEvents","setServerUrl","serverUrl","setUseDynamicConfig","useDynamicConfig","logRevenue","userProperties","logRevenueV2","identify","identifyInstance","IDENTIFY","payload","setGroup","groupType","groupName","groupIdentify","GROUP_IDENTIFY","groupProperties","setUserProperties","clearUserProperties","uploadEvents","getSessionId","setMinTimeBetweenSessionsMillis","minTimeBetweenSessionsMillis","setServerZone","serverZone","updateServerUrl","setEventUploadMaxBatchSize","eventUploadMaxBatchSize","setEventUploadPeriodMillis","eventUploadPeriodMillis","setEventUploadThreshold","eventUploadThreshold","setPlan","plan","setIngestionMetadata","ingestionMetadata","addEventMiddleware","middleware","add","enableLogging","addLogCallback","callback","addListener","setLogLevel","logLevel","libraryName","setLibraryName","libraryVersion","setLibraryVersion","middlewareCompleted","run"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SACEA,aAAa,EACbC,kBAAkB,QAEb,cAAc;AAErB,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,QAAQ,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,YAAY;AACzE,SAEEC,KAAK,EACLC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,UAAU,EACVC,eAAe,EACfC,gBAAgB,EAChBC,IAAI,EACJC,iBAAiB,QAEZ,SAAS;AAChB,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,oBAAgD,GACpDhB,aAAa,CAACgB,oBAAoB;AAEpC,SACEb,QAA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EAC5B;AACF"}

@@ -1,2 +0,10 @@

/**
* Strings that have special meaning when used as an event's type
* and have different specifications.
*/
export let SpecialEventType = /*#__PURE__*/function (SpecialEventType) {
SpecialEventType["IDENTIFY"] = "$identify";
SpecialEventType["GROUP_IDENTIFY"] = "$groupidentify";
return SpecialEventType;
}({});
//# sourceMappingURL=types.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
{"version":3,"names":["SpecialEventType"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"AA4GA;AACA;AACA;AACA;AACA,WAAYA,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA"}

@@ -5,1 +5,2 @@ export declare const Constants: {

};
//# sourceMappingURL=constants.d.ts.map

@@ -0,8 +1,21 @@

export declare enum IdentifyOperation {
SET = "$set",
SET_ONCE = "$setOnce",
ADD = "$add",
APPEND = "$append",
PREINSERT = "$preInsert",
POSTINSERT = "$postInsert",
UNSET = "$unset"
}
export interface IdentifyPayload {
[IdentifyOperation.ADD]?: Record<string, number>;
[IdentifyOperation.UNSET]?: Record<string, unknown>;
[IdentifyOperation.SET]?: Record<string, unknown>;
[IdentifyOperation.SET_ONCE]?: Record<string, unknown>;
[IdentifyOperation.APPEND]?: Record<string, unknown>;
[IdentifyOperation.PREINSERT]?: Record<string, unknown>;
[IdentifyOperation.POSTINSERT]?: Record<string, unknown>;
}
export declare class Identify {
payload: Record<string, Record<string, unknown>>;
private static OP_SET;
private static OP_SET_ONCE;
private static OP_ADD;
private static OP_APPEND;
private static OP_UNSET;
payload: IdentifyPayload;
private static ALL_OPS;

@@ -15,4 +28,7 @@ constructor();

append(key: string, value: unknown): void;
preInsert(key: string, value: unknown): void;
postInsert(key: string, value: unknown): void;
private addOp;
private opMap;
}
//# sourceMappingURL=identify.d.ts.map

@@ -1,3 +0,5 @@

import { Identify } from './identify';
export { Identify };
import { EmitterSubscription } from 'react-native';
import { Identify, IdentifyPayload, IdentifyOperation } from './identify';
import { Event, BaseEvent, IdentifyEvent, GroupIdentifyEvent, Middleware, MiddlewareExtra, SpecialEventType, Plan, IngestionMetadata, AmplitudeLogError } from './types';
export { Identify, Event, BaseEvent, IdentifyEvent, GroupIdentifyEvent, Middleware, MiddlewareExtra, SpecialEventType, IdentifyPayload, IdentifyOperation, Plan, IngestionMetadata, };
export declare class Amplitude {

@@ -7,2 +9,4 @@ private static _instances;

instanceName: string;
private readonly _middlewareRunner;
private readonly _nativeEventEmitter;
private constructor();

@@ -17,4 +21,6 @@ static getInstance(instanceName?: string): Amplitude;

* @param eventType The name of the event you wish to track.
* @param eventProperties The event's properties.
* @param extra Extra untyped parameters for use in middleware.
*/
logEvent(eventType: string, eventProperties?: Record<string, unknown>): Promise<boolean>;
logEvent(eventType: string, eventProperties?: Record<string, unknown>, extra?: MiddlewareExtra): Promise<boolean>;
/**

@@ -47,3 +53,3 @@ * Enable COPPA (Children's Online Privacy Protection Act) restrictions on

*/
getDeviceId(): Promise<string>;
getDeviceId(): Promise<string | null>;
/**

@@ -120,4 +126,5 @@ * Use the Advertising ID on Android if available from Google Play Services.

* @param identifyInstance
* @param extra
*/
identify(identifyInstance: Identify): Promise<boolean>;
identify(identifyInstance: Identify, extra?: MiddlewareExtra): Promise<boolean>;
/**

@@ -135,4 +142,5 @@ * Adds a user to a group or groups. You need to specify a groupType and groupName(s).

* @param identifyInstance
* @param extra
*/
groupIdentify(groupType: string, groupName: string | string[], identifyInstance: Identify): Promise<boolean>;
groupIdentify(groupType: string, groupName: string | string[], identifyInstance: Identify, extra?: MiddlewareExtra): Promise<boolean>;
/**

@@ -176,4 +184,64 @@ * Adds properties that are tracked on the user level.

setServerZone(serverZone: string, updateServerUrl?: boolean): Promise<boolean>;
/**
* Sets event upload max batch size. This controls the maximum number of events sent with
* each upload request.
*
* @param eventUploadMaxBatchSize the event upload max batch size
*/
setEventUploadMaxBatchSize(eventUploadMaxBatchSize: number): Promise<boolean>;
/**
* Sets event upload period millis. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadPeriodMillis the event upload period millis
*/
setEventUploadPeriodMillis(eventUploadPeriodMillis: number): Promise<boolean>;
/**
* Sets event upload threshold. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadThreshold the event upload threshold
*/
setEventUploadThreshold(eventUploadThreshold: number): Promise<boolean>;
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan: Plan): Promise<boolean>;
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata: IngestionMetadata): Promise<boolean>;
addEventMiddleware(middleware: Middleware): Amplitude;
/**
* Enable/disable message logging by the SDK.
*
* @param enableLogging whether to enable message logging by the SDK.
*/
enableLogging(enableLogging: boolean): Promise<boolean>;
/**
* Add log callback, it can help read and collect error message from sdk. The call back function like the following format
* ({ tag, message }: { tag: string, message: string }) => {
* //implement your own logic
* }
*
* @param callback
*/
addLogCallback(callback: (error: AmplitudeLogError) => void): EmitterSubscription;
/**
* Sets the logging level. Logging messages will only appear if they are the same severity
* level or higher than the set log level.
*
* @param logLevel the log level
*/
setLogLevel(logLevel: number): Promise<boolean>;
private _setLibraryName;
private _setLibraryVersion;
private _runMiddlewares;
}
//# sourceMappingURL=index.d.ts.map

@@ -1,3 +0,5 @@

declare type PropertiesObject = Record<string, any>;
declare type RevenueProperties = {
import type { EmitterSubscription } from 'react-native';
import { IdentifyPayload } from './identify';
type PropertiesObject = Record<string, any>;
type RevenueProperties = {
price: number;

@@ -11,2 +13,6 @@ productId?: string;

};
export type AmplitudeLogError = {
tag: string;
message: string;
};
export interface AmplitudeReactNativeModule {

@@ -20,3 +26,3 @@ initialize(instanceName: string, apiKey: string): Promise<boolean>;

setDeviceId(instanceName: string, deviceId: string): Promise<boolean>;
getDeviceId(instanceName: string): Promise<string>;
getDeviceId(instanceName: string): Promise<string | null>;
setAdvertisingIdForDeviceId(instanceName: string): Promise<boolean>;

@@ -41,3 +47,83 @@ setAppSetIdForDeviceId(instanceName: string): Promise<boolean>;

setServerZone(instanceName: string, serverZone: string, updateServerUrl: boolean): Promise<boolean>;
setEventUploadMaxBatchSize(instanceName: string, eventUploadMaxBatchSize: number): Promise<boolean>;
setEventUploadPeriodMillis(instanceName: string, eventUploadPeriodMillis: number): Promise<boolean>;
setEventUploadThreshold(instanceName: string, eventUploadThreshold: number): Promise<boolean>;
setPlan(instanceName: string, plan: Plan): Promise<boolean>;
setIngestionMetadata(instanceName: string, ingestionMetadata: IngestionMetadata): Promise<boolean>;
enableLogging(instanceName: string, enableLogging: boolean): Promise<boolean>;
addLogCallback(instanceName: string, callback: (error: AmplitudeLogError) => void): EmitterSubscription;
setLogLevel(instanceName: string, logLevel: number): Promise<boolean>;
}
/**
* Strings that have special meaning when used as an event's type
* and have different specifications.
*/
export declare enum SpecialEventType {
IDENTIFY = "$identify",
GROUP_IDENTIFY = "$groupidentify"
}
export interface BaseEvent {
eventType: Exclude<string, SpecialEventType>;
userId?: string;
deviceId?: string;
eventProperties?: PropertiesObject;
}
export interface IdentifyEvent extends BaseEvent {
eventType: SpecialEventType.IDENTIFY;
userProperties: IdentifyPayload;
}
export interface GroupIdentifyEvent extends BaseEvent {
eventType: SpecialEventType.GROUP_IDENTIFY;
groupType: string;
groupName: string | string[];
groupProperties: IdentifyPayload;
}
export type Event = BaseEvent | IdentifyEvent | GroupIdentifyEvent;
/**
* Unstructured object to let users pass extra data to middleware
*/
export interface MiddlewareExtra {
[name: string]: any;
}
/**
* Data to be processed by middleware
*/
export interface MiddlewarePayload {
event: Event;
extra?: MiddlewareExtra;
}
/**
* Function called at the end of each Middleware to run the next middleware in the chain
*/
export type MiddlewareNext = (payload: MiddlewarePayload) => void;
/**
* A function to run on the Event stream (each logEvent call)
*
* @param payload The event and extra data being sent
* @param next Function to run the next middleware in the chain, not calling next will end the middleware chain
*/
export type Middleware = (payload: MiddlewarePayload, next: MiddlewareNext) => void;
/**
* Tracking plan
*/
export type Plan = {
/** The tracking plan branch name e.g. "main" */
branch?: string;
/** The tracking plan source e.g. "web", "mobile" */
source?: string;
/** The tracking plan version e.g. "1", "15" */
version?: string;
/** The tracking plan version Id e.g. "9ec23ba0-275f-468f-80d1-66b88bff9529" */
versionId?: string;
};
/**
* Ingestion metadata
*/
export type IngestionMetadata = {
/** The source name of ingestion metadata e.g. "ampli" */
sourceName?: string;
/** The source version of ingestion metadata e.g. "2.0.0" */
sourceVersion?: string;
};
export {};
//# sourceMappingURL=types.d.ts.map
MIT License
Copyright (c) 2020 Amplitude Inc.
Copyright (c) 2023 Amplitude Inc.

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "@amplitude/react-native",
"version": "2.6.0",
"version": "2.17.2",
"description": "Official React Native SDK",

@@ -29,7 +29,6 @@ "main": "lib/commonjs/index",

"bootstrap": "yarn example && yarn && yarn pods",
"docs:create-docs": "typedoc --tsconfig ./tsconfig.build.json --theme './node_modules/typedoc-neo-theme'",
"docs:create-docs": "typedoc --tsconfig ./tsconfig.build.json",
"docs:gen-docs": "rm -rf docs && yarn run docs:create-docs && git add docs",
"docs:deploy": "gh-pages -d docs",
"release": "semantic-release",
"release-temp": "release-it"
"release": "semantic-release"
},

@@ -52,31 +51,28 @@ "keywords": [

"devDependencies": {
"@google/semantic-release-replace-plugin": "^1.0.2",
"@google/semantic-release-replace-plugin": "^1.2.0",
"@react-native-community/eslint-config": "^2.0.0",
"@release-it/conventional-changelog": "^2.0.1",
"@semantic-release/commit-analyzer": "^8.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.2.0",
"@semantic-release/npm": "^7.0.10",
"@semantic-release/release-notes-generator": "^9.0.2",
"@types/jest": "^26.0.0",
"@types/react": "^16.9.19",
"@types/react-native": "0.62.13",
"eslint": "^7.2.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-prettier": "^3.1.3",
"gh-pages": "3.1.0",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.5.3",
"pod-install": "^0.1.0",
"prettier": "^2.0.5",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-builder-bob": "^0.17.1",
"release-it": "^14.5.1",
"semantic-release": "^17.4.1",
"typedoc": "^0.20.28",
"typedoc-neo-theme": "^1.1.0",
"typescript": "^4.1.3"
"@semantic-release/git": "^9.0.1",
"@semantic-release/github": "^7.2.3",
"@semantic-release/npm": "^9.0.2",
"@semantic-release/release-notes-generator": "^9.0.3",
"@types/jest": "^26.0.24",
"@types/react": "^16.14.35",
"@types/react-native": "0.62.18",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.4.1",
"gh-pages": "3.2.3",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"pod-install": "^0.1.38",
"prettier": "^2.8.5",
"react": "17.0.2",
"react-native": "0.68.6",
"react-native-builder-bob": "^0.20.4",
"semantic-release": "^19.0.5",
"typedoc": "^0.23.28",
"typescript": "^4.9.5"
},

@@ -108,19 +104,2 @@ "peerDependencies": {

},
"release-it": {
"git": {
"commitMessage": "chore: release ${version}",
"tagName": "v${version}"
},
"npm": {
"publish": true
},
"github": {
"release": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular"
}
}
},
"react-native-builder-bob": {

@@ -127,0 +106,0 @@ "source": "src",

@@ -18,3 +18,3 @@ <p align="center">

## **NOTE for iOS Targets**:
As of the v2.09 release we no longer require any modifications to the Podfile. `use_modular_headers!` and `use_frameworks!` are no longer needed and can be removed upon updating to >= v.2.0.9. If you run into any issues during installationg it is likely caused by your pod cache and there are a few options to resolve this, see [here](https://github.com/amplitude/Amplitude-ReactNative/issues/46#issuecomment-802933175) for suggestions on how to resolve any caching issues.
As of the v2.09 release we no longer require any modifications to the Podfile. `use_modular_headers!` and `use_frameworks!` are no longer needed and can be removed upon updating to >= v.2.0.9. If you run into any issues during installation it is likely caused by your pod cache and there are a few options to resolve this, see [here](https://github.com/amplitude/Amplitude-ReactNative/issues/46#issuecomment-802933175) for suggestions on how to resolve any caching issues.

@@ -21,0 +21,0 @@ ## Installation and Quick Start

@@ -6,3 +6,3 @@ export const Constants: {

packageSourceName: 'amplitude-react-native',
packageVersion: '2.6.0',
packageVersion: '2.17.2',
};

@@ -0,16 +1,36 @@

export enum IdentifyOperation {
SET = '$set',
SET_ONCE = '$setOnce',
ADD = '$add',
APPEND = '$append',
PREINSERT = '$preInsert',
POSTINSERT = '$postInsert',
UNSET = '$unset',
}
export interface IdentifyPayload {
// Add operations can only take numbers
[IdentifyOperation.ADD]?: Record<string, number>;
// This reads the keys of the passed object, but the values are not used
[IdentifyOperation.UNSET]?: Record<string, unknown>;
[IdentifyOperation.SET]?: Record<string, unknown>;
[IdentifyOperation.SET_ONCE]?: Record<string, unknown>;
[IdentifyOperation.APPEND]?: Record<string, unknown>;
[IdentifyOperation.PREINSERT]?: Record<string, unknown>;
[IdentifyOperation.POSTINSERT]?: Record<string, unknown>;
}
export class Identify {
payload: Record<string, Record<string, unknown>>;
payload: IdentifyPayload;
private static OP_SET = '$set';
private static OP_SET_ONCE = '$setOnce';
private static OP_ADD = '$add';
private static OP_APPEND = '$append';
private static OP_UNSET = '$unset';
private static ALL_OPS = [
Identify.OP_SET,
Identify.OP_SET_ONCE,
Identify.OP_ADD,
Identify.OP_APPEND,
Identify.OP_UNSET,
IdentifyOperation.SET,
IdentifyOperation.SET_ONCE,
IdentifyOperation.ADD,
IdentifyOperation.APPEND,
IdentifyOperation.PREINSERT,
IdentifyOperation.POSTINSERT,
IdentifyOperation.UNSET,
];

@@ -23,22 +43,30 @@

set(key: string, value: unknown): void {
this.addOp(Identify.OP_SET, key, value);
this.addOp(IdentifyOperation.SET, key, value);
}
setOnce(key: string, value: unknown): void {
this.addOp(Identify.OP_SET_ONCE, key, value);
this.addOp(IdentifyOperation.SET_ONCE, key, value);
}
add(key: string, value: number): void {
this.addOp(Identify.OP_ADD, key, value);
this.addOp(IdentifyOperation.ADD, key, value);
}
unset(key: string): void {
this.addOp(Identify.OP_UNSET, key, '-');
this.addOp(IdentifyOperation.UNSET, key, '-');
}
append(key: string, value: unknown): void {
this.addOp(Identify.OP_APPEND, key, value);
this.addOp(IdentifyOperation.APPEND, key, value);
}
private addOp(op: string, key: string, value: unknown): void {
preInsert(key: string, value: unknown): void {
this.addOp(IdentifyOperation.PREINSERT, key, value);
}
postInsert(key: string, value: unknown): void {
this.addOp(IdentifyOperation.POSTINSERT, key, value);
}
private addOp(op: IdentifyOperation, key: string, value: unknown): void {
if (!Identify.ALL_OPS.includes(op)) {

@@ -54,8 +82,8 @@ throw new Error(

private opMap(key: string): Record<string, unknown> {
if (!Object.prototype.hasOwnProperty.call(this.payload, key)) {
this.payload[key] = {};
private opMap(op: IdentifyOperation): Record<string, unknown> {
if (!Object.prototype.hasOwnProperty.call(this.payload, op)) {
this.payload[op] = {};
}
return this.payload[key];
return this.payload[op]!;
}
}

@@ -1,6 +0,23 @@

import { NativeModules } from 'react-native';
import {
NativeModules,
NativeEventEmitter,
EmitterSubscription,
} from 'react-native';
import { Constants } from './constants';
import { Identify } from './identify';
import { AmplitudeReactNativeModule } from './types';
import { Identify, IdentifyPayload, IdentifyOperation } from './identify';
import {
AmplitudeReactNativeModule,
Event,
BaseEvent,
IdentifyEvent,
GroupIdentifyEvent,
Middleware,
MiddlewareExtra,
SpecialEventType,
Plan,
IngestionMetadata,
AmplitudeLogError,
} from './types';
import { MiddlewareRunner } from './middlewareRunner';

@@ -10,3 +27,16 @@ const AmplitudeReactNative: AmplitudeReactNativeModule =

export { Identify };
export {
Identify,
Event,
BaseEvent,
IdentifyEvent,
GroupIdentifyEvent,
Middleware,
MiddlewareExtra,
SpecialEventType,
IdentifyPayload,
IdentifyOperation,
Plan,
IngestionMetadata,
};

@@ -17,7 +47,14 @@ export class Amplitude {

instanceName: string;
private readonly _middlewareRunner: MiddlewareRunner;
private readonly _nativeEventEmitter: NativeEventEmitter;
private constructor(instanceName: string) {
this.instanceName = instanceName;
this._middlewareRunner = new MiddlewareRunner();
this._setLibraryName(Constants.packageSourceName);
this._setLibraryVersion(Constants.packageVersion);
this._nativeEventEmitter = new NativeEventEmitter(
NativeModules.AmplitudeReactNative,
);
}

@@ -48,15 +85,37 @@

* @param eventType The name of the event you wish to track.
* @param eventProperties The event's properties.
* @param extra Extra untyped parameters for use in middleware.
*/
logEvent(
async logEvent(
eventType: string,
eventProperties?: Record<string, unknown>,
extra?: MiddlewareExtra,
): Promise<boolean> {
if (eventProperties && Object.keys(eventProperties).length > 0) {
const event: BaseEvent = {
eventType,
eventProperties,
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
if (
event.eventProperties &&
Object.keys(event.eventProperties).length > 0
) {
return AmplitudeReactNative.logEventWithProperties(
this.instanceName,
eventType,
eventProperties,
event.eventType,
event.eventProperties,
);
}
return AmplitudeReactNative.logEvent(this.instanceName, eventType);
return AmplitudeReactNative.logEvent(this.instanceName, event.eventType);
}

@@ -103,3 +162,3 @@

*/
getDeviceId(): Promise<string> {
getDeviceId(): Promise<string | null> {
return AmplitudeReactNative.getDeviceId(this.instanceName);

@@ -207,7 +266,27 @@ }

* @param identifyInstance
* @param extra
*/
identify(identifyInstance: Identify): Promise<boolean> {
async identify(
identifyInstance: Identify,
extra?: MiddlewareExtra,
): Promise<boolean> {
const event: IdentifyEvent = {
eventType: SpecialEventType.IDENTIFY,
userProperties: { ...identifyInstance.payload },
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.identify(
this.instanceName,
identifyInstance.payload,
event.userProperties,
);

@@ -235,13 +314,33 @@ }

* @param identifyInstance
* @param extra
*/
groupIdentify(
async groupIdentify(
groupType: string,
groupName: string | string[],
identifyInstance: Identify,
extra?: MiddlewareExtra,
): Promise<boolean> {
const event: GroupIdentifyEvent = {
eventType: SpecialEventType.GROUP_IDENTIFY,
groupType,
groupName,
groupProperties: { ...identifyInstance.payload },
};
if (!this._runMiddlewares(event, extra)) {
return Promise.resolve(false);
}
if (event.userId) {
await AmplitudeReactNative.setUserId(this.instanceName, event.userId);
}
if (event.deviceId) {
await AmplitudeReactNative.setDeviceId(this.instanceName, event.deviceId);
}
return AmplitudeReactNative.groupIdentify(
this.instanceName,
groupType,
groupName,
identifyInstance.payload,
event.groupType,
event.groupName,
event.groupProperties,
);

@@ -321,2 +420,107 @@ }

/**
* Sets event upload max batch size. This controls the maximum number of events sent with
* each upload request.
*
* @param eventUploadMaxBatchSize the event upload max batch size
*/
setEventUploadMaxBatchSize(
eventUploadMaxBatchSize: number,
): Promise<boolean> {
return AmplitudeReactNative.setEventUploadMaxBatchSize(
this.instanceName,
eventUploadMaxBatchSize,
);
}
/**
* Sets event upload period millis. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadPeriodMillis the event upload period millis
*/
setEventUploadPeriodMillis(
eventUploadPeriodMillis: number,
): Promise<boolean> {
return AmplitudeReactNative.setEventUploadPeriodMillis(
this.instanceName,
eventUploadPeriodMillis,
);
}
/**
* Sets event upload threshold. The SDK will attempt to batch upload unsent events
* every eventUploadPeriodMillis milliseconds, or if the unsent event count exceeds the
* event upload threshold.
*
* @param eventUploadThreshold the event upload threshold
*/
setEventUploadThreshold(eventUploadThreshold: number): Promise<boolean> {
return AmplitudeReactNative.setEventUploadThreshold(
this.instanceName,
eventUploadThreshold,
);
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan: Plan): Promise<boolean> {
return AmplitudeReactNative.setPlan(this.instanceName, plan);
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata: IngestionMetadata): Promise<boolean> {
return AmplitudeReactNative.setIngestionMetadata(
this.instanceName,
ingestionMetadata,
);
}
addEventMiddleware(middleware: Middleware): Amplitude {
this._middlewareRunner.add(middleware);
return this;
}
/**
* Enable/disable message logging by the SDK.
*
* @param enableLogging whether to enable message logging by the SDK.
*/
enableLogging(enableLogging: boolean): Promise<boolean> {
return AmplitudeReactNative.enableLogging(this.instanceName, enableLogging);
}
/**
* Add log callback, it can help read and collect error message from sdk. The call back function like the following format
* ({ tag, message }: { tag: string, message: string }) => {
* //implement your own logic
* }
*
* @param callback
*/
addLogCallback(
callback: (error: AmplitudeLogError) => void,
): EmitterSubscription {
return this._nativeEventEmitter.addListener('AmplitudeLogError', callback);
}
/**
* Sets the logging level. Logging messages will only appear if they are the same severity
* level or higher than the set log level.
*
* @param logLevel the log level
*/
setLogLevel(logLevel: number): Promise<boolean> {
return AmplitudeReactNative.setLogLevel(this.instanceName, logLevel);
}
// Private bridging calls

@@ -333,2 +537,14 @@ private _setLibraryName(libraryName: string): Promise<boolean> {

}
private _runMiddlewares(
event: Event,
extra: MiddlewareExtra | undefined,
): boolean {
let middlewareCompleted = false;
this._middlewareRunner.run({ event, extra }, () => {
middlewareCompleted = true;
});
return middlewareCompleted;
}
}

@@ -0,1 +1,4 @@

import type { EmitterSubscription } from 'react-native';
import { IdentifyPayload } from './identify';
type PropertiesObject = Record<string, any>;

@@ -13,2 +16,4 @@

export type AmplitudeLogError = { tag: string; message: string };
export interface AmplitudeReactNativeModule {

@@ -26,3 +31,3 @@ initialize(instanceName: string, apiKey: string): Promise<boolean>;

setDeviceId(instanceName: string, deviceId: string): Promise<boolean>;
getDeviceId(instanceName: string): Promise<string>;
getDeviceId(instanceName: string): Promise<string | null>;
setAdvertisingIdForDeviceId(instanceName: string): Promise<boolean>;

@@ -81,2 +86,110 @@ setAppSetIdForDeviceId(instanceName: string): Promise<boolean>;

): Promise<boolean>;
setEventUploadMaxBatchSize(
instanceName: string,
eventUploadMaxBatchSize: number,
): Promise<boolean>;
setEventUploadPeriodMillis(
instanceName: string,
eventUploadPeriodMillis: number,
): Promise<boolean>;
setEventUploadThreshold(
instanceName: string,
eventUploadThreshold: number,
): Promise<boolean>;
setPlan(instanceName: string, plan: Plan): Promise<boolean>;
setIngestionMetadata(
instanceName: string,
ingestionMetadata: IngestionMetadata,
): Promise<boolean>;
enableLogging(instanceName: string, enableLogging: boolean): Promise<boolean>;
addLogCallback(
instanceName: string,
callback: (error: AmplitudeLogError) => void,
): EmitterSubscription;
setLogLevel(instanceName: string, logLevel: number): Promise<boolean>;
}
/**
* Strings that have special meaning when used as an event's type
* and have different specifications.
*/
export enum SpecialEventType {
IDENTIFY = '$identify',
GROUP_IDENTIFY = '$groupidentify',
}
export interface BaseEvent {
eventType: Exclude<string, SpecialEventType>;
userId?: string;
deviceId?: string;
eventProperties?: PropertiesObject;
}
export interface IdentifyEvent extends BaseEvent {
eventType: SpecialEventType.IDENTIFY;
userProperties: IdentifyPayload;
}
export interface GroupIdentifyEvent extends BaseEvent {
eventType: SpecialEventType.GROUP_IDENTIFY;
groupType: string;
groupName: string | string[];
groupProperties: IdentifyPayload;
}
export type Event = BaseEvent | IdentifyEvent | GroupIdentifyEvent;
/**
* Unstructured object to let users pass extra data to middleware
*/
export interface MiddlewareExtra {
[name: string]: any;
}
/**
* Data to be processed by middleware
*/
export interface MiddlewarePayload {
event: Event;
extra?: MiddlewareExtra;
}
/**
* Function called at the end of each Middleware to run the next middleware in the chain
*/
export type MiddlewareNext = (payload: MiddlewarePayload) => void;
/**
* A function to run on the Event stream (each logEvent call)
*
* @param payload The event and extra data being sent
* @param next Function to run the next middleware in the chain, not calling next will end the middleware chain
*/
export type Middleware = (
payload: MiddlewarePayload,
next: MiddlewareNext,
) => void;
/**
* Tracking plan
*/
export type Plan = {
/** The tracking plan branch name e.g. "main" */
branch?: string;
/** The tracking plan source e.g. "web", "mobile" */
source?: string;
/** The tracking plan version e.g. "1", "15" */
version?: string;
/** The tracking plan version Id e.g. "9ec23ba0-275f-468f-80d1-66b88bff9529" */
versionId?: string;
};
/**
* Ingestion metadata
*/
export type IngestionMetadata = {
/** The source name of ingestion metadata e.g. "ampli" */
sourceName?: string;
/** The source version of ingestion metadata e.g. "2.0.0" */
sourceVersion?: string;
};
it.todo('write a test');

Sorry, the diff of this file is not supported yet