@leisuresaas/react-native 0.6.8-dev.1 → 0.6.8-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/analytics.ts +13 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leisuresaas/react-native",
|
|
3
|
-
"version": "0.6.8-dev.
|
|
3
|
+
"version": "0.6.8-dev.2",
|
|
4
4
|
"description": "React Native SDK for LeisureSaas: OAuth, Public Ads/App Config, Drive User Plane (publishable keys). Frontend-only — no Integration Key.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/src/analytics.ts
CHANGED
|
@@ -114,6 +114,19 @@ export function track(name: string, props?: AnalyticsProps): void {
|
|
|
114
114
|
enqueue({ ...baseEvent(name), props: stringProps(props) });
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Call right after sign-in: sends an `identify` event with the user's token now, so this device's
|
|
119
|
+
* earlier anonymous events count as the user's (the first user seen on a device keeps it).
|
|
120
|
+
* Needs `getAccessToken` in the options; the user comes from the token.
|
|
121
|
+
*/
|
|
122
|
+
export function identify(): Promise<void> {
|
|
123
|
+
if (!collecting() || !opts) {
|
|
124
|
+
return Promise.resolve();
|
|
125
|
+
}
|
|
126
|
+
enqueue(baseEvent("identify"));
|
|
127
|
+
return flushAnalytics();
|
|
128
|
+
}
|
|
129
|
+
|
|
117
130
|
/** Opts this device in or out. Opting out drops queued events; the choice is kept in secure storage. */
|
|
118
131
|
export async function setAnalyticsEnabled(enabled: boolean): Promise<void> {
|
|
119
132
|
optedOut = !enabled;
|