@zoho_apptics/apptics-js-sdk 2.0.0-beta.1 → 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 +127 -16
- package/README.md +357 -215
- 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 -4
- package/dist/cjs/core/consent.d.ts +17 -4
- package/dist/cjs/core/consent.js +81 -14
- 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 +66 -17
- package/dist/cjs/core/constants.js +76 -19
- 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.d.ts +0 -3
- package/dist/cjs/core/env.js +1 -9
- 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 +29 -0
- package/dist/cjs/core/hooks.js +12 -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 +11 -5
- package/dist/cjs/core/state.js +4 -4
- package/dist/cjs/core/storage.d.ts +7 -0
- package/dist/cjs/core/storage.js +28 -9
- package/dist/cjs/core/stylesheet.js +1 -1
- package/dist/cjs/core/transport.d.ts +15 -4
- package/dist/cjs/core/transport.js +72 -25
- package/dist/cjs/core/utils.js +1 -1
- package/dist/cjs/core/validate.js +6 -5
- package/dist/cjs/device/appversion.d.ts +10 -1
- package/dist/cjs/device/appversion.js +26 -3
- package/dist/cjs/device/index.d.ts +17 -2
- package/dist/cjs/device/index.js +251 -35
- 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 +7 -3
- package/dist/cjs/engagement/session.d.ts +17 -0
- package/dist/cjs/engagement/session.js +154 -23
- package/dist/cjs/engagement/track.d.ts +4 -4
- package/dist/cjs/engagement/track.js +23 -17
- package/dist/cjs/errors/send.js +2 -2
- package/dist/cjs/errors/track.d.ts +2 -1
- package/dist/cjs/errors/track.js +8 -5
- package/dist/cjs/feedback/controls.d.ts +36 -4
- package/dist/cjs/feedback/controls.js +302 -67
- 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.d.ts +3 -6
- package/dist/cjs/feedback/logs.js +12 -21
- package/dist/cjs/feedback/quartz.js +5 -2
- package/dist/cjs/feedback/send.d.ts +6 -3
- package/dist/cjs/feedback/send.js +59 -41
- package/dist/cjs/feedback/styles.js +2 -2
- package/dist/cjs/feedback/template.d.ts +4 -2
- package/dist/cjs/feedback/template.js +73 -44
- package/dist/cjs/feedback/ui.d.ts +47 -4
- package/dist/cjs/feedback/ui.js +351 -97
- package/dist/cjs/heatmap/send.d.ts +2 -0
- package/dist/cjs/heatmap/send.js +3 -5
- package/dist/cjs/heatmap/track.js +13 -9
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +55 -18
- package/dist/cjs/lifecycle.d.ts +13 -2
- package/dist/cjs/lifecycle.js +233 -118
- 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.d.ts +17 -10
- package/dist/cjs/remoteconfig/fetch.js +146 -32
- package/dist/cjs/remoteconfig/index.d.ts +9 -5
- package/dist/cjs/remoteconfig/index.js +24 -32
- package/dist/cjs/remoteconfig/store.d.ts +15 -7
- package/dist/cjs/remoteconfig/store.js +68 -35
- package/dist/cjs/remoteconfig/tz-countries.js +1 -1
- package/dist/cjs/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/cjs/{core → remotelog}/callsite.js +6 -5
- package/dist/cjs/remotelog/gate.js +1 -1
- package/dist/cjs/remotelog/logger.js +2 -2
- package/dist/cjs/remotelog/send.js +6 -5
- package/dist/cjs/remotelogger/index.js +1 -1
- package/dist/cjs/scheduler.d.ts +3 -1
- package/dist/cjs/scheduler.js +34 -25
- 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 +90 -29
- package/dist/cjs/user/index.d.ts +7 -0
- package/dist/cjs/user/index.js +25 -3
- package/dist/esm/core/attempts.js +1 -1
- package/dist/esm/core/batch.js +4 -4
- package/dist/esm/core/consent.d.ts +17 -4
- package/dist/esm/core/consent.js +84 -20
- 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 +66 -17
- package/dist/esm/core/constants.js +73 -20
- 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.d.ts +0 -3
- package/dist/esm/core/env.js +2 -9
- 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 +29 -0
- package/dist/esm/core/hooks.js +12 -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 +11 -5
- package/dist/esm/core/state.js +4 -4
- package/dist/esm/core/storage.d.ts +7 -0
- package/dist/esm/core/storage.js +28 -11
- package/dist/esm/core/stylesheet.js +1 -1
- package/dist/esm/core/transport.d.ts +15 -4
- package/dist/esm/core/transport.js +73 -28
- package/dist/esm/core/utils.js +1 -1
- package/dist/esm/core/validate.js +6 -5
- package/dist/esm/device/appversion.d.ts +10 -1
- package/dist/esm/device/appversion.js +26 -4
- package/dist/esm/device/index.d.ts +17 -2
- package/dist/esm/device/index.js +255 -42
- 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 +7 -3
- package/dist/esm/engagement/session.d.ts +17 -0
- package/dist/esm/engagement/session.js +152 -24
- package/dist/esm/engagement/track.d.ts +4 -4
- package/dist/esm/engagement/track.js +24 -18
- package/dist/esm/errors/send.js +2 -2
- package/dist/esm/errors/track.d.ts +2 -1
- package/dist/esm/errors/track.js +8 -5
- package/dist/esm/feedback/controls.d.ts +36 -4
- package/dist/esm/feedback/controls.js +298 -68
- 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.d.ts +3 -6
- package/dist/esm/feedback/logs.js +12 -21
- package/dist/esm/feedback/quartz.js +5 -2
- package/dist/esm/feedback/send.d.ts +6 -3
- package/dist/esm/feedback/send.js +61 -44
- package/dist/esm/feedback/styles.js +2 -2
- package/dist/esm/feedback/template.d.ts +4 -2
- package/dist/esm/feedback/template.js +73 -44
- package/dist/esm/feedback/ui.d.ts +47 -4
- package/dist/esm/feedback/ui.js +353 -99
- package/dist/esm/heatmap/send.d.ts +2 -0
- package/dist/esm/heatmap/send.js +3 -5
- package/dist/esm/heatmap/track.js +13 -9
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +58 -21
- package/dist/esm/lifecycle.d.ts +13 -2
- package/dist/esm/lifecycle.js +238 -125
- 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.d.ts +17 -10
- package/dist/esm/remoteconfig/fetch.js +147 -33
- package/dist/esm/remoteconfig/index.d.ts +9 -5
- package/dist/esm/remoteconfig/index.js +24 -32
- package/dist/esm/remoteconfig/store.d.ts +15 -7
- package/dist/esm/remoteconfig/store.js +68 -36
- package/dist/esm/remoteconfig/tz-countries.js +1 -1
- package/dist/esm/{core → remotelog}/callsite.d.ts +5 -4
- package/dist/esm/{core → remotelog}/callsite.js +6 -5
- package/dist/esm/remotelog/gate.js +1 -1
- package/dist/esm/remotelog/logger.js +2 -2
- package/dist/esm/remotelog/send.js +6 -5
- package/dist/esm/remotelogger/index.js +1 -1
- package/dist/esm/scheduler.d.ts +3 -1
- package/dist/esm/scheduler.js +35 -27
- 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 +90 -29
- package/dist/esm/user/index.d.ts +7 -0
- package/dist/esm/user/index.js +26 -5
- 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 +3 -0
- package/dist/remoteconfig.esm.min.js.map +1 -0
- package/dist/remotelogger.esm.min.js +3 -0
- package/dist/remotelogger.esm.min.js.map +1 -0
- package/package.json +17 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js +0 -3
- package/dist/chunks/lifecycle-VYr43KcB.min.js.map +0 -1
- package/dist/cjs/auto-init.d.ts +0 -8
- package/dist/cjs/auto-init.js +0 -32
- package/dist/esm/auto-init.d.ts +0 -8
- package/dist/esm/auto-init.js +0 -29
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
|
|
|
@@ -44,7 +44,7 @@ The config object is **required**, with `base_url`, `auth_key`, `app_domain` and
|
|
|
44
44
|
|
|
45
45
|
`Apptics.init()` returns right away. The SDK finishes starting once its storage has loaded, usually within a few milliseconds. Calls you make before that are queued and run in order, so you don't have to wait. If you need to know when it's running, use `await Apptics.ready()`.
|
|
46
46
|
|
|
47
|
-
Every call belongs to an object, named after its feature, so you import only the object
|
|
47
|
+
Every call belongs to an object, named after its feature, so you import only the object: `Apptics.init()`, `AppticsEvent.addEvent()`, `AppticsError.trackError()`, `AppticsFeedback.feedbackFormOpen()`. See [The API at a glance](#the-api-at-a-glance). CommonJS works too (`const { Apptics } = require('@zoho_apptics/apptics-js-sdk')`). Importing the SDK is safe during server-side rendering: nothing runs until `Apptics.init()` is called in the browser.
|
|
48
48
|
|
|
49
49
|
### With a `<script>` tag (CDN)
|
|
50
50
|
|
|
@@ -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://
|
|
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
|
-
|
|
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,40 +79,30 @@ 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 |
|
|
83
|
-
| `AppticsEvent` | `addEvent(eventName, groupName
|
|
84
|
-
| `AppticsScreen` | `inScreen(screenName, properties?)` → id, `outScreen(id)` | main |
|
|
85
|
-
| `AppticsError` | `trackError(error, properties?)`, `
|
|
82
|
+
| `Apptics` | `init(config)`, `ready()`, `flush()`, `reset()`, `enableDebug()`, `disableDebug()` (both typed in the browser console only) | main |
|
|
83
|
+
| `AppticsEvent` | `addEvent(eventName, groupName, properties?)`, `addEvent(DefinedEvents.X, properties?)`, `setClickTracking(enabled?)`, `DefinedEvents` | main |
|
|
84
|
+
| `AppticsScreen` | `inScreen(screenName, properties?)` → id, `outScreen(id)`, `setScreenTracking(enabled?)` | main |
|
|
85
|
+
| `AppticsError` | `trackError(error, properties?)`, `setErrorTracking(enabled?)` | main |
|
|
86
86
|
| `AppticsUser` | `setUser(userid, groupid?, properties?)`, `getUser()`, `UserBuilder` | main |
|
|
87
87
|
| `AppticsSettings` | `setTrackingStatus(status)`, `getTrackingStatus()`, the `AP_TRACKING_STATUS` constants | main |
|
|
88
|
-
| `AppticsApi` | `startTrackApi(url, method?)` → id, `endTrackApi(id, responseCode, responseMessage?)`, `configure(config)`, `
|
|
89
|
-
| `AppticsHeatmap` | `
|
|
88
|
+
| `AppticsApi` | `startTrackApi(url, method?)` → id, `endTrackApi(id, responseCode, responseMessage?)`, `configure(config)`, `setApiTracking(enabled?)`, `ApiTrackingBuilder` | main |
|
|
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
|
-
The
|
|
95
|
+
The `set…Tracking(enabled?)` calls switch each automatic tracker on or off while the page runs
|
|
96
|
+
(see [Turning automatic tracking on and off](#turning-automatic-tracking-on-and-off)).
|
|
95
97
|
|
|
96
98
|
### Frameworks
|
|
97
99
|
|
|
98
|
-
React,
|
|
99
|
-
|
|
100
|
-
| Framework | Start | Screen on navigation, with `track_screen: false` |
|
|
101
|
-
|---|---|---|
|
|
102
|
-
| React, Remix, Gatsby | `useEffect(() => { Apptics.init(config); }, [])` | `useLocation()` in an effect |
|
|
103
|
-
| Vue 3 | a plugin: `app.use(apptics, { router })` | `router.afterEach(to => AppticsScreen.inScreen(to.path))` |
|
|
104
|
-
| Angular | an injectable service | `router.events` filtered to `NavigationEnd` |
|
|
105
|
-
| Svelte, SvelteKit | `src/hooks.client.ts`, or `onMount` | `afterNavigate` |
|
|
106
|
-
| Ember | an instance initializer | `router.on('routeDidChange', …)` |
|
|
107
|
-
| Next.js | `'use client'` component in the layout | `usePathname()` in an effect |
|
|
108
|
-
| Nuxt 3 | `plugins/apptics.client.ts` | `useRouter().afterEach(…)` |
|
|
109
|
-
| Plain JS, jQuery | the `<script>` tag itself | `AppticsScreen.inScreen()` where you change view |
|
|
110
|
-
|
|
111
|
-
**Server-side rendering** (Next, Nuxt, SvelteKit, Remix, Angular Universal): importing the SDK on the server is safe (`Apptics.init()` returns `false` instead of throwing), but it tracks nothing there. Start it from a browser-only hook, as the recipes do. There is no Node/server-side tracking: `engines.node` in `package.json` is the floor for building the package and running its CLI.
|
|
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.
|
|
112
102
|
|
|
113
103
|
## Error Tracking
|
|
114
104
|
|
|
115
|
-
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.
|
|
116
106
|
|
|
117
107
|
Report an error your code caught:
|
|
118
108
|
|
|
@@ -126,36 +116,70 @@ try {
|
|
|
126
116
|
}
|
|
127
117
|
```
|
|
128
118
|
|
|
129
|
-
`AppticsError.trackError` also accepts `error` and `unhandledrejection` events as they are, and properties as a second argument.
|
|
119
|
+
`AppticsError.trackError` also accepts `error` and `unhandledrejection` events as they are, and properties as a second argument.
|
|
130
120
|
|
|
131
|
-
|
|
121
|
+
To record only the errors you report yourself, turn the automatic tracking off.
|
|
122
|
+
`AppticsError.trackError()` records either way.
|
|
132
123
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
**In `Apptics.init()`:**
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
Apptics.init({ ...config, track_error: false });
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**While the page runs:**
|
|
131
|
+
|
|
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.
|
|
140
149
|
|
|
141
150
|
## Event Tracking
|
|
142
151
|
|
|
143
|
-
Track an event, with
|
|
152
|
+
Track an event in a group, with optional properties:
|
|
144
153
|
|
|
145
154
|
```ts
|
|
146
155
|
import { AppticsEvent } from '@zoho_apptics/apptics-js-sdk';
|
|
147
156
|
|
|
157
|
+
AppticsEvent.addEvent('eventName', 'eventGroupName');
|
|
148
158
|
AppticsEvent.addEvent('eventName', 'eventGroupName', { propKey: 'propValue' });
|
|
149
159
|
```
|
|
150
160
|
|
|
161
|
+
The group is required. An event without one (left out, `''`, or properties in its place, as in
|
|
162
|
+
`addEvent('eventName', { propKey: 'propValue' })`) is not logged, and the console says so, debug
|
|
163
|
+
or not:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
AppticsEvent.addEvent: groupName is required for "eventName": addEvent(eventName, groupName, properties?)
|
|
167
|
+
```
|
|
168
|
+
|
|
151
169
|
Event and group names start with a letter, followed by letters, digits or `_`, at most 100
|
|
152
|
-
characters, and may not start with `ap_` or `AP_`, which is reserved for defined events.
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
characters, and may not start with `ap_` or `AP_`, which is reserved for defined events. An event
|
|
171
|
+
with an invalid name or group is not logged, and the console says why.
|
|
172
|
+
|
|
173
|
+
Properties: keys start with a letter, followed by up to 49 letters, digits or `_`, and may not
|
|
174
|
+
start with `ap_`. Values are numbers, booleans or strings of up to 250 characters; anything else
|
|
175
|
+
(an object, an array) is sent as its JSON text. A property that breaks these rules
|
|
176
|
+
is dropped and the event is still logged with the rest. At most 24 properties and 7,666
|
|
177
|
+
characters in all; past that the later ones are dropped. The same rules apply to screen and error
|
|
178
|
+
properties.
|
|
155
179
|
|
|
156
180
|
### Defined events
|
|
157
181
|
|
|
158
|
-
Apptics' ready-made events,
|
|
182
|
+
Apptics' ready-made events, each with its own `AP_` group. They are
|
|
159
183
|
not tracked automatically; log the ones that apply:
|
|
160
184
|
|
|
161
185
|
```ts
|
|
@@ -167,17 +191,19 @@ AppticsEvent.addEvent(DefinedEvents.AP_USER_LOGIN);
|
|
|
167
191
|
AppticsEvent.addEvent(DefinedEvents.AP_SEARCH, { results: 12 });
|
|
168
192
|
```
|
|
169
193
|
|
|
170
|
-
| Group | Events |
|
|
171
|
-
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `AP_APPLICATION` | `
|
|
175
|
-
| `AP_OTHERS` | `
|
|
176
|
-
| `
|
|
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 |
|
|
177
201
|
|
|
178
202
|
With a `<script>` tag it is `AppticsEvent.DefinedEvents` too.
|
|
179
203
|
|
|
180
|
-
|
|
204
|
+
### Click tracking
|
|
205
|
+
|
|
206
|
+
Clicks can be tracked from attributes in your markup, with no code:
|
|
181
207
|
|
|
182
208
|
```html
|
|
183
209
|
<section apgroupaction="checkout">
|
|
@@ -185,21 +211,33 @@ Clicks can also be tracked from markup, without code:
|
|
|
185
211
|
</section>
|
|
186
212
|
```
|
|
187
213
|
|
|
188
|
-
Clicking the button, or anything inside it, tracks `buy_clicked` in group `checkout
|
|
189
|
-
`
|
|
190
|
-
|
|
214
|
+
Clicking the button, or anything inside it, tracks `buy_clicked` in group `checkout`, the nearest
|
|
215
|
+
`apgroupaction` around it, with the properties in `apeventprops` (JSON). An element with no
|
|
216
|
+
`apgroupaction` around it is not tracked, and the console says the group is missing. The `data-`
|
|
217
|
+
spellings work too (`data-apeventaction`, `data-apgroupaction`, `data-apeventprops`), which React
|
|
218
|
+
and TypeScript accept as they are.
|
|
191
219
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
220
|
+
#### Turning click tracking off
|
|
221
|
+
|
|
222
|
+
Click tracking from markup is on by default. `AppticsEvent.addEvent()` records either way.
|
|
223
|
+
|
|
224
|
+
**In `Apptics.init()`:**
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
Apptics.init({ ...config, track_click: false });
|
|
228
|
+
```
|
|
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
|
+
```
|
|
198
236
|
|
|
199
237
|
## Screen Tracking
|
|
200
238
|
|
|
201
239
|
Screens are tracked automatically, from the URL (see [below](#automatic-screen-tracking)). To
|
|
202
|
-
record one yourself, with your own name or with properties, call `AppticsScreen.inScreen
|
|
240
|
+
record one yourself, with your own name or with properties, call `AppticsScreen.inScreen`:
|
|
203
241
|
|
|
204
242
|
```ts
|
|
205
243
|
import { AppticsScreen } from '@zoho_apptics/apptics-js-sdk';
|
|
@@ -210,7 +248,7 @@ AppticsScreen.inScreen('checkout');
|
|
|
210
248
|
Each screen view records how long it lasted. It ends when the next screen starts, when the page
|
|
211
249
|
is hidden (coming back starts a new view of the same screen), or when its session ends.
|
|
212
250
|
`AppticsScreen.inScreen` returns the view's id; hand it to `AppticsScreen.outScreen` to end the view yourself (a dialog
|
|
213
|
-
that closes without the page changing, say)
|
|
251
|
+
that closes without the page changing, say):
|
|
214
252
|
|
|
215
253
|
```ts
|
|
216
254
|
import { AppticsScreen } from '@zoho_apptics/apptics-js-sdk';
|
|
@@ -229,8 +267,7 @@ on a page records a view of the page, named the same way from its path, and a ne
|
|
|
229
267
|
path changes.
|
|
230
268
|
|
|
231
269
|
An `AppticsScreen.inScreen()` call made during a navigation, from a router hook for example,
|
|
232
|
-
replaces the automatic view of it, so the navigation counts once, under your name.
|
|
233
|
-
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.
|
|
234
271
|
|
|
235
272
|
### Automatic screen tracking
|
|
236
273
|
|
|
@@ -274,15 +311,22 @@ Apptics.init({
|
|
|
274
311
|
An entry that can't be used (no `name`, a regex that does not compile) is left out, and
|
|
275
312
|
`Apptics.init()` says which in the console.
|
|
276
313
|
|
|
277
|
-
**An app that names its screens from its router** keeps doing so with `AppticsScreen.inScreen()
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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()`:**
|
|
281
318
|
|
|
282
319
|
```ts
|
|
283
320
|
Apptics.init({ ...config, track_screen: false });
|
|
284
321
|
```
|
|
285
322
|
|
|
323
|
+
**While the page runs:**
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
AppticsScreen.setScreenTracking(false); // only inScreen() calls are recorded
|
|
327
|
+
AppticsScreen.setScreenTracking(true); // back on: the page as it is now is recorded
|
|
328
|
+
```
|
|
329
|
+
|
|
286
330
|
`Apptics.reset()` takes the history wrappers off; the `Apptics.init()` it runs puts them back.
|
|
287
331
|
|
|
288
332
|
## Track User
|
|
@@ -295,7 +339,7 @@ import { AppticsUser } from '@zoho_apptics/apptics-js-sdk';
|
|
|
295
339
|
AppticsUser.setUser('user-id', 'customer-group-id'); // the group is optional
|
|
296
340
|
```
|
|
297
341
|
|
|
298
|
-
`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.
|
|
299
343
|
|
|
300
344
|
### Track User with properties
|
|
301
345
|
|
|
@@ -325,13 +369,28 @@ import { AppticsSettings } from '@zoho_apptics/apptics-js-sdk';
|
|
|
325
369
|
AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.USAGE_TRACKING_WITHOUT_PII);
|
|
326
370
|
```
|
|
327
371
|
|
|
328
|
-
| `AppticsSettings.AP_TRACKING_STATUS.` |
|
|
329
|
-
|
|
330
|
-
| `USAGE_TRACKING_WITH_PII` |
|
|
331
|
-
| `USAGE_TRACKING_WITHOUT_PII` |
|
|
332
|
-
| `
|
|
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
|
+
```
|
|
384
|
+
|
|
385
|
+
An unknown value is ignored, with a console warning.
|
|
333
386
|
|
|
334
|
-
|
|
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
|
+
```
|
|
335
394
|
|
|
336
395
|
### Privacy
|
|
337
396
|
|
|
@@ -341,17 +400,26 @@ AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.USAGE_TRACK
|
|
|
341
400
|
|
|
342
401
|
## API Tracking
|
|
343
402
|
|
|
344
|
-
Record the API calls your app makes, for the console's API page. Either let the SDK
|
|
345
|
-
`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()`:**
|
|
346
407
|
|
|
347
408
|
```ts
|
|
348
|
-
Apptics.init({ ...config, track_api: true });
|
|
409
|
+
Apptics.init({ ...config, track_api: true });
|
|
349
410
|
```
|
|
350
411
|
|
|
351
|
-
|
|
412
|
+
**While the page runs:**
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
AppticsApi.setApiTracking(true); // record every fetch and XHR call
|
|
416
|
+
AppticsApi.setApiTracking(false); // stop
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
Which hosts and endpoints are recorded is set with
|
|
352
420
|
[`AppticsApi.configure`](#configuring-api-tracking).
|
|
353
421
|
|
|
354
|
-
or record calls yourself with `AppticsApi.startTrackApi` / `endTrackApi
|
|
422
|
+
or record calls yourself with `AppticsApi.startTrackApi` / `endTrackApi`. The
|
|
355
423
|
SDK times the call between the two:
|
|
356
424
|
|
|
357
425
|
```ts
|
|
@@ -414,7 +482,7 @@ The rules apply to every call, the ones `track_api` catches and the ones you rep
|
|
|
414
482
|
|
|
415
483
|
The SDK's own requests are never recorded, and neither are calls to `localhost` or a bare IP
|
|
416
484
|
address: the server only accepts hostnames with a dot and a letters-only suffix, so the SDK drops
|
|
417
|
-
those calls and says so in the console. `AppticsApi.
|
|
485
|
+
those calls and says so in the console. `AppticsApi.setApiTracking(false)` removes the wrappers again.
|
|
418
486
|
With a `<script>` tag, `AppticsApi` is a global as it is here, `AppticsApi.ApiTrackingBuilder`
|
|
419
487
|
included.
|
|
420
488
|
|
|
@@ -425,10 +493,11 @@ Read parameters set in the console. Its own entry point, so apps that don't use
|
|
|
425
493
|
```ts
|
|
426
494
|
import { AppticsRemoteConfig } from '@zoho_apptics/apptics-js-sdk/remote-config';
|
|
427
495
|
|
|
428
|
-
const
|
|
496
|
+
const { bannerText } = await AppticsRemoteConfig.fetchValues(['bannerText']); // null if there is none
|
|
429
497
|
const some = await AppticsRemoteConfig.fetchValues(['primaryColor', 'maxItems']);
|
|
430
498
|
// → { primaryColor: '#0b6e4f', maxItems: '10' }
|
|
431
499
|
const all = await AppticsRemoteConfig.fetchValues(); // every parameter
|
|
500
|
+
const fresh = await AppticsRemoteConfig.fetchValues(['bannerText'], true); // coldFetch: asks the server now
|
|
432
501
|
|
|
433
502
|
// for a custom condition: its name, then this device's values, comma separated
|
|
434
503
|
AppticsRemoteConfig.setCustomConditionValue('is_custom', 'custom_color');
|
|
@@ -447,13 +516,16 @@ Values are text, as the console stores them: `Number(values.maxItems)`,
|
|
|
447
516
|
The SDK fetches once on its own when it starts (or when this module is imported after it has),
|
|
448
517
|
so values are this session's without a call of yours.
|
|
449
518
|
|
|
450
|
-
**Fetching.**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
and
|
|
519
|
+
**Fetching.** The first fetch of each page load asks for the whole rule set, and its answer
|
|
520
|
+
replaces what was stored. After that the SDK keeps the values up to date by itself: every 3
|
|
521
|
+
minutes, and when the tab comes back after 15 seconds or more away, it asks only for what changed
|
|
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
|
|
524
|
+
callback, and returns a Promise either way. To ask the server now instead, see
|
|
525
|
+
[Cold fetch](#cold-fetch).
|
|
454
526
|
|
|
455
|
-
**When a fetch fails** (offline, or a server error),
|
|
456
|
-
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).
|
|
457
529
|
|
|
458
530
|
**Custom conditions.** `setCustomConditionValue(conditionname, value)` says what this device is
|
|
459
531
|
for the custom condition with that name in the console, with several values comma separated
|
|
@@ -467,18 +539,42 @@ Conditions on the user, such as the customer group, are re-applied on their own
|
|
|
467
539
|
|
|
468
540
|
| Call | Notes |
|
|
469
541
|
|---|---|
|
|
470
|
-
| `
|
|
471
|
-
| `fetchValues(names?, callback?)` | The parameters named in the list, `null` for a missing one; with no names, every parameter. `fetchValues(callback)` works 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. |
|
|
472
543
|
| `setCustomConditionValue(conditionname, value)` | This device's values for a custom condition, comma separated (`'gold,platinum'`); an empty value removes them. |
|
|
473
544
|
|
|
474
545
|
With a `<script>` tag, `AppticsRemoteConfig` is a global as it is here.
|
|
475
546
|
|
|
547
|
+
### Cold fetch
|
|
548
|
+
|
|
549
|
+
By default `fetchValues` answers from the values the page already has, which the
|
|
550
|
+
SDK keeps up to date every 3 minutes. For a value that must be current now, say right after it was
|
|
551
|
+
changed in the console, or before a step that depends on it, pass `true` as the last argument:
|
|
552
|
+
`fetchValues(['bannerText'], true)`, `fetchValues(['primaryColor', 'maxItems'], true)`,
|
|
553
|
+
`fetchValues(true)` for every parameter, or after a callback, as in
|
|
554
|
+
`fetchValues(['bannerText'], render, true)`.
|
|
555
|
+
|
|
556
|
+
What a cold fetch does:
|
|
557
|
+
|
|
558
|
+
- It asks the server for the whole rule set now, whatever the page
|
|
559
|
+
has already fetched, and the answer **replaces** the stored set, as the first fetch of a page
|
|
560
|
+
load does. The value is then chosen from it as usual, and the SDK's 3-minute updates go on from
|
|
561
|
+
there.
|
|
562
|
+
- It waits for start-up, and on a first visit for the device to be registered, before asking:
|
|
563
|
+
calling it straight after `Apptics.init()` is fine.
|
|
564
|
+
- **At most three cold fetches in any minute**, per page. One past that makes no request and
|
|
565
|
+
answers from the values the page already has, as `coldFetch: false` would.
|
|
566
|
+
- Cold fetches made at the same time share one request.
|
|
567
|
+
- If it fails (offline, or a server error), it answers from the values fetched before, or `null`
|
|
568
|
+
with none fetched yet, as any fetch does.
|
|
569
|
+
|
|
570
|
+
`coldFetch` is `false` by default. Use it for the moments that need it, not on every read: each
|
|
571
|
+
one is a request for the whole rule set.
|
|
572
|
+
|
|
476
573
|
## Remote Logger
|
|
477
574
|
|
|
478
575
|
Send your app's log lines to the console's Remote Logger page with `AppticsLogger`, from its own
|
|
479
576
|
entry point (`@zoho_apptics/apptics-js-sdk/remote-logger`) so apps that don't log don't ship it.
|
|
480
|
-
Nothing is logged on its own: only the lines your app writes, at five levels
|
|
481
|
-
`v` / `d` / `i` / `w` / `e` with their names in full. A line is recorded as it is written, with no
|
|
577
|
+
Nothing is logged on its own: only the lines your app writes, at five levels. A line is recorded as it is written, with no
|
|
482
578
|
switch to turn on first:
|
|
483
579
|
|
|
484
580
|
```ts
|
|
@@ -499,16 +595,71 @@ AppticsLogger.error('Payment failed', err); // an Error as properties:
|
|
|
499
595
|
| `AppticsLogger.warn(message, properties?)` | 4, Warning |
|
|
500
596
|
| `AppticsLogger.error(message, properties?)` | 5, Error |
|
|
501
597
|
|
|
502
|
-
`properties` is appended to the message: an object as JSON (`Payment started {"orderId":42,"method":"card"}`)
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
598
|
+
`properties` is appended to the message: an object as JSON (`Payment started {"orderId":42,"method":"card"}`).
|
|
599
|
+
|
|
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.
|
|
509
656
|
|
|
510
|
-
|
|
511
|
-
|
|
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.
|
|
512
663
|
|
|
513
664
|
## In-App Feedback
|
|
514
665
|
|
|
@@ -566,14 +717,33 @@ where the form is shown, for example to set a brand color:
|
|
|
566
717
|
.zasdk-modal { --zasdk-primary-color: #0b5d8f; }
|
|
567
718
|
```
|
|
568
719
|
|
|
569
|
-
The
|
|
570
|
-
`--zasdk-input-background`, `--zasdk-primary-color` (
|
|
571
|
-
`--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.
|
|
572
725
|
|
|
573
726
|
The form is a modal dialog for keyboards and screen readers: it takes focus when it opens, Escape or
|
|
574
727
|
the close control (with Enter or Space) closes it, and it honours `prefers-reduced-motion`.
|
|
575
728
|
|
|
576
|
-
|
|
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.
|
|
577
747
|
|
|
578
748
|
### Send Feedback/Bug Report programmatically
|
|
579
749
|
|
|
@@ -584,7 +754,7 @@ try {
|
|
|
584
754
|
await AppticsFeedback.sendFeedback({
|
|
585
755
|
type: AppticsFeedback.AP_FEEDBACK_TYPE.BUG, // BUG (0), FEEDBACK (1, the default), HELP (2), REPORT (3)
|
|
586
756
|
message: 'Checkout is broken',
|
|
587
|
-
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
|
|
588
758
|
includeLog: true, // the addFeedbackLog() lines
|
|
589
759
|
includeDiagnostics: true, // the addDiagnosticsInfo() entries and the device details
|
|
590
760
|
isAnonymous: false, // true sends it from nobody
|
|
@@ -626,29 +796,31 @@ and then travel with it as two text files.
|
|
|
626
796
|
| `feedbacklog.txt` | `addFeedbackLog` lines, in order, each prefixed with its ISO timestamp | There are lines, unless `includeLog` is `false` |
|
|
627
797
|
| `dyninfo.txt` | `addDiagnosticsInfo` entries as `[heading]` blocks, then a `[Device Info]` block | There are diagnostics, or `includeDiagnostics` is `true` |
|
|
628
798
|
|
|
629
|
-
Only the entries a submission actually carried are removed once the server has them, so anything
|
|
630
|
-
recorded while a submission is in flight waits for the next one. Entries older than
|
|
631
|
-
`batch_request_timeout` days are left out, at most 1,000 are kept (oldest dropped first), a single
|
|
632
|
-
message is truncated at 10,000 characters, and neither file is sent above 2 MB.
|
|
633
|
-
|
|
634
799
|
## Heatmaps
|
|
635
800
|
|
|
636
801
|
Records where people click and how far they scroll, for the console's heatmaps. It is on the
|
|
637
802
|
main entry point and off until you turn it on.
|
|
638
803
|
|
|
639
|
-
|
|
640
|
-
import { Apptics, AppticsHeatmap } from '@zoho_apptics/apptics-js-sdk';
|
|
804
|
+
**In `Apptics.init()`:**
|
|
641
805
|
|
|
806
|
+
```ts
|
|
642
807
|
Apptics.init({ ...config, track_heatmap: true });
|
|
643
|
-
// or turn it on later: AppticsHeatmap.trackHeatmap(true)
|
|
644
808
|
```
|
|
645
809
|
|
|
646
|
-
|
|
647
|
-
|
|
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.
|
|
648
820
|
|
|
649
821
|
| Call | Notes |
|
|
650
822
|
|---|---|
|
|
651
|
-
| `AppticsHeatmap.
|
|
823
|
+
| `AppticsHeatmap.setHeatmapTracking(enabled?)` | Starts or stops capture; `enabled` defaults to `true`. |
|
|
652
824
|
|
|
653
825
|
Heatmap records go out with the rest of the stored data: on the flush timer, or when you call
|
|
654
826
|
`Apptics.flush()`.
|
|
@@ -665,32 +837,20 @@ Debug mode is off by default; you follow it in the Apptics web console.
|
|
|
665
837
|
|
|
666
838
|
### Debug mode
|
|
667
839
|
|
|
668
|
-
When
|
|
669
|
-
|
|
670
|
-
request on the server: follow them in the Apptics web console, along with the request id and the
|
|
671
|
-
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.
|
|
672
842
|
|
|
673
|
-
|
|
674
|
-
|
|
843
|
+
Debug mode is switched from the browser's developer console only. Open the console on the page and
|
|
844
|
+
type:
|
|
675
845
|
|
|
676
|
-
|
|
846
|
+
```js
|
|
677
847
|
Apptics.enableDebug(); // turn debug mode on
|
|
678
848
|
Apptics.disableDebug(); // and off again
|
|
679
849
|
```
|
|
680
850
|
|
|
681
|
-
`Apptics.enableDebug()` and `Apptics.disableDebug()` don't need `Apptics.init()`: call it before `Apptics.init()`, while the SDK starts or at any
|
|
682
|
-
time after, and it takes effect at once. What the app chooses this way holds for the rest of the
|
|
683
|
-
page's life, over `debug` in `Apptics.init()` and through `Apptics.reset()`, so a page whose config turns
|
|
684
|
-
debug mode on can still switch it off with `Apptics.disableDebug()`. With a `<script>` tag they are
|
|
685
|
-
the same calls on the `Apptics` global.
|
|
686
|
-
|
|
687
|
-
Debug mode changes where payloads go, not what is in them. It switches itself off after an hour
|
|
688
|
-
with nothing tracked, so a forgotten tab stops tracing on its own.
|
|
689
|
-
|
|
690
851
|
| Key / call | Default | Notes |
|
|
691
852
|
|---|---|---|
|
|
692
|
-
| `
|
|
693
|
-
| `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. |
|
|
694
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. |
|
|
695
855
|
|
|
696
856
|
## Configuration
|
|
@@ -703,59 +863,56 @@ Everything `Apptics.init(config)` accepts.
|
|
|
703
863
|
| `auth_key` | yes | The app's auth key, from the Apptics web console |
|
|
704
864
|
| `app_domain` | yes | The app's domain registered in the Apptics web console, e.g. `com.zylker.web` |
|
|
705
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 |
|
|
706
|
-
| `debug` | | Debug mode: follow requests in the Apptics web console (see [Debugging](#debugging)). Off by default |
|
|
707
866
|
| `ignore_do_not_track` | | Track even when the browser sends Do Not Track. Off by default |
|
|
708
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)) |
|
|
709
868
|
| `track_heatmap` | | Record clicks and scrolls (see [Heatmaps](#heatmaps)). Off by default |
|
|
710
869
|
| `heatmap_max_per_session` | | Most heatmap records one visit may produce: 500 by default, 0 to 10000. Capture pauses past it |
|
|
711
870
|
| `track_screen` | | Record a screen view for every navigation, named by its path. On by default; `false` turns it off (see [Automatic screen tracking](#automatic-screen-tracking)) |
|
|
871
|
+
| `track_error` | | Record uncaught errors and unhandled promise rejections. On by default; `false` turns it off (see [Error Tracking](#error-tracking)) |
|
|
872
|
+
| `track_click` | | Record clicks on elements tagged `apeventaction`. On by default; `false` turns it off (see [Click tracking](#click-tracking)) |
|
|
712
873
|
| `screen_routes` | | How automatic screen tracking names a path: route patterns (`'/users/{id}/orders'`), `{ equals, name }` and `{ regex, name }` rules, tried in order (see [Automatic screen tracking](#automatic-screen-tracking)) |
|
|
713
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) |
|
|
714
875
|
| `device_name` | | Names this device in debug mode (see [Debugging](#debugging)) |
|
|
715
876
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
`aaid`, `zsoid` and `projectID` are no longer needed, and are ignored if passed.
|
|
877
|
+
`Apptics.flush()` sends at most once every 15 seconds, however often it is called: a call sooner
|
|
878
|
+
than that sends nothing, and what is stored goes with the next send.
|
|
719
879
|
|
|
720
|
-
###
|
|
880
|
+
### Turning automatic tracking on and off
|
|
721
881
|
|
|
722
|
-
|
|
882
|
+
Each tracker the SDK runs on its own has a config key, read when `Apptics.init()` runs, and a call
|
|
883
|
+
to switch it while the page runs. The call takes `true` or `false`; with no argument it means
|
|
884
|
+
`true`.
|
|
723
885
|
|
|
724
|
-
|
|
|
886
|
+
| Tracker | Default | Config key | Call |
|
|
725
887
|
|---|---|---|---|
|
|
726
|
-
|
|
|
727
|
-
|
|
|
728
|
-
|
|
|
729
|
-
|
|
|
730
|
-
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
| `Apptics.reset()` | Clear stored identity, queued data and remote config values, then start again. |
|
|
755
|
-
|
|
756
|
-
Entry points: `@zoho_apptics/apptics-js-sdk` (everything above except what follows), `/feedback`, `/remote-config`
|
|
757
|
-
(see [Remote Config](#remote-config)), `/remote-logger` (see [Remote Logger](#remote-logger)). Types ship with the package:
|
|
758
|
-
`import type { AppticsConfig, TrackingStatus } from '@zoho_apptics/apptics-js-sdk'`.
|
|
888
|
+
| Screen views from the URL | on | `track_screen` | `AppticsScreen.setScreenTracking(enabled)` |
|
|
889
|
+
| Uncaught errors and unhandled rejections | on | `track_error` | `AppticsError.setErrorTracking(enabled)` |
|
|
890
|
+
| Clicks on tagged elements | on | `track_click` | `AppticsEvent.setClickTracking(enabled)` |
|
|
891
|
+
| The app's fetch and XHR calls | off | `track_api` | `AppticsApi.setApiTracking(enabled)` |
|
|
892
|
+
| Clicks and scrolls for heatmaps | off | `track_heatmap` | `AppticsHeatmap.setHeatmapTracking(enabled)` |
|
|
893
|
+
|
|
894
|
+
- The config key decides at start-up. A call made before `Apptics.init()` is replaced by it, and
|
|
895
|
+
`Apptics.reset()` goes back to the config too.
|
|
896
|
+
- The calls you make yourself (`addEvent`, `inScreen`, `trackError`, `startTrackApi`) record
|
|
897
|
+
whichever way a switch is set.
|
|
898
|
+
- To stop all tracking for a visitor, use
|
|
899
|
+
`AppticsSettings.setTrackingStatus(AppticsSettings.AP_TRACKING_STATUS.NO_TRACKING)` instead (see
|
|
900
|
+
[Tracking settings](#tracking-settings)).
|
|
901
|
+
|
|
902
|
+
### Sessions
|
|
903
|
+
|
|
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.
|
|
906
|
+
|
|
907
|
+
- When the tab goes inactive (hidden, minimised, or its window loses focus to another one), that
|
|
908
|
+
moment is the session's last active time. Moving focus into an iframe on the page does not count.
|
|
909
|
+
- Back within 30 minutes, the same session goes on.
|
|
910
|
+
- Not back by then, the session ends at its last active time and is sent, so the time away is not
|
|
911
|
+
counted. Coming back later starts a new session.
|
|
912
|
+
- A tab closed while inactive ends its session at its last active time too, not when it closed; a
|
|
913
|
+
tab closed while in use ends it then.
|
|
914
|
+
- While another tab of the site is still on the session, a tab that goes inactive or closes only
|
|
915
|
+
leaves it: the last one ends it.
|
|
759
916
|
|
|
760
917
|
## Loading from a CDN
|
|
761
918
|
|
|
@@ -763,9 +920,13 @@ For `<script type="module">`, load the minified ESM build (a few requests instea
|
|
|
763
920
|
|
|
764
921
|
```html
|
|
765
922
|
<script type="module">
|
|
766
|
-
import { Apptics, AppticsEvent } from 'https://
|
|
767
|
-
//
|
|
768
|
-
|
|
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';
|
|
769
930
|
|
|
770
931
|
Apptics.init({
|
|
771
932
|
base_url: 'YOUR_BASE_URL',
|
|
@@ -780,37 +941,31 @@ For `<script type="module">`, load the minified ESM build (a few requests instea
|
|
|
780
941
|
|
|
781
942
|
| File | For | Size (gzipped) |
|
|
782
943
|
|---|---|---|
|
|
783
|
-
| `
|
|
784
|
-
| `
|
|
785
|
-
| `
|
|
944
|
+
| `apptics.min.js` | `<script>` pages; sets `window.apptics`, includes every module | ~75 kB |
|
|
945
|
+
| `apptics.esm.min.js` | `<script type="module">`; the main entry (with the `chunks/` files it imports) | ~32 kB |
|
|
946
|
+
| `feedback.esm.min.js` | `AppticsFeedback`, the feedback form in its 21 languages, for module pages | ~36 kB more |
|
|
947
|
+
| `remoteconfig.esm.min.js` | `AppticsRemoteConfig`, for module pages | ~7 kB more |
|
|
948
|
+
| `remotelogger.esm.min.js` | `AppticsLogger`, for module pages | ~1 kB more |
|
|
949
|
+
| `pushnotification.esm.min.js` | `AppticsPushNotification`, for module pages | ~3 kB more |
|
|
786
950
|
|
|
787
|
-
The module files share one copy of the SDK through `
|
|
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.
|
|
788
952
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
```bash
|
|
792
|
-
curl -s https://cdn.jsdelivr.net/npm/@zoho_apptics/apptics-js-sdk@2.0.0-beta.1/dist/apptics.min.js \
|
|
793
|
-
| openssl dgst -sha384 -binary | openssl base64 -A
|
|
794
|
-
```
|
|
795
|
-
|
|
796
|
-
```html
|
|
797
|
-
<script src="…/apptics.min.js" integrity="sha384-…" crossorigin="anonymous"></script>
|
|
798
|
-
```
|
|
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.
|
|
799
954
|
|
|
800
|
-
## Migrating from 1.0.2 to 2.0.0
|
|
955
|
+
## Migrating from 1.0.2 to 2.0.0
|
|
801
956
|
|
|
802
957
|
### What you need to change
|
|
803
958
|
|
|
804
959
|
- **Every call is on the object of its feature.** Rename them everywhere, router hooks included: a
|
|
805
960
|
call to an old name left in place throws.
|
|
806
961
|
|
|
807
|
-
| 1.0.2 | 2.0.0
|
|
962
|
+
| 1.0.2 | 2.0.0 |
|
|
808
963
|
|---|---|
|
|
809
964
|
| `apptics.init(config)` | `Apptics.init(config)` |
|
|
810
965
|
| `apptics.trackEvent(name, group, props)` | `AppticsEvent.addEvent(eventName, groupName, properties)` |
|
|
811
966
|
| `apptics.trackScreen(name, props)` | `AppticsScreen.inScreen(screenName, properties)`, which also returns the view's id for `AppticsScreen.outScreen(id)` |
|
|
812
967
|
| `apptics.trackError(event, props)` | `AppticsError.trackError(error, properties)` |
|
|
813
|
-
| `apptics.enableGlobalErrorHandler(on)` | `AppticsError.
|
|
968
|
+
| `apptics.enableGlobalErrorHandler(on)` | `AppticsError.setErrorTracking(enabled)`, or `track_error` in `Apptics.init()` |
|
|
814
969
|
| `apptics.setUser(userid, groupid, props)` | `AppticsUser.setUser(userid, groupid, properties)` |
|
|
815
970
|
| `apptics.getUser()`, `new users.UserBuilder()` | `AppticsUser.getUser()`, `new AppticsUser.UserBuilder()` |
|
|
816
971
|
| `apptics.setTrackingStatus(s)`, `getTrackingStatus()` | `AppticsSettings.setTrackingStatus(status)`, `AppticsSettings.getTrackingStatus()` |
|
|
@@ -823,6 +978,10 @@ curl -s https://cdn.jsdelivr.net/npm/@zoho_apptics/apptics-js-sdk@2.0.0-beta.1/d
|
|
|
823
978
|
required (1.0.2's `base_domain` and `token` still work, with a warning). The SDK gets `aaid` and the portal and project ids from the server itself, so
|
|
824
979
|
`aaid`/`aaID`, `zsoid` and `projectID` are no longer needed and are ignored if passed. Without a
|
|
825
980
|
required key, `Apptics.init()` logs which one is missing and returns `false`.
|
|
981
|
+
- **Every event needs a group.** 1.0.2 filed an event with no group under `default`; now it is
|
|
982
|
+
not logged, and the console says the group is missing. Pass one to every
|
|
983
|
+
`AppticsEvent.addEvent(eventName, groupName, properties?)`, and put an `apgroupaction` around
|
|
984
|
+
every element tracked with `apeventaction`. Defined events bring their own.
|
|
826
985
|
- **`appversion` is required.** 1.0.2 quietly defaulted it to `1.0`, which attributed every session,
|
|
827
986
|
error and crash to a version that was never shipped. Pass your real build version.
|
|
828
987
|
- **npm users can import the SDK.** 1.0.2 exported nothing, so it only worked alongside the console
|
|
@@ -835,25 +994,8 @@ curl -s https://cdn.jsdelivr.net/npm/@zoho_apptics/apptics-js-sdk@2.0.0-beta.1/d
|
|
|
835
994
|
|
|
836
995
|
- **The optional modules are their own entry points for npm users**, so an app ships only what it
|
|
837
996
|
uses: `AppticsFeedback` from `/feedback` (every feedback call, logs and diagnostics included; the
|
|
838
|
-
form adds its own styles), `AppticsRemoteConfig` from `/remote-config
|
|
839
|
-
`/remote-logger`. The `<script>` build has everything, as globals and on `window.apptics`.
|
|
840
|
-
|
|
841
|
-
### Behaviour you may notice
|
|
842
|
-
|
|
843
|
-
- **`debug: true` now turns on debug mode** (requests followed in the Apptics web console). In 1.0.2 it logged to the browser console.
|
|
844
|
-
- When the Apptics server tells the SDK to stop tracking an app version, it stops; 1.0.2 ignored that signal.
|
|
845
|
-
- `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.
|
|
846
|
-
- `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.
|
|
847
|
-
- **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.
|
|
848
|
-
- **Events and properties follow the Android rules**: an event with an invalid group is not logged (a missing group is still `default`), 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.
|
|
849
|
-
- Calling `Apptics.init()` a second time is ignored; use `Apptics.reset()` to start over.
|
|
850
|
-
- `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.
|
|
851
|
-
- `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.
|
|
852
|
-
- `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.
|
|
853
|
-
- Clicks tracked with `apeventaction` (or `data-apeventaction`) no longer need jQuery.
|
|
854
|
-
- 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.
|
|
855
|
-
- Queued data is sent when the page is hidden or closed, using `pagehide` / `visibilitychange` instead of `beforeunload`.
|
|
856
|
-
- New, and off until you use them: heatmaps (`AppticsHeatmap.trackHeatmap()`), 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`.
|
|
857
999
|
|
|
858
1000
|
## License
|
|
859
1001
|
|