Repository URL to install this package:
|
Version:
0.8.0 ▾
|
export const ActionTypes = {
INIT_AMPLITUDE: '@doodle/amplitude/INIT_AMPLITUDE',
INIT_AMPLITUDE_SUCCESS: '@doodle/amplitude/INIT_AMPLITUDE_SUCCESS',
LOG_AMPLITUDE_EVENT: '@doodle/amplitude/LOG_AMPLITUDE_EVENT',
SET_AMPLITUDE_USER_ID: '@doodle/amplitude/SET_AMPLITUDE_USER_ID',
SET_AMPLITUDE_USER_PROPERTIES: '@doodle/amplitude/SET_AMPLITUDE_USER_PROPERTIES',
UNSET_AMPLITUDE_USER_PROPERTY: '@doodle/amplitude/UNSET_AMPLITUDE_USER_PROPERTIES',
REGENERATE_AMPLITUDE_DEVICE_ID: '@doodle/amplitude/REGENERATE_AMPLITUDE_DEVICE_ID',
INIT_AMPLITUDE_FAILED: '@doodle/amplitude/INIT_AMPLITUDE_FAILED',
};
/**
* initializes amplitude.
* @method
* @public
*/
export const initAmplitude = () => ({
type: ActionTypes.INIT_AMPLITUDE,
});
/**
* Triggered when amplitude is successfull initialized
* @method
* @public
*/
export const initAmplitudeSuccess = () => ({
type: ActionTypes.INIT_AMPLITUDE_SUCCESS,
});
/**
* Logs an event via the amplitude sdk
* @method
* @public
* @param {string} eventType The type of the event.
* @param {string} eventName The name of the event.
* @param {object} eventProperties Key / Value pairs of properties. The key should be a string.
* @param {function} callback Will be called after an event is succesfully logged.
*/
export const logAmplitudeEvent = (eventType, eventName, eventProperties = {}, callback) => ({
type: ActionTypes.LOG_AMPLITUDE_EVENT,
payload: {
eventType,
eventName,
eventProperties,
callback,
},
});
/**
* Sets a specific userId for the session
* @method
* @public
* @param {*} userId The userId sould be the userId of the logged in doodle account. Set to null to reset the user after logout.
*/
export const setAmplitudeUserId = userId => ({
type: ActionTypes.SET_AMPLITUDE_USER_ID,
userId,
});
/**
* Sets one or multiple user properties.
* @method
* @public
* @param {object} userProperties Key/value pairs of user properties
* @param {boolean} once Set to true if this specific propertie should only be tracked once.
*/
export const setAmplitudeUserProperties = (userProperties, once) => ({
type: ActionTypes.SET_AMPLITUDE_USER_PROPERTIES,
payload: {
userProperties,
once,
},
});
/**
* Unset a specific user property
* @method
* @public
* @param {string} userProperty Name of the user property you want to delete.
*/
export const unsetAmplitudeUserProperty = userProperty => ({
type: ActionTypes.UNSET_AMPLITUDE_USER_PROPERTY,
userProperty,
});
/**
* Generates a new deviceId by manually
* @method
* @public
*/
export const regenerateAmplitudeDeviceId = () => ({
type: ActionTypes.REGENERATE_AMPLITUDE_DEVICE_ID,
});