GithubHelp home page GithubHelp logo

tracardi-js's Issues

Error: onContextReady will not run if there is no event tracked.

       const options = {
            listeners: {
                onContextReady: ({helpers, context}) => {
                    const btn0 = document.querySelector('#button')
                    console.log(btn0)
                    helpers.onClick(btn0, async ()=> {
                        const response = await helpers.track("btn-clicked", {"data": "data"});

                        if(response) {
                            alert("OK")
                        }
                    });
                }
            },
            tracker: {
                url: {
                    script: 'dist/tracker.js',
                    api: 'http://localhost:8686'
                },
                source: {
                    id: "2b196a06-dd82-4f03-b21c-e5a40e97ec18"
                }
            }
        }

The above will not trigger onCOntextReady if there is no:

<script>
    window.response.context.profile = true;
    window.tracker.track("etst", {})
</script>

Javascript integration is not working on 0.8.1 version

I am using javascript in local web page header but getting a below error in the console:
Uncaught (in promise) ReferenceError: config is not defined
at liliput.js:6320:25
at l (liliput.js:130:40)
at t._invoke (liliput.js:360:22)
at Generator.next (liliput.js:185:21)
at f (liliput.js:6112:99)
at o (liliput.js:6114:194)
at liliput.js:6114:364
at new Promise ()
at liliput.js:6114:97
at liliput.js:6432:20
(anonymous) @ liliput.js:6320
l @ liliput.js:130
t._invoke @ liliput.js:360
(anonymous) @ liliput.js:185
f @ liliput.js:6112
o @ liliput.js:6114
(anonymous) @ liliput.js:6114
(anonymous) @ liliput.js:6114
(anonymous) @ liliput.js:6432
(anonymous) @ liliput.js:6805
l @ liliput.js:130
t._invoke @ liliput.js:360
(anonymous) @ liliput.js:185
f @ liliput.js:6112
o @ liliput.js:6114
(anonymous) @ liliput.js:6114
(anonymous) @ liliput.js:6114
(anonymous) @ liliput.js:6859
(anonymous) @ liliput.js:2525
l @ liliput.js:130
t._invoke @ liliput.js:360
(anonymous) @ liliput.js:185
c @ liliput.js:822
o @ liliput.js:844
Promise.then (async)
c @ liliput.js:832
o @ liliput.js:844
(anonymous) @ liliput.js:851
(anonymous) @ liliput.js:840
(anonymous) @ liliput.js:3054
(anonymous) @ liliput.js:3142
(anonymous) @ liliput.js:4545
Be.C.dispatch @ liliput.js:4631
(anonymous) @ liliput.js:4044
(anonymous) @ liliput.js:4043
l @ liliput.js:130
t._invoke @ liliput.js:360
(anonymous) @ liliput.js:185
c @ liliput.js:822
o @ liliput.js:844
(anonymous) @ liliput.js:851
(anonymous) @ liliput.js:840
Be.A.track @ liliput.js:4063
i @ web_page.html:5
(anonymous) @ web_page.html:5
load (async)
(anonymous) @ web_page.html:5
i @ web_page.html:5

Please help me how to use javascript for integration?
This is my web page:

<script>
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tracardi=t()}(function(){return function n(o,i,a){function c(e,t){if(!i[e]){if(!o[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(d)return d(e,!0);throw(r=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",r}r=i[e]={exports:{}},o[e][0].call(r.exports,function(t){return c(o[e][1][t]||t)},r,r.exports,n,o,i,a)}return i[e].exports}for(var d="function"==typeof require&&require,t=0;t<a.length;t++)c(a[t]);return c}({1:[function(t,e,r){"use strict";!function(t){t=t||window;var r=[],n=!1,o=!1;function i(){if(!n){n=!0;for(var t=0;t<r.length;t++)r[t].fn.call(window,r[t].ctx);r=[]}}function a(){"complete"===document.readyState&&i()}t.documentReady=function(t,e){if("function"!=typeof t)throw new TypeError("callback for documentReady(fn) must be a function");n?setTimeout(function(){t(e)},1):(r.push({fn:t,ctx:e}),"complete"===document.readyState||!document.attachEvent&&"interactive"===document.readyState?setTimeout(i,1):o||(document.addEventListener?(document.addEventListener("DOMContentLoaded",i,!1),window.addEventListener("load",i,!1)):(document.attachEvent("onreadystatechange",a),window.attachEvent("onload",i)),o=!0))}}(window);var n=[];window.tracker||(window.tracker={}),window.response||(window.response={context:{}}),window.onTracardiReady={bind:function(t){"function"==typeof t&&n.push(t)},call:function(e){n.forEach(function(t){t(e)})}},function(){for(var r=[],n="liliput.min.js",t=["track"],e=0;e<t.length;e++){var o=t[e];window.tracker[o]=function(e){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(e),r.push(t),window.tracker}}(o)}function i(){if(console.debug("[Tracker] Rerun callbacks."),void 0!==window.tracardi.default)if(window.tracardi.default.getState().plugins.tracardi.initialized)for(window.tracker=window.tracardi.default;0<r.length;){var t=r.shift(),e=t.shift();tracker[e]&&tracker[e].apply(tracker,t)}else console.error("[Tracardi] Callbacks stopped. Tracker not initialized.");else console.error("[Tracardi] Callbacks stopped. Tracker not initialized. Is script url correct?")}documentReady(function(){var t,e,r;"1"!==navigator.doNotTrack||!0!==(null===(t=options)||void 0===t||null===(e=t.tracker)||void 0===e||null===(r=e.settings)||void 0===r?void 0:r.respectDoNotTrack)?((e=document.createElement("script")).type="text/javascript",e.async=!0,void 0!==options.tracker||void 0!==options.tracker.url||void 0!==options.tracker.url.script?(null!==options.tracker.url.script?options.tracker.url.script.startsWith("http")||options.tracker.url.script.startsWith("//")?e.src=options.tracker.url.script+"/"+n:e.src=options.tracker.url.script:e.src=n,console.debug("[Tracker] Loading: "+e.src),e.addEventListener?e.addEventListener("load",function(t){i()},!1):e.onreadystatechange=function(){"complete"!==this.readyState&&"loaded"!==this.readyState||i(window.event)},(r=document.getElementsByTagName("script")[0]).parentNode.insertBefore(e,r)):console.error("[Tracker] Undefined options.tracker.url.script. This url defines location of tracker code.")):console.log("We are respecting do not track setting. Tracardi disabled.")})}()},{}]},{},[1])(1)});

var options = {
    tracker: {
        url: {
            // This is url to tracardi backend. Please mind the correct port.
            script: 'dist/liliput.min.js',
            api: 'http://127.0.0.1:8686'
        },
        source: {
            id: "65a550d4-ee3a-4a01-9d1f-0c9839ae6ed5"
        }
        // Please see the documentation for more settings: http://docs.tracardi.com/integration/js-integration/
    }
}
</script> ​

My First Heading

My first paragraph.

​<script> window.response.context.profile = true; window.tracker.track("test", {"firstname": "abc"}); console.log("successfully load"); </script> ​

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.