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

@devops-optimove/optigration-sdk-js

v1.0.17

Published

1. Get a webhook from optimove 2. Use the webhook values you got and create an instance of the engagement SDK 3. You can use one of the public methods the SDK has * getMetaData() - Returns a json of the campaign's metadata * getCustomersByBatc

Downloads

3

Readme

Optimove Engagement sdk

How to use:

  1. Get a webhook from optimove
  2. Use the webhook values you got and create an instance of the engagement SDK
  3. You can use one of the public methods the SDK has
    • getMetaData() - Returns a json of the campaign's metadata
    • getCustomersByBatchID(batchID) - Returns a stream of customers for the batchID file number you passed

| Error Message | Explanation | | --- | --- | | metadata is empty or does not exist. | Metadata issues. Please, check your settings object and "metadataFilePath" field, especially. | | Couldn't receive a metadata.| Something wrong with creating metadata object. | | batchID: ${batchID} is not valid. | Wrong BatchIDNumber was provided for getCustomersByBatchID function. | | sdk settings are manadatory.| No SDK settings object or it has no keys. | | tenantID is manadatory.| No tenantID field in the setting object | | bucketName is mandatory.| No bucketName field in the setting object | | customersFolderPath is mandatory.| No customersFolderPath field in the setting object | | metadataFilePath is mandatory.| No metadataFilePath field in the setting object | | decryptionKey is mandatory.| No decryptionKey field in the setting object | | _getStorage error - error details. | Google Cloud issue. Contact Optimove if the issue repeats. |

to install run: npm i @devops-optimove/optigration-sdk-js

const EngagerSDK = require('https://www.npmjs.com/package/@devops-optimove/optigration-sdk-js')

// Example of a webhook payload:
{
  EventTypeID: 14,
  TimeStamp: "2022-07-19 08:54",
  CampaignID: 38085,
  EngagementID: 144523,
  TenantID: 28209,
  BucketName: "optigration-external-eu",
  CustomersFolderPath: "2022-07-19 09 00 webhhook-name channel-id engagement-id/customers",
  MetadataFilePath: "2022-07-19 09 00 webhhook-name channel-id  engagement-id/metadata_engagement-id",
  DecryptionKey: "your-decryption-key",
  ChannelID: 1
}

// Example of getMetaData response
{
  actionID: 1712,
  actionName: 'demo-1',
  campaignID: 38456,
  campaignPlanID: 10828,
  channelID: 1,
  channelName: 'the-campaign-channel',
  engagementID: 144950,
  numberOfCustomers: 2403,
  numberOfFiles: 5,
  planDetailChannelID: 86923,
  promotions: 'promo1,promo2',
  scheduledTime: '2023-10-15T09:00:00Z',
  targetGroupName: 'the-tg-name',
  templateID: 4,
  templateName: 'the-template-name',
  tenantID: 1099,
  bucketName: 'optigration-external-eu',
  customersFolderPath: '2022-07-19 09 00 webhhook-name channel-id engagement-id/customers',
  metadataFilePath: '2022-07-19 09 00 webhhook-name channel-id  engagement-id/metadata_engagement-id',
  duration: 1,
  internalAccountID: 'brand-id',
  accountName: 'my-account',
  identifier: 'webhook-identifier',
  tags: 'tag1,tag2'
}

// Use the values you got from the webhook in your settings object
const settings = {    
    campaignID: webhook.CampaignID,
    engagementID: webhook.EngagementID,
    tenantID: webhook.TenantID,
    bucketName: webhook.BucketName,            
    customersFolderPath: webhook.CustomersFolderPath,
    metadataFilePath: webhook.MetadataFilePath,
    decryptionKey: webhook.DecryptionKey
}

const engagerSDK = new EngagerSDK(settings);

const getMetaData = async () => {
     try {
        const metaData = await engagerSDK.getMetaData();
        return metaData;
    }
    catch (err) {
        console.log(err);
    }
}

const getCustomersByBatchID = (batchID) => {
    try {        
        const customersStream = engagerSDK.getCustomersByBatchID(batchID);
        return customersStream;
    }
    catch (err) {
        console.log(err);
    }
}

async function run() {
    const campaignMetadata = await getMetaData();
    console.log(`Campaign metadata ${JSON.stringify(campaignMetadata)}`)

    for (let index = 1; index < campaignMetadata.numberOfFiles; index++) {
        const customersStream = getCustomersByBatchID(index);
        readFile(customersStream, index);
    }
}

const readFile = (customersStream, index) => {
    console.log(`Reading file #${index}`);

    customersStream.on('data', (customerObject) => {
        console.log(`Record for file #${index}`)
        console.log(customerObject);
    })

    customersStream.on('end', () => {
        console.log(`Finished reading customers file stream #${index}`);        
    }) 

    customersStream.on('error', (err) => {
        console.error(err);        
    }) 
}

run();