New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

capacitor-amplitude

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-amplitude - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0-beta.1

android/src/main/java/com/rediska1114/plugins/amplitude/AmplitudePlugin.kt

151

dist/esm/definitions.d.ts

@@ -1,120 +0,51 @@

type PropertiesObject = Record<string, any>;
type RevenueProperties = {
price: number;
productId?: string;
quantity?: number;
revenueType?: string;
receipt?: string;
receiptSignature?: string;
eventProperties?: PropertiesObject;
};
type AmplitudeInstance = {
instanceName: string;
};
export type PropertiesObject = Record<string, any>;
export interface AmplitudePlugin {
initialize(options: AmplitudeInstance & {
initialize(options: {
apiKey: string;
libraryName?: string;
libraryVersion?: string;
} & AmplitudeConfiguration): Promise<void>;
track(options: InstanceNameOptions & {
eventName: string;
properties: PropertiesObject;
}): Promise<void>;
logEvent(options: AmplitudeInstance & {
eventType: string;
identifyUser(options: InstanceNameOptions & {
properties: PropertiesObject;
}): Promise<void>;
logEventWithProperties(options: AmplitudeInstance & {
eventType: string;
eventProperties: PropertiesObject;
setUserId(options: InstanceNameOptions & {
userId: string;
}): Promise<void>;
enableCoppaControl(options: AmplitudeInstance): Promise<void>;
disableCoppaControl(options: AmplitudeInstance): Promise<void>;
regenerateDeviceId(options: AmplitudeInstance): Promise<void>;
setDeviceId(options: AmplitudeInstance & {
setDeviceId(options: InstanceNameOptions & {
deviceId: string;
}): Promise<void>;
getDeviceId(options: AmplitudeInstance): Promise<{
deviceId: string;
}>;
useAdvertisingIdForDeviceId(options: AmplitudeInstance): Promise<void>;
setOptOut(options: AmplitudeInstance & {
optOut: boolean;
}): Promise<void>;
trackingSessionEvents(options: AmplitudeInstance & {
trackingSessionEvents: boolean;
}): Promise<void>;
setUseDynamicConfig(options: AmplitudeInstance & {
useDynamicConfig: boolean;
}): Promise<void>;
setUserId(options: AmplitudeInstance & {
userId: string | null;
}): Promise<void>;
setServerUrl(options: AmplitudeInstance & {
serverUrl: string;
}): Promise<void>;
logRevenueV2(options: AmplitudeInstance & {
userProperties: RevenueProperties;
}): Promise<void>;
identify(options: AmplitudeInstance & {
userProperties: PropertiesObject;
}): Promise<void>;
setGroup(options: AmplitudeInstance & {
reset(options: InstanceNameOptions): Promise<void>;
setGroup(options: InstanceNameOptions & {
groupType: string;
groupName: string | string[];
groupName: string;
}): Promise<void>;
groupIdentify(options: AmplitudeInstance & {
groupType: string;
groupName: string | string[];
userProperties: PropertiesObject;
}): Promise<void>;
setUserProperties(options: AmplitudeInstance & {
userProperties: PropertiesObject;
}): Promise<void>;
clearUserProperties(options: AmplitudeInstance): Promise<void>;
uploadEvents(options: AmplitudeInstance): Promise<void>;
getSessionId(options: AmplitudeInstance): Promise<{
sessionId: number;
}>;
setMinTimeBetweenSessionsMillis(options: AmplitudeInstance & {
minTimeBetweenSessionsMillis: number;
}): Promise<void>;
setServerZone(options: AmplitudeInstance & {
serverZone: string;
updateServerUrl: boolean;
}): Promise<void>;
setEventUploadMaxBatchSize(options: AmplitudeInstance & {
eventUploadMaxBatchSize: number;
}): Promise<void>;
setEventUploadPeriodMillis(options: AmplitudeInstance & {
eventUploadPeriodMillis: number;
}): Promise<void>;
setEventUploadThreshold(options: AmplitudeInstance & {
eventUploadThreshold: number;
}): Promise<void>;
setPlan(options: AmplitudeInstance & {
plan: Plan;
}): Promise<void>;
setIngestionMetadata(options: AmplitudeInstance & {
ingestionMetadata: IngestionMetadata;
}): Promise<void>;
logRevenue(options: InstanceNameOptions & unknown): Promise<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 {};
export interface AmplitudeConfiguration {
autocapture?: Array<'SESSIONS' | 'APP_LIFECYCLES' | 'DEEP_LINKS' | 'SCREEN_VIEWS'>;
deviceId?: string;
partnerId?: string;
flushIntervalMillis?: number;
flushQueueSize?: number;
flushMaxRetries?: number;
minIdLength?: number;
identifyBatchIntervalMillis?: number;
flushEventsOnClose?: boolean;
optOut?: boolean;
minTimeBetweenSessionsMillis?: number;
serverUrl?: string;
serverZone?: 'EU' | 'US';
useBatch?: boolean;
useAdvertisingIdForDeviceId?: boolean;
useAppSetIdForDeviceId?: boolean;
enableCoppaControl?: boolean;
instanceName?: string;
migrateLegacyData?: boolean;
offline?: boolean;
locationListening?: boolean;
}
export interface InstanceNameOptions {
instanceName: string;
}

@@ -1,203 +0,28 @@

import type { IngestionMetadata, Plan } from './definitions';
import { Identify } from './identify';
import type { AmplitudeConfiguration, PropertiesObject } from './definitions';
export * from './definitions';
export * from './identify';
export declare class Amplitude {
private static _instances;
private static _defaultInstanceName;
instanceName: string;
constructor(instanceName?: string);
static getInstance(instanceName?: string): Amplitude;
init(apiKey: string): Promise<void>;
/**
* Tracks an event. Events are saved locally.
* Uploads are batched to occur every 30 events or every 30 seconds
* (whichever comes first), as well as on app close.
*
* @param eventType The name of the event you wish to track.
*/
logEvent(eventType: string, eventProperties?: Record<string, unknown>): Promise<void>;
/**
* Enable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*
* This can be used by any customer that does not want to collect IDFA, IDFV,
* city, IP address and location tracking.
*/
enableCoppaControl(): Promise<void>;
/**
* Disable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*/
disableCoppaControl(): Promise<void>;
/**
* Regenerate the DeviceId
*/
regenerateDeviceId(): Promise<void>;
/**
* Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>
*
* @param deviceId The device id.
*/
setDeviceId(deviceId: string): Promise<void>;
/**
* Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.
* @returns the deviceId.
*/
getDeviceId(): Promise<string>;
/**
* Use the Advertising ID on Android if available from Google Play Services.
* Must be called before init.
*/
useAdvertisingIdForDeviceId(): Promise<void>;
/**
* Enables tracking opt out.
*
* If the user wants to opt out of all tracking, use this method to enable
* opt out for them. Once opt out is enabled, no events will be saved locally
* or sent to the server.
*
* Calling this method again with enabled set to false will turn tracking back on for the user.
*
* @param optOut
*/
setOptOut(optOut: boolean): Promise<void>;
/**
* Whether to automatically log start and end session events corresponding to
* the start and end of a user's session.
*
* @param trackingSessionEvents
*/
trackingSessionEvents(trackingSessionEvents: boolean): Promise<void>;
/**
* If your app has its own login system that you want to track users with,
* you can set the userId.
*
* @param userId
*/
setUserId(userId: string | null): Promise<void>;
/**
* Customize the destination for server url.
*
* @param serverUrl
*/
setServerUrl(serverUrl: string): Promise<void>;
/**
* Dynamically adjust server URL
*
* @param useDynamicConfig
*/
setUseDynamicConfig(useDynamicConfig: boolean): Promise<void>;
/**
* Log revenue data.
*
* Note: price is a required field to log revenue events.
* If quantity is not specified then defaults to 1.
*
* @param userProperties
*/
logRevenue(userProperties: {
price: number;
productId?: string;
quantity?: number;
revenueType?: string;
receipt?: string;
receiptSignature?: string;
eventProperties?: {
[key: string]: any;
};
initialize(apiKey: string, configuration: AmplitudeConfiguration): Promise<void>;
track(options: {
eventName: string;
properties: PropertiesObject;
}): Promise<void>;
/**
* Send an identify call containing user property operations to Amplitude servers.
*
* @param identifyInstance
*/
identify(identifyInstance: Identify): Promise<void>;
/**
* Adds a user to a group or groups. You need to specify a groupType and groupName(s).
* @param groupType
* @param groupName
*/
setGroup(groupType: string, groupName: string | string[]): Promise<void>;
/**
* Set or update properties of particular groups
*
* @param groupType
* @param groupName
* @param identifyInstance
*/
groupIdentify(groupType: string, groupName: string | string[], identifyInstance: Identify): Promise<void>;
/**
* Adds properties that are tracked on the user level.
* Note: Property keys must be [String] objects and values must be serializable.
*
* @param userProperties
*/
setUserProperties(userProperties: Record<string, unknown>): Promise<void>;
/**
* Clears all properties that are tracked on the user level.
*
* Note: This operation is irreversible!!
*/
clearUserProperties(): Promise<void>;
/**
* Upload all unsent events.
*/
uploadEvents(): Promise<void>;
/**
* Fetches the sessionId, a timestamp used for log session event.
* @returns the sessionId.
*/
getSessionId(): Promise<number>;
/**
* Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.
* The default time is 5 minutes.
*
* @param minTimeBetweenSessionsMillis
*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis: number): Promise<void>;
/**
* Set Amplitude Server Zone, switch to zone related configuration,
* including dynamic configuration. If updateServerUrl is true, including server url as well.
* Recommend to keep updateServerUrl to be true for alignment.
*
* @param serverZone amplitude serverZone, US or EU, default is US
* @param updateServerUrl if update server url when update server zone, recommend setting true
*/
setServerZone(serverZone: string, updateServerUrl?: boolean): Promise<void>;
/**
* 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<void>;
/**
* 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<void>;
/**
* 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<void>;
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan: Plan): Promise<void>;
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata: IngestionMetadata): Promise<void>;
identifyUser(options: {
properties: PropertiesObject;
}): Promise<void>;
setUserId(options: {
userId: string;
}): Promise<void>;
setDeviceId(options: {
deviceId: string;
}): Promise<void>;
reset(): Promise<void>;
setGroup(options: {
groupType: string;
groupName: string;
}): Promise<void>;
logRevenue(_: unknown): Promise<void>;
}
import { registerPlugin } from '@capacitor/core';
import { PACKAGE_SOURCE_NAME, PACKAGE_VERSION } from './constants';
// import { Identify } from './identify';
const CapacitorAmplitude = registerPlugin('Amplitude', {

@@ -11,341 +11,32 @@ // web: () => import('./web').then(m => new m.AmplitudeWeb()),

this.instanceName = instanceName;
// this._setLibraryName(Constants.packageSourceName);
// this._setLibraryVersion(Constants.packageVersion);
}
static getInstance(instanceName = 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];
initialize(apiKey, configuration) {
return CapacitorAmplitude.initialize(Object.assign({ instanceName: this.instanceName, apiKey }, configuration));
}
init(apiKey) {
return CapacitorAmplitude.initialize({
instanceName: this.instanceName,
apiKey,
libraryName: PACKAGE_SOURCE_NAME,
libraryVersion: PACKAGE_VERSION,
});
track(options) {
return CapacitorAmplitude.track(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Tracks an event. Events are saved locally.
* Uploads are batched to occur every 30 events or every 30 seconds
* (whichever comes first), as well as on app close.
*
* @param eventType The name of the event you wish to track.
*/
logEvent(eventType, eventProperties) {
if (eventProperties && Object.keys(eventProperties).length > 0) {
return CapacitorAmplitude.logEventWithProperties({
instanceName: this.instanceName,
eventType,
eventProperties,
});
}
return CapacitorAmplitude.logEvent({
instanceName: this.instanceName,
eventType,
});
identifyUser(options) {
return CapacitorAmplitude.identifyUser(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Enable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*
* This can be used by any customer that does not want to collect IDFA, IDFV,
* city, IP address and location tracking.
*/
enableCoppaControl() {
return CapacitorAmplitude.enableCoppaControl({
instanceName: this.instanceName,
});
setUserId(options) {
return CapacitorAmplitude.setUserId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Disable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*/
disableCoppaControl() {
return CapacitorAmplitude.disableCoppaControl({
instanceName: this.instanceName,
});
setDeviceId(options) {
return CapacitorAmplitude.setDeviceId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Regenerate the DeviceId
*/
regenerateDeviceId() {
return CapacitorAmplitude.regenerateDeviceId({
instanceName: this.instanceName,
});
reset() {
return CapacitorAmplitude.reset({ instanceName: this.instanceName });
}
/**
* Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>
*
* @param deviceId The device id.
*/
setDeviceId(deviceId) {
return CapacitorAmplitude.setDeviceId({
instanceName: this.instanceName,
deviceId,
});
setGroup(options) {
return CapacitorAmplitude.setGroup(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.
* @returns the deviceId.
*/
getDeviceId() {
return CapacitorAmplitude.getDeviceId({
logRevenue(_) {
return CapacitorAmplitude.logRevenue({
instanceName: this.instanceName,
}).then(({ deviceId }) => deviceId);
}
/**
* Use the Advertising ID on Android if available from Google Play Services.
* Must be called before init.
*/
useAdvertisingIdForDeviceId() {
return CapacitorAmplitude.useAdvertisingIdForDeviceId({
instanceName: this.instanceName,
});
}
/**
* Enables tracking opt out.
*
* If the user wants to opt out of all tracking, use this method to enable
* opt out for them. Once opt out is enabled, no events will be saved locally
* or sent to the server.
*
* Calling this method again with enabled set to false will turn tracking back on for the user.
*
* @param optOut
*/
setOptOut(optOut) {
return CapacitorAmplitude.setOptOut({
instanceName: this.instanceName,
optOut,
});
}
/**
* Whether to automatically log start and end session events corresponding to
* the start and end of a user's session.
*
* @param trackingSessionEvents
*/
trackingSessionEvents(trackingSessionEvents) {
return CapacitorAmplitude.trackingSessionEvents({
instanceName: this.instanceName,
trackingSessionEvents,
});
}
/**
* If your app has its own login system that you want to track users with,
* you can set the userId.
*
* @param userId
*/
setUserId(userId) {
return CapacitorAmplitude.setUserId({
instanceName: this.instanceName,
userId,
});
}
/**
* Customize the destination for server url.
*
* @param serverUrl
*/
setServerUrl(serverUrl) {
return CapacitorAmplitude.setServerUrl({
instanceName: this.instanceName,
serverUrl,
});
}
/**
* Dynamically adjust server URL
*
* @param useDynamicConfig
*/
setUseDynamicConfig(useDynamicConfig) {
return CapacitorAmplitude.setUseDynamicConfig({
instanceName: this.instanceName,
useDynamicConfig,
});
}
/**
* Log revenue data.
*
* Note: price is a required field to log revenue events.
* If quantity is not specified then defaults to 1.
*
* @param userProperties
*/
logRevenue(userProperties) {
return CapacitorAmplitude.logRevenueV2({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Send an identify call containing user property operations to Amplitude servers.
*
* @param identifyInstance
*/
identify(identifyInstance) {
return CapacitorAmplitude.identify({
instanceName: this.instanceName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds a user to a group or groups. You need to specify a groupType and groupName(s).
* @param groupType
* @param groupName
*/
setGroup(groupType, groupName) {
return CapacitorAmplitude.setGroup({
instanceName: this.instanceName,
groupType,
groupName,
});
}
/**
* Set or update properties of particular groups
*
* @param groupType
* @param groupName
* @param identifyInstance
*/
groupIdentify(groupType, groupName, identifyInstance) {
return CapacitorAmplitude.groupIdentify({
instanceName: this.instanceName,
groupType,
groupName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds properties that are tracked on the user level.
* Note: Property keys must be [String] objects and values must be serializable.
*
* @param userProperties
*/
setUserProperties(userProperties) {
return CapacitorAmplitude.setUserProperties({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Clears all properties that are tracked on the user level.
*
* Note: This operation is irreversible!!
*/
clearUserProperties() {
return CapacitorAmplitude.clearUserProperties({
instanceName: this.instanceName,
});
}
/**
* Upload all unsent events.
*/
uploadEvents() {
return CapacitorAmplitude.uploadEvents({ instanceName: this.instanceName });
}
/**
* Fetches the sessionId, a timestamp used for log session event.
* @returns the sessionId.
*/
getSessionId() {
return CapacitorAmplitude.getSessionId({
instanceName: this.instanceName,
}).then(({ sessionId }) => sessionId);
}
/**
* Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.
* The default time is 5 minutes.
*
* @param minTimeBetweenSessionsMillis
*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis) {
return CapacitorAmplitude.setMinTimeBetweenSessionsMillis({
instanceName: this.instanceName,
minTimeBetweenSessionsMillis,
});
}
/**
* Set Amplitude Server Zone, switch to zone related configuration,
* including dynamic configuration. If updateServerUrl is true, including server url as well.
* Recommend to keep updateServerUrl to be true for alignment.
*
* @param serverZone amplitude serverZone, US or EU, default is US
* @param updateServerUrl if update server url when update server zone, recommend setting true
*/
setServerZone(serverZone, updateServerUrl = true) {
return CapacitorAmplitude.setServerZone({
instanceName: 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 CapacitorAmplitude.setEventUploadMaxBatchSize({
instanceName: 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) {
return CapacitorAmplitude.setEventUploadPeriodMillis({
instanceName: 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 CapacitorAmplitude.setEventUploadThreshold({
instanceName: this.instanceName,
eventUploadThreshold,
});
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan) {
return CapacitorAmplitude.setPlan({
instanceName: this.instanceName,
plan,
});
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata) {
return CapacitorAmplitude.setIngestionMetadata({
instanceName: this.instanceName,
ingestionMetadata,
});
}
}
// private static _instances: Record<string, Amplitude>;
Amplitude._defaultInstanceName = '$default_instance';
//# sourceMappingURL=index.js.map

@@ -7,5 +7,2 @@ 'use strict';

const PACKAGE_SOURCE_NAME = 'capacitor-amplitude';
const PACKAGE_VERSION = '2.0.0';
exports.IdentifyOperation = void 0;

@@ -69,2 +66,3 @@ (function (IdentifyOperation) {

// import { Identify } from './identify';
const CapacitorAmplitude = core.registerPlugin('Amplitude', {

@@ -76,340 +74,31 @@ // web: () => import('./web').then(m => new m.AmplitudeWeb()),

this.instanceName = instanceName;
// this._setLibraryName(Constants.packageSourceName);
// this._setLibraryVersion(Constants.packageVersion);
}
static getInstance(instanceName = 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];
initialize(apiKey, configuration) {
return CapacitorAmplitude.initialize(Object.assign({ instanceName: this.instanceName, apiKey }, configuration));
}
init(apiKey) {
return CapacitorAmplitude.initialize({
instanceName: this.instanceName,
apiKey,
libraryName: PACKAGE_SOURCE_NAME,
libraryVersion: PACKAGE_VERSION,
});
track(options) {
return CapacitorAmplitude.track(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Tracks an event. Events are saved locally.
* Uploads are batched to occur every 30 events or every 30 seconds
* (whichever comes first), as well as on app close.
*
* @param eventType The name of the event you wish to track.
*/
logEvent(eventType, eventProperties) {
if (eventProperties && Object.keys(eventProperties).length > 0) {
return CapacitorAmplitude.logEventWithProperties({
instanceName: this.instanceName,
eventType,
eventProperties,
});
}
return CapacitorAmplitude.logEvent({
instanceName: this.instanceName,
eventType,
});
identifyUser(options) {
return CapacitorAmplitude.identifyUser(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Enable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*
* This can be used by any customer that does not want to collect IDFA, IDFV,
* city, IP address and location tracking.
*/
enableCoppaControl() {
return CapacitorAmplitude.enableCoppaControl({
instanceName: this.instanceName,
});
setUserId(options) {
return CapacitorAmplitude.setUserId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Disable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*/
disableCoppaControl() {
return CapacitorAmplitude.disableCoppaControl({
instanceName: this.instanceName,
});
setDeviceId(options) {
return CapacitorAmplitude.setDeviceId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Regenerate the DeviceId
*/
regenerateDeviceId() {
return CapacitorAmplitude.regenerateDeviceId({
instanceName: this.instanceName,
});
reset() {
return CapacitorAmplitude.reset({ instanceName: this.instanceName });
}
/**
* Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>
*
* @param deviceId The device id.
*/
setDeviceId(deviceId) {
return CapacitorAmplitude.setDeviceId({
instanceName: this.instanceName,
deviceId,
});
setGroup(options) {
return CapacitorAmplitude.setGroup(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.
* @returns the deviceId.
*/
getDeviceId() {
return CapacitorAmplitude.getDeviceId({
logRevenue(_) {
return CapacitorAmplitude.logRevenue({
instanceName: this.instanceName,
}).then(({ deviceId }) => deviceId);
}
/**
* Use the Advertising ID on Android if available from Google Play Services.
* Must be called before init.
*/
useAdvertisingIdForDeviceId() {
return CapacitorAmplitude.useAdvertisingIdForDeviceId({
instanceName: this.instanceName,
});
}
/**
* Enables tracking opt out.
*
* If the user wants to opt out of all tracking, use this method to enable
* opt out for them. Once opt out is enabled, no events will be saved locally
* or sent to the server.
*
* Calling this method again with enabled set to false will turn tracking back on for the user.
*
* @param optOut
*/
setOptOut(optOut) {
return CapacitorAmplitude.setOptOut({
instanceName: this.instanceName,
optOut,
});
}
/**
* Whether to automatically log start and end session events corresponding to
* the start and end of a user's session.
*
* @param trackingSessionEvents
*/
trackingSessionEvents(trackingSessionEvents) {
return CapacitorAmplitude.trackingSessionEvents({
instanceName: this.instanceName,
trackingSessionEvents,
});
}
/**
* If your app has its own login system that you want to track users with,
* you can set the userId.
*
* @param userId
*/
setUserId(userId) {
return CapacitorAmplitude.setUserId({
instanceName: this.instanceName,
userId,
});
}
/**
* Customize the destination for server url.
*
* @param serverUrl
*/
setServerUrl(serverUrl) {
return CapacitorAmplitude.setServerUrl({
instanceName: this.instanceName,
serverUrl,
});
}
/**
* Dynamically adjust server URL
*
* @param useDynamicConfig
*/
setUseDynamicConfig(useDynamicConfig) {
return CapacitorAmplitude.setUseDynamicConfig({
instanceName: this.instanceName,
useDynamicConfig,
});
}
/**
* Log revenue data.
*
* Note: price is a required field to log revenue events.
* If quantity is not specified then defaults to 1.
*
* @param userProperties
*/
logRevenue(userProperties) {
return CapacitorAmplitude.logRevenueV2({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Send an identify call containing user property operations to Amplitude servers.
*
* @param identifyInstance
*/
identify(identifyInstance) {
return CapacitorAmplitude.identify({
instanceName: this.instanceName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds a user to a group or groups. You need to specify a groupType and groupName(s).
* @param groupType
* @param groupName
*/
setGroup(groupType, groupName) {
return CapacitorAmplitude.setGroup({
instanceName: this.instanceName,
groupType,
groupName,
});
}
/**
* Set or update properties of particular groups
*
* @param groupType
* @param groupName
* @param identifyInstance
*/
groupIdentify(groupType, groupName, identifyInstance) {
return CapacitorAmplitude.groupIdentify({
instanceName: this.instanceName,
groupType,
groupName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds properties that are tracked on the user level.
* Note: Property keys must be [String] objects and values must be serializable.
*
* @param userProperties
*/
setUserProperties(userProperties) {
return CapacitorAmplitude.setUserProperties({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Clears all properties that are tracked on the user level.
*
* Note: This operation is irreversible!!
*/
clearUserProperties() {
return CapacitorAmplitude.clearUserProperties({
instanceName: this.instanceName,
});
}
/**
* Upload all unsent events.
*/
uploadEvents() {
return CapacitorAmplitude.uploadEvents({ instanceName: this.instanceName });
}
/**
* Fetches the sessionId, a timestamp used for log session event.
* @returns the sessionId.
*/
getSessionId() {
return CapacitorAmplitude.getSessionId({
instanceName: this.instanceName,
}).then(({ sessionId }) => sessionId);
}
/**
* Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.
* The default time is 5 minutes.
*
* @param minTimeBetweenSessionsMillis
*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis) {
return CapacitorAmplitude.setMinTimeBetweenSessionsMillis({
instanceName: this.instanceName,
minTimeBetweenSessionsMillis,
});
}
/**
* Set Amplitude Server Zone, switch to zone related configuration,
* including dynamic configuration. If updateServerUrl is true, including server url as well.
* Recommend to keep updateServerUrl to be true for alignment.
*
* @param serverZone amplitude serverZone, US or EU, default is US
* @param updateServerUrl if update server url when update server zone, recommend setting true
*/
setServerZone(serverZone, updateServerUrl = true) {
return CapacitorAmplitude.setServerZone({
instanceName: 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 CapacitorAmplitude.setEventUploadMaxBatchSize({
instanceName: 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) {
return CapacitorAmplitude.setEventUploadPeriodMillis({
instanceName: 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 CapacitorAmplitude.setEventUploadThreshold({
instanceName: this.instanceName,
eventUploadThreshold,
});
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan) {
return CapacitorAmplitude.setPlan({
instanceName: this.instanceName,
plan,
});
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata) {
return CapacitorAmplitude.setIngestionMetadata({
instanceName: this.instanceName,
ingestionMetadata,
});
}
}
// private static _instances: Record<string, Amplitude>;
Amplitude._defaultInstanceName = '$default_instance';

@@ -416,0 +105,0 @@

var capacitorAmplitude = (function (exports, core) {
'use strict';
const PACKAGE_SOURCE_NAME = 'capacitor-amplitude';
const PACKAGE_VERSION = '2.0.0';
exports.IdentifyOperation = void 0;

@@ -65,2 +62,3 @@ (function (IdentifyOperation) {

// import { Identify } from './identify';
const CapacitorAmplitude = core.registerPlugin('Amplitude', {

@@ -72,340 +70,31 @@ // web: () => import('./web').then(m => new m.AmplitudeWeb()),

this.instanceName = instanceName;
// this._setLibraryName(Constants.packageSourceName);
// this._setLibraryVersion(Constants.packageVersion);
}
static getInstance(instanceName = 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];
initialize(apiKey, configuration) {
return CapacitorAmplitude.initialize(Object.assign({ instanceName: this.instanceName, apiKey }, configuration));
}
init(apiKey) {
return CapacitorAmplitude.initialize({
instanceName: this.instanceName,
apiKey,
libraryName: PACKAGE_SOURCE_NAME,
libraryVersion: PACKAGE_VERSION,
});
track(options) {
return CapacitorAmplitude.track(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Tracks an event. Events are saved locally.
* Uploads are batched to occur every 30 events or every 30 seconds
* (whichever comes first), as well as on app close.
*
* @param eventType The name of the event you wish to track.
*/
logEvent(eventType, eventProperties) {
if (eventProperties && Object.keys(eventProperties).length > 0) {
return CapacitorAmplitude.logEventWithProperties({
instanceName: this.instanceName,
eventType,
eventProperties,
});
}
return CapacitorAmplitude.logEvent({
instanceName: this.instanceName,
eventType,
});
identifyUser(options) {
return CapacitorAmplitude.identifyUser(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Enable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*
* This can be used by any customer that does not want to collect IDFA, IDFV,
* city, IP address and location tracking.
*/
enableCoppaControl() {
return CapacitorAmplitude.enableCoppaControl({
instanceName: this.instanceName,
});
setUserId(options) {
return CapacitorAmplitude.setUserId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Disable COPPA (Children's Online Privacy Protection Act) restrictions on
* IDFA, IDFV, city, IP address and location tracking.
*/
disableCoppaControl() {
return CapacitorAmplitude.disableCoppaControl({
instanceName: this.instanceName,
});
setDeviceId(options) {
return CapacitorAmplitude.setDeviceId(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Regenerate the DeviceId
*/
regenerateDeviceId() {
return CapacitorAmplitude.regenerateDeviceId({
instanceName: this.instanceName,
});
reset() {
return CapacitorAmplitude.reset({ instanceName: this.instanceName });
}
/**
* Sets a custom device id. <b>Note: only do this if you know what you are doing!</b>
*
* @param deviceId The device id.
*/
setDeviceId(deviceId) {
return CapacitorAmplitude.setDeviceId({
instanceName: this.instanceName,
deviceId,
});
setGroup(options) {
return CapacitorAmplitude.setGroup(Object.assign({ instanceName: this.instanceName }, options));
}
/**
* Fetches the deviceId, a unique identifier shared between multiple users using the same app on the same device.
* @returns the deviceId.
*/
getDeviceId() {
return CapacitorAmplitude.getDeviceId({
logRevenue(_) {
return CapacitorAmplitude.logRevenue({
instanceName: this.instanceName,
}).then(({ deviceId }) => deviceId);
}
/**
* Use the Advertising ID on Android if available from Google Play Services.
* Must be called before init.
*/
useAdvertisingIdForDeviceId() {
return CapacitorAmplitude.useAdvertisingIdForDeviceId({
instanceName: this.instanceName,
});
}
/**
* Enables tracking opt out.
*
* If the user wants to opt out of all tracking, use this method to enable
* opt out for them. Once opt out is enabled, no events will be saved locally
* or sent to the server.
*
* Calling this method again with enabled set to false will turn tracking back on for the user.
*
* @param optOut
*/
setOptOut(optOut) {
return CapacitorAmplitude.setOptOut({
instanceName: this.instanceName,
optOut,
});
}
/**
* Whether to automatically log start and end session events corresponding to
* the start and end of a user's session.
*
* @param trackingSessionEvents
*/
trackingSessionEvents(trackingSessionEvents) {
return CapacitorAmplitude.trackingSessionEvents({
instanceName: this.instanceName,
trackingSessionEvents,
});
}
/**
* If your app has its own login system that you want to track users with,
* you can set the userId.
*
* @param userId
*/
setUserId(userId) {
return CapacitorAmplitude.setUserId({
instanceName: this.instanceName,
userId,
});
}
/**
* Customize the destination for server url.
*
* @param serverUrl
*/
setServerUrl(serverUrl) {
return CapacitorAmplitude.setServerUrl({
instanceName: this.instanceName,
serverUrl,
});
}
/**
* Dynamically adjust server URL
*
* @param useDynamicConfig
*/
setUseDynamicConfig(useDynamicConfig) {
return CapacitorAmplitude.setUseDynamicConfig({
instanceName: this.instanceName,
useDynamicConfig,
});
}
/**
* Log revenue data.
*
* Note: price is a required field to log revenue events.
* If quantity is not specified then defaults to 1.
*
* @param userProperties
*/
logRevenue(userProperties) {
return CapacitorAmplitude.logRevenueV2({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Send an identify call containing user property operations to Amplitude servers.
*
* @param identifyInstance
*/
identify(identifyInstance) {
return CapacitorAmplitude.identify({
instanceName: this.instanceName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds a user to a group or groups. You need to specify a groupType and groupName(s).
* @param groupType
* @param groupName
*/
setGroup(groupType, groupName) {
return CapacitorAmplitude.setGroup({
instanceName: this.instanceName,
groupType,
groupName,
});
}
/**
* Set or update properties of particular groups
*
* @param groupType
* @param groupName
* @param identifyInstance
*/
groupIdentify(groupType, groupName, identifyInstance) {
return CapacitorAmplitude.groupIdentify({
instanceName: this.instanceName,
groupType,
groupName,
userProperties: identifyInstance.payload,
});
}
/**
* Adds properties that are tracked on the user level.
* Note: Property keys must be [String] objects and values must be serializable.
*
* @param userProperties
*/
setUserProperties(userProperties) {
return CapacitorAmplitude.setUserProperties({
instanceName: this.instanceName,
userProperties,
});
}
/**
* Clears all properties that are tracked on the user level.
*
* Note: This operation is irreversible!!
*/
clearUserProperties() {
return CapacitorAmplitude.clearUserProperties({
instanceName: this.instanceName,
});
}
/**
* Upload all unsent events.
*/
uploadEvents() {
return CapacitorAmplitude.uploadEvents({ instanceName: this.instanceName });
}
/**
* Fetches the sessionId, a timestamp used for log session event.
* @returns the sessionId.
*/
getSessionId() {
return CapacitorAmplitude.getSessionId({
instanceName: this.instanceName,
}).then(({ sessionId }) => sessionId);
}
/**
* Sets the minimum cutoff time in millisseconds for sessions to be considered distinct.
* The default time is 5 minutes.
*
* @param minTimeBetweenSessionsMillis
*/
setMinTimeBetweenSessionsMillis(minTimeBetweenSessionsMillis) {
return CapacitorAmplitude.setMinTimeBetweenSessionsMillis({
instanceName: this.instanceName,
minTimeBetweenSessionsMillis,
});
}
/**
* Set Amplitude Server Zone, switch to zone related configuration,
* including dynamic configuration. If updateServerUrl is true, including server url as well.
* Recommend to keep updateServerUrl to be true for alignment.
*
* @param serverZone amplitude serverZone, US or EU, default is US
* @param updateServerUrl if update server url when update server zone, recommend setting true
*/
setServerZone(serverZone, updateServerUrl = true) {
return CapacitorAmplitude.setServerZone({
instanceName: 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 CapacitorAmplitude.setEventUploadMaxBatchSize({
instanceName: 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) {
return CapacitorAmplitude.setEventUploadPeriodMillis({
instanceName: 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 CapacitorAmplitude.setEventUploadThreshold({
instanceName: this.instanceName,
eventUploadThreshold,
});
}
/**
* Sets tracking plan information.
*
* @param plan Plan object
*/
setPlan(plan) {
return CapacitorAmplitude.setPlan({
instanceName: this.instanceName,
plan,
});
}
/**
* Sets ingestion metadata information.
*
* @param ingestionMetadata IngestionMetadata object
*/
setIngestionMetadata(ingestionMetadata) {
return CapacitorAmplitude.setIngestionMetadata({
instanceName: this.instanceName,
ingestionMetadata,
});
}
}
// private static _instances: Record<string, Amplitude>;
Amplitude._defaultInstanceName = '$default_instance';

@@ -412,0 +101,0 @@

{
"name": "capacitor-amplitude",
"version": "2.0.1",
"version": "3.0.0-beta.1",
"description": "Amplitude plugin for capacitor",

@@ -72,4 +72,7 @@ "main": "dist/plugin.cjs.js",

"src": "ios"
},
"android": {
"src": "android"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc