npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deepin-js-sdk

v1.2.0

Published

Javascript SDK to use deepin platform

Downloads

1

Readme

Deepin SDK

MIT License NPM version Package Quality TypeScript

Table of Contents

How to install and import deepin SDK

deepin-sdk can be used in react, vue, svelte, react-native, flutter, cordova and in other capacities you may require that can run javascript code as follows:

With Package Managers

You can use one of the following commands to install the sdk.

  npm i deepin-js-sdk
  yarn add deepin-js-sdk

The following code shows you how could it be imported in es6 or 7 or typescript.

  import deepIn from 'deepin-js-sdk'
  ...

Code Example In Vue

Without Package Managers

Copy the following line in an html file

<script src="https://dash.mydeepin.ir/download/deepin-js-sdk-v1.1.3.js"></script>
<script>
  const deepIn = window.Deepin
  ...
</script>

Code Example In VanillaJS

Initialization And Test

First you need to create a new source(web sdk) in deepin panel and get a writekey then use deepin instance to be able to initialize it by the following code:

deepIn.init(writeKey);

Now you are ready to send events using this instance, It creates a bundle of events and send them together by default. Thus, for the first time you can use the following code to send a page event instantly and check whether the event has been sent successfully.

deepIn.init(writekey);
deepIn.page(); // calls a page event
deepIn.flush(); // cleanse the queue and sends all the events

Initialize sdk in react-native

In react-native make sure you call init method after intrack initialization

if (!(await InTrack.isInitialized())) {
  //init inTrack
  await InTrack.init({
    appKey: "INTRACK_APP_KEY__",
    iosAuthKey: "ّINTRACK_AUTH_KEY_FOR_IOS__",
    androidAuthKey: "INTRACK_AUTH_KEY_FOR_ANDROID__",
  });
  InTrack.start();
  // other inTrack related codes...

  // init DeepIn:
  DeepIn.init(writekey);
}

Api

Init

Use the init method to initialize the deepIn SDK.

deepIn.init(writeKey);

writeKey

The given writekey for the source you have created in deepin panel.

Identify

Use the identify method to link your users and their actions, to a recognizable userId and traits.

deepIn.identify(userId, [traits], [commonProps]);

userId

The database ID for the user. If you don’t know who the user is yet, you can set the userId an empty string and just record traits.

traits (optional)

A dictionary of traits you know about the user, you can read more about traits in the identify traits type

commonProps (optional)

A dictionary of properties, you can read more about common properties in the common properties type

deepIn.identify("12091906-01011992", {
  firstName: "Grace Hopper",
  username: "[email protected]",
});

Track

The Track method lets you record actions your users perform.

deepIn.track(event, [properties]);

event

The name of the event you’re tracking.

category

The category of the event you’re tracking.

commonProps (optional)

A dictionary of properties for the event, If the event was 'Added to Cart', it might have properties like price and productType, you can read more about common properties in the common properties type

deepIn.track("Added to Cart", "Sell", {
  properties: {
    price: 1000,
    productType: "mobile",
  },
});

Page

The Page method lets you record page views on your website, along with optional extra information about the page viewed by the user.

deepIn.page([category], [channel], [properties]);

category (optional)

The category of the page. Useful for cases like ecommerce where many pages might live under a single category.

channel (optional)

The channel of the page.

commonProps (optional)

A dictionary of properties, you can read more about common properties in the common properties type

deepIn.page("Pricing");
deepIn.page("Pricing", "", {
  page: {
    title: "Deepin Pricing",
    url: "https://mydeepin.ir/pricing",
    referrer: "https://mydeepin.ir",
  },
});

Group

The Group method associates an identified user with a company, organization, project, workspace, team, tribe, platoon, assemblage, cluster, troop, gang, party, society or any other collective noun you come up with for the same concept.

deepIn.group(groupId, [traits], [commonProps]);

groupId

The Group ID to associate with the current user.

traits (optional)

A dictionary of traits for the group. Example traits for a group include address, website, and employees. you can read more about traits in the group traits type

commonProps (optional)

A dictionary of properties, you can read more about common properties in the common properties type

deepIn.group("UNIVAC Working Group", {
  employees: "Eckert–Mauchly",
  industry: "IT",
});

Alias

The Alias method combines two unassociated user identities. Segment usually handles aliasing automatically when you call identify on a user, however some tools require an explicit alias call.

deepIn.alias(userId, [previousId]);

userId

The new user ID you want to associate with the user.

previousId (optional)

The previous ID that the user was recognized by. This defaults to the currently identified user’s ID.