capacitor-appmetrica
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -17,2 +17,86 @@ declare module '@capacitor/core' { | ||
}>; | ||
reportUserProfile(options: { | ||
updates: UserProfileUpdate[]; | ||
}): Promise<void>; | ||
} | ||
export declare enum Gender { | ||
MALE = 0, | ||
FEMALE = 1, | ||
OTHER = 2 | ||
} | ||
export declare class UserProfile { | ||
updates: UserProfileUpdate[]; | ||
apply(update: UserProfileUpdate): this; | ||
applyFromArray(updatesArray: UserProfileUpdate[]): this; | ||
} | ||
export declare class UserProfileUpdate { | ||
attributeName: string; | ||
methodName: string; | ||
key: string | null; | ||
values: any[]; | ||
constructor(attributeName: string, methodName: string, key: string | null, ...values: any[]); | ||
} | ||
export declare class BirthDateAttribute { | ||
private attributeName; | ||
withAge(age: number): UserProfileUpdate; | ||
withBirthDate(date: Date): UserProfileUpdate; | ||
withBirthDate(year: number): UserProfileUpdate; | ||
withBirthDate(year: number, month: number): UserProfileUpdate; | ||
withBirthDate(year: number, month: number, day: number): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class GenderAttribute { | ||
private attributeName; | ||
withValue(value: Gender): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class NameAttribute { | ||
private attributeName; | ||
withValue(value: string): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class NotificationsEnabledAttribute { | ||
private attributeName; | ||
withValue(value: boolean): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class CustomBooleanAttribute { | ||
private attributeName; | ||
key: string; | ||
constructor(key: string); | ||
withValue(value: boolean): UserProfileUpdate; | ||
withValueIfUndefined(value: boolean): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class CustomCounterAttribute { | ||
private attributeName; | ||
private key; | ||
constructor(key: string); | ||
withDelta(value: number): UserProfileUpdate; | ||
} | ||
export declare class CustomNumberAttribute { | ||
private attributeName; | ||
private key; | ||
constructor(key: string); | ||
withValue(value: number): UserProfileUpdate; | ||
withValueIfUndefined(value: number): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class CustomStringAttribute { | ||
private attributeName; | ||
private key; | ||
constructor(key: string); | ||
withValue(value: string): UserProfileUpdate; | ||
withValueIfUndefined(value: string): UserProfileUpdate; | ||
withValueReset(): UserProfileUpdate; | ||
} | ||
export declare class ProfileAttribute { | ||
static BirthDate(): BirthDateAttribute; | ||
static Gender(): GenderAttribute; | ||
static Name(): NameAttribute; | ||
static NotificationsEnabled(): NotificationsEnabledAttribute; | ||
static CustomBool(key: string): CustomBooleanAttribute; | ||
static CustomCounter(key: string): CustomCounterAttribute; | ||
static CustomNumber(key: string): CustomNumberAttribute; | ||
static CustomString(key: string): CustomStringAttribute; | ||
} |
@@ -1,2 +0,166 @@ | ||
export {}; | ||
export var Gender; | ||
(function (Gender) { | ||
Gender[Gender["MALE"] = 0] = "MALE"; | ||
Gender[Gender["FEMALE"] = 1] = "FEMALE"; | ||
Gender[Gender["OTHER"] = 2] = "OTHER"; | ||
})(Gender || (Gender = {})); | ||
export class UserProfile { | ||
constructor() { | ||
this.updates = []; | ||
} | ||
apply(update) { | ||
this.updates.push(update); | ||
return this; | ||
} | ||
applyFromArray(updatesArray) { | ||
this.updates.push(...updatesArray); | ||
return this; | ||
} | ||
} | ||
export class UserProfileUpdate { | ||
constructor(attributeName, methodName, key, ...values) { | ||
this.attributeName = attributeName; | ||
this.methodName = methodName; | ||
this.key = key; | ||
this.values = values; | ||
} | ||
} | ||
export class BirthDateAttribute { | ||
constructor() { | ||
this.attributeName = 'birthDate'; | ||
} | ||
withAge(age) { | ||
return new UserProfileUpdate(this.attributeName, 'withAge', null, age); | ||
} | ||
withBirthDate(yearOrDate, month, day) { | ||
const args = []; | ||
if (typeof yearOrDate !== 'number') { | ||
args.push(yearOrDate.getDate(), yearOrDate.getMonth(), yearOrDate.getFullYear()); | ||
} | ||
else { | ||
args.push(yearOrDate); | ||
if (month !== undefined) | ||
args.push(month); | ||
if (day !== undefined) | ||
args.push(day); | ||
} | ||
return new UserProfileUpdate(this.attributeName, 'withBirthDate', null, ...args); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
export class GenderAttribute { | ||
constructor() { | ||
this.attributeName = 'gender'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value.toString()); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
export class NameAttribute { | ||
constructor() { | ||
this.attributeName = 'name'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
export class NotificationsEnabledAttribute { | ||
constructor() { | ||
this.attributeName = 'notificationsEnabled'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
export class CustomBooleanAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customBoolean'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
export class CustomCounterAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customCounter'; | ||
this.key = key; | ||
} | ||
withDelta(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withDelta', this.key, value); | ||
} | ||
} | ||
export class CustomNumberAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customNumber'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
export class CustomStringAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customString'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
export class ProfileAttribute { | ||
static BirthDate() { | ||
return new BirthDateAttribute(); | ||
} | ||
static Gender() { | ||
return new GenderAttribute(); | ||
} | ||
static Name() { | ||
return new NameAttribute(); | ||
} | ||
static NotificationsEnabled() { | ||
return new NotificationsEnabledAttribute(); | ||
} | ||
static CustomBool(key) { | ||
return new CustomBooleanAttribute(key); | ||
} | ||
static CustomCounter(key) { | ||
return new CustomCounterAttribute(key); | ||
} | ||
static CustomNumber(key) { | ||
return new CustomNumberAttribute(key); | ||
} | ||
static CustomString(key) { | ||
return new CustomStringAttribute(key); | ||
} | ||
} | ||
//# sourceMappingURL=definitions.js.map |
@@ -0,1 +1,2 @@ | ||
import { UserProfile } from '.'; | ||
export declare class Appmetrica { | ||
@@ -6,2 +7,3 @@ private appmetrica; | ||
getDeviceID(): Promise<string>; | ||
reportUserProfile(profile: UserProfile): Promise<void>; | ||
} |
@@ -16,3 +16,12 @@ import { Plugins } from '@capacitor/core'; | ||
} | ||
reportUserProfile(profile) { | ||
const updates = profile.updates.map(m => ({ | ||
attributeName: m.attributeName, | ||
methodName: m.methodName, | ||
key: m.key, | ||
values: m.values, | ||
})); | ||
return this.appmetrica.reportUserProfile({ updates }); | ||
} | ||
} | ||
//# sourceMappingURL=plugin.js.map |
{ | ||
"name": "capacitor-appmetrica", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"description": "Capacitor plugin for Appmetrica", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
186
plugin.js
var capacitorAppmetrica = (function (exports, core) { | ||
'use strict'; | ||
exports.Gender = void 0; | ||
(function (Gender) { | ||
Gender[Gender["MALE"] = 0] = "MALE"; | ||
Gender[Gender["FEMALE"] = 1] = "FEMALE"; | ||
Gender[Gender["OTHER"] = 2] = "OTHER"; | ||
})(exports.Gender || (exports.Gender = {})); | ||
class UserProfile { | ||
constructor() { | ||
this.updates = []; | ||
} | ||
apply(update) { | ||
this.updates.push(update); | ||
return this; | ||
} | ||
applyFromArray(updatesArray) { | ||
this.updates.push(...updatesArray); | ||
return this; | ||
} | ||
} | ||
class UserProfileUpdate { | ||
constructor(attributeName, methodName, key, ...values) { | ||
this.attributeName = attributeName; | ||
this.methodName = methodName; | ||
this.key = key; | ||
this.values = values; | ||
} | ||
} | ||
class BirthDateAttribute { | ||
constructor() { | ||
this.attributeName = 'birthDate'; | ||
} | ||
withAge(age) { | ||
return new UserProfileUpdate(this.attributeName, 'withAge', null, age); | ||
} | ||
withBirthDate(yearOrDate, month, day) { | ||
const args = []; | ||
if (typeof yearOrDate !== 'number') { | ||
args.push(yearOrDate.getDate(), yearOrDate.getMonth(), yearOrDate.getFullYear()); | ||
} | ||
else { | ||
args.push(yearOrDate); | ||
if (month !== undefined) | ||
args.push(month); | ||
if (day !== undefined) | ||
args.push(day); | ||
} | ||
return new UserProfileUpdate(this.attributeName, 'withBirthDate', null, ...args); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
class GenderAttribute { | ||
constructor() { | ||
this.attributeName = 'gender'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value.toString()); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
class NameAttribute { | ||
constructor() { | ||
this.attributeName = 'name'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
class NotificationsEnabledAttribute { | ||
constructor() { | ||
this.attributeName = 'notificationsEnabled'; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', null, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', null); | ||
} | ||
} | ||
class CustomBooleanAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customBoolean'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
class CustomCounterAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customCounter'; | ||
this.key = key; | ||
} | ||
withDelta(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withDelta', this.key, value); | ||
} | ||
} | ||
class CustomNumberAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customNumber'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
class CustomStringAttribute { | ||
constructor(key) { | ||
this.attributeName = 'customString'; | ||
this.key = key; | ||
} | ||
withValue(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValue', this.key, value); | ||
} | ||
withValueIfUndefined(value) { | ||
return new UserProfileUpdate(this.attributeName, 'withValueIfUndefined', this.key, value); | ||
} | ||
withValueReset() { | ||
return new UserProfileUpdate(this.attributeName, 'withValueReset', this.key); | ||
} | ||
} | ||
class ProfileAttribute { | ||
static BirthDate() { | ||
return new BirthDateAttribute(); | ||
} | ||
static Gender() { | ||
return new GenderAttribute(); | ||
} | ||
static Name() { | ||
return new NameAttribute(); | ||
} | ||
static NotificationsEnabled() { | ||
return new NotificationsEnabledAttribute(); | ||
} | ||
static CustomBool(key) { | ||
return new CustomBooleanAttribute(key); | ||
} | ||
static CustomCounter(key) { | ||
return new CustomCounterAttribute(key); | ||
} | ||
static CustomNumber(key) { | ||
return new CustomNumberAttribute(key); | ||
} | ||
static CustomString(key) { | ||
return new CustomStringAttribute(key); | ||
} | ||
} | ||
const AppmetricaPlugin = core.Plugins.Appmetrica; | ||
@@ -18,5 +184,25 @@ class Appmetrica { | ||
} | ||
reportUserProfile(profile) { | ||
const updates = profile.updates.map(m => ({ | ||
attributeName: m.attributeName, | ||
methodName: m.methodName, | ||
key: m.key, | ||
values: m.values, | ||
})); | ||
return this.appmetrica.reportUserProfile({ updates }); | ||
} | ||
} | ||
exports.Appmetrica = Appmetrica; | ||
exports.BirthDateAttribute = BirthDateAttribute; | ||
exports.CustomBooleanAttribute = CustomBooleanAttribute; | ||
exports.CustomCounterAttribute = CustomCounterAttribute; | ||
exports.CustomNumberAttribute = CustomNumberAttribute; | ||
exports.CustomStringAttribute = CustomStringAttribute; | ||
exports.GenderAttribute = GenderAttribute; | ||
exports.NameAttribute = NameAttribute; | ||
exports.NotificationsEnabledAttribute = NotificationsEnabledAttribute; | ||
exports.ProfileAttribute = ProfileAttribute; | ||
exports.UserProfile = UserProfile; | ||
exports.UserProfileUpdate = UserProfileUpdate; | ||
@@ -23,0 +209,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -7,5 +7,9 @@ # Capacitor Appmetrica plugin | ||
// TODO | ||
- logEvent | ||
- setUserProfileID | ||
- reportUserProfile | ||
- getDeviceID | ||
# Usage example: | ||
0. Add in `capacitor.config.json` | ||
@@ -43,3 +47,3 @@ | ||
... | ||
import { Appmetrica } from 'capacitor-appmetrica' | ||
import { Appmetrica, UserProfile, ProfileAttribute } from 'capacitor-appmetrica' | ||
@@ -53,4 +57,23 @@ @Injectable() | ||
} | ||
async setUserProfileID(id: string) { | ||
return this.appmetrica.setUserProfileID(id) | ||
} | ||
async reportUserProfile() { | ||
const userProfile = new UserProfile() | ||
userProfile.applyFromArray([ | ||
ProfileAttribute.Name().withValue('Ivan'), | ||
ProfileAttribute.BirthDate().withBirthDate(new Date()), | ||
ProfileAttribute.CustomString('born_in').withValueIfUndefined('Moscow'), | ||
]) | ||
await this.appmetrica.reportUserProfile(userProfile) | ||
} | ||
async getDeviceID(): string { | ||
return this.appmetrica.getDeviceID() | ||
} | ||
} | ||
``` |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
310512
510
77
1