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

vue-impression-tracker

v1.2.1

Published

This library is used to track impressions using a Vue mixin. It currently support Vue v2 applications.

Downloads

2

Readme

vue-impression-tracker

This library is used to track impressions using a Vue mixin. It currently support Vue v2 applications.

Mixin

This library defines a Vue Mixin which accepts props, generates an impression id, and calls your provided logImpression function when a piece of content is viewed. Include the Mixin in your component with the following code:

Tracked Component

<script setup lang="ts">
defineProps({
  // Required props:
  // The function to log the impression.
  logImpression: Function,
  // ID for the piece of content we are tracking,.
  contentId: String,
  // A function to generate a UUID.
  uuid: Function,

  // Optional props:
  // The function to log an action or click.
  logAction: Function,
  // Called when an error occurs. Defaults to console.error.
  handleError: Function,
  // Specifies the source type. Defaults to DELIVERY.
  defaultSourceType: [Number, String],
  // Specify an insertion id. Defaults to undefined.
  insertionId: String,
  // Specify an impression id. Defaults to generating one with the required uuid function.
  impressionId: String,
});
</script>

<template>
  <div>Your Content</div>
</template>

<script lang="ts">
import impressionTracker from "vue-impression-tracker";
export default {
  mixins: [impressionTracker],
};
</script>

Parent Component

Also reference the Sending Engagements on Web docs.

<script setup lang="ts">
import { createEventLogger } from 'promoted-snowplow-logger';
import { v4 } from "uuid";

const handleError = process.env.NODE_ENV !== 'production' ? (err) => { throw err; } : console.error;

const eventLogger = createEventLogger({
  enabled: true,
  platformName: 'mymarket',
  handleError,
});

const logImpression = eventLogger.logImpression;
const logAction = eventLogger.logAction;

const uuid = v4;
</script>

<template>
  <YourComponent :logImpression="logImpression" :logAction="logAction" :uuid="uuid" :handleError="handleError">
</template>

Click Handler Example

<script setup lang="ts">
defineProps({
  logAction: Function,
});
</script>
<template>
  <div v-on:click="logActionFunctor">Your Content</div>
  <div v-on:click="logActionFunctor({
      impressionId: "my-custom-impression-id"
      actionType: 2,
      elementId: "some-element-id";
      targetUrl: "https://mysite.com/content/123"
    })">With a custom impression id</div>
</template>

<script lang="ts">
import impressionTracker from "vue-impression-tracker";
export default {
  mixins: [impressionTracker],
};
</script>

Local Development

Run the watcher with: yarn build:watch.

Symlink the built module if you haven't yet.

cd dist
yarn link

Run unit tests with yarn test or link the built module to a test app.

yarn link vue-impression-tracker

Deploy

We use a GitHub action that runs semantic-release to determine how to update versions. Just do a normal code review and this should work. Depending on the message prefixes (e.g. feat: , fix: , clean: , docs: ), it'll update the version appropriately.

When doing a breaking change, add BREAKING CHANGE: to the PR. The colon is important.