@zoho_apptics/apptics-js-sdk 2.0.0-beta.2 → 2.0.0
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/CHANGELOG.md +47 -0
- package/README.md +229 -174
- package/dist/apptics-pn-sw.js +3 -0
- package/dist/apptics-pn-sw.js.map +1 -0
- package/dist/apptics.esm.min.js +2 -2
- package/dist/apptics.esm.min.js.map +1 -1
- package/dist/apptics.min.js +2 -2
- package/dist/apptics.min.js.map +1 -1
- package/dist/chunks/batch-Axq9sTzR.min.js +3 -0
- package/dist/chunks/batch-Axq9sTzR.min.js.map +1 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js +3 -0
- package/dist/chunks/lifecycle-Cvg78jN_.min.js.map +1 -0
- package/dist/chunks/send-DBpesydB.min.js +3 -0
- package/dist/chunks/send-DBpesydB.min.js.map +1 -0
- package/dist/chunks/transport-B21X39p4.min.js +3 -0
- package/dist/chunks/transport-B21X39p4.min.js.map +1 -0
- package/dist/cjs/core/attempts.js +1 -1
- package/dist/cjs/core/batch.js +4 -3
- package/dist/cjs/core/consent.d.ts +9 -6
- package/dist/cjs/core/consent.js +63 -10
- package/dist/cjs/core/console-call.d.ts +23 -0
- package/dist/cjs/core/console-call.js +63 -0
- package/dist/cjs/core/constants.d.ts +44 -0
- package/dist/cjs/core/constants.js +55 -1
- package/dist/cjs/core/db.js +31 -7
- package/dist/cjs/core/debug.d.ts +6 -4
- package/dist/cjs/core/debug.js +36 -12
- package/dist/cjs/core/env.js +1 -1
- package/dist/cjs/core/framework-id.d.ts +1 -1
- package/dist/cjs/core/framework-id.js +3 -3
- package/dist/cjs/core/guard.js +19 -4
- package/dist/cjs/core/hooks.d.ts +25 -1
- package/dist/cjs/core/hooks.js +11 -1
- package/dist/cjs/core/locks.js +1 -1
- package/dist/cjs/core/logger.js +1 -1
- package/dist/cjs/core/shield.d.ts +31 -0
- package/dist/cjs/core/shield.js +129 -0
- package/dist/cjs/core/state.d.ts +5 -1
- package/dist/cjs/core/state.js +3 -1
- package/dist/cjs/core/storage.d.ts +7 -0
- package/dist/cjs/core/storage.js +28 -6
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.d.ts +15 -4
- package/dist/cjs/core/transport.js +63 -13
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +6 -5
- package/dist/cjs/device/appversion.js +1 -1
- package/dist/cjs/device/index.js +63 -15
- package/dist/cjs/engagement/api-rules.js +1 -1
- package/dist/cjs/engagement/auto-api.js +4 -3
- package/dist/cjs/engagement/auto-screen.js +10 -6
- package/dist/cjs/engagement/defined-events.d.ts +2 -3
- package/dist/cjs/engagement/defined-events.js +10 -16
- package/dist/cjs/engagement/send.js +1 -1
- package/dist/cjs/engagement/session.js +77 -37
- package/dist/cjs/engagement/track.js +9 -6
- package/dist/cjs/errors/send.js +1 -1
- package/dist/cjs/errors/track.js +3 -2
- package/dist/cjs/feedback/controls.d.ts +30 -4
- package/dist/cjs/feedback/controls.js +237 -51
- package/dist/cjs/feedback/i18n/index.d.ts +31 -0
- package/dist/cjs/feedback/i18n/index.js +187 -0
- package/dist/cjs/feedback/i18n/strings.d.ts +9 -0
- package/dist/cjs/feedback/i18n/strings.js +8 -0
- package/dist/cjs/feedback/index.js +1 -1
- package/dist/cjs/feedback/logs.js +5 -4
- package/dist/cjs/feedback/quartz.js +5 -2
- package/dist/cjs/feedback/send.d.ts +4 -1
- package/dist/cjs/feedback/send.js +56 -15
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +4 -2
- package/dist/cjs/feedback/template.js +67 -46
- package/dist/cjs/feedback/ui.d.ts +40 -4
- package/dist/cjs/feedback/ui.js +208 -89
- package/dist/cjs/heatmap/send.js +1 -1
- package/dist/cjs/heatmap/track.js +13 -9
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/lifecycle.js +119 -72
- package/dist/cjs/pushnotification/display.d.ts +65 -0
- package/dist/cjs/pushnotification/display.js +112 -0
- package/dist/cjs/pushnotification/index.d.ts +20 -0
- package/dist/cjs/pushnotification/index.js +96 -0
- package/dist/cjs/pushnotification/kept-opens.d.ts +23 -0
- package/dist/cjs/pushnotification/kept-opens.js +64 -0
- package/dist/cjs/pushnotification/notify.d.ts +45 -0
- package/dist/cjs/pushnotification/notify.js +476 -0
- package/dist/cjs/pushnotification/payload.d.ts +65 -0
- package/dist/cjs/pushnotification/payload.js +279 -0
- package/dist/cjs/pushnotification/session.d.ts +46 -0
- package/dist/cjs/pushnotification/session.js +413 -0
- package/dist/cjs/pushnotification/stats.d.ts +45 -0
- package/dist/cjs/pushnotification/stats.js +244 -0
- package/dist/cjs/pushnotification/wms.d.ts +30 -0
- package/dist/cjs/pushnotification/wms.js +374 -0
- package/dist/cjs/remoteconfig/country.js +1 -1
- package/dist/cjs/remoteconfig/custom.js +4 -3
- package/dist/cjs/remoteconfig/evaluate.js +1 -1
- package/dist/cjs/remoteconfig/fetch.js +27 -8
- package/dist/cjs/remoteconfig/index.d.ts +1 -6
- package/dist/cjs/remoteconfig/index.js +4 -28
- package/dist/cjs/remoteconfig/store.js +1 -1
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/remotelog/callsite.js +1 -1
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +1 -1
- package/dist/cjs/remotelog/send.js +5 -4
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.js +11 -5
- package/dist/cjs/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/cjs/sw/timers.d.ts +44 -0
- package/dist/cjs/types.d.ts +31 -15
- package/dist/cjs/user/index.d.ts +7 -0
- package/dist/cjs/user/index.js +25 -7
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +4 -3
- package/dist/esm/core/consent.d.ts +9 -6
- package/dist/esm/core/consent.js +67 -16
- package/dist/esm/core/console-call.d.ts +23 -0
- package/dist/esm/core/console-call.js +60 -0
- package/dist/esm/core/constants.d.ts +44 -0
- package/dist/esm/core/constants.js +52 -2
- package/dist/esm/core/db.js +31 -7
- package/dist/esm/core/debug.d.ts +6 -4
- package/dist/esm/core/debug.js +37 -13
- package/dist/esm/core/env.js +1 -1
- package/dist/esm/core/framework-id.d.ts +1 -1
- package/dist/esm/core/framework-id.js +3 -3
- package/dist/esm/core/guard.js +19 -4
- package/dist/esm/core/hooks.d.ts +25 -1
- package/dist/esm/core/hooks.js +11 -1
- package/dist/esm/core/locks.js +1 -1
- package/dist/esm/core/logger.js +1 -1
- package/dist/esm/core/shield.d.ts +31 -0
- package/dist/esm/core/shield.js +119 -0
- package/dist/esm/core/state.d.ts +5 -1
- package/dist/esm/core/state.js +3 -1
- package/dist/esm/core/storage.d.ts +7 -0
- package/dist/esm/core/storage.js +28 -8
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.d.ts +15 -4
- package/dist/esm/core/transport.js +64 -16
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +6 -5
- package/dist/esm/device/appversion.js +1 -1
- package/dist/esm/device/index.js +67 -19
- package/dist/esm/engagement/api-rules.js +1 -1
- package/dist/esm/engagement/auto-api.js +4 -3
- package/dist/esm/engagement/auto-screen.js +10 -6
- package/dist/esm/engagement/defined-events.d.ts +2 -3
- package/dist/esm/engagement/defined-events.js +10 -16
- package/dist/esm/engagement/send.js +1 -1
- package/dist/esm/engagement/session.js +77 -37
- package/dist/esm/engagement/track.js +9 -6
- package/dist/esm/errors/send.js +1 -1
- package/dist/esm/errors/track.js +3 -2
- package/dist/esm/feedback/controls.d.ts +30 -4
- package/dist/esm/feedback/controls.js +234 -52
- package/dist/esm/feedback/i18n/index.d.ts +31 -0
- package/dist/esm/feedback/i18n/index.js +178 -0
- package/dist/esm/feedback/i18n/strings.d.ts +9 -0
- package/dist/esm/feedback/i18n/strings.js +4 -0
- package/dist/esm/feedback/index.js +1 -1
- package/dist/esm/feedback/logs.js +5 -4
- package/dist/esm/feedback/quartz.js +5 -2
- package/dist/esm/feedback/send.d.ts +4 -1
- package/dist/esm/feedback/send.js +56 -16
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +4 -2
- package/dist/esm/feedback/template.js +67 -46
- package/dist/esm/feedback/ui.d.ts +40 -4
- package/dist/esm/feedback/ui.js +210 -91
- package/dist/esm/heatmap/send.js +1 -1
- package/dist/esm/heatmap/track.js +13 -9
- package/dist/esm/index.js +2 -2
- package/dist/esm/lifecycle.js +120 -73
- package/dist/esm/pushnotification/display.d.ts +65 -0
- package/dist/esm/pushnotification/display.js +95 -0
- package/dist/esm/pushnotification/index.d.ts +20 -0
- package/dist/esm/pushnotification/index.js +91 -0
- package/dist/esm/pushnotification/kept-opens.d.ts +23 -0
- package/dist/esm/pushnotification/kept-opens.js +62 -0
- package/dist/esm/pushnotification/notify.d.ts +45 -0
- package/dist/esm/pushnotification/notify.js +469 -0
- package/dist/esm/pushnotification/payload.d.ts +65 -0
- package/dist/esm/pushnotification/payload.js +272 -0
- package/dist/esm/pushnotification/session.d.ts +46 -0
- package/dist/esm/pushnotification/session.js +402 -0
- package/dist/esm/pushnotification/stats.d.ts +45 -0
- package/dist/esm/pushnotification/stats.js +238 -0
- package/dist/esm/pushnotification/wms.d.ts +30 -0
- package/dist/esm/pushnotification/wms.js +368 -0
- package/dist/esm/remoteconfig/country.js +1 -1
- package/dist/esm/remoteconfig/custom.js +4 -3
- package/dist/esm/remoteconfig/evaluate.js +1 -1
- package/dist/esm/remoteconfig/fetch.js +27 -8
- package/dist/esm/remoteconfig/index.d.ts +1 -6
- package/dist/esm/remoteconfig/index.js +4 -28
- package/dist/esm/remoteconfig/store.js +1 -1
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/remotelog/callsite.js +1 -1
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +1 -1
- package/dist/esm/remotelog/send.js +5 -4
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.js +11 -5
- package/dist/esm/sw/apptics-pn-sw.d.ts +83 -0
- package/dist/esm/sw/timers.d.ts +44 -0
- package/dist/esm/types.d.ts +31 -15
- package/dist/esm/user/index.d.ts +7 -0
- package/dist/esm/user/index.js +26 -9
- package/dist/feedback.esm.min.js +2 -2
- package/dist/feedback.esm.min.js.map +1 -1
- package/dist/pushnotification.esm.min.js +3 -0
- package/dist/pushnotification.esm.min.js.map +1 -0
- package/dist/remoteconfig.esm.min.js +2 -2
- package/dist/remoteconfig.esm.min.js.map +1 -1
- package/dist/remotelogger.esm.min.js +2 -2
- package/dist/remotelogger.esm.min.js.map +1 -1
- package/package.json +15 -2
- package/dist/chunks/lifecycle-C6m1W7jo.min.js +0 -3
- package/dist/chunks/lifecycle-C6m1W7jo.min.js.map +0 -1
- package/dist/chunks/send-CgUO82ne.min.js +0 -3
- package/dist/chunks/send-CgUO82ne.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Apptics JavaScript SDK
|
|
2
2
|
|
|
3
|
-
JavaScript/TypeScript library for [Zoho Apptics](https://www.zoho.com/apptics/) on the web: usage analytics, error tracking, API tracking, remote config, remote logging, in-app feedback and
|
|
3
|
+
JavaScript/TypeScript library for [Zoho Apptics](https://www.zoho.com/apptics/) on the web: usage analytics, error tracking, API tracking, remote config, remote logging, in-app feedback, heatmaps and push notifications.
|
|
4
4
|
|
|
5
5
|
### Prerequisites
|
|
6
6
|
|
|
@@ -12,10 +12,10 @@ The SDK is plain TypeScript with no framework dependency. It works with any bund
|
|
|
12
12
|
## Install Apptics
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm install @zoho_apptics/apptics-js-sdk
|
|
15
|
+
npm install @zoho_apptics/apptics-js-sdk
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Upgrading from 1.0.2? `Apptics.init()` takes different config now; see [Migrating from 1.0.2 to 2.0.0](#migrating-from-102-to-200).
|
|
19
19
|
|
|
20
20
|
## Initialize Apptics
|
|
21
21
|
|
|
@@ -52,7 +52,7 @@ Load the browser build and call `Apptics.init()` after it. One `<script>` tag is
|
|
|
52
52
|
form's styles are inside the build, so there is no stylesheet to add.
|
|
53
53
|
|
|
54
54
|
```html
|
|
55
|
-
<script src="https://static.zohocdn.com/apptics-js-sdk/2.0.0
|
|
55
|
+
<script src="https://static.zohocdn.com/apptics-js-sdk/2.0.0/apptics.min.js"></script>
|
|
56
56
|
<script>
|
|
57
57
|
Apptics.init({
|
|
58
58
|
base_url: 'YOUR_BASE_URL',
|
|
@@ -65,13 +65,13 @@ form's styles are inside the build, so there is no stylesheet to add.
|
|
|
65
65
|
</script>
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
The build defines the same objects as globals (`Apptics`, `AppticsEvent`, `AppticsScreen`, `AppticsApi`, `AppticsError`, `AppticsUser`, `AppticsSettings`, `AppticsFeedback`, `AppticsLogger`, `AppticsRemoteConfig`, `AppticsHeatmap`), so a page's code reads as it would after an import. Every module is included (feedback, heatmaps, remote config, the remote logger), and everything is also on `window.apptics`. Define `window.appticsReady = () => { … }` to run code once it's ready.
|
|
68
|
+
The build defines the same objects as globals (`Apptics`, `AppticsEvent`, `AppticsScreen`, `AppticsApi`, `AppticsError`, `AppticsUser`, `AppticsSettings`, `AppticsFeedback`, `AppticsLogger`, `AppticsRemoteConfig`, `AppticsPushNotification`, `AppticsHeatmap`), so a page's code reads as it would after an import. Every module is included (feedback, heatmaps, remote config, the remote logger, push notification), and everything is also on `window.apptics`. Define `window.appticsReady = () => { … }` to run code once it's ready.
|
|
69
69
|
|
|
70
70
|
`Apptics.init()` runs exactly once; a second call logs a warning and returns `false`. Calls that track
|
|
71
71
|
or send something are ignored until `Apptics.init()` has run, and the first such call logs a console
|
|
72
72
|
warning saying so.
|
|
73
73
|
|
|
74
|
-
Each release has its own folder on the CDN, `https://static.zohocdn.com/apptics-js-sdk/{version}/`, so a page keeps loading the version it names until you change it. See [Loading from a CDN](#loading-from-a-cdn) for module builds
|
|
74
|
+
Each release has its own folder on the CDN, `https://static.zohocdn.com/apptics-js-sdk/{version}/`, so a page keeps loading the version it names until you change it. See [Loading from a CDN](#loading-from-a-cdn) for the module builds.
|
|
75
75
|
|
|
76
76
|
### The API at a glance
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ Each feature's calls are on one object:
|
|
|
79
79
|
|
|
80
80
|
| Object | Calls | Entry point |
|
|
81
81
|
|---|---|---|
|
|
82
|
-
| `Apptics` | `init(config)`, `ready()`, `flush()`, `reset()`, `enableDebug()`, `disableDebug()` | main |
|
|
82
|
+
| `Apptics` | `init(config)`, `ready()`, `flush()`, `reset()`, `enableDebug()`, `disableDebug()` (both typed in the browser console only) | main |
|
|
83
83
|
| `AppticsEvent` | `addEvent(eventName, groupName, properties?)`, `addEvent(DefinedEvents.X, properties?)`, `setClickTracking(enabled?)`, `DefinedEvents` | main |
|
|
84
84
|
| `AppticsScreen` | `inScreen(screenName, properties?)` → id, `outScreen(id)`, `setScreenTracking(enabled?)` | main |
|
|
85
85
|
| `AppticsError` | `trackError(error, properties?)`, `setErrorTracking(enabled?)` | main |
|
|
@@ -89,29 +89,20 @@ Each feature's calls are on one object:
|
|
|
89
89
|
| `AppticsHeatmap` | `setHeatmapTracking(enabled?)` | main |
|
|
90
90
|
| `AppticsLogger` | `verbose(message, properties?)`, `debug(message, properties?)`, `info(message, properties?)`, `warn(message, properties?)`, `error(message, properties?)` | `/remote-logger` |
|
|
91
91
|
| `AppticsFeedback` | `feedbackFormOpen(options?)`, `feedbackFormClose()`, `sendFeedback(options?)`, `addFeedbackLog(message)`, `addDiagnosticsInfo(heading, key, value)`, `setFeedbackTheme(theme)`, the `AP_FEEDBACK_TYPE` constants | `/feedback` |
|
|
92
|
-
| `AppticsRemoteConfig` | `
|
|
92
|
+
| `AppticsRemoteConfig` | `fetchValues(names?, callback?, coldFetch?)`, `setCustomConditionValue(conditionname, value)` | `/remote-config` |
|
|
93
|
+
| `AppticsPushNotification` | `setEnabled(enabled)`, `isEnabled()`, `requestPermission()` | `/push-notification` |
|
|
93
94
|
|
|
94
95
|
The `set…Tracking(enabled?)` calls switch each automatic tracker on or off while the page runs
|
|
95
96
|
(see [Turning automatic tracking on and off](#turning-automatic-tracking-on-and-off)).
|
|
96
97
|
|
|
97
98
|
### Frameworks
|
|
98
99
|
|
|
99
|
-
React,
|
|
100
|
-
|
|
101
|
-
| Framework | Start | Screen on navigation, with `track_screen: false` |
|
|
102
|
-
|---|---|---|
|
|
103
|
-
| React, Remix, Gatsby | `useEffect(() => { Apptics.init(config); }, [])` | `useLocation()` in an effect |
|
|
104
|
-
| Vue 3 | a plugin: `app.use(apptics, { router })` | `router.afterEach(to => AppticsScreen.inScreen(to.path))` |
|
|
105
|
-
| Angular | an injectable service | `router.events` filtered to `NavigationEnd` |
|
|
106
|
-
| Svelte, SvelteKit | `src/hooks.client.ts`, or `onMount` | `afterNavigate` |
|
|
107
|
-
| Ember | an instance initializer | `router.on('routeDidChange', …)` |
|
|
108
|
-
| Next.js | `'use client'` component in the layout | `usePathname()` in an effect |
|
|
109
|
-
| Nuxt 3 | `plugins/apptics.client.ts` | `useRouter().afterEach(…)` |
|
|
110
|
-
| Plain JS, jQuery | the `<script>` tag itself | `AppticsScreen.inScreen()` where you change view |
|
|
100
|
+
Works the same with React, Remix, Gatsby, Next.js, Vue, Nuxt, Angular, Svelte, SvelteKit, Ember,
|
|
101
|
+
Solid, jQuery and plain JavaScript: call `Apptics.init()` once in the browser, and screens are tracked from the URL.
|
|
111
102
|
|
|
112
103
|
## Error Tracking
|
|
113
104
|
|
|
114
|
-
Uncaught errors
|
|
105
|
+
Uncaught errors, unhandled promise rejections and scripts, images or stylesheets that fail to load are tracked automatically, as JS errors in the console. Errors from the SDK itself are not recorded as your app's errors.
|
|
115
106
|
|
|
116
107
|
Report an error your code caught:
|
|
117
108
|
|
|
@@ -127,23 +118,34 @@ try {
|
|
|
127
118
|
|
|
128
119
|
`AppticsError.trackError` also accepts `error` and `unhandledrejection` events as they are, and properties as a second argument.
|
|
129
120
|
|
|
130
|
-
To record only the errors you report yourself, turn the automatic tracking off
|
|
131
|
-
|
|
121
|
+
To record only the errors you report yourself, turn the automatic tracking off.
|
|
122
|
+
`AppticsError.trackError()` records either way.
|
|
123
|
+
|
|
124
|
+
**In `Apptics.init()`:**
|
|
132
125
|
|
|
133
126
|
```ts
|
|
134
|
-
Apptics.init({ ...config, track_error: false });
|
|
135
|
-
AppticsError.setErrorTracking(false); // or while the page runs; true turns it back on
|
|
127
|
+
Apptics.init({ ...config, track_error: false });
|
|
136
128
|
```
|
|
137
129
|
|
|
138
|
-
|
|
130
|
+
**While the page runs:**
|
|
139
131
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
132
|
+
```ts
|
|
133
|
+
AppticsError.setErrorTracking(false); // only trackError() calls are recorded
|
|
134
|
+
AppticsError.setErrorTracking(true); // back on
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Scripts from other domains
|
|
138
|
+
|
|
139
|
+
For a script loaded from another domain (a CDN, say), the browser hides the details of its errors
|
|
140
|
+
and the SDK records only `Script error.`. To get the message and stack, load the script with the
|
|
141
|
+
`crossorigin` attribute, from a server that allows it (its responses carry
|
|
142
|
+
`Access-Control-Allow-Origin`):
|
|
143
|
+
|
|
144
|
+
```html
|
|
145
|
+
<script src="https://example.com/script.js" crossorigin="anonymous"></script>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The Apptics CDN allows it, so the SDK's own `<script>` tag can carry `crossorigin="anonymous"` too.
|
|
147
149
|
|
|
148
150
|
## Event Tracking
|
|
149
151
|
|
|
@@ -189,13 +191,13 @@ AppticsEvent.addEvent(DefinedEvents.AP_USER_LOGIN);
|
|
|
189
191
|
AppticsEvent.addEvent(DefinedEvents.AP_SEARCH, { results: 12 });
|
|
190
192
|
```
|
|
191
193
|
|
|
192
|
-
| Group | Events |
|
|
193
|
-
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `AP_APPLICATION` | `
|
|
197
|
-
| `AP_OTHERS` | `
|
|
198
|
-
| `
|
|
194
|
+
| Group | Events | When to log them |
|
|
195
|
+
|---|---|---|
|
|
196
|
+
| `AP_USER_LIFE_CYCLE` | `AP_USER_SIGNUP`, `AP_USER_LOGIN`, `AP_USER_LOGOUT` | Sign-up, sign-in, sign-out |
|
|
197
|
+
| `AP_PAGE_LIFE_CYCLE` | `AP_PAGE_LOAD`, `AP_PAGE_VISIBLE`, `AP_PAGE_HIDDEN`, `AP_PAGE_UNLOAD`, `AP_PAGE_PRINT` | The page loads, its tab is shown or hidden, it is left, or printed |
|
|
198
|
+
| `AP_APPLICATION` | `AP_PWA_INSTALL`, `AP_PWA_LAUNCH`, `AP_PURCHASE`, `AP_SEARCH`, `AP_SHARE`, `AP_FILE_DOWNLOAD`, `AP_COPY`, `AP_NOTIFICATION_RECEIVE`, `AP_NOTIFICATION_OPEN`, `AP_NOTIFICATION_DISMISS`, `AP_NOTIFICATION_PERMISSION_GRANTED`, `AP_NOTIFICATION_PERMISSION_DENIED` | The installed web app, purchases, search, sharing, downloads, copying, and notifications |
|
|
199
|
+
| `AP_OTHERS` | `AP_NETWORK_ONLINE`, `AP_NETWORK_OFFLINE`, `AP_SWITCH_THEME_LIGHT`, `AP_SWITCH_THEME_DARK`, `AP_SWITCH_THEME_CUSTOM`, `AP_SWITCH_LANGUAGE`, `AP_FULLSCREEN_ENTER`, `AP_FULLSCREEN_EXIT` | Connection, theme, language and full-screen changes |
|
|
200
|
+
| `AP_BROWSER` | `AP_BROWSER_UPDATE`, `AP_BROWSER_UNSUPPORTED` | The visitor's browser was updated, or isn't supported by your app |
|
|
199
201
|
|
|
200
202
|
With a `<script>` tag it is `AppticsEvent.DefinedEvents` too.
|
|
201
203
|
|
|
@@ -217,14 +219,20 @@ and TypeScript accept as they are.
|
|
|
217
219
|
|
|
218
220
|
#### Turning click tracking off
|
|
219
221
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
Click tracking from markup is on by default. `AppticsEvent.addEvent()` records either way.
|
|
223
|
+
|
|
224
|
+
**In `Apptics.init()`:**
|
|
222
225
|
|
|
223
226
|
```ts
|
|
224
|
-
Apptics.init({ ...config, track_click: false });
|
|
225
|
-
AppticsEvent.setClickTracking(true); // or switch it later
|
|
227
|
+
Apptics.init({ ...config, track_click: false });
|
|
226
228
|
```
|
|
227
229
|
|
|
230
|
+
**While the page runs:**
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
AppticsEvent.setClickTracking(false); // tagged clicks are not recorded
|
|
234
|
+
AppticsEvent.setClickTracking(true); // back on
|
|
235
|
+
```
|
|
228
236
|
|
|
229
237
|
## Screen Tracking
|
|
230
238
|
|
|
@@ -259,8 +267,7 @@ on a page records a view of the page, named the same way from its path, and a ne
|
|
|
259
267
|
path changes.
|
|
260
268
|
|
|
261
269
|
An `AppticsScreen.inScreen()` call made during a navigation, from a router hook for example,
|
|
262
|
-
replaces the automatic view of it, so the navigation counts once, under your name.
|
|
263
|
-
300 ms for such a call before it is recorded; a call after that is a screen view of its own.
|
|
270
|
+
replaces the automatic view of it, so the navigation counts once, under your name.
|
|
264
271
|
|
|
265
272
|
### Automatic screen tracking
|
|
266
273
|
|
|
@@ -304,16 +311,16 @@ Apptics.init({
|
|
|
304
311
|
An entry that can't be used (no `name`, a regex that does not compile) is left out, and
|
|
305
312
|
`Apptics.init()` says which in the console.
|
|
306
313
|
|
|
307
|
-
**An app that names its screens from its router** keeps doing so with `AppticsScreen.inScreen()
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
314
|
+
**An app that names its screens from its router** keeps doing so with `AppticsScreen.inScreen()`. To track
|
|
315
|
+
only the screens you name yourself, turn automatic tracking off.
|
|
316
|
+
|
|
317
|
+
**In `Apptics.init()`:**
|
|
311
318
|
|
|
312
319
|
```ts
|
|
313
320
|
Apptics.init({ ...config, track_screen: false });
|
|
314
321
|
```
|
|
315
322
|
|
|
316
|
-
|
|
323
|
+
**While the page runs:**
|
|
317
324
|
|
|
318
325
|
```ts
|
|
319
326
|
AppticsScreen.setScreenTracking(false); // only inScreen() calls are recorded
|
|
@@ -332,7 +339,7 @@ import { AppticsUser } from '@zoho_apptics/apptics-js-sdk';
|
|
|
332
339
|
AppticsUser.setUser('user-id', 'customer-group-id'); // the group is optional
|
|
333
340
|
```
|
|
334
341
|
|
|
335
|
-
`AppticsUser.setUser`
|
|
342
|
+
`AppticsUser.setUser` registers the user; it does not change the tracking status. The user goes on the data only with `USAGE_TRACKING_WITH_PII`, so an app that wants its data attributed to the user sets that status itself (see [Tracking settings](#tracking-settings)). `AppticsUser.getUser()` returns the active user.
|
|
336
343
|
|
|
337
344
|
### Track User with properties
|
|
338
345
|
|
|
@@ -362,13 +369,28 @@ import { AppticsSettings } from '@zoho_apptics/apptics-js-sdk';
|
|
|
362
369
|
AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII);
|
|
363
370
|
```
|
|
364
371
|
|
|
365
|
-
| `AppticsSettings.AP_TRACKING_STATUS.` |
|
|
366
|
-
|
|
367
|
-
| `USAGE_TRACKING_WITH_PII` |
|
|
368
|
-
| `USAGE_TRACKING_WITHOUT_PII` |
|
|
369
|
-
| `
|
|
372
|
+
| `AppticsSettings.AP_TRACKING_STATUS.` | Meaning |
|
|
373
|
+
|---|---|
|
|
374
|
+
| `USAGE_TRACKING_WITH_PII` | Track, with the registered user on the data |
|
|
375
|
+
| `USAGE_TRACKING_WITHOUT_PII` | Track by device, with no user on the data (the default) |
|
|
376
|
+
| `ANONYMOUS` | Track anonymously: by an anonymous id, never the device id, and with no user on the data |
|
|
377
|
+
| `NO_TRACKING` | Track nothing |
|
|
378
|
+
|
|
379
|
+
Each value is its own name: `AP_TRACKING_STATUS.ANONYMOUS` is `'ANONYMOUS'`. `AppticsSettings.getTrackingStatus()` returns the current one the same way:
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
AppticsSettings.getTrackingStatus() === AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS; // 'ANONYMOUS'
|
|
383
|
+
```
|
|
370
384
|
|
|
371
|
-
|
|
385
|
+
An unknown value is ignored, with a console warning.
|
|
386
|
+
|
|
387
|
+
The status is kept in the browser across visits, and only these calls change it: `AppticsUser.setUser` does not.
|
|
388
|
+
|
|
389
|
+
To track a visitor anonymously:
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.ANONYMOUS);
|
|
393
|
+
```
|
|
372
394
|
|
|
373
395
|
### Privacy
|
|
374
396
|
|
|
@@ -378,14 +400,23 @@ AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.USAGE_TRACK
|
|
|
378
400
|
|
|
379
401
|
## API Tracking
|
|
380
402
|
|
|
381
|
-
Record the API calls your app makes, for the console's API page. Either let the SDK
|
|
382
|
-
`fetch` and `XMLHttpRequest
|
|
403
|
+
Record the API calls your app makes, for the console's API page. Either let the SDK record
|
|
404
|
+
`fetch` and `XMLHttpRequest` calls, off by default:
|
|
405
|
+
|
|
406
|
+
**In `Apptics.init()`:**
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
Apptics.init({ ...config, track_api: true });
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**While the page runs:**
|
|
383
413
|
|
|
384
414
|
```ts
|
|
385
|
-
|
|
415
|
+
AppticsApi.setApiTracking(true); // record every fetch and XHR call
|
|
416
|
+
AppticsApi.setApiTracking(false); // stop
|
|
386
417
|
```
|
|
387
418
|
|
|
388
|
-
|
|
419
|
+
Which hosts and endpoints are recorded is set with
|
|
389
420
|
[`AppticsApi.configure`](#configuring-api-tracking).
|
|
390
421
|
|
|
391
422
|
or record calls yourself with `AppticsApi.startTrackApi` / `endTrackApi`. The
|
|
@@ -462,11 +493,11 @@ Read parameters set in the console. Its own entry point, so apps that don't use
|
|
|
462
493
|
```ts
|
|
463
494
|
import { AppticsRemoteConfig } from '@zoho_apptics/apptics-js-sdk/remote-config';
|
|
464
495
|
|
|
465
|
-
const
|
|
496
|
+
const { bannerText } = await AppticsRemoteConfig.fetchValues(['bannerText']); // null if there is none
|
|
466
497
|
const some = await AppticsRemoteConfig.fetchValues(['primaryColor', 'maxItems']);
|
|
467
498
|
// → { primaryColor: '#0b6e4f', maxItems: '10' }
|
|
468
499
|
const all = await AppticsRemoteConfig.fetchValues(); // every parameter
|
|
469
|
-
const fresh = await AppticsRemoteConfig.
|
|
500
|
+
const fresh = await AppticsRemoteConfig.fetchValues(['bannerText'], true); // coldFetch: asks the server now
|
|
470
501
|
|
|
471
502
|
// for a custom condition: its name, then this device's values, comma separated
|
|
472
503
|
AppticsRemoteConfig.setCustomConditionValue('is_custom', 'custom_color');
|
|
@@ -488,13 +519,13 @@ so values are this session's without a call of yours.
|
|
|
488
519
|
**Fetching.** The first fetch of each page load asks for the whole rule set, and its answer
|
|
489
520
|
replaces what was stored. After that the SDK keeps the values up to date by itself: every 3
|
|
490
521
|
minutes, and when the tab comes back after 15 seconds or more away, it asks only for what changed
|
|
491
|
-
since its last fetch and merges that into the stored set. `
|
|
492
|
-
from those values, so reading a value on every render costs no requests.
|
|
522
|
+
since its last fetch and merges that into the stored set. `fetchValues` answers
|
|
523
|
+
from those values, so reading a value on every render costs no requests. It also takes a
|
|
493
524
|
callback, and returns a Promise either way. To ask the server now instead, see
|
|
494
525
|
[Cold fetch](#cold-fetch).
|
|
495
526
|
|
|
496
|
-
**When a fetch fails** (offline, or a server error),
|
|
497
|
-
with none fetched yet, `null` (and `fetchValues()` answers with no parameters).
|
|
527
|
+
**When a fetch fails** (offline, or a server error), it answers with the values fetched before;
|
|
528
|
+
with none fetched yet, `null` for each name (and `fetchValues()` answers with no parameters).
|
|
498
529
|
|
|
499
530
|
**Custom conditions.** `setCustomConditionValue(conditionname, value)` says what this device is
|
|
500
531
|
for the custom condition with that name in the console, with several values comma separated
|
|
@@ -508,32 +539,30 @@ Conditions on the user, such as the customer group, are re-applied on their own
|
|
|
508
539
|
|
|
509
540
|
| Call | Notes |
|
|
510
541
|
|---|---|
|
|
511
|
-
| `
|
|
512
|
-
| `fetchValues(names?, callback?, coldFetch?)` | The parameters named in the list, `null` for a missing one; with no names, every parameter. `fetchValues(callback)`, `fetchValues(names, coldFetch)` and `fetchValues(coldFetch)` work too. |
|
|
542
|
+
| `fetchValues(names?, callback?, coldFetch?)` | The parameters named in the list (one name reads one parameter), `null` for a missing one; with no names, every parameter. `fetchValues(callback)`, `fetchValues(names, coldFetch)` and `fetchValues(coldFetch)` work too. |
|
|
513
543
|
| `setCustomConditionValue(conditionname, value)` | This device's values for a custom condition, comma separated (`'gold,platinum'`); an empty value removes them. |
|
|
514
544
|
|
|
515
545
|
With a `<script>` tag, `AppticsRemoteConfig` is a global as it is here.
|
|
516
546
|
|
|
517
547
|
### Cold fetch
|
|
518
548
|
|
|
519
|
-
By default `
|
|
549
|
+
By default `fetchValues` answers from the values the page already has, which the
|
|
520
550
|
SDK keeps up to date every 3 minutes. For a value that must be current now, say right after it was
|
|
521
551
|
changed in the console, or before a step that depends on it, pass `true` as the last argument:
|
|
522
|
-
`
|
|
552
|
+
`fetchValues(['bannerText'], true)`, `fetchValues(['primaryColor', 'maxItems'], true)`,
|
|
523
553
|
`fetchValues(true)` for every parameter, or after a callback, as in
|
|
524
|
-
`
|
|
554
|
+
`fetchValues(['bannerText'], render, true)`.
|
|
525
555
|
|
|
526
556
|
What a cold fetch does:
|
|
527
557
|
|
|
528
|
-
- It asks the server for the whole rule set now
|
|
558
|
+
- It asks the server for the whole rule set now, whatever the page
|
|
529
559
|
has already fetched, and the answer **replaces** the stored set, as the first fetch of a page
|
|
530
560
|
load does. The value is then chosen from it as usual, and the SDK's 3-minute updates go on from
|
|
531
561
|
there.
|
|
532
562
|
- It waits for start-up, and on a first visit for the device to be registered, before asking:
|
|
533
563
|
calling it straight after `Apptics.init()` is fine.
|
|
534
564
|
- **At most three cold fetches in any minute**, per page. One past that makes no request and
|
|
535
|
-
answers from the values the page already has, as `coldFetch: false` would
|
|
536
|
-
`console_log: true`, the console says so.
|
|
565
|
+
answers from the values the page already has, as `coldFetch: false` would.
|
|
537
566
|
- Cold fetches made at the same time share one request.
|
|
538
567
|
- If it fails (offline, or a server error), it answers from the values fetched before, or `null`
|
|
539
568
|
with none fetched yet, as any fetch does.
|
|
@@ -566,15 +595,71 @@ AppticsLogger.error('Payment failed', err); // an Error as properties:
|
|
|
566
595
|
| `AppticsLogger.warn(message, properties?)` | 4, Warning |
|
|
567
596
|
| `AppticsLogger.error(message, properties?)` | 5, Error |
|
|
568
597
|
|
|
569
|
-
`properties` is appended to the message: an object as JSON (`Payment started {"orderId":42,"method":"card"}`)
|
|
570
|
-
an `Error` as its stack. Each line records the time it was logged and the function, file and line
|
|
571
|
-
that logged it, even when logged before start-up finishes. Lines are stored before they are sent
|
|
572
|
-
and go out in batches of up to 50: a line survives a failed send and a reload, and is removed once
|
|
573
|
-
the server accepts it. At most 1 MB of lines waits at once, oldest dropped first,
|
|
574
|
-
and a line is trimmed to 10,000 characters. Nothing is recorded while the server has the remote
|
|
575
|
-
logger switched off for the app, or while tracking is off.
|
|
598
|
+
`properties` is appended to the message: an object as JSON (`Payment started {"orderId":42,"method":"card"}`).
|
|
576
599
|
|
|
577
|
-
|
|
600
|
+
## Push Notification
|
|
601
|
+
|
|
602
|
+
Messages sent from the console to the people on your site, delivered while the page is open. Its
|
|
603
|
+
own entry point, so apps that don't use it don't ship it:
|
|
604
|
+
|
|
605
|
+
```ts
|
|
606
|
+
import { AppticsPushNotification } from '@zoho_apptics/apptics-js-sdk/push-notification';
|
|
607
|
+
|
|
608
|
+
// ask from a click; each message from the console then shows as a browser notification
|
|
609
|
+
button.onclick = () => AppticsPushNotification.requestPermission();
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
Importing the entry is enough: once the console has push on for the app, the SDK registers this
|
|
613
|
+
browser on its own and connects. The calls are for asking by hand:
|
|
614
|
+
|
|
615
|
+
| Call | What it does |
|
|
616
|
+
|---|---|
|
|
617
|
+
| `setEnabled(true)` | Registers this browser now. Resolves `true` once registered, `false` when the console has push off. It also undoes an earlier `setEnabled(false)`. Called before `init()`, it waits for the SDK to start. |
|
|
618
|
+
| `setEnabled(false)` | Stops push for this browser, and keeps it stopped on later visits until `setEnabled(true)`. Resolves `true` once the server agrees. Anything but `true` or `false` is ignored, with a console warning. |
|
|
619
|
+
| `isEnabled()` | Whether this browser is registered for push right now. |
|
|
620
|
+
| `requestPermission()` | Asks the visitor to allow browser notifications. Call it from a click: browsers show the prompt only after a user gesture. Resolves with `'granted'`, `'denied'`, `'default'` (dismissed) or `'unsupported'`. The SDK never asks on its own. |
|
|
621
|
+
|
|
622
|
+
Once the visitor allows notifications, each message is also shown as a browser notification,
|
|
623
|
+
while a tab of your site is open (in the background too), as the console's web preview shows it.
|
|
624
|
+
|
|
625
|
+
Only `http` and `https` URLs are opened.
|
|
626
|
+
|
|
627
|
+
- **Tracking status:** push works with anonymous tracking too. With `NO_TRACKING` there is no
|
|
628
|
+
push; it comes back when tracking does.
|
|
629
|
+
- **Foreground only:** messages travel over Zoho's WMS connection, not the browser's Web Push, so
|
|
630
|
+
they arrive only while a page of your site is open.
|
|
631
|
+
- **No server setup:** on your own domain, the SDK connects to WMS through a frame from your
|
|
632
|
+
Apptics data centre (the host in `base_url`), so your site needs no routing or proxy.
|
|
633
|
+
- **Content-Security-Policy:** the SDK loads `wmsliteapi.js` from the URL the console gives it. A site with a strict policy must allow:
|
|
634
|
+
- `script-src`: the origin of that URL (a Zoho static domain, such as `https://static.zohocdn.com`)
|
|
635
|
+
and the SDK's own (`https://static.zohocdn.com` for the CDN build);
|
|
636
|
+
- `frame-src`: on your own domain, the Apptics host of your data centre, as in `base_url`
|
|
637
|
+
(for example `https://apptics.zoho.com`);
|
|
638
|
+
- `connect-src`: on a Zoho domain, WMS's servers for your data centre, as the WMS documentation
|
|
639
|
+
gives them: `connect-src 'self' https://*.zoho.<tld> wss://*.zoho.<tld>` (`https://*.zohocloud.ca
|
|
640
|
+
wss://*.zohocloud.ca` in CA, `https://*.zoho.com.cn wss://*.zoho.com.cn` in CN).
|
|
641
|
+
- **Pages that use WMS themselves** keep working as before: messages for other products still
|
|
642
|
+
reach them.
|
|
643
|
+
|
|
644
|
+
### The service worker
|
|
645
|
+
|
|
646
|
+
To register the service worker, add a file named `apptics-pn-sw.js` at the root of your site, so it
|
|
647
|
+
is served at `https://<your-site>/apptics-pn-sw.js`, holding this one line:
|
|
648
|
+
|
|
649
|
+
```js
|
|
650
|
+
importScripts('https://static.zohocdn.com/apptics-js-sdk/2.0.0/apptics-pn-sw.js');
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
The SDK registers it on its own when push is on; you don't call `navigator.serviceWorker.register`.
|
|
654
|
+
With it, notifications get their action buttons, the image carousel and the countdown, and a
|
|
655
|
+
click is handled after the tab has closed. Without it, each message shows as a plain notification.
|
|
656
|
+
|
|
657
|
+
- The file must be at the root, named exactly `apptics-pn-sw.js`; another path or name is not used.
|
|
658
|
+
- When you update the SDK, change the version in the `importScripts` URL to match.
|
|
659
|
+
- If your site's own service worker already controls the root, the SDK keeps it and shows plain
|
|
660
|
+
notifications.
|
|
661
|
+
|
|
662
|
+
With a `<script>` tag, `AppticsPushNotification` is a global as it is here.
|
|
578
663
|
|
|
579
664
|
## In-App Feedback
|
|
580
665
|
|
|
@@ -632,14 +717,33 @@ where the form is shown, for example to set a brand color:
|
|
|
632
717
|
.zasdk-modal { --zasdk-primary-color: #0b5d8f; }
|
|
633
718
|
```
|
|
634
719
|
|
|
635
|
-
The
|
|
636
|
-
`--zasdk-input-background`, `--zasdk-primary-color` (
|
|
637
|
-
`--zasdk-
|
|
720
|
+
The ones a page sets are `--zasdk-background-color` (the card), `--zasdk-text-color`,
|
|
721
|
+
`--zasdk-border-color`, `--zasdk-input-background`, `--zasdk-primary-color` (Send, the switches
|
|
722
|
+
and consent tick when on, and the focus outline), `--zasdk-button-text-color` (the text on Send),
|
|
723
|
+
`--zasdk-link-color` (the View links, Attachments and the picked option in a dropdown) and
|
|
724
|
+
`--zasdk-shadow`. Each one left unset keeps the form's own color for the theme in use.
|
|
638
725
|
|
|
639
726
|
The form is a modal dialog for keyboards and screen readers: it takes focus when it opens, Escape or
|
|
640
727
|
the close control (with Enter or Space) closes it, and it honours `prefers-reduced-motion`.
|
|
641
728
|
|
|
642
|
-
|
|
729
|
+
**Attachments:** up to 5 images, `.png`, `.jpg`, `.jpeg`, `.gif` or `.svg`, 10 MB in all.
|
|
730
|
+
|
|
731
|
+
### The form's language
|
|
732
|
+
|
|
733
|
+
The form is in 21 languages: English, Čeština, Dansk, Deutsch, Español (España and México),
|
|
734
|
+
Français (Canada and France), Bahasa Indonesia, Italiano, 日本語, 한국어, Nederlands, Polski,
|
|
735
|
+
Português (Brasil and Portugal), Русский, Svenska, Türkçe, 中文简体 and 中文繁體. It opens in the
|
|
736
|
+
browser's language: the first of the visitor's browser languages it has, with a region it
|
|
737
|
+
doesn't have read as its language (`de-AT` is Deutsch, `es-AR` is Español – México), else English.
|
|
738
|
+
|
|
739
|
+
The visitor can pick another from the dropdown at the top of the form. Each language is listed by
|
|
740
|
+
its own name, with the English name in brackets (`Deutsch (German)`). The form changes at once and
|
|
741
|
+
keeps everything the visitor entered: what they typed, the type, the user, the consent tick, the
|
|
742
|
+
switches, the attachments and a recorded clip. The pick is remembered in that browser, so the form opens in it next time. There is no call to
|
|
743
|
+
set the language: the browser's language and the visitor's pick decide it.
|
|
744
|
+
|
|
745
|
+
Only the form's own words change. What the visitor types, file names, the logs and diagnostics it
|
|
746
|
+
shows, and the screen recorder's own controls stay as they are.
|
|
643
747
|
|
|
644
748
|
### Send Feedback/Bug Report programmatically
|
|
645
749
|
|
|
@@ -650,7 +754,7 @@ try {
|
|
|
650
754
|
await AppticsFeedback.sendFeedback({
|
|
651
755
|
type: AppticsFeedback.AP_FEEDBACK_TYPE.BUG, // BUG (0), FEEDBACK (1, the default), HELP (2), REPORT (3)
|
|
652
756
|
message: 'Checkout is broken',
|
|
653
|
-
attachments: [screenshotFile], // at most 5, 10 MB in all
|
|
757
|
+
attachments: [screenshotFile], // images (.png, .jpg, .jpeg, .gif, .svg): at most 5, 10 MB in all
|
|
654
758
|
includeLog: true, // the addFeedbackLog() lines
|
|
655
759
|
includeDiagnostics: true, // the addDiagnosticsInfo() entries and the device details
|
|
656
760
|
isAnonymous: false, // true sends it from nobody
|
|
@@ -692,25 +796,27 @@ and then travel with it as two text files.
|
|
|
692
796
|
| `feedbacklog.txt` | `addFeedbackLog` lines, in order, each prefixed with its ISO timestamp | There are lines, unless `includeLog` is `false` |
|
|
693
797
|
| `dyninfo.txt` | `addDiagnosticsInfo` entries as `[heading]` blocks, then a `[Device Info]` block | There are diagnostics, or `includeDiagnostics` is `true` |
|
|
694
798
|
|
|
695
|
-
Only the entries a submission actually carried are removed once the server has them, so anything
|
|
696
|
-
recorded while a submission is in flight waits for the next one. Entries older than
|
|
697
|
-
`batch_request_timeout` days are left out, at most 1,000 are kept (oldest dropped first), a single
|
|
698
|
-
message is truncated at 10,000 characters, and neither file is sent above 2 MB.
|
|
699
|
-
|
|
700
799
|
## Heatmaps
|
|
701
800
|
|
|
702
801
|
Records where people click and how far they scroll, for the console's heatmaps. It is on the
|
|
703
802
|
main entry point and off until you turn it on.
|
|
704
803
|
|
|
705
|
-
|
|
706
|
-
import { Apptics, AppticsHeatmap } from '@zoho_apptics/apptics-js-sdk';
|
|
804
|
+
**In `Apptics.init()`:**
|
|
707
805
|
|
|
806
|
+
```ts
|
|
708
807
|
Apptics.init({ ...config, track_heatmap: true });
|
|
709
|
-
// or turn it on later: AppticsHeatmap.setHeatmapTracking(true)
|
|
710
808
|
```
|
|
711
809
|
|
|
712
|
-
|
|
713
|
-
|
|
810
|
+
**While the page runs:**
|
|
811
|
+
|
|
812
|
+
```ts
|
|
813
|
+
import { AppticsHeatmap } from '@zoho_apptics/apptics-js-sdk';
|
|
814
|
+
|
|
815
|
+
AppticsHeatmap.setHeatmapTracking(true); // start capture
|
|
816
|
+
AppticsHeatmap.setHeatmapTracking(false); // stop
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
With a `<script>` tag, `AppticsHeatmap` is a global.
|
|
714
820
|
|
|
715
821
|
| Call | Notes |
|
|
716
822
|
|---|---|
|
|
@@ -731,32 +837,20 @@ Debug mode is off by default; you follow it in the Apptics web console.
|
|
|
731
837
|
|
|
732
838
|
### Debug mode
|
|
733
839
|
|
|
734
|
-
When
|
|
735
|
-
|
|
736
|
-
request on the server: follow them in the Apptics web console, along with the request id and the
|
|
737
|
-
link to the server's logs for that request.
|
|
840
|
+
When data isn't showing up in the console, turn on debug mode, then follow each request in the
|
|
841
|
+
Apptics web console as it arrives.
|
|
738
842
|
|
|
739
|
-
|
|
740
|
-
|
|
843
|
+
Debug mode is switched from the browser's developer console only. Open the console on the page and
|
|
844
|
+
type:
|
|
741
845
|
|
|
742
|
-
|
|
846
|
+
```js
|
|
743
847
|
Apptics.enableDebug(); // turn debug mode on
|
|
744
848
|
Apptics.disableDebug(); // and off again
|
|
745
849
|
```
|
|
746
850
|
|
|
747
|
-
`Apptics.enableDebug()` and `Apptics.disableDebug()` don't need `Apptics.init()`: call it before `Apptics.init()`, while the SDK starts or at any
|
|
748
|
-
time after, and it takes effect at once. What the app chooses this way holds for the rest of the
|
|
749
|
-
page's life, over `debug` in `Apptics.init()` and through `Apptics.reset()`, so a page whose config turns
|
|
750
|
-
debug mode on can still switch it off with `Apptics.disableDebug()`. With a `<script>` tag they are
|
|
751
|
-
the same calls on the `Apptics` global.
|
|
752
|
-
|
|
753
|
-
Debug mode changes where payloads go, not what is in them. It switches itself off after an hour
|
|
754
|
-
with nothing tracked, so a forgotten tab stops tracing on its own.
|
|
755
|
-
|
|
756
851
|
| Key / call | Default | Notes |
|
|
757
852
|
|---|---|---|
|
|
758
|
-
| `
|
|
759
|
-
| `Apptics.enableDebug()` / `Apptics.disableDebug()` | | Turn debug mode on or off, with or without `Apptics.init()`. |
|
|
853
|
+
| `Apptics.enableDebug()` / `Apptics.disableDebug()` | off | Turn debug mode on or off, typed in the browser console, with or without `Apptics.init()`. Ignored when called from code. |
|
|
760
854
|
| `device_name` | unset | Names this device in the debug stream, so testers on the same build can tell their requests apart. Without it, while debug mode is on, a name is made from the browser and OS. |
|
|
761
855
|
|
|
762
856
|
## Configuration
|
|
@@ -769,7 +863,6 @@ Everything `Apptics.init(config)` accepts.
|
|
|
769
863
|
| `auth_key` | yes | The app's auth key, from the Apptics web console |
|
|
770
864
|
| `app_domain` | yes | The app's domain registered in the Apptics web console, e.g. `com.zylker.web` |
|
|
771
865
|
| `appversion` | yes | Your app's version, e.g. `2.4.0`. No default: everything the SDK reports is tied to the build it came from. Changing it registers the new version |
|
|
772
|
-
| `debug` | | Debug mode: follow requests in the Apptics web console (see [Debugging](#debugging)). Off by default |
|
|
773
866
|
| `ignore_do_not_track` | | Track even when the browser sends Do Not Track. Off by default |
|
|
774
867
|
| `track_api` | | Record the app's own fetch and XHR calls. Off by default; which hosts and endpoints, through `AppticsApi.configure` (see [API Tracking](#api-tracking)) |
|
|
775
868
|
| `track_heatmap` | | Record clicks and scrolls (see [Heatmaps](#heatmaps)). Off by default |
|
|
@@ -781,16 +874,6 @@ Everything `Apptics.init(config)` accepts.
|
|
|
781
874
|
| `feedback_theme` | | The feedback form's theme: `'light'`, `'dark'` or `'auto'` (the default, which follows the visitor's system setting). See [Show feedback screen](#show-feedback-screen) |
|
|
782
875
|
| `device_name` | | Names this device in debug mode (see [Debugging](#debugging)) |
|
|
783
876
|
|
|
784
|
-
The earlier names still work, with a console warning naming the key to use: `serviceUrl` and
|
|
785
|
-
`base_domain` for `base_url`, `zak` and `token` for `auth_key`, and `identifier` for `app_domain`.
|
|
786
|
-
`aaid`, `zsoid` and `projectID` are no longer needed, and are ignored if passed.
|
|
787
|
-
|
|
788
|
-
**Changing `base_url`, `app_domain` or `auth_key`.** What the SDK stores in a browser belongs to
|
|
789
|
-
the app it was registered with. When a page starts with a different `base_url`, `app_domain` or
|
|
790
|
-
`auth_key` from the stored data's, the SDK clears all of it, unsent data included, and starts as on
|
|
791
|
-
a first visit: the app version and the device are registered again. Only a short fingerprint of
|
|
792
|
-
`auth_key` is stored, not the key itself.
|
|
793
|
-
|
|
794
877
|
`Apptics.flush()` sends at most once every 15 seconds, however often it is called: a call sooner
|
|
795
878
|
than that sends nothing, and what is stored goes with the next send.
|
|
796
879
|
|
|
@@ -816,18 +899,14 @@ to switch it while the page runs. The call takes `true` or `false`; with no argu
|
|
|
816
899
|
`AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.NO_TRACKING)` instead (see
|
|
817
900
|
[Tracking settings](#tracking-settings)).
|
|
818
901
|
|
|
819
|
-
The 2.0.0-beta.1 names of three of these calls still work, with a console warning naming the one to
|
|
820
|
-
use: `AppticsApi.enableApiTracking`, `AppticsError.trackGlobalErrorHandler` and
|
|
821
|
-
`AppticsHeatmap.trackHeatmap`.
|
|
822
|
-
|
|
823
902
|
### Sessions
|
|
824
903
|
|
|
825
|
-
A session starts with the visit and goes on while the user comes back to the tab within
|
|
826
|
-
|
|
904
|
+
A session starts with the visit and goes on while the user comes back to the tab within 30
|
|
905
|
+
minutes, counted from the moment the tab went inactive.
|
|
827
906
|
|
|
828
907
|
- When the tab goes inactive (hidden, minimised, or its window loses focus to another one), that
|
|
829
908
|
moment is the session's last active time. Moving focus into an iframe on the page does not count.
|
|
830
|
-
- Back within
|
|
909
|
+
- Back within 30 minutes, the same session goes on.
|
|
831
910
|
- Not back by then, the session ends at its last active time and is sent, so the time away is not
|
|
832
911
|
counted. Coming back later starts a new session.
|
|
833
912
|
- A tab closed while inactive ends its session at its last active time too, not when it closed; a
|
|
@@ -841,12 +920,13 @@ For `<script type="module">`, load the minified ESM build (a few requests instea
|
|
|
841
920
|
|
|
842
921
|
```html
|
|
843
922
|
<script type="module">
|
|
844
|
-
import { Apptics, AppticsEvent } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0
|
|
845
|
-
// Feedback, remote config
|
|
846
|
-
// only the ones it imports
|
|
847
|
-
import { AppticsFeedback } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0
|
|
848
|
-
import { AppticsRemoteConfig } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0
|
|
849
|
-
import { AppticsLogger } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0
|
|
923
|
+
import { Apptics, AppticsEvent } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0/apptics.esm.min.js';
|
|
924
|
+
// Feedback, remote config, the remote logger and push notification are files of their own, so
|
|
925
|
+
// a page downloads only the ones it imports
|
|
926
|
+
import { AppticsFeedback } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0/feedback.esm.min.js';
|
|
927
|
+
import { AppticsRemoteConfig } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0/remoteconfig.esm.min.js';
|
|
928
|
+
import { AppticsLogger } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0/remotelogger.esm.min.js';
|
|
929
|
+
import { AppticsPushNotification } from 'https://static.zohocdn.com/apptics-js-sdk/2.0.0/pushnotification.esm.min.js';
|
|
850
930
|
|
|
851
931
|
Apptics.init({
|
|
852
932
|
base_url: 'YOUR_BASE_URL',
|
|
@@ -861,33 +941,25 @@ For `<script type="module">`, load the minified ESM build (a few requests instea
|
|
|
861
941
|
|
|
862
942
|
| File | For | Size (gzipped) |
|
|
863
943
|
|---|---|---|
|
|
864
|
-
| `apptics.min.js` | `<script>` pages; sets `window.apptics`, includes every module | ~
|
|
944
|
+
| `apptics.min.js` | `<script>` pages; sets `window.apptics`, includes every module | ~75 kB |
|
|
865
945
|
| `apptics.esm.min.js` | `<script type="module">`; the main entry (with the `chunks/` files it imports) | ~32 kB |
|
|
866
|
-
| `feedback.esm.min.js` | `AppticsFeedback`, the feedback form, for module pages | ~
|
|
946
|
+
| `feedback.esm.min.js` | `AppticsFeedback`, the feedback form in its 21 languages, for module pages | ~36 kB more |
|
|
867
947
|
| `remoteconfig.esm.min.js` | `AppticsRemoteConfig`, for module pages | ~7 kB more |
|
|
868
948
|
| `remotelogger.esm.min.js` | `AppticsLogger`, for module pages | ~1 kB more |
|
|
949
|
+
| `pushnotification.esm.min.js` | `AppticsPushNotification`, for module pages | ~3 kB more |
|
|
869
950
|
|
|
870
951
|
The module files share one copy of the SDK through the `chunks/` folder beside them, so load them all from the same version's folder.
|
|
871
952
|
|
|
872
|
-
Every release is in a folder of its own, `https://static.zohocdn.com/apptics-js-sdk/{version}/`, holding `apptics.min.js`, `apptics.esm.min.js`, `feedback.esm.min.js`, `remoteconfig.esm.min.js`, `remotelogger.esm.min.js`, `chunks/` and the source maps. Add `defer` if you don't need the SDK before the page renders.
|
|
873
|
-
|
|
874
|
-
```bash
|
|
875
|
-
curl -s https://static.zohocdn.com/apptics-js-sdk/2.0.0-beta.2/apptics.min.js \
|
|
876
|
-
| openssl dgst -sha384 -binary | openssl base64 -A
|
|
877
|
-
```
|
|
878
|
-
|
|
879
|
-
```html
|
|
880
|
-
<script src="…/apptics.min.js" integrity="sha384-…" crossorigin="anonymous"></script>
|
|
881
|
-
```
|
|
953
|
+
Every release is in a folder of its own, `https://static.zohocdn.com/apptics-js-sdk/{version}/`, holding `apptics.min.js`, `apptics.esm.min.js`, `feedback.esm.min.js`, `remoteconfig.esm.min.js`, `remotelogger.esm.min.js`, `pushnotification.esm.min.js`, `chunks/` and the source maps. Add `defer` if you don't need the SDK before the page renders.
|
|
882
954
|
|
|
883
|
-
## Migrating from 1.0.2 to 2.0.0
|
|
955
|
+
## Migrating from 1.0.2 to 2.0.0
|
|
884
956
|
|
|
885
957
|
### What you need to change
|
|
886
958
|
|
|
887
959
|
- **Every call is on the object of its feature.** Rename them everywhere, router hooks included: a
|
|
888
960
|
call to an old name left in place throws.
|
|
889
961
|
|
|
890
|
-
| 1.0.2 | 2.0.0
|
|
962
|
+
| 1.0.2 | 2.0.0 |
|
|
891
963
|
|---|---|
|
|
892
964
|
| `apptics.init(config)` | `Apptics.init(config)` |
|
|
893
965
|
| `apptics.trackEvent(name, group, props)` | `AppticsEvent.addEvent(eventName, groupName, properties)` |
|
|
@@ -922,25 +994,8 @@ curl -s https://static.zohocdn.com/apptics-js-sdk/2.0.0-beta.2/apptics.min.js \
|
|
|
922
994
|
|
|
923
995
|
- **The optional modules are their own entry points for npm users**, so an app ships only what it
|
|
924
996
|
uses: `AppticsFeedback` from `/feedback` (every feedback call, logs and diagnostics included; the
|
|
925
|
-
form adds its own styles), `AppticsRemoteConfig` from `/remote-config
|
|
926
|
-
`/remote-logger`. The `<script>` build has everything, as globals and on `window.apptics`.
|
|
927
|
-
|
|
928
|
-
### Behaviour you may notice
|
|
929
|
-
|
|
930
|
-
- **`debug: true` now turns on debug mode** (requests followed in the Apptics web console). In 1.0.2 it logged to the browser console.
|
|
931
|
-
- When the Apptics server tells the SDK to stop tracking an app version, it stops; 1.0.2 ignored that signal. Events, screens, sessions, API calls and errors each follow their own switch in the Apptics console, so turning one off leaves the others on.
|
|
932
|
-
- `ignore_do_not_track: true` now ignores the browser's Do Not Track setting; in 1.0.2 it disabled tracking. Do Not Track is decided on every visit and never stored.
|
|
933
|
-
- `mute()` and `unmute()` are gone. To stop tracking, use `AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.NO_TRACKING)`; unlike `mute()`, it is stored across visits. Feedback is still sent with tracking off.
|
|
934
|
-
- **Screens are tracked automatically**, from the URL, including single-page route changes. An `AppticsScreen.inScreen()` called from your router replaces the automatic view of that navigation, so nothing is counted twice; `track_screen: false` turns automatic tracking off, and `screen_routes` names paths. Each screen view now records how long it lasted.
|
|
935
|
-
- **Events and properties are checked**: an event with a missing or invalid group is not logged, names and keys may not start with `ap_`, and a bad property is dropped on its own rather than taking the others with it. Booleans arrive as Boolean, and `1` / `0` as Number. An invalid name is said in the console.
|
|
936
|
-
- Calling `Apptics.init()` a second time is ignored; use `Apptics.reset()` to start over.
|
|
937
|
-
- `Apptics.init()` still returns at once, but start-up finishes a few milliseconds later, once storage loads, so `window.appticsReady()` fires slightly later than in 1.0.2. Calls made in between are queued and replayed; `await Apptics.ready()` waits for it. A first visit with no network starts once the browser is back online.
|
|
938
|
-
- `AppticsFeedback.sendFeedback()` returns a Promise. `includeLog` and `includeDiagnostics` are three-way: `true` always sends that file, `false` never does, and leaving it unset sends it when something is stored.
|
|
939
|
-
- `dyninfo.txt` carries the diagnostics entries and a `[Device Info]` block. Stored feedback logs and diagnostics are capped at 1,000 entries and 10,000 characters per message.
|
|
940
|
-
- Clicks tracked with `apeventaction` (or `data-apeventaction`) no longer need jQuery.
|
|
941
|
-
- Data moves from localStorage to IndexedDB on the first visit (device identity, consent, unsent events, feedback log entries), and the old keys are removed. Where IndexedDB is unavailable, the SDK keeps using localStorage.
|
|
942
|
-
- Queued data is sent when the page is hidden or closed, using `pagehide` / `visibilitychange` instead of `beforeunload`.
|
|
943
|
-
- New, and off until you use them: heatmaps (`AppticsHeatmap.setHeatmapTracking()`), remote config, API tracking and the remote logger (`AppticsLogger`). Remote config, once imported, fetches its values on start-up.
|
|
997
|
+
form adds its own styles), `AppticsRemoteConfig` from `/remote-config`, `AppticsLogger` from
|
|
998
|
+
`/remote-logger` and `AppticsPushNotification` from `/push-notification`. The `<script>` build has everything, as globals and on `window.apptics`.
|
|
944
999
|
|
|
945
1000
|
## License
|
|
946
1001
|
|