expo-analytics-amplitude
Advanced tools
Comparing version 8.3.1 to 9.0.0
@@ -20,13 +20,49 @@ export interface AmplitudeTrackingOptions { | ||
} | ||
export declare function initializeAsync(apiKey: string): Promise<void>; | ||
export declare function setUserIdAsync(userId: string): Promise<void>; | ||
export declare function setUserPropertiesAsync(userProperties: { | ||
[name: string]: any; | ||
}): Promise<void>; | ||
export declare function clearUserPropertiesAsync(): Promise<void>; | ||
export declare function logEventAsync(eventName: string): Promise<void>; | ||
export declare function logEventWithPropertiesAsync(eventName: string, properties: { | ||
[name: string]: any; | ||
}): Promise<void>; | ||
export declare function setGroupAsync(groupType: string, groupNames: string[]): Promise<void>; | ||
export declare function setTrackingOptionsAsync(options: AmplitudeTrackingOptions): Promise<void>; | ||
/** | ||
* @deprecated Use initializeAsync instead | ||
*/ | ||
export declare function initialize(apiKey: string): Promise<void>; | ||
/** | ||
* @deprecated Use setUserIdAsync instead | ||
*/ | ||
export declare function setUserId(userId: string): Promise<void>; | ||
/** | ||
* @deprecated Use setUserPropertiesAsync instead | ||
*/ | ||
export declare function setUserProperties(userProperties: { | ||
[name: string]: any; | ||
}): Promise<void>; | ||
/** | ||
* @deprecated Use clearUserPropertiesAsync instead | ||
*/ | ||
export declare function clearUserProperties(): Promise<void>; | ||
/** | ||
* @deprecated Use logEventAsync instead | ||
*/ | ||
export declare function logEvent(eventName: string): Promise<void>; | ||
/** | ||
* @deprecated Use logEventWithPropertiesAsync instead | ||
*/ | ||
export declare function logEventWithProperties(eventName: string, properties: { | ||
[name: string]: any; | ||
}): Promise<void>; | ||
/** | ||
* @deprecated Use setGroupAsync instead | ||
*/ | ||
export declare function setGroup(groupType: string, groupNames: string[]): Promise<void>; | ||
export declare function setTrackingOptions(options: AmplitudeTrackingOptions): any; | ||
/** | ||
* @deprecated Use setTrackingOptionsAsync instead | ||
*/ | ||
export declare function setTrackingOptions(options: AmplitudeTrackingOptions): Promise<void>; |
import { UnavailabilityError } from '@unimodules/core'; | ||
import ExpoAmplitude from './ExpoAmplitude'; | ||
export function initialize(apiKey) { | ||
if (!ExpoAmplitude.initialize) { | ||
throw new UnavailabilityError('Amplitude', 'initialize'); | ||
export async function initializeAsync(apiKey) { | ||
if (!ExpoAmplitude.initializeAsync) { | ||
throw new UnavailabilityError('Amplitude', 'initializeAsync'); | ||
} | ||
return ExpoAmplitude.initialize(apiKey); | ||
return await ExpoAmplitude.initializeAsync(apiKey); | ||
} | ||
export function setUserId(userId) { | ||
if (!ExpoAmplitude.setUserId) { | ||
throw new UnavailabilityError('Amplitude', 'setUserId'); | ||
export async function setUserIdAsync(userId) { | ||
if (!ExpoAmplitude.setUserIdAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setUserIdAsync'); | ||
} | ||
return ExpoAmplitude.setUserId(userId); | ||
return await ExpoAmplitude.setUserIdAsync(userId); | ||
} | ||
export function setUserProperties(userProperties) { | ||
if (!ExpoAmplitude.setUserProperties) { | ||
throw new UnavailabilityError('Amplitude', 'setUserProperties'); | ||
export async function setUserPropertiesAsync(userProperties) { | ||
if (!ExpoAmplitude.setUserPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setUserPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.setUserProperties(userProperties); | ||
return await ExpoAmplitude.setUserPropertiesAsync(userProperties); | ||
} | ||
export function clearUserProperties() { | ||
if (!ExpoAmplitude.clearUserProperties) { | ||
throw new UnavailabilityError('Amplitude', 'clearUserProperties'); | ||
export async function clearUserPropertiesAsync() { | ||
if (!ExpoAmplitude.clearUserPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'clearUserPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.clearUserProperties(); | ||
return await ExpoAmplitude.clearUserPropertiesAsync(); | ||
} | ||
export function logEvent(eventName) { | ||
if (!ExpoAmplitude.logEvent) { | ||
throw new UnavailabilityError('Amplitude', 'logEvent'); | ||
export async function logEventAsync(eventName) { | ||
if (!ExpoAmplitude.logEventAsync) { | ||
throw new UnavailabilityError('Amplitude', 'logEventAsync'); | ||
} | ||
return ExpoAmplitude.logEvent(eventName); | ||
return await ExpoAmplitude.logEventAsync(eventName); | ||
} | ||
export function logEventWithProperties(eventName, properties) { | ||
if (!ExpoAmplitude.logEventWithProperties) { | ||
throw new UnavailabilityError('Amplitude', 'logEventWithProperties'); | ||
export async function logEventWithPropertiesAsync(eventName, properties) { | ||
if (!ExpoAmplitude.logEventWithPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'logEventWithPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.logEventWithProperties(eventName, properties); | ||
return await ExpoAmplitude.logEventWithPropertiesAsync(eventName, properties); | ||
} | ||
export function setGroup(groupType, groupNames) { | ||
if (!ExpoAmplitude.setGroup) { | ||
throw new UnavailabilityError('Amplitude', 'setGroup'); | ||
export async function setGroupAsync(groupType, groupNames) { | ||
if (!ExpoAmplitude.setGroupAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setGroupAsync'); | ||
} | ||
return ExpoAmplitude.setGroup(groupType, groupNames); | ||
return await ExpoAmplitude.setGroupAsync(groupType, groupNames); | ||
} | ||
export function setTrackingOptions(options) { | ||
if (!ExpoAmplitude.setTrackingOptions) { | ||
throw new UnavailabilityError('Amplitude', 'setTrackingOptions'); | ||
export async function setTrackingOptionsAsync(options) { | ||
if (!ExpoAmplitude.setTrackingOptionsAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setTrackingOptionsAsync'); | ||
} | ||
return ExpoAmplitude.setTrackingOptions(options); | ||
return await ExpoAmplitude.setTrackingOptionsAsync(options); | ||
} | ||
/* | ||
* Legacy methods for backwards-compatibility. | ||
* These should be removed in SDK 41 | ||
*/ | ||
/** | ||
* @deprecated Use initializeAsync instead | ||
*/ | ||
export async function initialize(apiKey) { | ||
console.warn("'Amplitude.initialize' is deprecated in favor of 'Amplitude.initializeAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await initializeAsync(apiKey); | ||
} | ||
/** | ||
* @deprecated Use setUserIdAsync instead | ||
*/ | ||
export async function setUserId(userId) { | ||
console.warn("'Amplitude.setUserId' is deprecated in favor of 'Amplitude.setUserIdAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await setUserIdAsync(userId); | ||
} | ||
/** | ||
* @deprecated Use setUserPropertiesAsync instead | ||
*/ | ||
export async function setUserProperties(userProperties) { | ||
console.warn("'Amplitude.setUserProperties' is deprecated in favor of 'Amplitude.setUserPropertiesAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await setUserPropertiesAsync(userProperties); | ||
} | ||
/** | ||
* @deprecated Use clearUserPropertiesAsync instead | ||
*/ | ||
export async function clearUserProperties() { | ||
console.warn("'Amplitude.clearUserProperties' is deprecated in favor of 'Amplitude.clearUserPropertiesAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await clearUserPropertiesAsync(); | ||
} | ||
/** | ||
* @deprecated Use logEventAsync instead | ||
*/ | ||
export async function logEvent(eventName) { | ||
console.warn("'Amplitude.logEvent' is deprecated in favor of 'Amplitude.logEventAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await logEventAsync(eventName); | ||
} | ||
/** | ||
* @deprecated Use logEventWithPropertiesAsync instead | ||
*/ | ||
export async function logEventWithProperties(eventName, properties) { | ||
console.warn("'Amplitude.logEventWithProperties' is deprecated in favor of 'Amplitude.logEventWithPropertiesAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await logEventWithPropertiesAsync(eventName, properties); | ||
} | ||
/** | ||
* @deprecated Use setGroupAsync instead | ||
*/ | ||
export async function setGroup(groupType, groupNames) { | ||
console.warn("'Amplitude.setGroup' is deprecated in favor of 'Amplitude.setGroupAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await setGroupAsync(groupType, groupNames); | ||
} | ||
/** | ||
* @deprecated Use setTrackingOptionsAsync instead | ||
*/ | ||
export async function setTrackingOptions(options) { | ||
console.warn("'Amplitude.setTrackingOptions' is deprecated in favor of 'Amplitude.setTrackingOptionsAsync'. Please use the new method, which contains no user-facing changes."); | ||
return await setTrackingOptionsAsync(options); | ||
} | ||
//# sourceMappingURL=Amplitude.js.map |
@@ -11,2 +11,18 @@ # Changelog | ||
## 9.0.0 — 2020-11-17 | ||
### 🛠 Breaking changes | ||
- Renamed all methods to include the 'Async' suffix: | ||
- `initialize` to `initializeAsync` | ||
- `setUserId` to `setUserIdAsync` | ||
- `setUserProperties` to `setUserPropertiesAsync` | ||
- `clearUserProperties` to `clearUserPropertiesAsync` | ||
- `logEvent` to `logEventAsync` | ||
- `logEventWithProperties` to `logEventWithPropertiesAsync` | ||
- `setGroup` to `setGroupAsync` | ||
- `setTrackingOptions` to `setTrackingOptionsAsync` | ||
([#9212](https://github.com/expo/expo/pull/9212/) by [@cruzach](https://github.com/cruzach)) | ||
- All methods now return a Promise. ([#9212](https://github.com/expo/expo/pull/9212/) by [@cruzach](https://github.com/cruzach)) | ||
## 8.3.1 — 2020-08-24 | ||
@@ -24,6 +40,6 @@ | ||
*This version does not introduce any user-facing changes.* | ||
_This version does not introduce any user-facing changes._ | ||
## 8.2.0 — 2020-05-27 | ||
*This version does not introduce any user-facing changes.* | ||
_This version does not introduce any user-facing changes._ |
{ | ||
"name": "expo-analytics-amplitude", | ||
"version": "8.3.1", | ||
"version": "9.0.0", | ||
"description": "Provides access to Amplitude (https://amplitude.com/) mobile analytics. This module wraps Amplitude-iOS (https://github.com/amplitude/Amplitude-iOS) and Android (https://github.com/amplitude/Amplitude-Android) SDKs.", | ||
@@ -42,3 +42,3 @@ "main": "build/Amplitude.js", | ||
}, | ||
"gitHead": "7943ac3267550aca1501c239a8675d680e1f6f3a" | ||
"gitHead": "bc6b4b3bc3cb5e44e477f145c72c07ed09588651" | ||
} |
@@ -16,3 +16,3 @@ # expo-analytics-amplitude | ||
For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/unimodules/react-native-unimodules) before continuing. | ||
For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing. | ||
@@ -19,0 +19,0 @@ ### Add the package to your npm dependencies |
@@ -25,59 +25,149 @@ import { UnavailabilityError } from '@unimodules/core'; | ||
export function initialize(apiKey: string): Promise<void> { | ||
if (!ExpoAmplitude.initialize) { | ||
throw new UnavailabilityError('Amplitude', 'initialize'); | ||
export async function initializeAsync(apiKey: string): Promise<void> { | ||
if (!ExpoAmplitude.initializeAsync) { | ||
throw new UnavailabilityError('Amplitude', 'initializeAsync'); | ||
} | ||
return ExpoAmplitude.initialize(apiKey); | ||
return await ExpoAmplitude.initializeAsync(apiKey); | ||
} | ||
export function setUserId(userId: string): Promise<void> { | ||
if (!ExpoAmplitude.setUserId) { | ||
throw new UnavailabilityError('Amplitude', 'setUserId'); | ||
export async function setUserIdAsync(userId: string): Promise<void> { | ||
if (!ExpoAmplitude.setUserIdAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setUserIdAsync'); | ||
} | ||
return ExpoAmplitude.setUserId(userId); | ||
return await ExpoAmplitude.setUserIdAsync(userId); | ||
} | ||
export function setUserProperties(userProperties: { [name: string]: any }): Promise<void> { | ||
if (!ExpoAmplitude.setUserProperties) { | ||
throw new UnavailabilityError('Amplitude', 'setUserProperties'); | ||
export async function setUserPropertiesAsync(userProperties: { | ||
[name: string]: any; | ||
}): Promise<void> { | ||
if (!ExpoAmplitude.setUserPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setUserPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.setUserProperties(userProperties); | ||
return await ExpoAmplitude.setUserPropertiesAsync(userProperties); | ||
} | ||
export function clearUserProperties(): Promise<void> { | ||
if (!ExpoAmplitude.clearUserProperties) { | ||
throw new UnavailabilityError('Amplitude', 'clearUserProperties'); | ||
export async function clearUserPropertiesAsync(): Promise<void> { | ||
if (!ExpoAmplitude.clearUserPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'clearUserPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.clearUserProperties(); | ||
return await ExpoAmplitude.clearUserPropertiesAsync(); | ||
} | ||
export function logEvent(eventName: string): Promise<void> { | ||
if (!ExpoAmplitude.logEvent) { | ||
throw new UnavailabilityError('Amplitude', 'logEvent'); | ||
export async function logEventAsync(eventName: string): Promise<void> { | ||
if (!ExpoAmplitude.logEventAsync) { | ||
throw new UnavailabilityError('Amplitude', 'logEventAsync'); | ||
} | ||
return ExpoAmplitude.logEvent(eventName); | ||
return await ExpoAmplitude.logEventAsync(eventName); | ||
} | ||
export function logEventWithProperties( | ||
export async function logEventWithPropertiesAsync( | ||
eventName: string, | ||
properties: { [name: string]: any } | ||
): Promise<void> { | ||
if (!ExpoAmplitude.logEventWithProperties) { | ||
throw new UnavailabilityError('Amplitude', 'logEventWithProperties'); | ||
if (!ExpoAmplitude.logEventWithPropertiesAsync) { | ||
throw new UnavailabilityError('Amplitude', 'logEventWithPropertiesAsync'); | ||
} | ||
return ExpoAmplitude.logEventWithProperties(eventName, properties); | ||
return await ExpoAmplitude.logEventWithPropertiesAsync(eventName, properties); | ||
} | ||
export function setGroup(groupType: string, groupNames: string[]): Promise<void> { | ||
if (!ExpoAmplitude.setGroup) { | ||
throw new UnavailabilityError('Amplitude', 'setGroup'); | ||
export async function setGroupAsync(groupType: string, groupNames: string[]): Promise<void> { | ||
if (!ExpoAmplitude.setGroupAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setGroupAsync'); | ||
} | ||
return ExpoAmplitude.setGroup(groupType, groupNames); | ||
return await ExpoAmplitude.setGroupAsync(groupType, groupNames); | ||
} | ||
export function setTrackingOptions(options: AmplitudeTrackingOptions) { | ||
if (!ExpoAmplitude.setTrackingOptions) { | ||
throw new UnavailabilityError('Amplitude', 'setTrackingOptions'); | ||
export async function setTrackingOptionsAsync(options: AmplitudeTrackingOptions): Promise<void> { | ||
if (!ExpoAmplitude.setTrackingOptionsAsync) { | ||
throw new UnavailabilityError('Amplitude', 'setTrackingOptionsAsync'); | ||
} | ||
return ExpoAmplitude.setTrackingOptions(options); | ||
return await ExpoAmplitude.setTrackingOptionsAsync(options); | ||
} | ||
/* | ||
* Legacy methods for backwards-compatibility. | ||
* These should be removed in SDK 41 | ||
*/ | ||
/** | ||
* @deprecated Use initializeAsync instead | ||
*/ | ||
export async function initialize(apiKey: string): Promise<void> { | ||
console.warn( | ||
"'Amplitude.initialize' is deprecated in favor of 'Amplitude.initializeAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await initializeAsync(apiKey); | ||
} | ||
/** | ||
* @deprecated Use setUserIdAsync instead | ||
*/ | ||
export async function setUserId(userId: string): Promise<void> { | ||
console.warn( | ||
"'Amplitude.setUserId' is deprecated in favor of 'Amplitude.setUserIdAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await setUserIdAsync(userId); | ||
} | ||
/** | ||
* @deprecated Use setUserPropertiesAsync instead | ||
*/ | ||
export async function setUserProperties(userProperties: { [name: string]: any }): Promise<void> { | ||
console.warn( | ||
"'Amplitude.setUserProperties' is deprecated in favor of 'Amplitude.setUserPropertiesAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await setUserPropertiesAsync(userProperties); | ||
} | ||
/** | ||
* @deprecated Use clearUserPropertiesAsync instead | ||
*/ | ||
export async function clearUserProperties(): Promise<void> { | ||
console.warn( | ||
"'Amplitude.clearUserProperties' is deprecated in favor of 'Amplitude.clearUserPropertiesAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await clearUserPropertiesAsync(); | ||
} | ||
/** | ||
* @deprecated Use logEventAsync instead | ||
*/ | ||
export async function logEvent(eventName: string): Promise<void> { | ||
console.warn( | ||
"'Amplitude.logEvent' is deprecated in favor of 'Amplitude.logEventAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await logEventAsync(eventName); | ||
} | ||
/** | ||
* @deprecated Use logEventWithPropertiesAsync instead | ||
*/ | ||
export async function logEventWithProperties( | ||
eventName: string, | ||
properties: { [name: string]: any } | ||
): Promise<void> { | ||
console.warn( | ||
"'Amplitude.logEventWithProperties' is deprecated in favor of 'Amplitude.logEventWithPropertiesAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await logEventWithPropertiesAsync(eventName, properties); | ||
} | ||
/** | ||
* @deprecated Use setGroupAsync instead | ||
*/ | ||
export async function setGroup(groupType: string, groupNames: string[]): Promise<void> { | ||
console.warn( | ||
"'Amplitude.setGroup' is deprecated in favor of 'Amplitude.setGroupAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await setGroupAsync(groupType, groupNames); | ||
} | ||
/** | ||
* @deprecated Use setTrackingOptionsAsync instead | ||
*/ | ||
export async function setTrackingOptions(options: AmplitudeTrackingOptions): Promise<void> { | ||
console.warn( | ||
"'Amplitude.setTrackingOptions' is deprecated in favor of 'Amplitude.setTrackingOptionsAsync'. Please use the new method, which contains no user-facing changes." | ||
); | ||
return await setTrackingOptionsAsync(options); | ||
} |
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
40117
523