{"_id":"@chamaeleonidae/amplitude-plugin","name":"@chamaeleonidae/amplitude-plugin","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@chamaeleonidae/amplitude-plugin","version":"1.0.0","description":"Amplitude Browser SDK destination plugin that syncs user attributes to Chameleon","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.js","import":"./dist/index.mjs"}},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest","lint":"tsc --noEmit"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.4.0","vitest":"^1.6.0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/chamaeleonidae/amplitude-plugin.git"},"keywords":["amplitude","chameleon","plugin","sdk","user-attributes"],"_id":"@chamaeleonidae/amplitude-plugin@1.0.0","gitHead":"3f071260cddd549c31b4ab09d7973d5997f8ad0d","bugs":{"url":"https://github.com/chamaeleonidae/amplitude-plugin/issues"},"homepage":"https://github.com/chamaeleonidae/amplitude-plugin#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-T0Kje0sauyY50zer8if8/NPSTFOi/ROaxXLd+pZWhcx8Qehm8TK2XNxKvCoRpV2YZ+BF2CmCQda/DHxN2C3iGA==","shasum":"ff61d2313cb1def9714578edd87b8a1eef4035a3","tarball":"https://registry.npmjs.org/@chamaeleonidae/amplitude-plugin/-/amplitude-plugin-1.0.0.tgz","fileCount":2,"unpackedSize":2829,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAwejloVAbPOTToyrxoAY2ZgjLJkuUn9HHYyqR7o98zYAiBSHTMBK/8wq7HGEZFZOZfyX2ZKgoETw24QNy4VeIfejg=="}]},"_npmUser":{"name":"bnorton","email":"brian.nort@gmail.com"},"directories":{},"maintainers":[{"name":"bnorton","email":"brian.nort@gmail.com"},{"name":"try.nbfontana","email":"neri@trychameleon.com"},{"name":"felipe-from-chameleon","email":"felipe@trychameleon.com"},{"name":"mamuh","email":"mariana@trychameleon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/amplitude-plugin_1.0.0_1775741153063_0.8812975429495877"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-09T13:25:52.943Z","1.0.0":"2026-04-09T13:25:53.206Z","modified":"2026-04-09T13:25:53.576Z"},"maintainers":[{"name":"bnorton","email":"brian.nort@gmail.com"},{"name":"try.nbfontana","email":"neri@trychameleon.com"},{"name":"felipe-from-chameleon","email":"felipe@trychameleon.com"},{"name":"mamuh","email":"mariana@trychameleon.com"}],"description":"Amplitude Browser SDK destination plugin that syncs user attributes to Chameleon","homepage":"https://github.com/chamaeleonidae/amplitude-plugin#readme","keywords":["amplitude","chameleon","plugin","sdk","user-attributes"],"repository":{"type":"git","url":"git+https://github.com/chamaeleonidae/amplitude-plugin.git"},"bugs":{"url":"https://github.com/chamaeleonidae/amplitude-plugin/issues"},"license":"MIT","readme":"# @chamaeleonidae/amplitude-plugin\n\nAmplitude Browser SDK destination plugin that intercepts `$identify` events and forwards user attributes to Chameleon via `chmln.identify()`.\n\n## Install\n\n```bash\nnpm install @chamaeleonidae/amplitude-plugin\n```\n\n## Usage\n\n```javascript\nimport * as amplitude from '@amplitude/analytics-browser';\nimport { ChameleonPlugin } from '@chamaeleonidae/amplitude-plugin';\n\namplitude.add(new ChameleonPlugin('YOUR_CHAMELEON_TOKEN'));\namplitude.init('YOUR_AMPLITUDE_API_KEY');\n```\n\nThe Chameleon SDK (`chmln.js`) must be loaded on the page. If `window.chmln` is not yet available when an `$identify` event fires, the plugin queues the call and polls with exponential backoff (~4 seconds total) until the SDK loads.\n\n## How it works\n\nWhen Amplitude dispatches an `$identify` event, the plugin:\n\n1. Extracts `user_properties` operations (`$set`, `$setOnce`, `$unset`)\n2. Merges them with the following precedence: `$unset` > `$set` > `$setOnce`\n3. Prefixes every key with `amplitude_` (e.g. `plan` becomes `amplitude_plan`)\n4. Calls `chmln.identify(user_id, prefixed_properties)`\n\n### `$unset` handling\n\nKeys in `$unset` are mapped to `null`, which tells Chameleon to clear those attributes. `$unset` has the highest precedence — if a key appears in both `$set` and `$unset`, it will be set to `null`.\n\n## Limitations\n\n- **`$add` is not supported.** Amplitude's `$add` operation (increment numeric values) is silently ignored. Only `$set`, `$setOnce`, and `$unset` are forwarded.\n- **No backfill.** The plugin only captures users who trigger a new `$identify` call after installation. Existing Amplitude user attributes are not retroactively synced. To backfill a specific user, trigger an identify call:\n\n```javascript\nconst identifyEvent = new amplitude.Identify();\nidentifyEvent.set('plan', 'enterprise');\namplitude.identify(identifyEvent);\n```\n\n## Development\n\n```bash\nbun install\nbun run test\nbun run build\n```\n","readmeFilename":"README.md","_rev":"1-fa94d100fd4853e00f73da141f135d42"}