Reference
Here are all the methods available to you through the ApmService class
This method logs in a user inside the ApmService SDK. Usually it should be call inside a callback when the user is connected to your system.
await ApmService.user.login(
email: string,
partnerClientId: string,
firstname: string,
lastname: string,
deviceStatusCode?: 0 | 1 | -1
);
This method disconnect anyone the ApmService SDK. It should be called after disconnecting anyone from your system.
await ApmService.user.logout():
This method return the current user connected (if someone is connected) or an empty user object if no one is currently connected.
ApmService.user.getUser();
This method initialize the Statistics Service. This is not necessary ! In fact, ApmService initialize automatically this service if it find a correct value for the key "trackingId" inside the ApmConfig
ApmService.stat.init(options: StatInitOptions)
interface StatInitOptions {
trackingId: string;
appId: string;
partnerLabel: string;
version: string;
language: string;
screenResolution: string;
viewportSize: string;
}
This method sends a custom event to the current Google Analytics DB configured. ApmService has already a defined tracking plan that is automatically tagged.
ApmService.stat.track(
bundle: Bundle,
params?: { [s: string]: string }
)
interface StatBundle {
category: string,
action: string,
label: string,
value?: string
};
Here are all the methods available to communicate directly with our API
This method sends back a static page that has been configured inside our back-office
await ApmService.partner.getPage(pageId: number);
This method is used to attribute a gift to a user. This will generate an "attributionId" linking user and gift inside our database. A user need to be connected
await ApmService.partner.burnGift(giftId: number):
This method will unsubscribe a user to the loyalty program. The user can leave a message explaining his unsubscription in the params
await ApmService.partner.unsubscribe(comment?: string);
This method will refresh ApmService state and get the last settings defined in the back-office. This method should be called if a user is connected.
It can take a RXJS
Subject<void>
as param, that will be called after the refresh is completedawait ApmService.partner.ics(sub?: Subject<void>);
This method will refresh ApmService state and get the last settings defined in the back-office. This method should be called if no user is connected
It can take a RXJS
Subject<void>
as param, that will be called after the refresh is completedawait ApmService.partner.getProg(sub?: Subject<void>);
This method is used to get all "Mentions/CGU" type pages
await ApmService.partner.getMentions();
This method initialize the Generosity Service. This is not necessary ! In fact, ApmService initialize automatically this service
ApmService.generosity.init();
This method is used to add into the generosity buffer a new interaction.
ApmService.generosity.add(tagId: string, properties?: { [s: string]: string });
This method is used to force the Generosity Service to unstack and handle all the interactions inside the queue.
This is not necessary to implement. In fact, each time the Generosity Service is updated, it will start to unstack automatically
ApmService.generosity.unstack();
UserProperties are sent to the server each time ics or getProg are triggerd
This method is used to add new user properties
ApmService.userProperties.add(properties: {[s: string]: string});
This method is used to removed user properties
ApmService.userProperties.remove(properties: string[]);
This method return the user properties of the current user (or undefined if no one is connected)
ApmService.userProperties.get();
This method is used to manually update ApmService User State. For example, if you need to change the userBalance without asking the ApmService to make a refresh call, this method is fit for it
ApmService.state.updateUserState(value: UpdateUserStateContent);
interface UpdateUserStateContent {
userBalance?: KeyValue<"clear" | "update", number>;
};
interface KeyValue<T, U> {
key: T;
value?: U;
}
This method is used to manually add inside the Notification Service stack, a new notif event. You need to configure notification inside the back-office.
ApmService.notif.add(event: NotifEventType, data?: any);
type NotifEventType =
"gift" |
"user_connect" |
"level" |
"earn" |
"trophy" |
"init" |
"generosity_win" |
"generosity_suggested" |
"win_points" |
"gift_accessible" |
"challenge_win" |
"trophy_win" |
"level_win" |
"challenge";
This method is used to clear all data stored by the SDKs inside LocalStorage or SessionStorage
If no storage is given, it will clear both Local and Session !
ApmService.storage.clear(storage?: "Local" | "Session");
This method is used to update the log level of the SDKs. It is useful for debug purposes, and can be managed also inside the back-office
ApmService.log.updateLevel(level: "disabled" | "debug" | "warn" | "error");
This method is used to open a deeplink. ApmView should be included in your app if you want this method to work
ApmService.navigate.to(deeplink: string);
Last modified 1yr ago