1.2.2 • Published 2 years ago
@stack-so/stack-js v1.2.2
@stack-so/stack-js
Stack JS Client Library
Install the Stack client library
npm install "@stack-so/stack"
Usage
Import the Stack Library
import stack from "stack-so";
stack.init(apiKey);
Track an event from a wallet
stack.track("CONNECT_WALLET", {
actor: {
type: "wallet",
address: "0x375892Bb243D35E4c12e8a87b95e24F7F53d493E"
}
});
Track an interaction
stack.track("LIKED_NFT", {
actor: {
type: "wallet",
address: "0x375892Bb243D35E4c12e8a87b95e24F7F53d493E"
},
object: {
type: "contract",
address: "0x5180db8f5c931aae63c74266b211f580155ecac8",
id: 3
};
})
Enrich your information with metadata
stack.track("VIEWED_COLLECTION", {
actor: {
type: "wallet",
address: "0x375892Bb243D35E4c12e8a87b95e24F7F53d493E"
},
object: {
type: "contract",
address: "0x5180db8f5c931aae63c74266b211f580155ecac8",
id: 3,
extras: {
device: "mobile",
source: "homepage
}
};
})
Specify related transactions
stack.track("INITIATED_NFT_PURCHASE", {
actor: {
type: "wallet",
address: "0x375892Bb243D35E4c12e8a87b95e24F7F53d493E"
},
object: {
type: "contract",
address: "0x5180db8f5c931aae63c74266b211f580155ecac8",
id: 3,
transactionHash: "0x5d0f516d4d526de5434dfe05a2fb6e93708e2f1d8910999059b46ae12b9331c3",
extras: {
device: "mobile",
source: "homepage"
}
};
})