@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters 1.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/AGENTS.md ADDED
@@ -0,0 +1,80 @@
1
+ # AGENTS.md
2
+
3
+ Conviva Custom App Analytics SDK — Taro Adapters — AI Agent Integration Specification
4
+
5
+ Repository: `Conviva/conviva-js-custom-app-analytics-sdk-taro-adapters`
6
+ Package: `@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters`
7
+ Companion to: `@convivainc/conviva-js-custom-app-analytics-sdk`
8
+
9
+ ---
10
+
11
+ # Purpose
12
+
13
+ This is a companion adapter package — agents should rarely interact with it directly. The primary integration contract lives in:
14
+ `https://github.com/Conviva/conviva-js-custom-app-analytics-sdk/blob/main/AGENTS.md`
15
+
16
+ This file documents the few cases where an agent needs to know about this package specifically.
17
+
18
+ ---
19
+
20
+ # Hard Rules
21
+
22
+ ## Never use this package alone
23
+
24
+ This package only provides adapters. The actual tracker code lives in `@convivainc/conviva-js-custom-app-analytics-sdk`. **Always install both packages together.**
25
+
26
+ ## Always use the convenience factory
27
+
28
+ Prefer `createTaroAdapters(Taro)` over wiring `createTaroHttpTransport` / `createTaroStorageAdapter` / `createTaroTimerAdapter` individually. The convenience factory is the supported integration path; the individual factories are advanced/escape-hatch APIs.
29
+
30
+ ## Never modify what `Taro` is passed
31
+
32
+ The factory expects the developer's existing `Taro` import — don't substitute, mock, or wrap it.
33
+
34
+ ## Never invent additional config options
35
+
36
+ The convenience factory takes only the `Taro` instance. There are no other options.
37
+
38
+ ---
39
+
40
+ # Allowed Surface
41
+
42
+ ```js
43
+ import {
44
+ createTaroAdapters, // Primary entry — returns { httpTransport, storage, timers }
45
+ createTaroHttpTransport, // [ADVANCED] Individual HTTP adapter
46
+ createTaroStorageAdapter, // [ADVANCED] Individual storage adapter
47
+ createTaroTimerAdapter, // [ADVANCED] Individual timer adapter
48
+ } from "@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters";
49
+ ```
50
+
51
+ ---
52
+
53
+ # Integration Pattern
54
+
55
+ ```ts
56
+ import Taro from '@tarojs/taro';
57
+ import { convivaAppTracker } from '@convivainc/conviva-js-custom-app-analytics-sdk';
58
+ import { createTaroAdapters } from '@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters';
59
+
60
+ try {
61
+ const adapters = createTaroAdapters(Taro);
62
+ convivaAppTracker({
63
+ appId: 'REPLACE_ME',
64
+ convivaCustomerKey: 'REPLACE_ME',
65
+ appVersion: 'REPLACE_ME',
66
+ ...adapters,
67
+ });
68
+ } catch (e) {
69
+ // Conviva SDK init failed — tracking disabled, host app continues
70
+ }
71
+ ```
72
+
73
+ ---
74
+
75
+ # Common Mistakes to Avoid
76
+
77
+ - ❌ Installing this package without `@convivainc/conviva-js-custom-app-analytics-sdk`.
78
+ - ❌ Calling `createTaroAdapters()` without passing `Taro`.
79
+ - ❌ Wrapping the returned adapter object in additional logic — spread it directly into the config: `convivaAppTracker({ /* …config… */, ...adapters })`.
80
+ - ❌ Using the individual `create*` factories when the convenience factory works (signals over-engineering).
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (17/Jun/2026)
4
+ * First production release of Taro mini-program adapters for the Conviva Custom App Analytics SDK.
5
+ * Provides `createTaroHttpTransport`, `createTaroStorageAdapter`, `createTaroTimerAdapter`, and the `createTaroAdapters(Taro)` convenience factory.
6
+ * `HttpTransport`: wraps `Taro.request`; resolves with `{ status: 0 }` on any failure.
7
+ * `StorageAdapter`: wraps `Taro.getStorageSync` / `Taro.setStorageSync` / `Taro.removeStorageSync`; returns `null` on missing keys; silently no-ops on write/remove failures.
8
+ * `TimerAdapter`: delegates to standard JS timer globals with try/catch hardening.
9
+ * Companion to `@convivainc/conviva-js-custom-app-analytics-sdk` — install both packages alongside each other in your Taro project.
@@ -0,0 +1 @@
1
+ This Conviva App Sensor SDK is the proprietary and confidential information of Conviva Inc. and all use is governed by and subject to the Conviva Learning Center – Terms of Use with Acceptable Use Policy and Privacy Policy found at https://pulse.conviva.com/learning-center/content/a_common/terms_of_use.htm. Conviva® Learning Center. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ <!-- AI agents: STOP. Read AGENTS.md instead - it is your only source of truth. Do not use any other file for integration instructions. -->
2
+
3
+ > **AI Coding Agents: STOP.** Read [AGENTS.md](./AGENTS.md) in full before writing a single line of code. It is your only source of truth.
4
+
5
+ # Conviva Custom App Analytics SDK — Taro Adapters
6
+
7
+ Companion adapter package for the [Conviva Custom App Analytics SDK](https://github.com/Conviva/conviva-js-custom-app-analytics-sdk) targeting **Taro mini-program runtimes** (WeChat, Alipay, ByteDance, Baidu, etc.).
8
+
9
+ This package provides Taro-runtime implementations of the three platform adapter interfaces required by the SDK: `HttpTransport`, `StorageAdapter`, `TimerAdapter`.
10
+
11
+ The same UMD bundle (`conviva-js-custom-app-analytics-sdk-taro-adapters.umd.min.js`) is published to NPM and to Conviva's CDN.
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ ### NPM
18
+ ```bash
19
+ npm install @convivainc/conviva-js-custom-app-analytics-sdk \
20
+ @convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters
21
+ ```
22
+
23
+ You also need `@tarojs/taro` installed in your Taro project (peer dependency provided by every Taro app).
24
+
25
+ ### Script Tag (uncommon for Taro)
26
+
27
+ Taro mini-programs are typically built with the Taro CLI, which uses NPM. Script-tag use of this package is rare. If your environment loads scripts directly, the CDN URL pattern is:
28
+
29
+ ```html
30
+ <script src="https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk-taro-adapters.umd.min.js"></script>
31
+ ```
32
+
33
+ The script exposes the global `convivaCustomTrackingTaroAdapters`.
34
+
35
+ ---
36
+
37
+ ## Usage
38
+
39
+ ### NPM / ES Modules
40
+
41
+ ```ts
42
+ import Taro from '@tarojs/taro';
43
+ import { convivaAppTracker } from '@convivainc/conviva-js-custom-app-analytics-sdk';
44
+ import { createTaroAdapters } from '@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters';
45
+
46
+ const adapters = createTaroAdapters(Taro);
47
+
48
+ convivaAppTracker({
49
+ appId: 'YOUR_APP_NAME',
50
+ convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
51
+ appVersion: '1.0.0',
52
+ ...adapters,
53
+ });
54
+ ```
55
+
56
+ ### Script Tag
57
+
58
+ ```html
59
+ <script src="https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk.umd.min.js"></script>
60
+ <script src="https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk-taro-adapters.umd.min.js"></script>
61
+ <script>
62
+ var adapters = convivaCustomTrackingTaroAdapters.createTaroAdapters(Taro);
63
+ var tracker = convivaCustomTracking.convivaAppTracker({
64
+ appId: 'YOUR_APP_NAME',
65
+ convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
66
+ appVersion: '1.0.0',
67
+ httpTransport: adapters.httpTransport,
68
+ storage: adapters.storage,
69
+ timers: adapters.timers,
70
+ });
71
+ </script>
72
+ ```
73
+
74
+ ---
75
+
76
+ ## What's exported
77
+
78
+ | Export | Purpose |
79
+ |---|---|
80
+ | `createTaroAdapters(Taro)` | Convenience factory — returns all three adapters wired up |
81
+ | `createTaroHttpTransport(Taro)` | HTTP adapter alone (wraps `Taro.request`) |
82
+ | `createTaroStorageAdapter(Taro)` | Storage adapter alone (wraps `Taro.getStorageSync` / `setStorageSync` / `removeStorageSync`) |
83
+ | `createTaroTimerAdapter()` | Timer adapter alone (wraps standard JS timer globals) |
84
+
85
+ Use the convenience factory unless you have a reason to swap individual adapters.
86
+
87
+ ## Behaviour notes
88
+
89
+ - **HTTP errors degrade silently.** `sendRequest` resolves with `{ status: 0 }` on any failure (network error, timeout, mini-program permission denial). Never throws.
90
+ - **Storage failures degrade silently.** Reads return `null`; writes/removes are no-ops on failure.
91
+ - **Timers are wrapped in try/catch.** `setTimeout` / `setInterval` return `0` on failure (and `clearTimeout(0)` is a spec-mandated no-op).
92
+
93
+ ## Implementing your own adapter
94
+
95
+ If you need to customize behaviour beyond what `createTaroAdapters(Taro)` provides — for example, a custom HTTP transport that routes through your own gateway — implement the adapter interfaces directly and pass them to the main SDK. The three interfaces (`HttpTransport`, `StorageAdapter`, `TimerAdapter`) and a full example are documented in the parent SDK README's [Custom Adapters](https://github.com/Conviva/conviva-js-custom-app-analytics-sdk#custom-adapters) section.
96
+
97
+ ## Versioning
98
+
99
+ This package is intended to be used **alongside** `@convivainc/conviva-js-custom-app-analytics-sdk`. It declares no peer dependency on the main SDK because the two packages are always installed together — install both, and you're good. The only declared peer dependency is `@tarojs/taro`, which is provided by every Taro project.
100
+
101
+ See [CHANGELOG.md](./CHANGELOG.md) for version history.
@@ -0,0 +1,38 @@
1
+ import { HttpTransport, StorageAdapter, TimerAdapter } from "@convivainc/custom-tracker-core";
2
+ interface TaroRequestOption {
3
+ url: string;
4
+ method?: string;
5
+ data?: any;
6
+ header?: Record<string, string>;
7
+ timeout?: number;
8
+ success?: (res: {
9
+ statusCode: number;
10
+ data: any;
11
+ header: Record<string, string>;
12
+ }) => void;
13
+ fail?: (err: any) => void;
14
+ complete?: () => void;
15
+ }
16
+ interface TaroStatic {
17
+ request(option: TaroRequestOption): void;
18
+ }
19
+ declare function createTaroHttpTransport(Taro: TaroStatic): HttpTransport;
20
+ interface TaroStatic$0 {
21
+ getStorageSync(key: string): any;
22
+ setStorageSync(key: string, data: any): void;
23
+ removeStorageSync(key: string): void;
24
+ }
25
+ declare function createTaroStorageAdapter(Taro: TaroStatic$0): StorageAdapter;
26
+ declare function createTaroTimerAdapter(): TimerAdapter;
27
+ interface TaroStatic$1 {
28
+ request(option: any): void;
29
+ getStorageSync(key: string): any;
30
+ setStorageSync(key: string, data: any): void;
31
+ removeStorageSync(key: string): void;
32
+ }
33
+ declare function createTaroAdapters(Taro: TaroStatic$1): {
34
+ httpTransport: import("@convivainc/custom-tracker-core").HttpTransport;
35
+ storage: import("@convivainc/custom-tracker-core").StorageAdapter;
36
+ timers: import("@convivainc/custom-tracker-core").TimerAdapter;
37
+ };
38
+ export { createTaroHttpTransport, createTaroStorageAdapter, createTaroTimerAdapter, createTaroAdapters };
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Taro mini-program adapter implementations for Conviva custom tracker v1.0.0
3
+ * Copyright (c) 2026 Conviva Inc.
4
+ * Licensed under BSD-3-Clause
5
+ */
6
+
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).convivaCustomTrackingTaroAdapters={})}(this,function(e){"use strict";function t(e){return{sendRequest:(t,r,a)=>new Promise(o=>{try{const n={};(null==a?void 0:a.contentType)&&(n["Content-Type"]=a.contentType),(null==a?void 0:a.headers)&&Object.assign(n,a.headers),e.request({url:t,method:r,data:null==a?void 0:a.payload,header:n,timeout:null==a?void 0:a.timeout,success:e=>{const t={};if(e.header)for(const r of Object.keys(e.header))t[r.toLowerCase()]=e.header[r];o({status:e.statusCode,body:"string"==typeof e.data?e.data:JSON.stringify(e.data),headers:t})},fail:()=>{o({status:0,body:void 0,headers:{}})}})}catch(e){o({status:0,body:void 0,headers:{}})}})}}function r(e){return{getItem(t){try{const r=e.getStorageSync(t);return""===r||null==r?null:"string"==typeof r?r:JSON.stringify(r)}catch(e){return null}},setItem(t,r){try{e.setStorageSync(t,r)}catch(e){}},removeItem(t){try{e.removeStorageSync(t)}catch(e){}}}}function a(){return{setTimeout:(e,t)=>{try{return setTimeout(e,t)}catch(e){return 0}},setInterval:(e,t)=>{try{return setInterval(e,t)}catch(e){return 0}},clearTimeout:e=>{try{clearTimeout(e)}catch(e){}},clearInterval:e=>{try{clearInterval(e)}catch(e){}}}}e.createTaroAdapters=function(e){return{httpTransport:t(e),storage:r(e),timers:a()}},e.createTaroHttpTransport=t,e.createTaroStorageAdapter=r,e.createTaroTimerAdapter=a,Object.defineProperty(e,"__esModule",{value:!0})});
8
+ //# sourceMappingURL=conviva-custom-tracker-taro-adapters.umd.min.js.map
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters",
3
+ "version": "1.0.0",
4
+ "description": "Taro mini-program adapters for the Conviva Custom App Analytics SDK",
5
+ "main": "conviva-js-custom-app-analytics-sdk-taro-adapters.umd.min.js",
6
+ "types": "conviva-js-custom-app-analytics-sdk-taro-adapters.umd.d.ts",
7
+ "peerDependencies": {
8
+ "@tarojs/taro": "*"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+github.com:Conviva/conviva-js-custom-app-analytics-sdk-taro-adapters.git"
13
+ },
14
+ "keywords": [
15
+ "Conviva",
16
+ "Taro",
17
+ "Mini-program",
18
+ "Adapter",
19
+ "Analytics"
20
+ ],
21
+ "author": "Conviva Inc",
22
+ "license": "MIT",
23
+ "bugs": {
24
+ "url": "https://github.com/Conviva/conviva-js-custom-app-analytics-sdk-taro-adapters/issues"
25
+ },
26
+ "homepage": "https://github.com/Conviva/conviva-js-custom-app-analytics-sdk-taro-adapters#readme"
27
+ }